create function open_pathfmt() to allow printf formatting on open()

save some space by allowing printf formatting directly rather than
having a buffer and using sprintf

Change-Id: I049c8f898fb4a68a26ad0f0646250c242647ba12
This commit is contained in:
William Wilgus 2022-11-19 22:39:14 -05:00 committed by William Wilgus
parent 8fe42c43c6
commit e7e20fab1b
8 changed files with 42 additions and 53 deletions

View file

@ -262,9 +262,9 @@ void read_color_theme_file(void) {
unknown_file.color = -1;
if (!global_settings.colors_file[0] || global_settings.colors_file[0] == '-')
return;
snprintf(buffer, MAX_PATH, THEME_DIR "/%s.colours",
global_settings.colors_file);
fd = open(buffer, O_RDONLY);
fd = open_pathfmt(O_RDONLY, THEME_DIR "/%s.colours",
global_settings.colors_file);
if (fd < 0)
return;
while (read_line(fd, buffer, MAX_PATH) > 0)
@ -303,9 +303,8 @@ void read_viewer_theme_file(void)
custom_filetype_icons[i] = filetypes[i].icon;
}
snprintf(buffer, MAX_PATH, "%s/%s.icons", ICON_DIR,
global_settings.viewers_icon_file);
fd = open(buffer, O_RDONLY);
fd = open_pathfmt(O_RDONLY, "%s/%s.icons", ICON_DIR,
global_settings.viewers_icon_file);
if (fd < 0)
return;
while (read_line(fd, buffer, MAX_PATH) > 0)