提交 a10c0e97 编写于 作者: weixin_48148422's avatar weixin_48148422

fix strtolower

上级 90e5690d
......@@ -184,7 +184,7 @@ char *strnchr(char *haystack, char needle, int32_t len, bool skipquote);
char **strsplit(char *src, const char *delim, int32_t *num);
void strtolower(char *dst, const char *src);
char* strtolower(char *dst, const char *src);
int64_t strnatoi(char *num, int32_t len);
......
......@@ -140,28 +140,31 @@ char *strnchr(char *haystack, char needle, int32_t len, bool skipquote) {
return NULL;
}
void strtolower(char *dst, const char *z) {
int quote = 0;
char *str = z;
if (dst == NULL) {
return;
}
while (*str) {
if (*str == '\'' || *str == '"') {
quote = quote ^ 1;
}
if ((!quote) && (*str >= 'A' && *str <= 'Z')) {
*dst++ = *str | 0x20;
} else {
*dst++ = *str;
char* strtolower(char *dst, const char *src) {
int esc = 0;
char quote = 0, *p = dst, c;
assert(dst != NULL);
for (c = *src++; c; c = *src++) {
if (esc) {
esc = 0;
} else if (quote) {
if (c == '\\') {
esc = 1;
} else if (c == quote) {
quote = 0;
}
} else if (c >= 'A' && c <= 'Z') {
c -= 'A' - 'a';
} else if (c == '\'' || c == '"') {
quote = c;
}
str++;
*p++ = c;
}
*dst = 0;
*p = 0;
return dst;
}
char *paGetToken(char *string, char **token, int32_t *tokenLen) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册