| 46 | */ |
| 47 | |
| 48 | static my_bool |
| 49 | write_escaped_string(IO_CACHE *file, LEX_STRING *val_s) |
| 50 | { |
| 51 | char *eos= val_s->str + val_s->length; |
| 52 | char *ptr= val_s->str; |
| 53 | |
| 54 | for (; ptr < eos; ptr++) |
| 55 | { |
| 56 | /* |
| 57 | Should be in sync with read_escaped_string() and |
| 58 | parse_quoted_escaped_string() |
| 59 | */ |
| 60 | switch(*ptr) { |
| 61 | case '\\': // escape character |
| 62 | if (my_b_append(file, (const uchar *)STRING_WITH_LEN("\\\\"))) |
| 63 | return TRUE; |
| 64 | break; |
| 65 | case '\n': // parameter value delimiter |
| 66 | if (my_b_append(file, (const uchar *)STRING_WITH_LEN("\\n"))) |
| 67 | return TRUE; |
| 68 | break; |
| 69 | case '\0': // problem for some string processing utilities |
| 70 | if (my_b_append(file, (const uchar *)STRING_WITH_LEN("\\0"))) |
| 71 | return TRUE; |
| 72 | break; |
| 73 | case 26: // problem for windows utilities (Ctrl-Z) |
| 74 | if (my_b_append(file, (const uchar *)STRING_WITH_LEN("\\z"))) |
| 75 | return TRUE; |
| 76 | break; |
| 77 | case '\'': // list of string delimiter |
| 78 | if (my_b_append(file, (const uchar *)STRING_WITH_LEN("\\\'"))) |
| 79 | return TRUE; |
| 80 | break; |
| 81 | default: |
| 82 | if (my_b_append(file, (const uchar *)ptr, 1)) |
| 83 | return TRUE; |
| 84 | } |
| 85 | } |
| 86 | return FALSE; |
| 87 | } |
| 88 | |
| 89 | |
| 90 | /** |
no test coverage detected