Skip to content

Commit 4cb9ba7

Browse files
committed
Init strbuf, compact & make it simpler
1 parent d2e0b4f commit 4cb9ba7

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

varnam.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -225,13 +225,12 @@ varnam_find_symbols_file_directory()
225225
return strbuf_to_s(varnam_symbols_dir);
226226
}
227227

228+
user_path = strbuf_init (20);
229+
228230
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32)
229231
tmp = getenv ("APPDATA");
230232
if (tmp != NULL) {
231233
strbuf_addf (user_path, "%s\\varnam\\vst\\", tmp);
232-
if (!is_directory (strbuf_to_s (user_path))) {
233-
strbuf_clear (user_path);
234-
}
235234
}
236235
#else
237236
tmp = getenv ("XDG_DATA_HOME");
@@ -247,15 +246,18 @@ varnam_find_symbols_file_directory()
247246
#endif
248247

249248
if (!strbuf_is_blank (user_path)) {
250-
return strbuf_to_s(user_path);
251-
}
252-
else {
253-
for (i = 0; i < ARRAY_SIZE (symbolsFileSearchPath); i++) {
254-
if (is_directory (symbolsFileSearchPath[i]))
255-
return symbolsFileSearchPath[i];
249+
if (is_path_exists (strbuf_to_s (user_path))) {
250+
if (is_directory (strbuf_to_s (user_path))) {
251+
return strbuf_to_s (user_path);
252+
}
256253
}
257254
}
258255

256+
for (i = 0; i < ARRAY_SIZE (symbolsFileSearchPath); i++) {
257+
if (is_directory (symbolsFileSearchPath[i]))
258+
return symbolsFileSearchPath[i];
259+
}
260+
259261
return NULL;
260262
}
261263

0 commit comments

Comments
 (0)