diff options
Diffstat (limited to 'Src/Zle')
-rw-r--r-- | Src/Zle/zle.h | 4 | ||||
-rw-r--r-- | Src/Zle/zle_main.c | 32 |
2 files changed, 22 insertions, 14 deletions
diff --git a/Src/Zle/zle.h b/Src/Zle/zle.h index 3671f90f3..69c73f4cf 100644 --- a/Src/Zle/zle.h +++ b/Src/Zle/zle.h @@ -62,11 +62,11 @@ typedef wint_t ZLE_INT_T; #define ZC_iblank wcsiblank #define ZC_icntrl iswcntrl #define ZC_idigit iswdigit -#define ZC_iident wcsiident +#define ZC_iident(x) wcsitype((x), IIDENT) #define ZC_ilower iswlower #define ZC_inblank iswspace #define ZC_iupper iswupper -#define ZC_iword wcsiword +#define ZC_iword(x) wcsitype((x), IWORD) #define ZC_tolower towlower #define ZC_toupper towupper diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c index 1c82611c2..1d4636937 100644 --- a/Src/Zle/zle_main.c +++ b/Src/Zle/zle_main.c @@ -1290,32 +1290,40 @@ bin_vared(char *name, char **args, Options ops, UNUSED(int func)) char **arr = getarrvalue(v), **aptr, **tmparr, **tptr; tptr = tmparr = (char **)zhalloc(sizeof(char *)*(arrlen(arr)+1)); for (aptr = arr; *aptr; aptr++) { - int sepcount = 0; + int sepcount = 0, clen; + convchar_t c; /* * See if this word contains a separator character * or backslash */ - for (t = *aptr; *t; t++) { - if (*t == Meta) { - if (isep(t[1] ^ 32)) - sepcount++; + MB_METACHARINIT(); + for (t = *aptr; *t; ) { + if (*t == '\\') { t++; - } else if (isep(*t) || *t == '\\') sepcount++; + } else { + t += MB_METACHARLENCONV(t, &c); + if (MB_ZISTYPE(c, ISEP)) + sepcount++; + } } if (sepcount) { /* Yes, so allocate enough space to quote it. */ char *newstr, *nptr; newstr = zhalloc(strlen(*aptr)+sepcount+1); /* Go through string quoting separators */ + MB_METACHARINIT(); for (t = *aptr, nptr = newstr; *t; ) { - if (*t == Meta) { - if (isep(t[1] ^ 32)) - *nptr++ = '\\'; - *nptr++ = *t++; - } else if (isep(*t) || *t == '\\') + if (*t == '\\') { *nptr++ = '\\'; - *nptr++ = *t++; + *nptr++ = *t++; + } else { + clen = MB_METACHARLENCONV(t, &c); + if (MB_ZISTYPE(c, ISEP)) + *nptr++ = '\\'; + while (clen--) + *nptr++ = *t++; + } } *nptr = '\0'; /* Stick this into the array of words to join up */ |