mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-12-16 09:01:25 +01:00
49991: single-byte brace expansion handles $'\0' and control character output aligns with multibyte
This commit is contained in:
parent
bdd37b4c14
commit
b80d160039
3 changed files with 17 additions and 12 deletions
|
|
@ -1,5 +1,8 @@
|
||||||
2022-04-04 Bart Schaefer <schaefer@zsh.org>
|
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()
|
* 49990: Src/hist.c: in single-byte, like multibyte, casemodify()
|
||||||
avoids metafying characters that it otherwise did not touch
|
avoids metafying characters that it otherwise did not touch
|
||||||
|
|
||||||
|
|
|
||||||
15
Src/glob.c
15
Src/glob.c
|
|
@ -2220,7 +2220,7 @@ bracechardots(char *str, convchar_t *c1p, convchar_t *c2p)
|
||||||
#ifdef MULTIBYTE_SUPPORT
|
#ifdef MULTIBYTE_SUPPORT
|
||||||
cstart == WEOF ||
|
cstart == WEOF ||
|
||||||
#else
|
#else
|
||||||
!cstart ||
|
!*pconv ||
|
||||||
#endif
|
#endif
|
||||||
pnext[0] != '.' || pnext[1] != '.')
|
pnext[0] != '.' || pnext[1] != '.')
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -2241,7 +2241,7 @@ bracechardots(char *str, convchar_t *c1p, convchar_t *c2p)
|
||||||
#ifdef MULTIBYTE_SUPPORT
|
#ifdef MULTIBYTE_SUPPORT
|
||||||
cend == WEOF ||
|
cend == WEOF ||
|
||||||
#else
|
#else
|
||||||
!cend ||
|
!*pconv ||
|
||||||
#endif
|
#endif
|
||||||
*pnext != Outbrace)
|
*pnext != Outbrace)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -2305,22 +2305,19 @@ xpandbraces(LinkList list, LinkNode *np)
|
||||||
strp = str - str3;
|
strp = str - str3;
|
||||||
lenalloc = strp + strlen(str2+1) + 1;
|
lenalloc = strp + strlen(str2+1) + 1;
|
||||||
do {
|
do {
|
||||||
#ifdef MULTIBYTE_SUPPORT
|
|
||||||
char *ncptr;
|
char *ncptr;
|
||||||
int nclen;
|
int nclen;
|
||||||
|
#ifdef MULTIBYTE_SUPPORT
|
||||||
mb_charinit();
|
mb_charinit();
|
||||||
ncptr = wcs_nicechar(cend, NULL, NULL);
|
ncptr = wcs_nicechar(cend, NULL, NULL);
|
||||||
|
#else
|
||||||
|
ncptr = nicechar(cend);
|
||||||
|
#endif
|
||||||
nclen = strlen(ncptr);
|
nclen = strlen(ncptr);
|
||||||
p = zhalloc(lenalloc + nclen);
|
p = zhalloc(lenalloc + nclen);
|
||||||
memcpy(p, str3, strp);
|
memcpy(p, str3, strp);
|
||||||
memcpy(p + strp, ncptr, nclen);
|
memcpy(p + strp, ncptr, nclen);
|
||||||
strcpy(p + strp + nclen, str2 + 1);
|
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);
|
insertlinknode(list, last, p);
|
||||||
if (rev) /* decreasing: add in reverse order. */
|
if (rev) /* decreasing: add in reverse order. */
|
||||||
last = nextnode(last);
|
last = nextnode(last);
|
||||||
|
|
|
||||||
|
|
@ -557,9 +557,14 @@ nicechar(int c)
|
||||||
*s++ = '\\';
|
*s++ = '\\';
|
||||||
c = 't';
|
c = 't';
|
||||||
} else if (c < 0x20) {
|
} else if (c < 0x20) {
|
||||||
|
/*
|
||||||
|
if (quotable) {
|
||||||
*s++ = '\\';
|
*s++ = '\\';
|
||||||
*s++ = 'C';
|
*s++ = 'C';
|
||||||
*s++ = '-';
|
*s++ = '-';
|
||||||
|
} else
|
||||||
|
*/
|
||||||
|
*s++ = '^';
|
||||||
c += 0x40;
|
c += 0x40;
|
||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue