diff options
author | unknown <knielsen@knielsen-hq.org> | 2012-08-24 14:02:32 +0200 |
---|---|---|
committer | unknown <knielsen@knielsen-hq.org> | 2012-08-24 14:02:32 +0200 |
commit | fc666a0df6c69a620d3cffacd78e2569fb0ac410 (patch) | |
tree | a956401c47c0464ad21f91d7e864af1ab89e0469 /sql/sql_string.cc | |
parent | e44a800d91a887119d3b612276b37f09b076fee1 (diff) | |
parent | 96703a63da2211cefcc480fa4f135acd94743622 (diff) | |
download | mariadb-git-fc666a0df6c69a620d3cffacd78e2569fb0ac410.tar.gz |
merge from 5.2
Diffstat (limited to 'sql/sql_string.cc')
-rw-r--r-- | sql/sql_string.cc | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/sql/sql_string.cc b/sql/sql_string.cc index 57a308f581d..5941022546c 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -1159,39 +1159,47 @@ outp: - -void String::print(String *str) +/* + Append characters to a single-quoted string '...', escaping special + characters as necessary. + Does not add the enclosing quotes, this is left up to caller. +*/ +void String::append_for_single_quote(const char *st, uint len) { - char *st= (char*)Ptr, *end= st+str_length; + const char *end= st+len; for (; st < end; st++) { uchar c= *st; switch (c) { case '\\': - str->append(STRING_WITH_LEN("\\\\")); + append(STRING_WITH_LEN("\\\\")); break; case '\0': - str->append(STRING_WITH_LEN("\\0")); + append(STRING_WITH_LEN("\\0")); break; case '\'': - str->append(STRING_WITH_LEN("\\'")); + append(STRING_WITH_LEN("\\'")); break; case '\n': - str->append(STRING_WITH_LEN("\\n")); + append(STRING_WITH_LEN("\\n")); break; case '\r': - str->append(STRING_WITH_LEN("\\r")); + append(STRING_WITH_LEN("\\r")); break; case '\032': // Ctrl-Z - str->append(STRING_WITH_LEN("\\Z")); + append(STRING_WITH_LEN("\\Z")); break; default: - str->append(c); + append(c); } } } +void String::print(String *str) +{ + str->append_for_single_quote(Ptr, str_length); +} /* Exchange state of this object and argument. |