summaryrefslogtreecommitdiff
path: root/mysys/string.c
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2016-02-15 22:50:59 +0100
committerSergei Golubchik <serg@mariadb.org>2016-02-15 22:50:59 +0100
commit271fed41061e25faa47b7a28108cf101ebb3551d (patch)
tree733bf84d468a1d47c71c87cfcee33098a090e3c5 /mysys/string.c
parentff26d93a8c25d667709180ad13a090309631990d (diff)
parente1385f2083f782d7064db3c0059fcca45bfcb2a4 (diff)
downloadmariadb-git-271fed41061e25faa47b7a28108cf101ebb3551d.tar.gz
Merge branch '5.5' into 10.0
Diffstat (limited to 'mysys/string.c')
-rw-r--r--mysys/string.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/mysys/string.c b/mysys/string.c
index cc73d18c601..a0fa3a02e17 100644
--- a/mysys/string.c
+++ b/mysys/string.c
@@ -142,16 +142,16 @@ my_bool dynstr_trunc(DYNAMIC_STRING *str, size_t n)
my_bool dynstr_append_os_quoted(DYNAMIC_STRING *str, const char *append, ...)
{
#ifdef __WIN__
- const char *quote_str= "\"";
- const uint quote_len= 1;
+ LEX_CSTRING quote= { C_STRING_WITH_LEN("\"") };
+ LEX_CSTRING replace= { C_STRING_WITH_LEN("\\\"") };
#else
- const char *quote_str= "\'";
- const uint quote_len= 1;
+ LEX_CSTRING quote= { C_STRING_WITH_LEN("\'") };
+ LEX_CSTRING replace= { C_STRING_WITH_LEN("'\"'\"'") };
#endif /* __WIN__ */
my_bool ret= TRUE;
va_list dirty_text;
- ret&= dynstr_append_mem(str, quote_str, quote_len); /* Leading quote */
+ ret&= dynstr_append_mem(str, quote.str, quote.length); /* Leading quote */
va_start(dirty_text, append);
while (append != NullS)
{
@@ -159,18 +159,17 @@ my_bool dynstr_append_os_quoted(DYNAMIC_STRING *str, const char *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')
+ while(*(next_pos= strcend(cur_pos, quote.str[0])) != '\0')
{
ret&= dynstr_append_mem(str, cur_pos, (uint) (next_pos - cur_pos));
- ret&= dynstr_append_mem(str ,"\\", 1);
- ret&= dynstr_append_mem(str, quote_str, quote_len);
+ ret&= dynstr_append_mem(str, replace.str, replace.length);
cur_pos= next_pos + 1;
}
ret&= dynstr_append_mem(str, cur_pos, (uint) (next_pos - cur_pos));
append= va_arg(dirty_text, char *);
}
va_end(dirty_text);
- ret&= dynstr_append_mem(str, quote_str, quote_len); /* Trailing quote */
+ ret&= dynstr_append_mem(str, quote.str, quote.length); /* Trailing quote */
return ret;
}