| 195 | */ |
| 196 | |
| 197 | static char *process_str_arg(CHARSET_INFO *cs, char *to, const char *end, |
| 198 | longlong length_arg, size_t width, char *par, |
| 199 | my_bool escaped_arg, my_bool nice_cut) |
| 200 | { |
| 201 | int well_formed_error; |
| 202 | uint dots= 0; |
| 203 | size_t plen, left_len= (size_t) (end - to) + 1, slen=0; |
| 204 | my_bool left_fill= 1; |
| 205 | size_t length; |
| 206 | |
| 207 | /* |
| 208 | The sign of the length argument specify whether the string should be right |
| 209 | or left adjusted |
| 210 | */ |
| 211 | if (length_arg < 0) |
| 212 | { |
| 213 | length= (size_t) -length_arg; |
| 214 | left_fill= 0; |
| 215 | } |
| 216 | else |
| 217 | length= (size_t) length_arg; |
| 218 | |
| 219 | if (!par) |
| 220 | par = (char*) "(null)"; |
| 221 | |
| 222 | if (nice_cut) |
| 223 | { |
| 224 | plen= slen= strnlen(par, width + 1); |
| 225 | if (plen > width) |
| 226 | plen= width; |
| 227 | if (left_len <= plen) |
| 228 | { |
| 229 | plen = left_len - 1; |
| 230 | length= plen; |
| 231 | } |
| 232 | if ((slen > plen)) |
| 233 | { |
| 234 | if (plen < 3) |
| 235 | { |
| 236 | dots= (uint) plen; |
| 237 | plen= 0; |
| 238 | } |
| 239 | else |
| 240 | { |
| 241 | dots= 3; |
| 242 | plen-= 3; |
| 243 | } |
| 244 | } |
| 245 | } |
| 246 | else |
| 247 | { |
| 248 | plen= slen= strnlen(par, width); |
| 249 | dots= 0; |
| 250 | if (left_len <= plen) |
| 251 | { |
| 252 | plen = left_len - 1; |
| 253 | length= plen; |
| 254 | } |
no test coverage detected