* Expand list of extra characters to not visually encode. */
| 331 | * Expand list of extra characters to not visually encode. |
| 332 | */ |
| 333 | static wchar_t * |
| 334 | makeextralist(int flags, const char *src) |
| 335 | { |
| 336 | wchar_t *dst, *d; |
| 337 | size_t len; |
| 338 | const wchar_t *s; |
| 339 | |
| 340 | len = strlen(src); |
| 341 | if ((dst = calloc(len + MAXEXTRAS, sizeof(*dst))) == NULL) |
| 342 | return NULL; |
| 343 | |
| 344 | if (mbstowcs(dst, src, len) == (size_t)-1) { |
| 345 | size_t i; |
| 346 | for (i = 0; i < len; i++) |
| 347 | dst[i] = (wchar_t)(u_char)src[i]; |
| 348 | d = dst + len; |
| 349 | } else |
| 350 | d = dst + wcslen(dst); |
| 351 | |
| 352 | if (flags & VIS_GLOB) |
| 353 | for (s = char_glob; *s; *d++ = *s++) |
| 354 | continue; |
| 355 | |
| 356 | if (flags & VIS_SHELL) |
| 357 | for (s = char_shell; *s; *d++ = *s++) |
| 358 | continue; |
| 359 | |
| 360 | if (flags & VIS_SP) *d++ = L' '; |
| 361 | if (flags & VIS_TAB) *d++ = L'\t'; |
| 362 | if (flags & VIS_NL) *d++ = L'\n'; |
| 363 | if ((flags & VIS_NOSLASH) == 0) *d++ = L'\\'; |
| 364 | *d = L'\0'; |
| 365 | |
| 366 | return dst; |
| 367 | } |
| 368 | |
| 369 | /* |
| 370 | * istrsenvisx() |