comparison src/chartab.c @ 440:8de8e3f6228a r21-2-28

Import from CVS: tag r21-2-28
author cvs
date Mon, 13 Aug 2007 11:33:38 +0200
parents 3ecd8885ac67
children abe6d1db359e
comparison
equal deleted inserted replaced
439:357dd071b03c 440:8de8e3f6228a
95 #ifdef MULE 95 #ifdef MULE
96 96
97 static Lisp_Object 97 static Lisp_Object
98 mark_char_table_entry (Lisp_Object obj) 98 mark_char_table_entry (Lisp_Object obj)
99 { 99 {
100 struct Lisp_Char_Table_Entry *cte = XCHAR_TABLE_ENTRY (obj); 100 Lisp_Char_Table_Entry *cte = XCHAR_TABLE_ENTRY (obj);
101 int i; 101 int i;
102 102
103 for (i = 0; i < 96; i++) 103 for (i = 0; i < 96; i++)
104 { 104 {
105 mark_object (cte->level2[i]); 105 mark_object (cte->level2[i]);
108 } 108 }
109 109
110 static int 110 static int
111 char_table_entry_equal (Lisp_Object obj1, Lisp_Object obj2, int depth) 111 char_table_entry_equal (Lisp_Object obj1, Lisp_Object obj2, int depth)
112 { 112 {
113 struct Lisp_Char_Table_Entry *cte1 = XCHAR_TABLE_ENTRY (obj1); 113 Lisp_Char_Table_Entry *cte1 = XCHAR_TABLE_ENTRY (obj1);
114 struct Lisp_Char_Table_Entry *cte2 = XCHAR_TABLE_ENTRY (obj2); 114 Lisp_Char_Table_Entry *cte2 = XCHAR_TABLE_ENTRY (obj2);
115 int i; 115 int i;
116 116
117 for (i = 0; i < 96; i++) 117 for (i = 0; i < 96; i++)
118 if (!internal_equal (cte1->level2[i], cte2->level2[i], depth + 1)) 118 if (!internal_equal (cte1->level2[i], cte2->level2[i], depth + 1))
119 return 0; 119 return 0;
122 } 122 }
123 123
124 static unsigned long 124 static unsigned long
125 char_table_entry_hash (Lisp_Object obj, int depth) 125 char_table_entry_hash (Lisp_Object obj, int depth)
126 { 126 {
127 struct Lisp_Char_Table_Entry *cte = XCHAR_TABLE_ENTRY (obj); 127 Lisp_Char_Table_Entry *cte = XCHAR_TABLE_ENTRY (obj);
128 128
129 return internal_array_hash (cte->level2, 96, depth); 129 return internal_array_hash (cte->level2, 96, depth);
130 } 130 }
131 131
132 static const struct lrecord_description char_table_entry_description[] = { 132 static const struct lrecord_description char_table_entry_description[] = {
133 { XD_LISP_OBJECT, offsetof(struct Lisp_Char_Table_Entry, level2), 96 }, 133 { XD_LISP_OBJECT_ARRAY, offsetof (Lisp_Char_Table_Entry, level2), 96 },
134 { XD_END } 134 { XD_END }
135 }; 135 };
136 136
137 DEFINE_LRECORD_IMPLEMENTATION ("char-table-entry", char_table_entry, 137 DEFINE_LRECORD_IMPLEMENTATION ("char-table-entry", char_table_entry,
138 mark_char_table_entry, internal_object_printer, 138 mark_char_table_entry, internal_object_printer,
139 0, char_table_entry_equal, 139 0, char_table_entry_equal,
140 char_table_entry_hash, 140 char_table_entry_hash,
141 char_table_entry_description, 141 char_table_entry_description,
142 struct Lisp_Char_Table_Entry); 142 Lisp_Char_Table_Entry);
143 #endif /* MULE */ 143 #endif /* MULE */
144 144
145 static Lisp_Object 145 static Lisp_Object
146 mark_char_table (Lisp_Object obj) 146 mark_char_table (Lisp_Object obj)
147 { 147 {
148 struct Lisp_Char_Table *ct = XCHAR_TABLE (obj); 148 Lisp_Char_Table *ct = XCHAR_TABLE (obj);
149 int i; 149 int i;
150 150
151 for (i = 0; i < NUM_ASCII_CHARS; i++) 151 for (i = 0; i < NUM_ASCII_CHARS; i++)
152 mark_object (ct->ascii[i]); 152 mark_object (ct->ascii[i]);
153 #ifdef MULE 153 #ifdef MULE
239 #ifdef MULE 239 #ifdef MULE
240 240
241 static void 241 static void
242 print_chartab_charset_row (Lisp_Object charset, 242 print_chartab_charset_row (Lisp_Object charset,
243 int row, 243 int row,
244 struct Lisp_Char_Table_Entry *cte, 244 Lisp_Char_Table_Entry *cte,
245 Lisp_Object printcharfun) 245 Lisp_Object printcharfun)
246 { 246 {
247 int i; 247 int i;
248 Lisp_Object cat = Qunbound; 248 Lisp_Object cat = Qunbound;
249 int first = -1; 249 int first = -1;
287 } 287 }
288 } 288 }
289 289
290 static void 290 static void
291 print_chartab_two_byte_charset (Lisp_Object charset, 291 print_chartab_two_byte_charset (Lisp_Object charset,
292 struct Lisp_Char_Table_Entry *cte, 292 Lisp_Char_Table_Entry *cte,
293 Lisp_Object printcharfun) 293 Lisp_Object printcharfun)
294 { 294 {
295 int i; 295 int i;
296 296
297 for (i = 32; i < 128; i++) 297 for (i = 32; i < 128; i++)
317 #endif /* MULE */ 317 #endif /* MULE */
318 318
319 static void 319 static void
320 print_char_table (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag) 320 print_char_table (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
321 { 321 {
322 struct Lisp_Char_Table *ct = XCHAR_TABLE (obj); 322 Lisp_Char_Table *ct = XCHAR_TABLE (obj);
323 char buf[200]; 323 char buf[200];
324 324
325 sprintf (buf, "#s(char-table type %s data (", 325 sprintf (buf, "#s(char-table type %s data (",
326 string_data (symbol_name (XSYMBOL 326 string_data (symbol_name (XSYMBOL
327 (char_table_type_to_symbol (ct->type))))); 327 (char_table_type_to_symbol (ct->type)))));
375 write_c_string (" ", printcharfun); 375 write_c_string (" ", printcharfun);
376 print_internal (ann, printcharfun, 0); 376 print_internal (ann, printcharfun, 0);
377 } 377 }
378 else 378 else
379 { 379 {
380 struct Lisp_Char_Table_Entry *cte = XCHAR_TABLE_ENTRY (ann); 380 Lisp_Char_Table_Entry *cte = XCHAR_TABLE_ENTRY (ann);
381 if (XCHARSET_DIMENSION (charset) == 1) 381 if (XCHARSET_DIMENSION (charset) == 1)
382 print_chartab_charset_row (charset, -1, cte, printcharfun); 382 print_chartab_charset_row (charset, -1, cte, printcharfun);
383 else 383 else
384 print_chartab_two_byte_charset (charset, cte, printcharfun); 384 print_chartab_two_byte_charset (charset, cte, printcharfun);
385 } 385 }
391 } 391 }
392 392
393 static int 393 static int
394 char_table_equal (Lisp_Object obj1, Lisp_Object obj2, int depth) 394 char_table_equal (Lisp_Object obj1, Lisp_Object obj2, int depth)
395 { 395 {
396 struct Lisp_Char_Table *ct1 = XCHAR_TABLE (obj1); 396 Lisp_Char_Table *ct1 = XCHAR_TABLE (obj1);
397 struct Lisp_Char_Table *ct2 = XCHAR_TABLE (obj2); 397 Lisp_Char_Table *ct2 = XCHAR_TABLE (obj2);
398 int i; 398 int i;
399 399
400 if (CHAR_TABLE_TYPE (ct1) != CHAR_TABLE_TYPE (ct2)) 400 if (CHAR_TABLE_TYPE (ct1) != CHAR_TABLE_TYPE (ct2))
401 return 0; 401 return 0;
402 402
414 } 414 }
415 415
416 static unsigned long 416 static unsigned long
417 char_table_hash (Lisp_Object obj, int depth) 417 char_table_hash (Lisp_Object obj, int depth)
418 { 418 {
419 struct Lisp_Char_Table *ct = XCHAR_TABLE (obj); 419 Lisp_Char_Table *ct = XCHAR_TABLE (obj);
420 unsigned long hashval = internal_array_hash (ct->ascii, NUM_ASCII_CHARS, 420 unsigned long hashval = internal_array_hash (ct->ascii, NUM_ASCII_CHARS,
421 depth); 421 depth);
422 #ifdef MULE 422 #ifdef MULE
423 hashval = HASH2 (hashval, 423 hashval = HASH2 (hashval,
424 internal_array_hash (ct->level1, NUM_LEADING_BYTES, depth)); 424 internal_array_hash (ct->level1, NUM_LEADING_BYTES, depth));
425 #endif /* MULE */ 425 #endif /* MULE */
426 return hashval; 426 return hashval;
427 } 427 }
428 428
429 static const struct lrecord_description char_table_description[] = { 429 static const struct lrecord_description char_table_description[] = {
430 { XD_LISP_OBJECT, offsetof(struct Lisp_Char_Table, ascii), NUM_ASCII_CHARS }, 430 { XD_LISP_OBJECT_ARRAY, offsetof (Lisp_Char_Table, ascii), NUM_ASCII_CHARS },
431 #ifdef MULE 431 #ifdef MULE
432 { XD_LISP_OBJECT, offsetof(struct Lisp_Char_Table, level1), NUM_LEADING_BYTES }, 432 { XD_LISP_OBJECT_ARRAY, offsetof (Lisp_Char_Table, level1), NUM_LEADING_BYTES },
433 #endif 433 #endif
434 { XD_LISP_OBJECT, offsetof(struct Lisp_Char_Table, mirror_table), 1 }, 434 { XD_LISP_OBJECT, offsetof (Lisp_Char_Table, mirror_table) },
435 { XD_LO_LINK, offsetof(struct Lisp_Char_Table, next_table) }, 435 { XD_LO_LINK, offsetof (Lisp_Char_Table, next_table) },
436 { XD_END } 436 { XD_END }
437 }; 437 };
438 438
439 DEFINE_LRECORD_IMPLEMENTATION ("char-table", char_table, 439 DEFINE_LRECORD_IMPLEMENTATION ("char-table", char_table,
440 mark_char_table, print_char_table, 0, 440 mark_char_table, print_char_table, 0,
441 char_table_equal, char_table_hash, 441 char_table_equal, char_table_hash,
442 char_table_description, 442 char_table_description,
443 struct Lisp_Char_Table); 443 Lisp_Char_Table);
444 444
445 DEFUN ("char-table-p", Fchar_table_p, 1, 1, 0, /* 445 DEFUN ("char-table-p", Fchar_table_p, 1, 1, 0, /*
446 Return non-nil if OBJECT is a char table. 446 Return non-nil if OBJECT is a char table.
447 447
448 A char table is a table that maps characters (or ranges of characters) 448 A char table is a table that maps characters (or ranges of characters)
541 CHECK_CHAR_TABLE (table); 541 CHECK_CHAR_TABLE (table);
542 return char_table_type_to_symbol (XCHAR_TABLE (table)->type); 542 return char_table_type_to_symbol (XCHAR_TABLE (table)->type);
543 } 543 }
544 544
545 void 545 void
546 fill_char_table (struct Lisp_Char_Table *ct, Lisp_Object value) 546 fill_char_table (Lisp_Char_Table *ct, Lisp_Object value)
547 { 547 {
548 int i; 548 int i;
549 549
550 for (i = 0; i < NUM_ASCII_CHARS; i++) 550 for (i = 0; i < NUM_ASCII_CHARS; i++)
551 ct->ascii[i] = value; 551 ct->ascii[i] = value;
561 DEFUN ("reset-char-table", Freset_char_table, 1, 1, 0, /* 561 DEFUN ("reset-char-table", Freset_char_table, 1, 1, 0, /*
562 Reset a char table to its default state. 562 Reset a char table to its default state.
563 */ 563 */
564 (table)) 564 (table))
565 { 565 {
566 struct Lisp_Char_Table *ct; 566 Lisp_Char_Table *ct;
567 567
568 CHECK_CHAR_TABLE (table); 568 CHECK_CHAR_TABLE (table);
569 ct = XCHAR_TABLE (table); 569 ct = XCHAR_TABLE (table);
570 570
571 switch (ct->type) 571 switch (ct->type)
597 Currently recognized types are 'char, 'category, 'display, 'generic, 597 Currently recognized types are 'char, 'category, 'display, 'generic,
598 and 'syntax. See `valid-char-table-type-p'. 598 and 'syntax. See `valid-char-table-type-p'.
599 */ 599 */
600 (type)) 600 (type))
601 { 601 {
602 struct Lisp_Char_Table *ct; 602 Lisp_Char_Table *ct;
603 Lisp_Object obj; 603 Lisp_Object obj;
604 enum char_table_type ty = symbol_to_char_table_type (type); 604 enum char_table_type ty = symbol_to_char_table_type (type);
605 605
606 ct = alloc_lcrecord_type (struct Lisp_Char_Table, &lrecord_char_table); 606 ct = alloc_lcrecord_type (Lisp_Char_Table, &lrecord_char_table);
607 ct->type = ty; 607 ct->type = ty;
608 if (ty == CHAR_TABLE_TYPE_SYNTAX) 608 if (ty == CHAR_TABLE_TYPE_SYNTAX)
609 { 609 {
610 ct->mirror_table = Fmake_char_table (Qgeneric); 610 ct->mirror_table = Fmake_char_table (Qgeneric);
611 fill_char_table (XCHAR_TABLE (ct->mirror_table), 611 fill_char_table (XCHAR_TABLE (ct->mirror_table),
629 static Lisp_Object 629 static Lisp_Object
630 make_char_table_entry (Lisp_Object initval) 630 make_char_table_entry (Lisp_Object initval)
631 { 631 {
632 Lisp_Object obj; 632 Lisp_Object obj;
633 int i; 633 int i;
634 struct Lisp_Char_Table_Entry *cte = 634 Lisp_Char_Table_Entry *cte =
635 alloc_lcrecord_type (struct Lisp_Char_Table_Entry, 635 alloc_lcrecord_type (Lisp_Char_Table_Entry, &lrecord_char_table_entry);
636 &lrecord_char_table_entry);
637 636
638 for (i = 0; i < 96; i++) 637 for (i = 0; i < 96; i++)
639 cte->level2[i] = initval; 638 cte->level2[i] = initval;
640 639
641 XSETCHAR_TABLE_ENTRY (obj, cte); 640 XSETCHAR_TABLE_ENTRY (obj, cte);
643 } 642 }
644 643
645 static Lisp_Object 644 static Lisp_Object
646 copy_char_table_entry (Lisp_Object entry) 645 copy_char_table_entry (Lisp_Object entry)
647 { 646 {
648 struct Lisp_Char_Table_Entry *cte = XCHAR_TABLE_ENTRY (entry); 647 Lisp_Char_Table_Entry *cte = XCHAR_TABLE_ENTRY (entry);
649 Lisp_Object obj; 648 Lisp_Object obj;
650 int i; 649 int i;
651 struct Lisp_Char_Table_Entry *ctenew = 650 Lisp_Char_Table_Entry *ctenew =
652 alloc_lcrecord_type (struct Lisp_Char_Table_Entry, 651 alloc_lcrecord_type (Lisp_Char_Table_Entry, &lrecord_char_table_entry);
653 &lrecord_char_table_entry);
654 652
655 for (i = 0; i < 96; i++) 653 for (i = 0; i < 96; i++)
656 { 654 {
657 Lisp_Object new = cte->level2[i]; 655 Lisp_Object new = cte->level2[i];
658 if (CHAR_TABLE_ENTRYP (new)) 656 if (CHAR_TABLE_ENTRYP (new))
672 It will contain the same values for the same characters and ranges 670 It will contain the same values for the same characters and ranges
673 as OLD-TABLE. The values will not themselves be copied. 671 as OLD-TABLE. The values will not themselves be copied.
674 */ 672 */
675 (old_table)) 673 (old_table))
676 { 674 {
677 struct Lisp_Char_Table *ct, *ctnew; 675 Lisp_Char_Table *ct, *ctnew;
678 Lisp_Object obj; 676 Lisp_Object obj;
679 int i; 677 int i;
680 678
681 CHECK_CHAR_TABLE (old_table); 679 CHECK_CHAR_TABLE (old_table);
682 ct = XCHAR_TABLE (old_table); 680 ct = XCHAR_TABLE (old_table);
683 ctnew = alloc_lcrecord_type (struct Lisp_Char_Table, &lrecord_char_table); 681 ctnew = alloc_lcrecord_type (Lisp_Char_Table, &lrecord_char_table);
684 ctnew->type = ct->type; 682 ctnew->type = ct->type;
685 683
686 for (i = 0; i < NUM_ASCII_CHARS; i++) 684 for (i = 0; i < NUM_ASCII_CHARS; i++)
687 { 685 {
688 Lisp_Object new = ct->ascii[i]; 686 Lisp_Object new = ct->ascii[i];
733 else 731 else
734 signal_simple_error ("Range must be t or a character", range); 732 signal_simple_error ("Range must be t or a character", range);
735 #else /* MULE */ 733 #else /* MULE */
736 else if (VECTORP (range)) 734 else if (VECTORP (range))
737 { 735 {
738 struct Lisp_Vector *vec = XVECTOR (range); 736 Lisp_Vector *vec = XVECTOR (range);
739 Lisp_Object *elts = vector_data (vec); 737 Lisp_Object *elts = vector_data (vec);
740 if (vector_length (vec) != 2) 738 if (vector_length (vec) != 2)
741 signal_simple_error ("Length of charset row vector must be 2", 739 signal_simple_error ("Length of charset row vector must be 2",
742 range); 740 range);
743 outrange->type = CHARTAB_RANGE_ROW; 741 outrange->type = CHARTAB_RANGE_ROW;
773 771
774 #ifdef MULE 772 #ifdef MULE
775 773
776 /* called from CHAR_TABLE_VALUE(). */ 774 /* called from CHAR_TABLE_VALUE(). */
777 Lisp_Object 775 Lisp_Object
778 get_non_ascii_char_table_value (struct Lisp_Char_Table *ct, int leading_byte, 776 get_non_ascii_char_table_value (Lisp_Char_Table *ct, int leading_byte,
779 Emchar c) 777 Emchar c)
780 { 778 {
781 Lisp_Object val; 779 Lisp_Object val;
782 Lisp_Object charset = CHARSET_BY_LEADING_BYTE (leading_byte); 780 Lisp_Object charset = CHARSET_BY_LEADING_BYTE (leading_byte);
783 int byte1, byte2; 781 int byte1, byte2;
784 782
785 BREAKUP_CHAR_1_UNSAFE (c, charset, byte1, byte2); 783 BREAKUP_CHAR_1_UNSAFE (c, charset, byte1, byte2);
786 val = ct->level1[leading_byte - MIN_LEADING_BYTE]; 784 val = ct->level1[leading_byte - MIN_LEADING_BYTE];
787 if (CHAR_TABLE_ENTRYP (val)) 785 if (CHAR_TABLE_ENTRYP (val))
788 { 786 {
789 struct Lisp_Char_Table_Entry *cte = XCHAR_TABLE_ENTRY (val); 787 Lisp_Char_Table_Entry *cte = XCHAR_TABLE_ENTRY (val);
790 val = cte->level2[byte1 - 32]; 788 val = cte->level2[byte1 - 32];
791 if (CHAR_TABLE_ENTRYP (val)) 789 if (CHAR_TABLE_ENTRYP (val))
792 { 790 {
793 cte = XCHAR_TABLE_ENTRY (val); 791 cte = XCHAR_TABLE_ENTRY (val);
794 assert (byte2 >= 32); 792 assert (byte2 >= 32);
801 } 799 }
802 800
803 #endif /* MULE */ 801 #endif /* MULE */
804 802
805 Lisp_Object 803 Lisp_Object
806 get_char_table (Emchar ch, struct Lisp_Char_Table *ct) 804 get_char_table (Emchar ch, Lisp_Char_Table *ct)
807 { 805 {
808 #ifdef MULE 806 #ifdef MULE
809 { 807 {
810 Lisp_Object charset; 808 Lisp_Object charset;
811 int byte1, byte2; 809 int byte1, byte2;
821 { 819 {
822 int lb = XCHARSET_LEADING_BYTE (charset) - MIN_LEADING_BYTE; 820 int lb = XCHARSET_LEADING_BYTE (charset) - MIN_LEADING_BYTE;
823 val = ct->level1[lb]; 821 val = ct->level1[lb];
824 if (CHAR_TABLE_ENTRYP (val)) 822 if (CHAR_TABLE_ENTRYP (val))
825 { 823 {
826 struct Lisp_Char_Table_Entry *cte = XCHAR_TABLE_ENTRY (val); 824 Lisp_Char_Table_Entry *cte = XCHAR_TABLE_ENTRY (val);
827 val = cte->level2[byte1 - 32]; 825 val = cte->level2[byte1 - 32];
828 if (CHAR_TABLE_ENTRYP (val)) 826 if (CHAR_TABLE_ENTRYP (val))
829 { 827 {
830 cte = XCHAR_TABLE_ENTRY (val); 828 cte = XCHAR_TABLE_ENTRY (val);
831 assert (byte2 >= 32); 829 assert (byte2 >= 32);
846 DEFUN ("get-char-table", Fget_char_table, 2, 2, 0, /* 844 DEFUN ("get-char-table", Fget_char_table, 2, 2, 0, /*
847 Find value for char CH in TABLE. 845 Find value for char CH in TABLE.
848 */ 846 */
849 (ch, table)) 847 (ch, table))
850 { 848 {
851 struct Lisp_Char_Table *ct; 849 Lisp_Char_Table *ct;
852 850
853 CHECK_CHAR_TABLE (table); 851 CHECK_CHAR_TABLE (table);
854 ct = XCHAR_TABLE (table); 852 ct = XCHAR_TABLE (table);
855 CHECK_CHAR_COERCE_INT (ch); 853 CHECK_CHAR_COERCE_INT (ch);
856 854
861 Find value for a range in TABLE. 859 Find value for a range in TABLE.
862 If there is more than one value, return MULTI (defaults to nil). 860 If there is more than one value, return MULTI (defaults to nil).
863 */ 861 */
864 (range, table, multi)) 862 (range, table, multi))
865 { 863 {
866 struct Lisp_Char_Table *ct; 864 Lisp_Char_Table *ct;
867 struct chartab_range rainj; 865 struct chartab_range rainj;
868 866
869 if (CHAR_OR_CHAR_INTP (range)) 867 if (CHAR_OR_CHAR_INTP (range))
870 return Fget_char_table (range, table); 868 return Fget_char_table (range, table);
871 CHECK_CHAR_TABLE (table); 869 CHECK_CHAR_TABLE (table);
1046 } 1044 }
1047 1045
1048 /* Assign VAL to all characters in RANGE in char table CT. */ 1046 /* Assign VAL to all characters in RANGE in char table CT. */
1049 1047
1050 void 1048 void
1051 put_char_table (struct Lisp_Char_Table *ct, struct chartab_range *range, 1049 put_char_table (Lisp_Char_Table *ct, struct chartab_range *range,
1052 Lisp_Object val) 1050 Lisp_Object val)
1053 { 1051 {
1054 switch (range->type) 1052 switch (range->type)
1055 { 1053 {
1056 case CHARTAB_RANGE_ALL: 1054 case CHARTAB_RANGE_ALL:
1079 } 1077 }
1080 break; 1078 break;
1081 1079
1082 case CHARTAB_RANGE_ROW: 1080 case CHARTAB_RANGE_ROW:
1083 { 1081 {
1084 struct Lisp_Char_Table_Entry *cte; 1082 Lisp_Char_Table_Entry *cte;
1085 int lb = XCHARSET_LEADING_BYTE (range->charset) - MIN_LEADING_BYTE; 1083 int lb = XCHARSET_LEADING_BYTE (range->charset) - MIN_LEADING_BYTE;
1086 /* make sure that there is a separate entry for the row. */ 1084 /* make sure that there is a separate entry for the row. */
1087 if (!CHAR_TABLE_ENTRYP (ct->level1[lb])) 1085 if (!CHAR_TABLE_ENTRYP (ct->level1[lb]))
1088 ct->level1[lb] = make_char_table_entry (ct->level1[lb]); 1086 ct->level1[lb] = make_char_table_entry (ct->level1[lb]);
1089 cte = XCHAR_TABLE_ENTRY (ct->level1[lb]); 1087 cte = XCHAR_TABLE_ENTRY (ct->level1[lb]);
1103 ct->ascii[byte1] = val; 1101 ct->ascii[byte1] = val;
1104 else if (EQ (charset, Vcharset_control_1)) 1102 else if (EQ (charset, Vcharset_control_1))
1105 ct->ascii[byte1 + 128] = val; 1103 ct->ascii[byte1 + 128] = val;
1106 else 1104 else
1107 { 1105 {
1108 struct Lisp_Char_Table_Entry *cte; 1106 Lisp_Char_Table_Entry *cte;
1109 int lb = XCHARSET_LEADING_BYTE (charset) - MIN_LEADING_BYTE; 1107 int lb = XCHARSET_LEADING_BYTE (charset) - MIN_LEADING_BYTE;
1110 /* make sure that there is a separate entry for the row. */ 1108 /* make sure that there is a separate entry for the row. */
1111 if (!CHAR_TABLE_ENTRYP (ct->level1[lb])) 1109 if (!CHAR_TABLE_ENTRYP (ct->level1[lb]))
1112 ct->level1[lb] = make_char_table_entry (ct->level1[lb]); 1110 ct->level1[lb] = make_char_table_entry (ct->level1[lb]);
1113 cte = XCHAR_TABLE_ENTRY (ct->level1[lb]); 1111 cte = XCHAR_TABLE_ENTRY (ct->level1[lb]);
1154 VAL must be a value appropriate for the type of TABLE. 1152 VAL must be a value appropriate for the type of TABLE.
1155 See `valid-char-table-type-p'. 1153 See `valid-char-table-type-p'.
1156 */ 1154 */
1157 (range, val, table)) 1155 (range, val, table))
1158 { 1156 {
1159 struct Lisp_Char_Table *ct; 1157 Lisp_Char_Table *ct;
1160 struct chartab_range rainj; 1158 struct chartab_range rainj;
1161 1159
1162 CHECK_CHAR_TABLE (table); 1160 CHECK_CHAR_TABLE (table);
1163 ct = XCHAR_TABLE (table); 1161 ct = XCHAR_TABLE (table);
1164 check_valid_char_table_value (val, ct->type, ERROR_ME); 1162 check_valid_char_table_value (val, ct->type, ERROR_ME);
1169 } 1167 }
1170 1168
1171 /* Map FN over the ASCII chars in CT. */ 1169 /* Map FN over the ASCII chars in CT. */
1172 1170
1173 static int 1171 static int
1174 map_over_charset_ascii (struct Lisp_Char_Table *ct, 1172 map_over_charset_ascii (Lisp_Char_Table *ct,
1175 int (*fn) (struct chartab_range *range, 1173 int (*fn) (struct chartab_range *range,
1176 Lisp_Object val, void *arg), 1174 Lisp_Object val, void *arg),
1177 void *arg) 1175 void *arg)
1178 { 1176 {
1179 struct chartab_range rainj; 1177 struct chartab_range rainj;
1199 #ifdef MULE 1197 #ifdef MULE
1200 1198
1201 /* Map FN over the Control-1 chars in CT. */ 1199 /* Map FN over the Control-1 chars in CT. */
1202 1200
1203 static int 1201 static int
1204 map_over_charset_control_1 (struct Lisp_Char_Table *ct, 1202 map_over_charset_control_1 (Lisp_Char_Table *ct,
1205 int (*fn) (struct chartab_range *range, 1203 int (*fn) (struct chartab_range *range,
1206 Lisp_Object val, void *arg), 1204 Lisp_Object val, void *arg),
1207 void *arg) 1205 void *arg)
1208 { 1206 {
1209 struct chartab_range rainj; 1207 struct chartab_range rainj;
1225 /* Map FN over the row ROW of two-byte charset CHARSET. 1223 /* Map FN over the row ROW of two-byte charset CHARSET.
1226 There must be a separate value for that row in the char table. 1224 There must be a separate value for that row in the char table.
1227 CTE specifies the char table entry for CHARSET. */ 1225 CTE specifies the char table entry for CHARSET. */
1228 1226
1229 static int 1227 static int
1230 map_over_charset_row (struct Lisp_Char_Table_Entry *cte, 1228 map_over_charset_row (Lisp_Char_Table_Entry *cte,
1231 Lisp_Object charset, int row, 1229 Lisp_Object charset, int row,
1232 int (*fn) (struct chartab_range *range, 1230 int (*fn) (struct chartab_range *range,
1233 Lisp_Object val, void *arg), 1231 Lisp_Object val, void *arg),
1234 void *arg) 1232 void *arg)
1235 { 1233 {
1265 } 1263 }
1266 } 1264 }
1267 1265
1268 1266
1269 static int 1267 static int
1270 map_over_other_charset (struct Lisp_Char_Table *ct, int lb, 1268 map_over_other_charset (Lisp_Char_Table *ct, int lb,
1271 int (*fn) (struct chartab_range *range, 1269 int (*fn) (struct chartab_range *range,
1272 Lisp_Object val, void *arg), 1270 Lisp_Object val, void *arg),
1273 void *arg) 1271 void *arg)
1274 { 1272 {
1275 Lisp_Object val = ct->level1[lb - MIN_LEADING_BYTE]; 1273 Lisp_Object val = ct->level1[lb - MIN_LEADING_BYTE];
1288 rainj.charset = charset; 1286 rainj.charset = charset;
1289 return (fn) (&rainj, val, arg); 1287 return (fn) (&rainj, val, arg);
1290 } 1288 }
1291 1289
1292 { 1290 {
1293 struct Lisp_Char_Table_Entry *cte = XCHAR_TABLE_ENTRY (val); 1291 Lisp_Char_Table_Entry *cte = XCHAR_TABLE_ENTRY (val);
1294 int charset94_p = (XCHARSET_CHARS (charset) == 94); 1292 int charset94_p = (XCHARSET_CHARS (charset) == 94);
1295 int start = charset94_p ? 33 : 32; 1293 int start = charset94_p ? 33 : 32;
1296 int stop = charset94_p ? 127 : 128; 1294 int stop = charset94_p ? 127 : 128;
1297 int i, retval; 1295 int i, retval;
1298 1296
1322 /* Map FN (with client data ARG) over range RANGE in char table CT. 1320 /* Map FN (with client data ARG) over range RANGE in char table CT.
1323 Mapping stops the first time FN returns non-zero, and that value 1321 Mapping stops the first time FN returns non-zero, and that value
1324 becomes the return value of map_char_table(). */ 1322 becomes the return value of map_char_table(). */
1325 1323
1326 int 1324 int
1327 map_char_table (struct Lisp_Char_Table *ct, 1325 map_char_table (Lisp_Char_Table *ct,
1328 struct chartab_range *range, 1326 struct chartab_range *range,
1329 int (*fn) (struct chartab_range *range, 1327 int (*fn) (struct chartab_range *range,
1330 Lisp_Object val, void *arg), 1328 Lisp_Object val, void *arg),
1331 void *arg) 1329 void *arg)
1332 { 1330 {
1449 the RANGE argument to `put-range-table'. If omitted or t, it defaults to 1447 the RANGE argument to `put-range-table'. If omitted or t, it defaults to
1450 the entire table. 1448 the entire table.
1451 */ 1449 */
1452 (function, table, range)) 1450 (function, table, range))
1453 { 1451 {
1454 struct Lisp_Char_Table *ct; 1452 Lisp_Char_Table *ct;
1455 struct slow_map_char_table_arg slarg; 1453 struct slow_map_char_table_arg slarg;
1456 struct gcpro gcpro1, gcpro2; 1454 struct gcpro gcpro1, gcpro2;
1457 struct chartab_range rainj; 1455 struct chartab_range rainj;
1458 1456
1459 CHECK_CHAR_TABLE (table); 1457 CHECK_CHAR_TABLE (table);
1617 int 1615 int
1618 check_category_char (Emchar ch, Lisp_Object table, 1616 check_category_char (Emchar ch, Lisp_Object table,
1619 unsigned int designator, unsigned int not) 1617 unsigned int designator, unsigned int not)
1620 { 1618 {
1621 REGISTER Lisp_Object temp; 1619 REGISTER Lisp_Object temp;
1622 struct Lisp_Char_Table *ctbl; 1620 Lisp_Char_Table *ctbl;
1623 #ifdef ERROR_CHECK_TYPECHECK 1621 #ifdef ERROR_CHECK_TYPECHECK
1624 if (NILP (Fcategory_table_p (table))) 1622 if (NILP (Fcategory_table_p (table)))
1625 signal_simple_error ("Expected category table", table); 1623 signal_simple_error ("Expected category table", table);
1626 #endif 1624 #endif
1627 ctbl = XCHAR_TABLE (table); 1625 ctbl = XCHAR_TABLE (table);