Skip to content

Commit

Permalink
Init strbuf, compact & make it simpler
Browse files Browse the repository at this point in the history
  • Loading branch information
subins2000 committed Oct 7, 2020
1 parent d2e0b4f commit 4cb9ba7
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions varnam.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,12 @@ varnam_find_symbols_file_directory()
return strbuf_to_s(varnam_symbols_dir);
}

user_path = strbuf_init (20);

#if defined(WIN32) || defined(_WIN32) || defined(__WIN32)
tmp = getenv ("APPDATA");
if (tmp != NULL) {
strbuf_addf (user_path, "%s\\varnam\\vst\\", tmp);
if (!is_directory (strbuf_to_s (user_path))) {
strbuf_clear (user_path);
}
}
#else
tmp = getenv ("XDG_DATA_HOME");
Expand All @@ -247,15 +246,18 @@ varnam_find_symbols_file_directory()
#endif

if (!strbuf_is_blank (user_path)) {
return strbuf_to_s(user_path);
}
else {
for (i = 0; i < ARRAY_SIZE (symbolsFileSearchPath); i++) {
if (is_directory (symbolsFileSearchPath[i]))
return symbolsFileSearchPath[i];
if (is_path_exists (strbuf_to_s (user_path))) {
if (is_directory (strbuf_to_s (user_path))) {
return strbuf_to_s (user_path);
}
}
}

for (i = 0; i < ARRAY_SIZE (symbolsFileSearchPath); i++) {
if (is_directory (symbolsFileSearchPath[i]))
return symbolsFileSearchPath[i];
}

return NULL;
}

Expand Down

0 comments on commit 4cb9ba7

Please sign in to comment.