aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2002-03-01 01:11:39 +0000
committerKenichi Handa2002-03-01 01:11:39 +0000
commite961d43908ff8bef5223f94f44ece00391e0a19b (patch)
tree1108a2f510b99935eb598d236dce987b8b22c586 /src
parent91183bfd93d103383d05b017f4686408fda954d3 (diff)
downloademacs-e961d43908ff8bef5223f94f44ece00391e0a19b.tar.gz
emacs-e961d43908ff8bef5223f94f44ece00391e0a19b.zip
Include "character.h" instead of "charset.h".
(set_canon, set_identity, shuffle): Adjusted for the new map_char_table spec. (init_casetab_once): Call CHAR_TABLE_SET instead of directly accessing the char table structure.
Diffstat (limited to 'src')
-rw-r--r--src/casetab.c95
1 files changed, 69 insertions, 26 deletions
diff --git a/src/casetab.c b/src/casetab.c
index de504e2e335..a361d092012 100644
--- a/src/casetab.c
+++ b/src/casetab.c
@@ -23,7 +23,7 @@ Boston, MA 02111-1307, USA. */
23#include <config.h> 23#include <config.h>
24#include "lisp.h" 24#include "lisp.h"
25#include "buffer.h" 25#include "buffer.h"
26#include "charset.h" 26#include "character.h"
27 27
28Lisp_Object Qcase_table_p, Qcase_table; 28Lisp_Object Qcase_table_p, Qcase_table;
29Lisp_Object Vascii_downcase_table, Vascii_upcase_table; 29Lisp_Object Vascii_downcase_table, Vascii_upcase_table;
@@ -178,25 +178,52 @@ set_case_table (table, standard)
178 char-tables CANON, UP, and DOWN are in CASE_TABLE. */ 178 char-tables CANON, UP, and DOWN are in CASE_TABLE. */
179 179
180static void 180static void
181set_canon (case_table, c, elt) 181set_canon (case_table, range, elt)
182 Lisp_Object case_table, c, elt; 182 Lisp_Object case_table, range, elt;
183{ 183{
184 Lisp_Object up = XCHAR_TABLE (case_table)->extras[0]; 184 Lisp_Object up = XCHAR_TABLE (case_table)->extras[0];
185 Lisp_Object canon = XCHAR_TABLE (case_table)->extras[1]; 185 Lisp_Object canon = XCHAR_TABLE (case_table)->extras[1];
186 int from, to;
186 187
187 if (NATNUMP (elt)) 188 if (NATNUMP (elt))
188 Faset (canon, c, Faref (case_table, Faref (up, elt))); 189 {
190 if (CONSP (range))
191 {
192 from = XINT (XCAR (range));
193 to = XINT (XCDR (range));
194 }
195 else
196 from = to = XINT (range);
197
198 for (; from <= to; from++)
199 {
200 Lisp_Object val1, val2;
201
202 val1 = Faref (up, elt);
203 if (EQ (val1, Qt))
204 val1 = elt;
205 else if (! NATNUMP (val1))
206 continue;
207 val2 = Faref (case_table, val1);
208 if (EQ (val2, Qt))
209 val2 = val1;
210 else if (! NATNUMP (val2))
211 continue;
212 Faset (canon, make_number (from), val2);
213 }
214 }
189} 215}
190 216
191/* Set elements of char-table TABLE for C to C itself. This is done 217/* Set elements of char-table TABLE for characters in RANGE to
192 only when ELT is a character. This is called in map_char_table. */ 218 themselves. This is done only when ELT is a character. This is
219 called in map_char_table. */
193 220
194static void 221static void
195set_identity (table, c, elt) 222set_identity (table, range, elt)
196 Lisp_Object table, c, elt; 223 Lisp_Object table, range, elt;
197{ 224{
198 if (NATNUMP (elt)) 225 if (EQ (elt, Qt) || NATNUMP (elt))
199 Faset (table, c, c); 226 Fset_char_table_range (table, range, Qt);
200} 227}
201 228
202/* Permute the elements of TABLE (which is initially an identity 229/* Permute the elements of TABLE (which is initially an identity
@@ -205,14 +232,32 @@ set_identity (table, c, elt)
205 operated. */ 232 operated. */
206 233
207static void 234static void
208shuffle (table, c, elt) 235shuffle (table, range, elt)
209 Lisp_Object table, c, elt; 236 Lisp_Object table, range, elt;
210{ 237{
211 if (NATNUMP (elt) && !EQ (c, elt)) 238 int from, to;
239
240 if (NATNUMP (elt))
212 { 241 {
213 Lisp_Object tem = Faref (table, elt); 242 Lisp_Object tem;
214 Faset (table, elt, c); 243
215 Faset (table, c, tem); 244 if (CONSP (range))
245 {
246 from = XINT (XCAR (range));
247 to = XINT (XCDR (range));
248 }
249 else
250 from = to = XINT (range);
251
252 for (; from <= to; from++)
253 if (from != XINT (elt))
254 {
255 tem = Faref (table, elt);
256 if (EQ (tem, Qt))
257 tem = elt;
258 Faset (table, elt, make_number (from));
259 Faset (table, make_number (from), tem);
260 }
216 } 261 }
217} 262}
218 263
@@ -237,22 +282,20 @@ init_casetab_once ()
237 Vascii_downcase_table = down; 282 Vascii_downcase_table = down;
238 XCHAR_TABLE (down)->purpose = Qcase_table; 283 XCHAR_TABLE (down)->purpose = Qcase_table;
239 284
240 for (i = 0; i < CHAR_TABLE_SINGLE_BYTE_SLOTS; i++) 285 for (i = 0; i < 128; i++)
241 XSETFASTINT (XCHAR_TABLE (down)->contents[i], 286 CHAR_TABLE_SET (down, i, (i >= 'A' && i <= 'Z') ? i + ('a' - 'A') : i);
242 (i >= 'A' && i <= 'Z') ? i + ('a' - 'A') : i);
243 287
244 XCHAR_TABLE (down)->extras[1] = Fcopy_sequence (down); 288 XCHAR_TABLE (down)->extras[1] = Fcopy_sequence (down);
245 289
246 up = Fmake_char_table (Qcase_table, Qnil); 290 up = Fmake_char_table (Qcase_table, Qnil);
247 XCHAR_TABLE (down)->extras[0] = up; 291 XCHAR_TABLE (down)->extras[0] = up;
248 292
249 for (i = 0; i < CHAR_TABLE_SINGLE_BYTE_SLOTS; i++) 293 for (i = 0; i < 128; i++)
250 XSETFASTINT (XCHAR_TABLE (up)->contents[i], 294 CHAR_TABLE_SET (up, i, ((i >= 'A' && i <= 'Z')
251 ((i >= 'A' && i <= 'Z') 295 ? i + ('a' - 'A')
252 ? i + ('a' - 'A') 296 : ((i >= 'a' && i <= 'z')
253 : ((i >= 'a' && i <= 'z') 297 ? i + ('A' - 'a')
254 ? i + ('A' - 'a') 298 : i)));
255 : i)));
256 299
257 XCHAR_TABLE (down)->extras[2] = Fcopy_sequence (up); 300 XCHAR_TABLE (down)->extras[2] = Fcopy_sequence (up);
258} 301}