From a72df8019c2137443c93e0e8fb9204470d8c4048 Mon Sep 17 00:00:00 2001 From: Subin Siby Date: Thu, 25 Jul 2019 16:51:36 +0530 Subject: [PATCH 1/3] Add VARNAM_SUGGESTIONS_DIR env var to mention directory where learnings should be stored --- varnam.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/varnam.c b/varnam.c index 796a62a..f63dd67 100644 --- a/varnam.c +++ b/varnam.c @@ -315,15 +315,21 @@ find_learnings_file_path (const char *langCode) strbuf_addf (path, "%s\\varnam\\suggestions\\", tmp); } #else - tmp = getenv ("XDG_DATA_HOME"); + tmp = getenv ("VARNAM_SUGGESTIONS_DIR"); if (tmp == NULL) { - tmp = getenv ("HOME"); - if (tmp != NULL) { - strbuf_addf (path, "%s/.local/share/varnam/suggestions/", tmp); - } + tmp = getenv ("XDG_DATA_HOME"); + if (tmp == NULL) { + tmp = getenv ("HOME"); + if (tmp != NULL) { + strbuf_addf (path, "%s/.local/share/varnam/suggestions/", tmp); + } + } + else { + strbuf_addf (path, "%s/varnam/suggestions/", tmp); + } } else { - strbuf_addf (path, "%s/varnam/suggestions/", tmp); + strbuf_addf (path, "%s/", tmp); } #endif From 23de5c0a9f17f14376b9d6b37016975f7d3e378f Mon Sep 17 00:00:00 2001 From: Subin Siby Date: Sat, 28 Nov 2020 02:01:41 +0530 Subject: [PATCH 2/3] Add VARNAM_SYMBOLS_DIR env variable support --- varnam.c | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/varnam.c b/varnam.c index f63dd67..8c55589 100644 --- a/varnam.c +++ b/varnam.c @@ -217,14 +217,20 @@ static const char* symbolsFileSearchPath[] = { const char* varnam_find_symbols_file_directory() { - char *tmp; - strbuf *user_path; - int i; - if (varnam_symbols_dir != NULL && is_directory(strbuf_to_s (varnam_symbols_dir))) { return strbuf_to_s(varnam_symbols_dir); } + char *env_symbols_dir = getenv("VARNAM_SYMBOLS_DIR"); + + if (env_symbols_dir != NULL) { + return env_symbols_dir; + } + + char *tmp; + strbuf *user_path; + int i; + user_path = strbuf_init (20); #if defined(WIN32) || defined(_WIN32) || defined(__WIN32) @@ -304,6 +310,12 @@ make_directory (const char *dirName) static strbuf* find_learnings_file_path (const char *langCode) { + char *env_symbols_dir = getenv("VARNAM_SUGGESTIONS_DIR"); + + if (env_symbols_dir != NULL) { + return env_symbols_dir; + } + char *tmp; strbuf *path; @@ -315,21 +327,15 @@ find_learnings_file_path (const char *langCode) strbuf_addf (path, "%s\\varnam\\suggestions\\", tmp); } #else - tmp = getenv ("VARNAM_SUGGESTIONS_DIR"); + tmp = getenv ("XDG_DATA_HOME"); if (tmp == NULL) { - tmp = getenv ("XDG_DATA_HOME"); - if (tmp == NULL) { - tmp = getenv ("HOME"); - if (tmp != NULL) { - strbuf_addf (path, "%s/.local/share/varnam/suggestions/", tmp); - } - } - else { - strbuf_addf (path, "%s/varnam/suggestions/", tmp); - } + tmp = getenv ("HOME"); + if (tmp != NULL) { + strbuf_addf (path, "%s/.local/share/varnam/suggestions/", tmp); + } } else { - strbuf_addf (path, "%s/", tmp); + strbuf_addf (path, "%s/varnam/suggestions/", tmp); } #endif @@ -347,7 +353,7 @@ find_learnings_file_path (const char *langCode) } } } - + strbuf_addf (path, "%s.vst.learnings", langCode); return path; } From e2eb3a7c2870396cd6f23ab42d3021cf90e1120b Mon Sep 17 00:00:00 2001 From: Subin Siby Date: Sat, 28 Nov 2020 02:21:40 +0530 Subject: [PATCH 3/3] Fix variable name --- varnam.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/varnam.c b/varnam.c index 8c55589..522ce07 100644 --- a/varnam.c +++ b/varnam.c @@ -310,10 +310,10 @@ make_directory (const char *dirName) static strbuf* find_learnings_file_path (const char *langCode) { - char *env_symbols_dir = getenv("VARNAM_SUGGESTIONS_DIR"); + char *env_suggestions_dir = getenv("VARNAM_SUGGESTIONS_DIR"); - if (env_symbols_dir != NULL) { - return env_symbols_dir; + if (env_suggestions_dir != NULL) { + return env_suggestions_dir; } char *tmp;