summary refs log tree commit diff
diff options
context:
space:
mode:
authorBart Schaefer <schaefer@zsh.org>2022-04-04 14:21:50 -0700
committerBart Schaefer <schaefer@zsh.org>2022-04-04 14:21:50 -0700
commitb80d1600395c46b24ebe8d34e40fb4e660692de1 (patch)
tree652cd1d82ac42ec66a41043395736a1fdb389e4c
parentbdd37b4c1490caad4750402cee887bb19e3502d7 (diff)
downloadzsh-b80d1600395c46b24ebe8d34e40fb4e660692de1.tar.gz
zsh-b80d1600395c46b24ebe8d34e40fb4e660692de1.tar.xz
zsh-b80d1600395c46b24ebe8d34e40fb4e660692de1.zip
49991: single-byte brace expansion handles $'\0' and control character output aligns with multibyte
-rw-r--r--ChangeLog3
-rw-r--r--Src/glob.c15
-rw-r--r--Src/utils.c11
3 files changed, 17 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 92e5b6716..d2ffce95e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2022-04-04  Bart Schaefer  <schaefer@zsh.org>
 
+	* 49991: Src/glob.c, Src/utils.c: single-byte brace expansion
+	handles $'\0' and control character output aligns with multibyte
+
 	* 49990: Src/hist.c: in single-byte, like multibyte, casemodify()
 	avoids metafying characters that it otherwise did not touch
 
diff --git a/Src/glob.c b/Src/glob.c
index d4ffc2274..ca28f20e8 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -2220,7 +2220,7 @@ bracechardots(char *str, convchar_t *c1p, convchar_t *c2p)
 #ifdef MULTIBYTE_SUPPORT
 	cstart == WEOF ||
 #else
-	!cstart ||
+	!*pconv ||
 #endif
 	pnext[0] != '.' || pnext[1] != '.')
 	return 0;
@@ -2241,7 +2241,7 @@ bracechardots(char *str, convchar_t *c1p, convchar_t *c2p)
 #ifdef MULTIBYTE_SUPPORT
 	cend == WEOF ||
 #else
-	!cend ||
+	!*pconv ||
 #endif
 	*pnext != Outbrace)
 	return 0;
@@ -2305,22 +2305,19 @@ xpandbraces(LinkList list, LinkNode *np)
 	    strp = str - str3;
 	    lenalloc = strp + strlen(str2+1) + 1;
 	    do {
-#ifdef MULTIBYTE_SUPPORT
 		char *ncptr;
 		int nclen;
+#ifdef MULTIBYTE_SUPPORT
 		mb_charinit();
 		ncptr = wcs_nicechar(cend, NULL, NULL);
+#else
+		ncptr = nicechar(cend);
+#endif
 		nclen = strlen(ncptr);
 		p = zhalloc(lenalloc + nclen);
 		memcpy(p, str3, strp);
 		memcpy(p + strp, ncptr, nclen);
 		strcpy(p + strp + nclen, str2 + 1);
-#else
-		p = zhalloc(lenalloc + 1);
-		memcpy(p, str3, strp);
-		sprintf(p + strp, "%c", cend);
-		strcat(p + strp, str2 + 1);
-#endif
 		insertlinknode(list, last, p);
 		if (rev)	/* decreasing:  add in reverse order. */
 		    last = nextnode(last);
diff --git a/Src/utils.c b/Src/utils.c
index f9127c70c..66cb2a63a 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -557,9 +557,14 @@ nicechar(int c)
 	*s++ = '\\';
 	c = 't';
     } else if (c < 0x20) {
-	*s++ = '\\';
-	*s++ = 'C';
-	*s++ = '-';
+      /*
+	if (quotable) {
+	    *s++ = '\\';
+	    *s++ = 'C';
+	    *s++ = '-';
+	} else
+      */
+	    *s++ = '^';
 	c += 0x40;
     }
     done: