diff options
author | Bart Schaefer <schaefer@ipost.com> | 2022-04-04 13:20:45 -0700 |
---|---|---|
committer | Bart Schaefer <schaefer@ipost.com> | 2022-04-04 13:20:45 -0700 |
commit | bdd37b4c1490caad4750402cee887bb19e3502d7 (patch) | |
tree | 3b76fe50e9161b5b762ed21ca3d251cfeb8b370d /Src | |
parent | f27e48827cc6ac224584328e632a89beed57c0ea (diff) | |
download | zsh-bdd37b4c1490caad4750402cee887bb19e3502d7.tar.gz zsh-bdd37b4c1490caad4750402cee887bb19e3502d7.tar.xz zsh-bdd37b4c1490caad4750402cee887bb19e3502d7.zip |
49990: casemodify() avoids metafying characters that it otherwise did not touch
Diffstat (limited to 'Src')
-rw-r--r-- | Src/hist.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/Src/hist.c b/Src/hist.c index d4557d424..f9440dba7 100644 --- a/Src/hist.c +++ b/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 |