From 35daa51878b8ceb1ed5c244120c237ec4b116765 Mon Sep 17 00:00:00 2001 From: facetosea <25808407@qq.com> Date: Wed, 11 Oct 2023 20:42:52 +0800 Subject: [PATCH 1/3] file path contains spaces on linux/mac --- source/client/src/clientEnv.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index dbddf9cac6..30f39d2b89 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -718,6 +718,22 @@ int taos_init() { } int taos_options_imp(TSDB_OPTION option, const char *str) { +#ifndef WINDOWS + int len = strlen(str); + if (len > 1 && str[0] != '"' && str[0] != '\'') { + if (len + 2 >= PATH_MAX) { + tscError("Too long path %s", str); + return -1; + } + char newstr[PATH_MAX]; + newstr[0] = '"'; + strncpy(newstr+1, str, len); + newstr[len + 1] = '"'; + newstr[len + 2] = '\0'; + str = newstr; + } +#endif + if (option == TSDB_OPTION_CONFIGDIR) { tstrncpy(configDir, str, PATH_MAX); tscInfo("set cfg:%s to %s", configDir, str); From 8d1e427861ca6a8f63af2402f8819bbf100f4553 Mon Sep 17 00:00:00 2001 From: facetosea <25808407@qq.com> Date: Thu, 12 Oct 2023 10:56:03 +0800 Subject: [PATCH 2/3] fix change scope --- source/client/src/clientEnv.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index 30f39d2b89..faf72108aa 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -718,23 +718,22 @@ int taos_init() { } int taos_options_imp(TSDB_OPTION option, const char *str) { -#ifndef WINDOWS - int len = strlen(str); - if (len > 1 && str[0] != '"' && str[0] != '\'') { - if (len + 2 >= PATH_MAX) { - tscError("Too long path %s", str); - return -1; - } - char newstr[PATH_MAX]; - newstr[0] = '"'; - strncpy(newstr+1, str, len); - newstr[len + 1] = '"'; - newstr[len + 2] = '\0'; - str = newstr; - } -#endif - if (option == TSDB_OPTION_CONFIGDIR) { +#ifndef WINDOWS + int len = strlen(str); + if (len > 1 && str[0] != '"' && str[0] != '\'') { + if (len + 2 >= PATH_MAX) { + tscError("Too long path %s", str); + return -1; + } + char newstr[PATH_MAX]; + newstr[0] = '"'; + strncpy(newstr+1, str, len); + newstr[len + 1] = '"'; + newstr[len + 2] = '\0'; + str = newstr; + } +#endif tstrncpy(configDir, str, PATH_MAX); tscInfo("set cfg:%s to %s", configDir, str); return 0; From 81dc3e7ea2110c90cf56c2210e49e0dd40350ce8 Mon Sep 17 00:00:00 2001 From: facetosea <25808407@qq.com> Date: Thu, 12 Oct 2023 15:04:53 +0800 Subject: [PATCH 3/3] fix test failed --- source/client/src/clientEnv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index faf72108aa..98782f74aa 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -720,13 +720,13 @@ int taos_init() { int taos_options_imp(TSDB_OPTION option, const char *str) { if (option == TSDB_OPTION_CONFIGDIR) { #ifndef WINDOWS + char newstr[PATH_MAX]; int len = strlen(str); if (len > 1 && str[0] != '"' && str[0] != '\'') { if (len + 2 >= PATH_MAX) { tscError("Too long path %s", str); return -1; } - char newstr[PATH_MAX]; newstr[0] = '"'; strncpy(newstr+1, str, len); newstr[len + 1] = '"';