summaryrefslogtreecommitdiff
path: root/Src/Zle/zle_main.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2006-07-24 22:00:19 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2006-07-24 22:00:19 +0000
commit50e9ab122b5022d8e90facb6ca01b32996ea16d1 (patch)
tree0bf441f7d4a77ac25fbe8ddcf8087f8526d72955 /Src/Zle/zle_main.c
parent6ca7b6abdf90d68c64bd57ac07d8a52ac6dc075b (diff)
downloadzsh-50e9ab122b5022d8e90facb6ca01b32996ea16d1.tar.gz
zsh-50e9ab122b5022d8e90facb6ca01b32996ea16d1.zip
22556: Multibyte separators and delimiters
Diffstat (limited to 'Src/Zle/zle_main.c')
-rw-r--r--Src/Zle/zle_main.c32
1 files changed, 20 insertions, 12 deletions
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 */