aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa1999-08-13 12:54:08 +0000
committerKenichi Handa1999-08-13 12:54:08 +0000
commit6662e69b7f96b9e760f3bbcff760d9a79e0dba3b (patch)
tree4e4bc89091d20dd10d78545a90e042b485427f23 /src
parent708ca3c8f934dca64b981ff9e35a474ee6eb0be8 (diff)
downloademacs-6662e69b7f96b9e760f3bbcff760d9a79e0dba3b.tar.gz
emacs-6662e69b7f96b9e760f3bbcff760d9a79e0dba3b.zip
(non_ascii_char_to_string): Handle modifier bits as
the same as Lisp reader.
Diffstat (limited to 'src')
-rw-r--r--src/charset.c43
1 files changed, 37 insertions, 6 deletions
diff --git a/src/charset.c b/src/charset.c
index b286c655792..9c6da218436 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -142,15 +142,46 @@ non_ascii_char_to_string (c, workbuf, str)
142{ 142{
143 int charset, c1, c2; 143 int charset, c1, c2;
144 144
145 if (c & ~GLYPH_MASK_CHAR) /* This includes the case C is negative. */ 145 if (c & CHAR_MODIFIER_MASK) /* This includes the case C is negative. */
146 { 146 {
147 /* Multibyte character can't have a modifier bit. */
148 if (! SINGLE_BYTE_CHAR_P ((c & ~CHAR_MODIFIER_MASK)))
149 invalid_character (c);
150
151 /* For Meta, Shift, and Control modifiers, we need special care. */
147 if (c & CHAR_META) 152 if (c & CHAR_META)
148 /* Move the meta bit to the right place for a string. */ 153 {
149 c |= 0x80; 154 /* Move the meta bit to the right place for a string. */
155 c = (c & ~CHAR_META) | 0x80;
156 }
157 if (c & CHAR_SHIFT)
158 {
159 /* Shift modifier is valid only with [A-Za-z]. */
160 if ((c & 0377) >= 'A' && (c & 0377) <= 'Z')
161 c &= ~CHAR_SHIFT;
162 else if ((c & 0377) >= 'a' && (c & 0377) <= 'z')
163 c = (c & ~CHAR_SHIFT) - ('a' - 'A');
164 }
150 if (c & CHAR_CTL) 165 if (c & CHAR_CTL)
151 c &= 0x9F; 166 {
152 else if (c & CHAR_SHIFT && (c & 0x7F) >= 'a' && (c & 0x7F) <= 'z') 167 /* Simulate the code in lread.c. */
153 c -= 'a' - 'A'; 168 /* Allow `\C- ' and `\C-?'. */
169 if (c == (CHAR_CTL | ' '))
170 c = 0;
171 else if (c == (CHAR_CTL | '?'))
172 c = 127;
173 /* ASCII control chars are made from letters (both cases),
174 as well as the non-letters within 0100...0137. */
175 else if ((c & 0137) >= 0101 && (c & 0137) <= 0132)
176 c &= (037 | (~0177 & ~CHAR_CTL));
177 else if ((c & 0177) >= 0100 && (c & 0177) <= 0137)
178 c &= (037 | (~0177 & ~CHAR_CTL));
179 }
180
181 /* If C still has any modifier bits, it is an invalid character. */
182 if (c & CHAR_MODIFIER_MASK)
183 invalid_character (c);
184
154 *str = workbuf; 185 *str = workbuf;
155 *workbuf = c; 186 *workbuf = c;
156 return 1; 187 return 1;