Mercurial > hg > xemacs-beta
comparison src/mule-charset.c @ 442:abe6d1db359e r21-2-36
Import from CVS: tag r21-2-36
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:35:02 +0200 |
parents | 8de8e3f6228a |
children | 576fb035e263 |
comparison
equal
deleted
inserted
replaced
441:72a7cfa4a488 | 442:abe6d1db359e |
---|---|
148 | 148 |
149 Lisp_Object Ql2r, Qr2l; | 149 Lisp_Object Ql2r, Qr2l; |
150 | 150 |
151 Lisp_Object Vcharset_hash_table; | 151 Lisp_Object Vcharset_hash_table; |
152 | 152 |
153 static Bufbyte next_allocated_1_byte_leading_byte; | |
154 static Bufbyte next_allocated_2_byte_leading_byte; | |
155 | |
156 /* Composite characters are characters constructed by overstriking two | 153 /* Composite characters are characters constructed by overstriking two |
157 or more regular characters. | 154 or more regular characters. |
158 | 155 |
159 1) The old Mule implementation involves storing composite characters | 156 1) The old Mule implementation involves storing composite characters |
160 in a buffer as a tag followed by all of the actual characters | 157 in a buffer as a tag followed by all of the actual characters |
218 /* Return the first character from a Mule-encoded string in STR, | 215 /* Return the first character from a Mule-encoded string in STR, |
219 assuming it's non-ASCII. Do not call this directly. | 216 assuming it's non-ASCII. Do not call this directly. |
220 Use the macro charptr_emchar() instead. */ | 217 Use the macro charptr_emchar() instead. */ |
221 | 218 |
222 Emchar | 219 Emchar |
223 non_ascii_charptr_emchar (CONST Bufbyte *str) | 220 non_ascii_charptr_emchar (const Bufbyte *str) |
224 { | 221 { |
225 Bufbyte i0 = *str, i1, i2 = 0; | 222 Bufbyte i0 = *str, i1, i2 = 0; |
226 Lisp_Object charset; | 223 Lisp_Object charset; |
227 | 224 |
228 if (i0 == LEADING_BYTE_CONTROL_1) | 225 if (i0 == LEADING_BYTE_CONTROL_1) |
328 /* Copy the character pointed to by PTR into STR, assuming it's | 325 /* Copy the character pointed to by PTR into STR, assuming it's |
329 non-ASCII. Do not call this directly. Use the macro | 326 non-ASCII. Do not call this directly. Use the macro |
330 charptr_copy_char() instead. */ | 327 charptr_copy_char() instead. */ |
331 | 328 |
332 Bytecount | 329 Bytecount |
333 non_ascii_charptr_copy_char (CONST Bufbyte *ptr, Bufbyte *str) | 330 non_ascii_charptr_copy_char (const Bufbyte *ptr, Bufbyte *str) |
334 { | 331 { |
335 Bufbyte *strptr = str; | 332 Bufbyte *strptr = str; |
336 *strptr = *ptr++; | 333 *strptr = *ptr++; |
337 switch (REP_BYTES_BY_FIRST_BYTE (*strptr)) | 334 switch (REP_BYTES_BY_FIRST_BYTE (*strptr)) |
338 { | 335 { |
527 { | 524 { |
528 int lb; | 525 int lb; |
529 | 526 |
530 if (dimension == 1) | 527 if (dimension == 1) |
531 { | 528 { |
532 if (next_allocated_1_byte_leading_byte > MAX_LEADING_BYTE_PRIVATE_1) | 529 if (chlook->next_allocated_1_byte_leading_byte > MAX_LEADING_BYTE_PRIVATE_1) |
533 lb = 0; | 530 lb = 0; |
534 else | 531 else |
535 lb = next_allocated_1_byte_leading_byte++; | 532 lb = chlook->next_allocated_1_byte_leading_byte++; |
536 } | 533 } |
537 else | 534 else |
538 { | 535 { |
539 if (next_allocated_2_byte_leading_byte > MAX_LEADING_BYTE_PRIVATE_2) | 536 if (chlook->next_allocated_2_byte_leading_byte > MAX_LEADING_BYTE_PRIVATE_2) |
540 lb = 0; | 537 lb = 0; |
541 else | 538 else |
542 lb = next_allocated_2_byte_leading_byte++; | 539 lb = chlook->next_allocated_2_byte_leading_byte++; |
543 } | 540 } |
544 | 541 |
545 if (!lb) | 542 if (!lb) |
546 signal_simple_error | 543 signal_simple_error |
547 ("No more character sets free for this dimension", | 544 ("No more character sets free for this dimension", |
691 int id, dimension = 1, chars = 94, graphic = 0, final = 0, columns = -1; | 688 int id, dimension = 1, chars = 94, graphic = 0, final = 0, columns = -1; |
692 int direction = CHARSET_LEFT_TO_RIGHT; | 689 int direction = CHARSET_LEFT_TO_RIGHT; |
693 int type; | 690 int type; |
694 Lisp_Object registry = Qnil; | 691 Lisp_Object registry = Qnil; |
695 Lisp_Object charset; | 692 Lisp_Object charset; |
696 Lisp_Object rest, keyword, value; | |
697 Lisp_Object ccl_program = Qnil; | 693 Lisp_Object ccl_program = Qnil; |
698 Lisp_Object short_name = Qnil, long_name = Qnil; | 694 Lisp_Object short_name = Qnil, long_name = Qnil; |
699 | 695 |
700 CHECK_SYMBOL (name); | 696 CHECK_SYMBOL (name); |
701 if (!NILP (doc_string)) | 697 if (!NILP (doc_string)) |
703 | 699 |
704 charset = Ffind_charset (name); | 700 charset = Ffind_charset (name); |
705 if (!NILP (charset)) | 701 if (!NILP (charset)) |
706 signal_simple_error ("Cannot redefine existing charset", name); | 702 signal_simple_error ("Cannot redefine existing charset", name); |
707 | 703 |
708 EXTERNAL_PROPERTY_LIST_LOOP (rest, keyword, value, props) | 704 { |
709 { | 705 EXTERNAL_PROPERTY_LIST_LOOP_3 (keyword, value, props) |
710 if (EQ (keyword, Qshort_name)) | 706 { |
711 { | 707 if (EQ (keyword, Qshort_name)) |
712 CHECK_STRING (value); | 708 { |
713 short_name = value; | 709 CHECK_STRING (value); |
714 } | 710 short_name = value; |
715 | 711 } |
716 if (EQ (keyword, Qlong_name)) | 712 |
717 { | 713 if (EQ (keyword, Qlong_name)) |
718 CHECK_STRING (value); | 714 { |
719 long_name = value; | 715 CHECK_STRING (value); |
720 } | 716 long_name = value; |
721 | 717 } |
722 else if (EQ (keyword, Qdimension)) | 718 |
723 { | 719 else if (EQ (keyword, Qdimension)) |
724 CHECK_INT (value); | 720 { |
725 dimension = XINT (value); | 721 CHECK_INT (value); |
726 if (dimension < 1 || dimension > 2) | 722 dimension = XINT (value); |
727 signal_simple_error ("Invalid value for 'dimension", value); | 723 if (dimension < 1 || dimension > 2) |
728 } | 724 signal_simple_error ("Invalid value for 'dimension", value); |
729 | 725 } |
730 else if (EQ (keyword, Qchars)) | 726 |
731 { | 727 else if (EQ (keyword, Qchars)) |
732 CHECK_INT (value); | 728 { |
733 chars = XINT (value); | 729 CHECK_INT (value); |
734 if (chars != 94 && chars != 96) | 730 chars = XINT (value); |
735 signal_simple_error ("Invalid value for 'chars", value); | 731 if (chars != 94 && chars != 96) |
736 } | 732 signal_simple_error ("Invalid value for 'chars", value); |
737 | 733 } |
738 else if (EQ (keyword, Qcolumns)) | 734 |
739 { | 735 else if (EQ (keyword, Qcolumns)) |
740 CHECK_INT (value); | 736 { |
741 columns = XINT (value); | 737 CHECK_INT (value); |
742 if (columns != 1 && columns != 2) | 738 columns = XINT (value); |
743 signal_simple_error ("Invalid value for 'columns", value); | 739 if (columns != 1 && columns != 2) |
744 } | 740 signal_simple_error ("Invalid value for 'columns", value); |
745 | 741 } |
746 else if (EQ (keyword, Qgraphic)) | 742 |
747 { | 743 else if (EQ (keyword, Qgraphic)) |
748 CHECK_INT (value); | 744 { |
749 graphic = XINT (value); | 745 CHECK_INT (value); |
750 if (graphic < 0 || graphic > 1) | 746 graphic = XINT (value); |
751 signal_simple_error ("Invalid value for 'graphic", value); | 747 if (graphic < 0 || graphic > 1) |
752 } | 748 signal_simple_error ("Invalid value for 'graphic", value); |
753 | 749 } |
754 else if (EQ (keyword, Qregistry)) | 750 |
755 { | 751 else if (EQ (keyword, Qregistry)) |
756 CHECK_STRING (value); | 752 { |
757 registry = value; | 753 CHECK_STRING (value); |
758 } | 754 registry = value; |
759 | 755 } |
760 else if (EQ (keyword, Qdirection)) | 756 |
761 { | 757 else if (EQ (keyword, Qdirection)) |
762 if (EQ (value, Ql2r)) | 758 { |
763 direction = CHARSET_LEFT_TO_RIGHT; | 759 if (EQ (value, Ql2r)) |
764 else if (EQ (value, Qr2l)) | 760 direction = CHARSET_LEFT_TO_RIGHT; |
765 direction = CHARSET_RIGHT_TO_LEFT; | 761 else if (EQ (value, Qr2l)) |
766 else | 762 direction = CHARSET_RIGHT_TO_LEFT; |
767 signal_simple_error ("Invalid value for 'direction", value); | 763 else |
768 } | 764 signal_simple_error ("Invalid value for 'direction", value); |
769 | 765 } |
770 else if (EQ (keyword, Qfinal)) | 766 |
771 { | 767 else if (EQ (keyword, Qfinal)) |
772 CHECK_CHAR_COERCE_INT (value); | 768 { |
773 final = XCHAR (value); | 769 CHECK_CHAR_COERCE_INT (value); |
774 if (final < '0' || final > '~') | 770 final = XCHAR (value); |
775 signal_simple_error ("Invalid value for 'final", value); | 771 if (final < '0' || final > '~') |
776 } | 772 signal_simple_error ("Invalid value for 'final", value); |
777 | 773 } |
778 else if (EQ (keyword, Qccl_program)) | 774 |
779 { | 775 else if (EQ (keyword, Qccl_program)) |
780 CHECK_VECTOR (value); | 776 { |
781 ccl_program = value; | 777 CHECK_VECTOR (value); |
782 } | 778 ccl_program = value; |
783 | 779 } |
784 else | 780 |
785 signal_simple_error ("Unrecognized property", keyword); | 781 else |
786 } | 782 signal_simple_error ("Unrecognized property", keyword); |
783 } | |
784 } | |
787 | 785 |
788 if (!final) | 786 if (!final) |
789 error ("'final must be specified"); | 787 error ("'final must be specified"); |
790 if (dimension == 2 && final > 0x5F) | 788 if (dimension == 2 && final > 0x5F) |
791 signal_simple_error | 789 signal_simple_error |
1091 else if (CHARSET_CHARS (cs) == 94) lowlim = 33, highlim = 126; | 1089 else if (CHARSET_CHARS (cs) == 94) lowlim = 33, highlim = 126; |
1092 else /* CHARSET_CHARS (cs) == 96) */ lowlim = 32, highlim = 127; | 1090 else /* CHARSET_CHARS (cs) == 96) */ lowlim = 32, highlim = 127; |
1093 | 1091 |
1094 CHECK_INT (arg1); | 1092 CHECK_INT (arg1); |
1095 /* It is useful (and safe, according to Olivier Galibert) to strip | 1093 /* It is useful (and safe, according to Olivier Galibert) to strip |
1096 the 8th bit off ARG1 and ARG2 becaue it allows programmers to | 1094 the 8th bit off ARG1 and ARG2 because it allows programmers to |
1097 write (make-char 'latin-iso8859-2 CODE) where code is the actual | 1095 write (make-char 'latin-iso8859-2 CODE) where code is the actual |
1098 Latin 2 code of the character. */ | 1096 Latin 2 code of the character. */ |
1099 a1 = XINT (arg1) & 0x7f; | 1097 a1 = XINT (arg1) & 0x7f; |
1100 if (a1 < lowlim || a1 > highlim) | 1098 if (a1 < lowlim || a1 > highlim) |
1101 args_out_of_range_3 (arg1, make_int (lowlim), make_int (highlim)); | 1099 args_out_of_range_3 (arg1, make_int (lowlim), make_int (highlim)); |
1257 /************************************************************************/ | 1255 /************************************************************************/ |
1258 | 1256 |
1259 void | 1257 void |
1260 syms_of_mule_charset (void) | 1258 syms_of_mule_charset (void) |
1261 { | 1259 { |
1260 INIT_LRECORD_IMPLEMENTATION (charset); | |
1261 | |
1262 DEFSUBR (Fcharsetp); | 1262 DEFSUBR (Fcharsetp); |
1263 DEFSUBR (Ffind_charset); | 1263 DEFSUBR (Ffind_charset); |
1264 DEFSUBR (Fget_charset); | 1264 DEFSUBR (Fget_charset); |
1265 DEFSUBR (Fcharset_list); | 1265 DEFSUBR (Fcharset_list); |
1266 DEFSUBR (Fcharset_name); | 1266 DEFSUBR (Fcharset_name); |
1344 for (i = 0; i < countof (chlook->charset_by_attributes); i++) | 1344 for (i = 0; i < countof (chlook->charset_by_attributes); i++) |
1345 for (j = 0; j < countof (chlook->charset_by_attributes[0]); j++) | 1345 for (j = 0; j < countof (chlook->charset_by_attributes[0]); j++) |
1346 for (k = 0; k < countof (chlook->charset_by_attributes[0][0]); k++) | 1346 for (k = 0; k < countof (chlook->charset_by_attributes[0][0]); k++) |
1347 chlook->charset_by_attributes[i][j][k] = Qnil; | 1347 chlook->charset_by_attributes[i][j][k] = Qnil; |
1348 | 1348 |
1349 next_allocated_1_byte_leading_byte = MIN_LEADING_BYTE_PRIVATE_1; | 1349 chlook->next_allocated_1_byte_leading_byte = MIN_LEADING_BYTE_PRIVATE_1; |
1350 next_allocated_2_byte_leading_byte = MIN_LEADING_BYTE_PRIVATE_2; | 1350 chlook->next_allocated_2_byte_leading_byte = MIN_LEADING_BYTE_PRIVATE_2; |
1351 } | 1351 } |
1352 | 1352 |
1353 void | 1353 void |
1354 complex_vars_of_mule_charset (void) | 1354 complex_vars_of_mule_charset (void) |
1355 { | 1355 { |