Commit d6d5195c authored by iggy@recycle.(none)'s avatar iggy@recycle.(none)

Merge recycle.(none):/src/bug22807/my50-bug22807

into  recycle.(none):/src/bug22807/my51-bug22807
parents e6d1953c d3e6cb6b
...@@ -137,37 +137,35 @@ my_bool dynstr_trunc(DYNAMIC_STRING *str, int n) ...@@ -137,37 +137,35 @@ my_bool dynstr_trunc(DYNAMIC_STRING *str, int n)
my_bool dynstr_append_os_quoted(DYNAMIC_STRING *str, const char *append, ...) my_bool dynstr_append_os_quoted(DYNAMIC_STRING *str, const char *append, ...)
{ {
#ifdef __WIN__ #ifdef __WIN__
char quote_str[]= "\""; const char *quote_str= "\"";
const uint quote_len= 1;
#else #else
char quote_str[]= "\'"; const char *quote_str= "\'";
const uint quote_len= 1;
#endif /* __WIN__ */ #endif /* __WIN__ */
my_bool ret= TRUE; my_bool ret= TRUE;
va_list dirty_text; va_list dirty_text;
ret&= dynstr_append(str, quote_str); /* Leading quote */ ret&= dynstr_append_mem(str, quote_str, quote_len); /* Leading quote */
va_start(dirty_text,append); va_start(dirty_text, append);
while (append != NullS) while (append != NullS)
{ {
char *cur_pos= append; const char *cur_pos= append;
char *next_pos= cur_pos; const char *next_pos= cur_pos;
/* Search for quote in each string and replace with escaped quote */ /* Search for quote in each string and replace with escaped quote */
while(*(next_pos= strcend(cur_pos, quote_str[0])) != '\0') while(*(next_pos= strcend(cur_pos, quote_str[0])) != '\0')
{ {
char *tmp_buff= my_malloc((next_pos - cur_pos) + 1, MYF(MY_ZEROFILL)); ret&= dynstr_append_mem(str, cur_pos, next_pos - cur_pos);
strnmov(tmp_buff, cur_pos, (next_pos - cur_pos)); ret&= dynstr_append_mem(str ,"\\", 1);
ret&= dynstr_append(str, tmp_buff); ret&= dynstr_append_mem(str, quote_str, quote_len);
my_free((gptr)tmp_buff, MYF(0));
ret&= dynstr_append(str ,"\\");
ret&= dynstr_append(str, quote_str);
cur_pos= next_pos + 1; cur_pos= next_pos + 1;
} }
ret&= dynstr_append(str, cur_pos); ret&= dynstr_append_mem(str, cur_pos, next_pos - cur_pos);
append= va_arg(dirty_text, char *); append= va_arg(dirty_text, char *);
} }
va_end(dirty_text); va_end(dirty_text);
ret&= dynstr_append(str, quote_str); /* Trailing quote */ ret&= dynstr_append_mem(str, quote_str, quote_len); /* Trailing quote */
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment