mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-22 16:20:23 +02:00
49990: casemodify() avoids metafying characters that it otherwise did not touch
This commit is contained in:
parent
f27e48827c
commit
bdd37b4c14
2 changed files with 19 additions and 5 deletions
|
@ -1,3 +1,8 @@
|
|||
2022-04-04 Bart Schaefer <schaefer@zsh.org>
|
||||
|
||||
* 49990: Src/hist.c: in single-byte, like multibyte, casemodify()
|
||||
avoids metafying characters that it otherwise did not touch
|
||||
|
||||
2022-04-03 Bart Schaefer <schaefer@zsh.org>
|
||||
|
||||
* 49955 (with thanks to Madhu <enometh@meer.net>): Src/glob.c:
|
||||
|
|
19
Src/hist.c
19
Src/hist.c
|
@ -2252,6 +2252,7 @@ casemodify(char *str, int how)
|
|||
#endif
|
||||
while (*str) {
|
||||
int c;
|
||||
int mod = 0;
|
||||
if (*str == Meta) {
|
||||
c = str[1] ^ 32;
|
||||
str += 2;
|
||||
|
@ -2259,13 +2260,17 @@ casemodify(char *str, int how)
|
|||
c = *str++;
|
||||
switch (how) {
|
||||
case CASMOD_LOWER:
|
||||
if (isupper(c))
|
||||
if (isupper(c)) {
|
||||
c = tolower(c);
|
||||
mod = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case CASMOD_UPPER:
|
||||
if (islower(c))
|
||||
if (islower(c)) {
|
||||
c = toupper(c);
|
||||
mod = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case CASMOD_CAPS:
|
||||
|
@ -2273,14 +2278,18 @@ casemodify(char *str, int how)
|
|||
if (!ialnum(c))
|
||||
nextupper = 1;
|
||||
else if (nextupper) {
|
||||
if (islower(c))
|
||||
if (islower(c)) {
|
||||
c = toupper(c);
|
||||
mod = 1;
|
||||
}
|
||||
nextupper = 0;
|
||||
} else if (isupper(c))
|
||||
} else if (isupper(c)) {
|
||||
c = tolower(c);
|
||||
mod = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (imeta(c)) {
|
||||
if (mod && imeta(c)) {
|
||||
*ptr2++ = Meta;
|
||||
*ptr2++ = c ^ 32;
|
||||
} else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue