87 |
|
|
88 |
|
|
89 |
int |
int |
90 |
char_string_with_unification (c, p) |
char_string (c, p) |
91 |
int c; |
int c; |
92 |
unsigned char *p; |
unsigned char *p; |
93 |
{ |
{ |
94 |
int bytes; |
int bytes; |
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 |
|
|
137 |
MAYBE_UNIFY_CHAR (c); |
MAYBE_UNIFY_CHAR (c); |
138 |
|
|
139 |
if (c <= MAX_3_BYTE_CHAR || c > MAX_5_BYTE_CHAR) |
if (c <= MAX_3_BYTE_CHAR) |
140 |
{ |
{ |
141 |
bytes = CHAR_STRING (c, p); |
bytes = CHAR_STRING (c, p); |
142 |
} |
} |
148 |
p[3] = (0x80 | (c & 0x3F)); |
p[3] = (0x80 | (c & 0x3F)); |
149 |
bytes = 4; |
bytes = 4; |
150 |
} |
} |
151 |
else |
else if (c <= MAX_5_BYTE_CHAR) |
152 |
{ |
{ |
153 |
p[0] = 0xF8; |
p[0] = 0xF8; |
154 |
p[1] = (0x80 | ((c >> 18) & 0x0F)); |
p[1] = (0x80 | ((c >> 18) & 0x0F)); |
157 |
p[4] = (0x80 | (c & 0x3F)); |
p[4] = (0x80 | (c & 0x3F)); |
158 |
bytes = 5; |
bytes = 5; |
159 |
} |
} |
160 |
|
else |
161 |
|
{ |
162 |
|
c = CHAR_TO_BYTE8 (c); |
163 |
|
bytes = BYTE8_STRING (c, p); |
164 |
|
} |
165 |
|
|
166 |
return bytes; |
return bytes; |
167 |
} |
} |
168 |
|
|
169 |
|
|
170 |
int |
int |
171 |
string_char_with_unification (p, advanced, len) |
string_char (p, advanced, len) |
172 |
const unsigned char *p; |
const unsigned char *p; |
173 |
const unsigned char **advanced; |
const unsigned char **advanced; |
174 |
int *len; |
int *len; |