| 139 | */ |
| 140 | |
| 141 | my_bool dynstr_append_os_quoted(DYNAMIC_STRING *str, const char *append, ...) |
| 142 | { |
| 143 | #ifdef __WIN__ |
| 144 | const char *quote_str= "\""; |
| 145 | const uint quote_len= 1; |
| 146 | #else |
| 147 | const char *quote_str= "\'"; |
| 148 | const uint quote_len= 1; |
| 149 | #endif /* __WIN__ */ |
| 150 | my_bool ret= TRUE; |
| 151 | va_list dirty_text; |
| 152 | |
| 153 | ret&= dynstr_append_mem(str, quote_str, quote_len); /* Leading quote */ |
| 154 | va_start(dirty_text, append); |
| 155 | while (append != NullS) |
| 156 | { |
| 157 | const char *cur_pos= append; |
| 158 | const char *next_pos= cur_pos; |
| 159 | |
| 160 | /* Search for quote in each string and replace with escaped quote */ |
| 161 | while(*(next_pos= strcend(cur_pos, quote_str[0])) != '\0') |
| 162 | { |
| 163 | ret&= dynstr_append_mem(str, cur_pos, (uint) (next_pos - cur_pos)); |
| 164 | ret&= dynstr_append_mem(str ,"\\", 1); |
| 165 | ret&= dynstr_append_mem(str, quote_str, quote_len); |
| 166 | cur_pos= next_pos + 1; |
| 167 | } |
| 168 | ret&= dynstr_append_mem(str, cur_pos, (uint) (next_pos - cur_pos)); |
| 169 | append= va_arg(dirty_text, char *); |
| 170 | } |
| 171 | va_end(dirty_text); |
| 172 | ret&= dynstr_append_mem(str, quote_str, quote_len); /* Trailing quote */ |
| 173 | |
| 174 | return ret; |
| 175 | } |
| 176 | |
| 177 | |
| 178 | void dynstr_free(DYNAMIC_STRING *str) |
nothing calls this directly
no test coverage detected