mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
String::append_for_single_quote() should signal OOM condition,
just like other String::append() methods do
This commit is contained in:
parent
4b169cd7c1
commit
faf4d99d22
2 changed files with 11 additions and 22 deletions
|
@ -1079,7 +1079,8 @@ outp:
|
||||||
characters as necessary.
|
characters as necessary.
|
||||||
Does not add the enclosing quotes, this is left up to caller.
|
Does not add the enclosing quotes, this is left up to caller.
|
||||||
*/
|
*/
|
||||||
void String::append_for_single_quote(const char *st, uint len)
|
#define APPEND(X) if (append(X)) return 1; else break
|
||||||
|
bool String::append_for_single_quote(const char *st, uint len)
|
||||||
{
|
{
|
||||||
const char *end= st+len;
|
const char *end= st+len;
|
||||||
for (; st < end; st++)
|
for (; st < end; st++)
|
||||||
|
@ -1087,28 +1088,16 @@ void String::append_for_single_quote(const char *st, uint len)
|
||||||
uchar c= *st;
|
uchar c= *st;
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case '\\':
|
case '\\': APPEND(STRING_WITH_LEN("\\\\"));
|
||||||
append(STRING_WITH_LEN("\\\\"));
|
case '\0': APPEND(STRING_WITH_LEN("\\0"));
|
||||||
break;
|
case '\'': APPEND(STRING_WITH_LEN("\\'"));
|
||||||
case '\0':
|
case '\n': APPEND(STRING_WITH_LEN("\\n"));
|
||||||
append(STRING_WITH_LEN("\\0"));
|
case '\r': APPEND(STRING_WITH_LEN("\\r"));
|
||||||
break;
|
case '\032': APPEND(STRING_WITH_LEN("\\Z"));
|
||||||
case '\'':
|
default: APPEND(c);
|
||||||
append(STRING_WITH_LEN("\\'"));
|
|
||||||
break;
|
|
||||||
case '\n':
|
|
||||||
append(STRING_WITH_LEN("\\n"));
|
|
||||||
break;
|
|
||||||
case '\r':
|
|
||||||
append(STRING_WITH_LEN("\\r"));
|
|
||||||
break;
|
|
||||||
case '\032': // Ctrl-Z
|
|
||||||
append(STRING_WITH_LEN("\\Z"));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
append(c);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void String::print(String *str)
|
void String::print(String *str)
|
||||||
|
|
|
@ -476,7 +476,7 @@ public:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
void print(String *print);
|
void print(String *print);
|
||||||
void append_for_single_quote(const char *st, uint len);
|
bool append_for_single_quote(const char *st, uint len);
|
||||||
|
|
||||||
/* Swap two string objects. Efficient way to exchange data without memcpy. */
|
/* Swap two string objects. Efficient way to exchange data without memcpy. */
|
||||||
void swap(String &s);
|
void swap(String &s);
|
||||||
|
|
Loading…
Reference in a new issue