diff options
| author | Michal Nazarewicz | 2016-09-07 21:00:57 +0200 |
|---|---|---|
| committer | Michal Nazarewicz | 2017-02-15 16:54:07 +0100 |
| commit | 6220faeb4e9be16b9dec728e72ea8dff2cfe35ba (patch) | |
| tree | d329bc3c65eb858ea8f03a2705ea5de696abac05 /src/casefiddle.c | |
| parent | 5ec3a58462e99533ea5200de356302181d634d0b (diff) | |
| download | emacs-6220faeb4e9be16b9dec728e72ea8dff2cfe35ba.tar.gz emacs-6220faeb4e9be16b9dec728e72ea8dff2cfe35ba.zip | |
casing: don’t assume letters are *either* upper- or lower-case (bug#24603)
A compatibility digraph characters, such as Dž, are neither upper- nor
lower-case. At the moment however, those are reported as upper-case¹
despite the fact that they change when upper-cased.
Stop checking if a character is upper-case before trying to up-case it
so that title-case characters are handled correctly. This fixes one of
the issues mentioned in bug#24603.
¹ Because they change when converted to lower-case. Notice an asymmetry
in that for a character to be considered lower-case it must not be
upper-case (plus the usual condition of changing when upper-cased).
* src/buffer.h (upcase1): Delete.
(upcase): Change to upcase character unconditionally just like downcase
does it. This is what upcase1 was.
* src/casefiddle.c (casify_object, casify_region): Use upcase instead
of upcase1 and don’t check !uppercasep(x) before calling upcase.
* src/keyboard.c (read_key_sequence): Don’t check if uppercase(x), just
downcase(x) and see if it changed.
* test/src/casefiddle-tests.el (casefiddle-tests--characters,
casefiddle-tests-casing): Update test cases which are now passing.
Diffstat (limited to 'src/casefiddle.c')
| -rw-r--r-- | src/casefiddle.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/src/casefiddle.c b/src/casefiddle.c index 28ffcb298ff..b2b87e7a858 100644 --- a/src/casefiddle.c +++ b/src/casefiddle.c | |||
| @@ -64,13 +64,9 @@ casify_object (enum case_action flag, Lisp_Object obj) | |||
| 64 | multibyte = 1; | 64 | multibyte = 1; |
| 65 | if (! multibyte) | 65 | if (! multibyte) |
| 66 | MAKE_CHAR_MULTIBYTE (c1); | 66 | MAKE_CHAR_MULTIBYTE (c1); |
| 67 | c = downcase (c1); | 67 | c = flag == CASE_DOWN ? downcase (c1) : upcase (c1); |
| 68 | if (inword) | 68 | if (c != c1) |
| 69 | XSETFASTINT (obj, c | flags); | ||
| 70 | else if (c == (XFASTINT (obj) & ~flagbits)) | ||
| 71 | { | 69 | { |
| 72 | if (! inword) | ||
| 73 | c = upcase1 (c1); | ||
| 74 | if (! multibyte) | 70 | if (! multibyte) |
| 75 | MAKE_CHAR_UNIBYTE (c); | 71 | MAKE_CHAR_UNIBYTE (c); |
| 76 | XSETFASTINT (obj, c | flags); | 72 | XSETFASTINT (obj, c | flags); |
| @@ -95,7 +91,7 @@ casify_object (enum case_action flag, Lisp_Object obj) | |||
| 95 | c = downcase (c); | 91 | c = downcase (c); |
| 96 | else if (!uppercasep (c) | 92 | else if (!uppercasep (c) |
| 97 | && (!inword || flag != CASE_CAPITALIZE_UP)) | 93 | && (!inword || flag != CASE_CAPITALIZE_UP)) |
| 98 | c = upcase1 (c1); | 94 | c = upcase (c1); |
| 99 | if ((int) flag >= (int) CASE_CAPITALIZE) | 95 | if ((int) flag >= (int) CASE_CAPITALIZE) |
| 100 | inword = (SYNTAX (c) == Sword); | 96 | inword = (SYNTAX (c) == Sword); |
| 101 | if (c != c1) | 97 | if (c != c1) |
| @@ -127,9 +123,8 @@ casify_object (enum case_action flag, Lisp_Object obj) | |||
| 127 | c = STRING_CHAR_AND_LENGTH (SDATA (obj) + i_byte, len); | 123 | c = STRING_CHAR_AND_LENGTH (SDATA (obj) + i_byte, len); |
| 128 | if (inword && flag != CASE_CAPITALIZE_UP) | 124 | if (inword && flag != CASE_CAPITALIZE_UP) |
| 129 | c = downcase (c); | 125 | c = downcase (c); |
| 130 | else if (!uppercasep (c) | 126 | else if (!inword || flag != CASE_CAPITALIZE_UP) |
| 131 | && (!inword || flag != CASE_CAPITALIZE_UP)) | 127 | c = upcase (c); |
| 132 | c = upcase1 (c); | ||
| 133 | if ((int) flag >= (int) CASE_CAPITALIZE) | 128 | if ((int) flag >= (int) CASE_CAPITALIZE) |
| 134 | inword = (SYNTAX (c) == Sword); | 129 | inword = (SYNTAX (c) == Sword); |
| 135 | o += CHAR_STRING (c, o); | 130 | o += CHAR_STRING (c, o); |
| @@ -236,9 +231,8 @@ casify_region (enum case_action flag, Lisp_Object b, Lisp_Object e) | |||
| 236 | c2 = c; | 231 | c2 = c; |
| 237 | if (inword && flag != CASE_CAPITALIZE_UP) | 232 | if (inword && flag != CASE_CAPITALIZE_UP) |
| 238 | c = downcase (c); | 233 | c = downcase (c); |
| 239 | else if (!uppercasep (c) | 234 | else if (!inword || flag != CASE_CAPITALIZE_UP) |
| 240 | && (!inword || flag != CASE_CAPITALIZE_UP)) | 235 | c = upcase (c); |
| 241 | c = upcase1 (c); | ||
| 242 | if ((int) flag >= (int) CASE_CAPITALIZE) | 236 | if ((int) flag >= (int) CASE_CAPITALIZE) |
| 243 | inword = ((SYNTAX (c) == Sword) | 237 | inword = ((SYNTAX (c) == Sword) |
| 244 | && (inword || !syntax_prefix_flag_p (c))); | 238 | && (inword || !syntax_prefix_flag_p (c))); |