aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2002-10-09 05:24:48 +0000
committerKenichi Handa2002-10-09 05:24:48 +0000
commite3d8eb8c6659fcefb3d2dbb1cc83d95b3b9a5bff (patch)
treeabea0f3f122f738a48a9a5c53b26cf337a43f3ea /src
parenteb41da4cb95b6715df1f76e185625144d37b5653 (diff)
downloademacs-e3d8eb8c6659fcefb3d2dbb1cc83d95b3b9a5bff.tar.gz
emacs-e3d8eb8c6659fcefb3d2dbb1cc83d95b3b9a5bff.zip
(char_string): Renamed from
char_string_with_unification. Pay attention to CHAR_MODIFIER_MASK. (string_char): Renamed from string_char.
Diffstat (limited to 'src')
-rw-r--r--src/character.c54
1 files changed, 50 insertions, 4 deletions
diff --git a/src/character.c b/src/character.c
index 2031e5e9b36..5501d8eb13a 100644
--- a/src/character.c
+++ b/src/character.c
@@ -87,15 +87,56 @@ int unibyte_to_multibyte_table[256];
87 87
88 88
89int 89int
90char_string_with_unification (c, p) 90char_string (c, p)
91 int c; 91 int c;
92 unsigned char *p; 92 unsigned char *p;
93{ 93{
94 int bytes; 94 int bytes;
95 95
96 if (c & CHAR_MODIFIER_MASK)
97 {
98 /* As a character not less than 256 can't have modifier bits, we
99 just ignore the bits. */
100 if (SINGLE_BYTE_CHAR_P ((c & ~CHAR_MODIFIER_MASK)))
101 {
102 /* For Meta, Shift, and Control modifiers, we need special care. */
103 if (c & CHAR_META)
104 {
105 /* Move the meta bit to the right place for a string. */
106 c = (c & ~CHAR_META) | 0x80;
107 }
108 if (c & CHAR_SHIFT)
109 {
110 /* Shift modifier is valid only with [A-Za-z]. */
111 if ((c & 0377) >= 'A' && (c & 0377) <= 'Z')
112 c &= ~CHAR_SHIFT;
113 else if ((c & 0377) >= 'a' && (c & 0377) <= 'z')
114 c = (c & ~CHAR_SHIFT) - ('a' - 'A');
115 }
116 if (c & CHAR_CTL)
117 {
118 /* Simulate the code in lread.c. */
119 /* Allow `\C- ' and `\C-?'. */
120 if (c == (CHAR_CTL | ' '))
121 c = 0;
122 else if (c == (CHAR_CTL | '?'))
123 c = 127;
124 /* ASCII control chars are made from letters (both cases),
125 as well as the non-letters within 0100...0137. */
126 else if ((c & 0137) >= 0101 && (c & 0137) <= 0132)
127 c &= (037 | (~0177 & ~CHAR_CTL));
128 else if ((c & 0177) >= 0100 && (c & 0177) <= 0137)
129 c &= (037 | (~0177 & ~CHAR_CTL));
130 }
131 }
132
133 /* If C still has any modifier bits, just ignore it. */
134 c &= ~CHAR_MODIFIER_MASK;
135 }
136
96 MAYBE_UNIFY_CHAR (c); 137 MAYBE_UNIFY_CHAR (c);
97 138
98 if (c <= MAX_3_BYTE_CHAR || c > MAX_5_BYTE_CHAR) 139 if (c <= MAX_3_BYTE_CHAR)
99 { 140 {
100 bytes = CHAR_STRING (c, p); 141 bytes = CHAR_STRING (c, p);
101 } 142 }
@@ -107,7 +148,7 @@ char_string_with_unification (c, p)
107 p[3] = (0x80 | (c & 0x3F)); 148 p[3] = (0x80 | (c & 0x3F));
108 bytes = 4; 149 bytes = 4;
109 } 150 }
110 else 151 else if (c <= MAX_5_BYTE_CHAR)
111 { 152 {
112 p[0] = 0xF8; 153 p[0] = 0xF8;
113 p[1] = (0x80 | ((c >> 18) & 0x0F)); 154 p[1] = (0x80 | ((c >> 18) & 0x0F));
@@ -116,13 +157,18 @@ char_string_with_unification (c, p)
116 p[4] = (0x80 | (c & 0x3F)); 157 p[4] = (0x80 | (c & 0x3F));
117 bytes = 5; 158 bytes = 5;
118 } 159 }
160 else
161 {
162 c = CHAR_TO_BYTE8 (c);
163 bytes = BYTE8_STRING (c, p);
164 }
119 165
120 return bytes; 166 return bytes;
121} 167}
122 168
123 169
124int 170int
125string_char_with_unification (p, advanced, len) 171string_char (p, advanced, len)
126 const unsigned char *p; 172 const unsigned char *p;
127 const unsigned char **advanced; 173 const unsigned char **advanced;
128 int *len; 174 int *len;