summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorunknown <iggy@recycle.(none)>2007-01-19 13:09:48 -0500
committerunknown <iggy@recycle.(none)>2007-01-19 13:09:48 -0500
commit4032c303a9d5e030149f2a0ff87d54408237ef7e (patch)
tree195d5da24c5c21d2ce5fa2c12c01b090329bbdc8 /mysys
parentb1bfec73099b8349f07673e68d1d7ac25316dd4c (diff)
downloadmariadb-git-4032c303a9d5e030149f2a0ff87d54408237ef7e.tar.gz
Bug#22807 mysql_upgrade fails when called with a basedir-path containing spaces
- Corrected compiler warnings and performance problems with new dynstr_append_os_quoted function. mysys/string.c: Bug#22807 mysql_upgrade fails when called with a basedir-path containing spaces - Fix compiler warnings. - Used dynstr_append_mem where string length is known.
Diffstat (limited to 'mysys')
-rw-r--r--mysys/string.c28
1 files changed, 13 insertions, 15 deletions
diff --git a/mysys/string.c b/mysys/string.c
index c5657cd430d..97a799a82b5 100644
--- a/mysys/string.c
+++ b/mysys/string.c
@@ -132,37 +132,35 @@ my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append,
my_bool dynstr_append_os_quoted(DYNAMIC_STRING *str, const char *append, ...)
{
#ifdef __WIN__
- char quote_str[]= "\"";
+ const char *quote_str= "\"";
+ const uint quote_len= 1;
#else
- char quote_str[]= "\'";
+ const char *quote_str= "\'";
+ const uint quote_len= 1;
#endif /* __WIN__ */
my_bool ret= TRUE;
va_list dirty_text;
- ret&= dynstr_append(str, quote_str); /* Leading quote */
- va_start(dirty_text,append);
+ ret&= dynstr_append_mem(str, quote_str, quote_len); /* Leading quote */
+ va_start(dirty_text, append);
while (append != NullS)
{
- char *cur_pos= append;
- char *next_pos= cur_pos;
+ const char *cur_pos= append;
+ const char *next_pos= cur_pos;
/* Search for quote in each string and replace with escaped quote */
while(*(next_pos= strcend(cur_pos, quote_str[0])) != '\0')
{
- char *tmp_buff= my_malloc((next_pos - cur_pos) + 1, MYF(MY_ZEROFILL));
- strnmov(tmp_buff, cur_pos, (next_pos - cur_pos));
- ret&= dynstr_append(str, tmp_buff);
- my_free((gptr)tmp_buff, MYF(0));
-
- ret&= dynstr_append(str ,"\\");
- ret&= dynstr_append(str, quote_str);
+ ret&= dynstr_append_mem(str, cur_pos, next_pos - cur_pos);
+ ret&= dynstr_append_mem(str ,"\\", 1);
+ ret&= dynstr_append_mem(str, quote_str, quote_len);
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 *);
}
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;
}