Mercurial > hg > xemacs-beta
comparison src/mule-coding.c @ 183:e121b013d1f0 r20-3b18
Import from CVS: tag r20-3b18
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:54:23 +0200 |
parents | bfd6434d15b3 |
children | 3d6bfa290dbd |
comparison
equal
deleted
inserted
replaced
182:f07455f06202 | 183:e121b013d1f0 |
---|---|
85 Lisp_Object charset[4]; | 85 Lisp_Object charset[4]; |
86 | 86 |
87 /* Which registers are currently invoked into the left (GL) and | 87 /* Which registers are currently invoked into the left (GL) and |
88 right (GR) halves of the 8-bit encoding space? */ | 88 right (GR) halves of the 8-bit encoding space? */ |
89 int register_left, register_right; | 89 int register_left, register_right; |
90 | 90 |
91 /* ISO_ESC holds a value indicating part of an escape sequence | 91 /* ISO_ESC holds a value indicating part of an escape sequence |
92 that has already been seen. */ | 92 that has already been seen. */ |
93 enum iso_esc_flag esc; | 93 enum iso_esc_flag esc; |
94 | 94 |
95 /* This records the bytes we've seen so far in an escape sequence, | 95 /* This records the bytes we've seen so far in an escape sequence, |
96 in case the sequence is invalid (we spit out the bytes unchanged). */ | 96 in case the sequence is invalid (we spit out the bytes unchanged). */ |
97 unsigned char esc_bytes[8]; | 97 unsigned char esc_bytes[8]; |
98 | 98 |
99 /* Index for next byte to store in ISO escape sequence. */ | 99 /* Index for next byte to store in ISO escape sequence. */ |
100 int esc_bytes_index; | 100 int esc_bytes_index; |
101 | 101 |
102 /* Stuff seen so far when composing a string. */ | 102 /* Stuff seen so far when composing a string. */ |
103 unsigned_char_dynarr *composite_chars; | 103 unsigned_char_dynarr *composite_chars; |
230 (markobj) (CODING_SYSTEM_DOC_STRING (codesys)); | 230 (markobj) (CODING_SYSTEM_DOC_STRING (codesys)); |
231 (markobj) (CODING_SYSTEM_MNEMONIC (codesys)); | 231 (markobj) (CODING_SYSTEM_MNEMONIC (codesys)); |
232 (markobj) (CODING_SYSTEM_EOL_LF (codesys)); | 232 (markobj) (CODING_SYSTEM_EOL_LF (codesys)); |
233 (markobj) (CODING_SYSTEM_EOL_CRLF (codesys)); | 233 (markobj) (CODING_SYSTEM_EOL_CRLF (codesys)); |
234 (markobj) (CODING_SYSTEM_EOL_CR (codesys)); | 234 (markobj) (CODING_SYSTEM_EOL_CR (codesys)); |
235 | 235 |
236 switch (CODING_SYSTEM_TYPE (codesys)) | 236 switch (CODING_SYSTEM_TYPE (codesys)) |
237 { | 237 { |
238 int i; | 238 int i; |
239 case CODESYS_ISO2022: | 239 case CODESYS_ISO2022: |
240 for (i = 0; i < 4; i++) | 240 for (i = 0; i < 4; i++) |
348 { | 348 { |
349 Lisp_Object codesys_obj = Qnil; | 349 Lisp_Object codesys_obj = Qnil; |
350 int len = string_length (XSYMBOL (CODING_SYSTEM_NAME (codesys))->name); | 350 int len = string_length (XSYMBOL (CODING_SYSTEM_NAME (codesys))->name); |
351 char *codesys_name = (char *) alloca (len + 7); | 351 char *codesys_name = (char *) alloca (len + 7); |
352 Lisp_Object codesys_name_sym, sub_codesys_obj; | 352 Lisp_Object codesys_name_sym, sub_codesys_obj; |
353 | 353 |
354 /* kludge */ | 354 /* kludge */ |
355 | 355 |
356 XSETCODING_SYSTEM (codesys_obj, codesys); | 356 XSETCODING_SYSTEM (codesys_obj, codesys); |
357 | 357 |
358 memcpy (codesys_name, | 358 memcpy (codesys_name, |
359 string_data (XSYMBOL (CODING_SYSTEM_NAME (codesys))->name), len); | 359 string_data (XSYMBOL (CODING_SYSTEM_NAME (codesys))->name), len); |
360 | 360 |
361 #define DEFINE_SUB_CODESYS(op_sys, Type) do { \ | 361 #define DEFINE_SUB_CODESYS(op_sys, Type) do { \ |
362 strcpy (codesys_name + len, "-" op_sys); \ | 362 strcpy (codesys_name + len, "-" op_sys); \ |
363 codesys_name_sym = intern (codesys_name); \ | 363 codesys_name_sym = intern (codesys_name); \ |
364 sub_codesys_obj = Fcopy_coding_system (codesys_obj, codesys_name_sym); \ | 364 sub_codesys_obj = Fcopy_coding_system (codesys_obj, codesys_name_sym); \ |
365 XCODING_SYSTEM_EOL_TYPE (sub_codesys_obj) = Type; \ | 365 XCODING_SYSTEM_EOL_TYPE (sub_codesys_obj) = Type; \ |
554 { | 554 { |
555 int i; | 555 int i; |
556 Lisp_Object result = Qnil; | 556 Lisp_Object result = Qnil; |
557 | 557 |
558 if (!load_here) | 558 if (!load_here) |
559 return Qnil; | 559 return Qnil; |
560 for (i = 0; i < Dynarr_length (load_here); i++) | 560 for (i = 0; i < Dynarr_length (load_here); i++) |
561 { | 561 { |
562 struct charset_conversion_spec *ccs = | 562 struct charset_conversion_spec *ccs = |
563 Dynarr_atp (load_here, i); | 563 Dynarr_atp (load_here, i); |
564 result = Fcons (list2 (ccs->from_charset, ccs->to_charset), result); | 564 result = Fcons (list2 (ccs->from_charset, ccs->to_charset), result); |
739 struct Lisp_Coding_System *codesys; | 739 struct Lisp_Coding_System *codesys; |
740 Lisp_Object rest, key, value; | 740 Lisp_Object rest, key, value; |
741 int ty; | 741 int ty; |
742 int need_to_setup_eol_systems = 1; | 742 int need_to_setup_eol_systems = 1; |
743 | 743 |
744 /* Convert type to constant */ | 744 /* Convert type to constant */ |
745 if (NILP (type) || EQ (type, Qautomatic_conversion)) | 745 if (NILP (type) || EQ (type, Qautomatic_conversion)) |
746 { ty = CODESYS_AUTODETECT; } | 746 { ty = CODESYS_AUTODETECT; } |
747 else if (EQ (type, Qshift_jis)) { ty = CODESYS_SHIFT_JIS; } | 747 else if (EQ (type, Qshift_jis)) { ty = CODESYS_SHIFT_JIS; } |
748 else if (EQ (type, Qiso2022)) { ty = CODESYS_ISO2022; } | 748 else if (EQ (type, Qiso2022)) { ty = CODESYS_ISO2022; } |
749 else if (EQ (type, Qbig5)) { ty = CODESYS_BIG5; } | 749 else if (EQ (type, Qbig5)) { ty = CODESYS_BIG5; } |
792 | 792 |
793 if (EQ (key, Qcharset_g0)) FROB_INITIAL_CHARSET (0); | 793 if (EQ (key, Qcharset_g0)) FROB_INITIAL_CHARSET (0); |
794 else if (EQ (key, Qcharset_g1)) FROB_INITIAL_CHARSET (1); | 794 else if (EQ (key, Qcharset_g1)) FROB_INITIAL_CHARSET (1); |
795 else if (EQ (key, Qcharset_g2)) FROB_INITIAL_CHARSET (2); | 795 else if (EQ (key, Qcharset_g2)) FROB_INITIAL_CHARSET (2); |
796 else if (EQ (key, Qcharset_g3)) FROB_INITIAL_CHARSET (3); | 796 else if (EQ (key, Qcharset_g3)) FROB_INITIAL_CHARSET (3); |
797 | 797 |
798 #define FROB_FORCE_CHARSET(charset_num) \ | 798 #define FROB_FORCE_CHARSET(charset_num) \ |
799 CODING_SYSTEM_ISO2022_FORCE_CHARSET_ON_OUTPUT (codesys, charset_num) = !NILP (value) | 799 CODING_SYSTEM_ISO2022_FORCE_CHARSET_ON_OUTPUT (codesys, charset_num) = !NILP (value) |
800 | 800 |
801 else if (EQ (key, Qforce_g0_on_output)) FROB_FORCE_CHARSET (0); | 801 else if (EQ (key, Qforce_g0_on_output)) FROB_FORCE_CHARSET (0); |
802 else if (EQ (key, Qforce_g1_on_output)) FROB_FORCE_CHARSET (1); | 802 else if (EQ (key, Qforce_g1_on_output)) FROB_FORCE_CHARSET (1); |
803 else if (EQ (key, Qforce_g2_on_output)) FROB_FORCE_CHARSET (2); | 803 else if (EQ (key, Qforce_g2_on_output)) FROB_FORCE_CHARSET (2); |
804 else if (EQ (key, Qforce_g3_on_output)) FROB_FORCE_CHARSET (3); | 804 else if (EQ (key, Qforce_g3_on_output)) FROB_FORCE_CHARSET (3); |
805 | 805 |
806 #define FROB_BOOLEAN_PROPERTY(prop) \ | 806 #define FROB_BOOLEAN_PROPERTY(prop) \ |
807 CODING_SYSTEM_ISO2022_##prop (codesys) = !NILP (value) | 807 CODING_SYSTEM_ISO2022_##prop (codesys) = !NILP (value) |
808 | 808 |
809 else if (EQ (key, Qshort)) FROB_BOOLEAN_PROPERTY (SHORT); | 809 else if (EQ (key, Qshort)) FROB_BOOLEAN_PROPERTY (SHORT); |
810 else if (EQ (key, Qno_ascii_eol)) FROB_BOOLEAN_PROPERTY (NO_ASCII_EOL); | 810 else if (EQ (key, Qno_ascii_eol)) FROB_BOOLEAN_PROPERTY (NO_ASCII_EOL); |
811 else if (EQ (key, Qno_ascii_cntl)) FROB_BOOLEAN_PROPERTY (NO_ASCII_CNTL); | 811 else if (EQ (key, Qno_ascii_cntl)) FROB_BOOLEAN_PROPERTY (NO_ASCII_CNTL); |
812 else if (EQ (key, Qseven)) FROB_BOOLEAN_PROPERTY (SEVEN); | 812 else if (EQ (key, Qseven)) FROB_BOOLEAN_PROPERTY (SEVEN); |
813 else if (EQ (key, Qlock_shift)) FROB_BOOLEAN_PROPERTY (LOCK_SHIFT); | 813 else if (EQ (key, Qlock_shift)) FROB_BOOLEAN_PROPERTY (LOCK_SHIFT); |
814 else if (EQ (key, Qno_iso6429)) FROB_BOOLEAN_PROPERTY (NO_ISO6429); | 814 else if (EQ (key, Qno_iso6429)) FROB_BOOLEAN_PROPERTY (NO_ISO6429); |
815 else if (EQ (key, Qescape_quoted)) FROB_BOOLEAN_PROPERTY (ESCAPE_QUOTED); | 815 else if (EQ (key, Qescape_quoted)) FROB_BOOLEAN_PROPERTY (ESCAPE_QUOTED); |
816 | 816 |
817 else if (EQ (key, Qinput_charset_conversion)) | 817 else if (EQ (key, Qinput_charset_conversion)) |
818 { | 818 { |
819 codesys->iso2022.input_conv = | 819 codesys->iso2022.input_conv = |
820 Dynarr_new (struct charset_conversion_spec); | 820 Dynarr_new (struct charset_conversion_spec); |
821 parse_charset_conversion_specs (codesys->iso2022.input_conv, | 821 parse_charset_conversion_specs (codesys->iso2022.input_conv, |
850 signal_simple_error ("Unrecognized property", key); | 850 signal_simple_error ("Unrecognized property", key); |
851 } | 851 } |
852 | 852 |
853 if (need_to_setup_eol_systems) | 853 if (need_to_setup_eol_systems) |
854 setup_eol_coding_systems (codesys); | 854 setup_eol_coding_systems (codesys); |
855 | 855 |
856 { | 856 { |
857 Lisp_Object codesys_obj; | 857 Lisp_Object codesys_obj; |
858 XSETCODING_SYSTEM (codesys_obj, codesys); | 858 XSETCODING_SYSTEM (codesys_obj, codesys); |
859 Fputhash (name, codesys_obj, Vcoding_system_hashtable); | 859 Fputhash (name, codesys_obj, Vcoding_system_hashtable); |
860 return codesys_obj; | 860 return codesys_obj; |
1026 else if (type == CODESYS_ISO2022) | 1026 else if (type == CODESYS_ISO2022) |
1027 { | 1027 { |
1028 #define INITIAL_CHARSET(charset_num) \ | 1028 #define INITIAL_CHARSET(charset_num) \ |
1029 (XCHARSET_NAME (XCODING_SYSTEM_ISO2022_INITIAL_CHARSET \ | 1029 (XCHARSET_NAME (XCODING_SYSTEM_ISO2022_INITIAL_CHARSET \ |
1030 (coding_system, charset_num))) | 1030 (coding_system, charset_num))) |
1031 | 1031 |
1032 if (EQ (prop, Qcharset_g0)) return INITIAL_CHARSET (0); | 1032 if (EQ (prop, Qcharset_g0)) return INITIAL_CHARSET (0); |
1033 else if (EQ (prop, Qcharset_g1)) return INITIAL_CHARSET (1); | 1033 else if (EQ (prop, Qcharset_g1)) return INITIAL_CHARSET (1); |
1034 else if (EQ (prop, Qcharset_g2)) return INITIAL_CHARSET (2); | 1034 else if (EQ (prop, Qcharset_g2)) return INITIAL_CHARSET (2); |
1035 else if (EQ (prop, Qcharset_g3)) return INITIAL_CHARSET (3); | 1035 else if (EQ (prop, Qcharset_g3)) return INITIAL_CHARSET (3); |
1036 | 1036 |
1043 else if (EQ (prop, Qforce_g2_on_output)) return FORCE_CHARSET (2); | 1043 else if (EQ (prop, Qforce_g2_on_output)) return FORCE_CHARSET (2); |
1044 else if (EQ (prop, Qforce_g3_on_output)) return FORCE_CHARSET (3); | 1044 else if (EQ (prop, Qforce_g3_on_output)) return FORCE_CHARSET (3); |
1045 | 1045 |
1046 #define LISP_BOOLEAN(prop) \ | 1046 #define LISP_BOOLEAN(prop) \ |
1047 (XCODING_SYSTEM_ISO2022_##prop (coding_system) ? Qt : Qnil) | 1047 (XCODING_SYSTEM_ISO2022_##prop (coding_system) ? Qt : Qnil) |
1048 | 1048 |
1049 else if (EQ (prop, Qshort)) return LISP_BOOLEAN (SHORT); | 1049 else if (EQ (prop, Qshort)) return LISP_BOOLEAN (SHORT); |
1050 else if (EQ (prop, Qno_ascii_eol)) return LISP_BOOLEAN (NO_ASCII_EOL); | 1050 else if (EQ (prop, Qno_ascii_eol)) return LISP_BOOLEAN (NO_ASCII_EOL); |
1051 else if (EQ (prop, Qno_ascii_cntl)) return LISP_BOOLEAN (NO_ASCII_CNTL); | 1051 else if (EQ (prop, Qno_ascii_cntl)) return LISP_BOOLEAN (NO_ASCII_CNTL); |
1052 else if (EQ (prop, Qseven)) return LISP_BOOLEAN (SEVEN); | 1052 else if (EQ (prop, Qseven)) return LISP_BOOLEAN (SEVEN); |
1053 else if (EQ (prop, Qlock_shift)) return LISP_BOOLEAN (LOCK_SHIFT); | 1053 else if (EQ (prop, Qlock_shift)) return LISP_BOOLEAN (LOCK_SHIFT); |
1054 else if (EQ (prop, Qno_iso6429)) return LISP_BOOLEAN (NO_ISO6429); | 1054 else if (EQ (prop, Qno_iso6429)) return LISP_BOOLEAN (NO_ISO6429); |
1055 else if (EQ (prop, Qescape_quoted)) return LISP_BOOLEAN (ESCAPE_QUOTED); | 1055 else if (EQ (prop, Qescape_quoted)) return LISP_BOOLEAN (ESCAPE_QUOTED); |
1056 | 1056 |
1057 else if (EQ (prop, Qinput_charset_conversion)) | 1057 else if (EQ (prop, Qinput_charset_conversion)) |
1058 return | 1058 return |
1059 unparse_charset_conversion_specs | 1059 unparse_charset_conversion_specs |
1060 (XCODING_SYSTEM (coding_system)->iso2022.input_conv); | 1060 (XCODING_SYSTEM (coding_system)->iso2022.input_conv); |
1061 else if (EQ (prop, Qoutput_charset_conversion)) | 1061 else if (EQ (prop, Qoutput_charset_conversion)) |
1208 struct detection_state | 1208 struct detection_state |
1209 { | 1209 { |
1210 enum eol_type eol_type; | 1210 enum eol_type eol_type; |
1211 int seen_non_ascii; | 1211 int seen_non_ascii; |
1212 int mask; | 1212 int mask; |
1213 | 1213 |
1214 struct | 1214 struct |
1215 { | 1215 { |
1216 int mask; | 1216 int mask; |
1217 int in_second_byte; | 1217 int in_second_byte; |
1218 } | 1218 } |
1219 big5; | 1219 big5; |
1220 | 1220 |
1221 struct | 1221 struct |
1222 { | 1222 { |
1223 int mask; | 1223 int mask; |
1224 int in_second_byte; | 1224 int in_second_byte; |
1225 } | 1225 } |
1226 shift_jis; | 1226 shift_jis; |
1227 | 1227 |
1228 struct | 1228 struct |
1229 { | 1229 { |
1230 int mask; | 1230 int mask; |
1231 int initted; | 1231 int initted; |
1232 struct iso2022_decoder iso; | 1232 struct iso2022_decoder iso; |
1310 st->eol_type holds the determined EOL type, or EOL_AUTODETECT if | 1310 st->eol_type holds the determined EOL type, or EOL_AUTODETECT if |
1311 not yet known. | 1311 not yet known. |
1312 | 1312 |
1313 st->mask holds the determined coding category mask, or ~0 if only | 1313 st->mask holds the determined coding category mask, or ~0 if only |
1314 ASCII has been seen so far. | 1314 ASCII has been seen so far. |
1315 | 1315 |
1316 Returns: | 1316 Returns: |
1317 | 1317 |
1318 0 == st->eol_type is EOL_AUTODETECT and/or more than coding category | 1318 0 == st->eol_type is EOL_AUTODETECT and/or more than coding category |
1319 is present in st->mask | 1319 is present in st->mask |
1320 1 == definitive answers are here for both st->eol_type and st->mask | 1320 1 == definitive answers are here for both st->eol_type and st->mask |
1329 if (st->eol_type == EOL_AUTODETECT) | 1329 if (st->eol_type == EOL_AUTODETECT) |
1330 st->eol_type = detect_eol_type (st, src, n); | 1330 st->eol_type = detect_eol_type (st, src, n); |
1331 | 1331 |
1332 if (just_do_eol) | 1332 if (just_do_eol) |
1333 return st->eol_type != EOL_AUTODETECT; | 1333 return st->eol_type != EOL_AUTODETECT; |
1334 | 1334 |
1335 if (!st->seen_non_ascii) | 1335 if (!st->seen_non_ascii) |
1336 { | 1336 { |
1337 for (; n; n--, src++) | 1337 for (; n; n--, src++) |
1338 { | 1338 { |
1339 c = *src; | 1339 c = *src; |
1395 { | 1395 { |
1396 int i; | 1396 int i; |
1397 int cat = -1; | 1397 int cat = -1; |
1398 | 1398 |
1399 mask = postprocess_iso2022_mask (mask); | 1399 mask = postprocess_iso2022_mask (mask); |
1400 | 1400 |
1401 /* Look through the coding categories by priority and find | 1401 /* Look through the coding categories by priority and find |
1402 the first one that is allowed. */ | 1402 the first one that is allowed. */ |
1403 for (i = 0; i <= CODING_CATEGORY_LAST; i++) | 1403 for (i = 0; i <= CODING_CATEGORY_LAST; i++) |
1404 { | 1404 { |
1405 cat = coding_category_by_priority[i]; | 1405 cat = coding_category_by_priority[i]; |
1433 *eol_type_in_out = XCODING_SYSTEM_EOL_TYPE (*codesys_in_out); | 1433 *eol_type_in_out = XCODING_SYSTEM_EOL_TYPE (*codesys_in_out); |
1434 | 1434 |
1435 memset (&decst, 0, sizeof (decst)); | 1435 memset (&decst, 0, sizeof (decst)); |
1436 decst.eol_type = *eol_type_in_out; | 1436 decst.eol_type = *eol_type_in_out; |
1437 decst.mask = ~0; | 1437 decst.mask = ~0; |
1438 | 1438 |
1439 /* If autodetection is called for, do it now. */ | 1439 /* If autodetection is called for, do it now. */ |
1440 if (XCODING_SYSTEM_TYPE (*codesys_in_out) == CODESYS_AUTODETECT || | 1440 if (XCODING_SYSTEM_TYPE (*codesys_in_out) == CODESYS_AUTODETECT || |
1441 *eol_type_in_out == EOL_AUTODETECT) | 1441 *eol_type_in_out == EOL_AUTODETECT) |
1442 { | 1442 { |
1443 | 1443 |
1444 while (1) | 1444 while (1) |
1445 { | 1445 { |
1446 unsigned char random_buffer[4096]; | 1446 unsigned char random_buffer[4096]; |
1447 int nread; | 1447 int nread; |
1448 | 1448 |
1449 nread = Lstream_read (stream, random_buffer, sizeof (random_buffer)); | 1449 nread = Lstream_read (stream, random_buffer, sizeof (random_buffer)); |
1450 if (!nread) | 1450 if (!nread) |
1451 break; | 1451 break; |
1452 if (detect_coding_type (&decst, random_buffer, nread, | 1452 if (detect_coding_type (&decst, random_buffer, nread, |
1453 XCODING_SYSTEM_TYPE (*codesys_in_out) != | 1453 XCODING_SYSTEM_TYPE (*codesys_in_out) != |
1492 decst.mask = ~0; | 1492 decst.mask = ~0; |
1493 while (1) | 1493 while (1) |
1494 { | 1494 { |
1495 unsigned char random_buffer[4096]; | 1495 unsigned char random_buffer[4096]; |
1496 int nread; | 1496 int nread; |
1497 | 1497 |
1498 nread = Lstream_read (XLSTREAM (instream), random_buffer, | 1498 nread = Lstream_read (XLSTREAM (instream), random_buffer, |
1499 sizeof (random_buffer)); | 1499 sizeof (random_buffer)); |
1500 if (!nread) | 1500 if (!nread) |
1501 break; | 1501 break; |
1502 if (detect_coding_type (&decst, random_buffer, nread, 0)) | 1502 if (detect_coding_type (&decst, random_buffer, nread, 0)) |
1507 val = subsidiary_coding_system (Fget_coding_system (Qautomatic_conversion), | 1507 val = subsidiary_coding_system (Fget_coding_system (Qautomatic_conversion), |
1508 decst.eol_type); | 1508 decst.eol_type); |
1509 else | 1509 else |
1510 { | 1510 { |
1511 int i; | 1511 int i; |
1512 | 1512 |
1513 val = Qnil; | 1513 val = Qnil; |
1514 | 1514 |
1515 decst.mask = postprocess_iso2022_mask (decst.mask); | 1515 decst.mask = postprocess_iso2022_mask (decst.mask); |
1516 | 1516 |
1517 for (i = CODING_CATEGORY_LAST; i >= 0; i--) | 1517 for (i = CODING_CATEGORY_LAST; i >= 0; i--) |
1518 { | 1518 { |
1519 int sys = coding_category_by_priority[i]; | 1519 int sys = coding_category_by_priority[i]; |
1520 if (decst.mask & (1 << sys)) | 1520 if (decst.mask & (1 << sys)) |
1521 { | 1521 { |
1643 enum eol_type eol_type; | 1643 enum eol_type eol_type; |
1644 | 1644 |
1645 /* Additional ISO2022 information. We define the structure above | 1645 /* Additional ISO2022 information. We define the structure above |
1646 because it's also needed by the detection routines. */ | 1646 because it's also needed by the detection routines. */ |
1647 struct iso2022_decoder iso2022; | 1647 struct iso2022_decoder iso2022; |
1648 | 1648 |
1649 /* Additional information (the state of the running CCL program) | 1649 /* Additional information (the state of the running CCL program) |
1650 used by the CCL decoder. */ | 1650 used by the CCL decoder. */ |
1651 struct ccl_program ccl; | 1651 struct ccl_program ccl; |
1652 | 1652 |
1653 struct detection_state decst; | 1653 struct detection_state decst; |
1780 else if (CODING_SYSTEM_TYPE (str->codesys) == CODESYS_CCL) | 1780 else if (CODING_SYSTEM_TYPE (str->codesys) == CODESYS_CCL) |
1781 { | 1781 { |
1782 set_ccl_program (&str->ccl, CODING_SYSTEM_CCL_DECODE (str->codesys), | 1782 set_ccl_program (&str->ccl, CODING_SYSTEM_CCL_DECODE (str->codesys), |
1783 0, 0, 0); | 1783 0, 0, 0); |
1784 } | 1784 } |
1785 | 1785 |
1786 str->flags = str->ch = 0; | 1786 str->flags = str->ch = 0; |
1787 } | 1787 } |
1788 | 1788 |
1789 static int | 1789 static int |
1790 decoding_rewinder (Lstream *stream) | 1790 decoding_rewinder (Lstream *stream) |
1904 | 1904 |
1905 /* If necessary, do encoding-detection now. We do this when | 1905 /* If necessary, do encoding-detection now. We do this when |
1906 we're a writing stream or a non-seekable reading stream, | 1906 we're a writing stream or a non-seekable reading stream, |
1907 meaning that we can't just process the whole input, | 1907 meaning that we can't just process the whole input, |
1908 rewind, and start over. */ | 1908 rewind, and start over. */ |
1909 | 1909 |
1910 if (CODING_SYSTEM_TYPE (str->codesys) == CODESYS_AUTODETECT || | 1910 if (CODING_SYSTEM_TYPE (str->codesys) == CODESYS_AUTODETECT || |
1911 str->eol_type == EOL_AUTODETECT) | 1911 str->eol_type == EOL_AUTODETECT) |
1912 { | 1912 { |
1913 Lisp_Object codesys = Qnil; | 1913 Lisp_Object codesys = Qnil; |
1914 | 1914 |
1931 set_decoding_stream_coding_system (decoding, codesys); | 1931 set_decoding_stream_coding_system (decoding, codesys); |
1932 if (was_end) | 1932 if (was_end) |
1933 str->flags |= CODING_STATE_END; | 1933 str->flags |= CODING_STATE_END; |
1934 } | 1934 } |
1935 } | 1935 } |
1936 | 1936 |
1937 switch (CODING_SYSTEM_TYPE (str->codesys)) | 1937 switch (CODING_SYSTEM_TYPE (str->codesys)) |
1938 { | 1938 { |
1939 #ifdef DEBUG_XEMACS | 1939 #ifdef DEBUG_XEMACS |
1940 case CODESYS_INTERNAL: | 1940 case CODESYS_INTERNAL: |
1941 Dynarr_add_many (dst, src, n); | 1941 Dynarr_add_many (dst, src, n); |
2015 { | 2015 { |
2016 char tempbuf[1024]; /* some random amount */ | 2016 char tempbuf[1024]; /* some random amount */ |
2017 Lstream *in = XLSTREAM(instream); | 2017 Lstream *in = XLSTREAM(instream); |
2018 Lstream *out = XLSTREAM(outstream); | 2018 Lstream *out = XLSTREAM(outstream); |
2019 Bufpos newpos, even_newer_pos; | 2019 Bufpos newpos, even_newer_pos; |
2020 | 2020 |
2021 while (1) | 2021 while (1) |
2022 { | 2022 { |
2023 Bufpos oldpos = lisp_buffer_stream_startpos (in); | 2023 Bufpos oldpos = lisp_buffer_stream_startpos (in); |
2024 int size_in_bytes = Lstream_read (in, tempbuf, sizeof (tempbuf)); | 2024 int size_in_bytes = Lstream_read (in, tempbuf, sizeof (tempbuf)); |
2025 if (!size_in_bytes) | 2025 if (!size_in_bytes) |
2244 set_ccl_program (&str->ccl, CODING_SYSTEM_CCL_ENCODE (str->codesys), 0, 0, 0); | 2244 set_ccl_program (&str->ccl, CODING_SYSTEM_CCL_ENCODE (str->codesys), 0, 0, 0); |
2245 break; | 2245 break; |
2246 default: | 2246 default: |
2247 break; | 2247 break; |
2248 } | 2248 } |
2249 | 2249 |
2250 str->flags = str->ch = 0; | 2250 str->flags = str->ch = 0; |
2251 } | 2251 } |
2252 | 2252 |
2253 static int | 2253 static int |
2254 encoding_rewinder (Lstream *stream) | 2254 encoding_rewinder (Lstream *stream) |
2546 eol_type = str->eol_type; | 2546 eol_type = str->eol_type; |
2547 | 2547 |
2548 while (n--) | 2548 while (n--) |
2549 { | 2549 { |
2550 c = *src++; | 2550 c = *src++; |
2551 | 2551 |
2552 if (ch) | 2552 if (ch) |
2553 { | 2553 { |
2554 /* Previous character was first byte of Shift-JIS Kanji char. */ | 2554 /* Previous character was first byte of Shift-JIS Kanji char. */ |
2555 if (BYTE_SJIS_TWO_BYTE_2_P (c)) | 2555 if (BYTE_SJIS_TWO_BYTE_2_P (c)) |
2556 { | 2556 { |
2653 Return the corresponding character. | 2653 Return the corresponding character. |
2654 */ | 2654 */ |
2655 (code)) | 2655 (code)) |
2656 { | 2656 { |
2657 unsigned char c1, c2, s1, s2; | 2657 unsigned char c1, c2, s1, s2; |
2658 | 2658 |
2659 CHECK_CONS (code); | 2659 CHECK_CONS (code); |
2660 CHECK_INT (XCAR (code)); | 2660 CHECK_INT (XCAR (code)); |
2661 CHECK_INT (XCDR (code)); | 2661 CHECK_INT (XCDR (code)); |
2662 s1 = XINT (XCAR (code)); | 2662 s1 = XINT (XCAR (code)); |
2663 s2 = XINT (XCDR (code)); | 2663 s2 = XINT (XCDR (code)); |
2678 */ | 2678 */ |
2679 (ch)) | 2679 (ch)) |
2680 { | 2680 { |
2681 Lisp_Object charset; | 2681 Lisp_Object charset; |
2682 int c1, c2, s1, s2; | 2682 int c1, c2, s1, s2; |
2683 | 2683 |
2684 CHECK_CHAR_COERCE_INT (ch); | 2684 CHECK_CHAR_COERCE_INT (ch); |
2685 BREAKUP_CHAR (XCHAR (ch), charset, c1, c2); | 2685 BREAKUP_CHAR (XCHAR (ch), charset, c1, c2); |
2686 if (EQ (charset, Vcharset_japanese_jisx0208)) | 2686 if (EQ (charset, Vcharset_japanese_jisx0208)) |
2687 { | 2687 { |
2688 ENCODE_SJIS (c1 | 0x80, c2 | 0x80, s1, s2); | 2688 ENCODE_SJIS (c1 | 0x80, c2 | 0x80, s1, s2); |
2863 else | 2863 else |
2864 DECODE_ADD_BINARY_CHAR (c, dst); | 2864 DECODE_ADD_BINARY_CHAR (c, dst); |
2865 } | 2865 } |
2866 label_continue_loop:; | 2866 label_continue_loop:; |
2867 } | 2867 } |
2868 | 2868 |
2869 DECODE_HANDLE_END_OF_CONVERSION (flags, ch, dst); | 2869 DECODE_HANDLE_END_OF_CONVERSION (flags, ch, dst); |
2870 | 2870 |
2871 CODING_STREAM_COMPOSE (str, flags, ch); | 2871 CODING_STREAM_COMPOSE (str, flags, ch); |
2872 } | 2872 } |
2873 | 2873 |
2887 | 2887 |
2888 while (n--) | 2888 while (n--) |
2889 { | 2889 { |
2890 c = *src++; | 2890 c = *src++; |
2891 if (c == '\n') | 2891 if (c == '\n') |
2892 { | 2892 { |
2893 if (eol_type != EOL_LF && eol_type != EOL_AUTODETECT) | 2893 if (eol_type != EOL_LF && eol_type != EOL_AUTODETECT) |
2894 Dynarr_add (dst, '\r'); | 2894 Dynarr_add (dst, '\r'); |
2895 if (eol_type != EOL_CR) | 2895 if (eol_type != EOL_CR) |
2896 Dynarr_add (dst, '\n'); | 2896 Dynarr_add (dst, '\n'); |
2897 } | 2897 } |
2941 Return the corresponding character. | 2941 Return the corresponding character. |
2942 */ | 2942 */ |
2943 (code)) | 2943 (code)) |
2944 { | 2944 { |
2945 unsigned char c1, c2, b1, b2; | 2945 unsigned char c1, c2, b1, b2; |
2946 | 2946 |
2947 CHECK_CONS (code); | 2947 CHECK_CONS (code); |
2948 CHECK_INT (XCAR (code)); | 2948 CHECK_INT (XCAR (code)); |
2949 CHECK_INT (XCDR (code)); | 2949 CHECK_INT (XCDR (code)); |
2950 b1 = XINT (XCAR (code)); | 2950 b1 = XINT (XCAR (code)); |
2951 b2 = XINT (XCDR (code)); | 2951 b2 = XINT (XCDR (code)); |
2968 */ | 2968 */ |
2969 (ch)) | 2969 (ch)) |
2970 { | 2970 { |
2971 Lisp_Object charset; | 2971 Lisp_Object charset; |
2972 int c1, c2, b1, b2; | 2972 int c1, c2, b1, b2; |
2973 | 2973 |
2974 CHECK_CHAR_COERCE_INT (ch); | 2974 CHECK_CHAR_COERCE_INT (ch); |
2975 BREAKUP_CHAR (XCHAR (ch), charset, c1, c2); | 2975 BREAKUP_CHAR (XCHAR (ch), charset, c1, c2); |
2976 if (EQ (charset, Vcharset_chinese_big5_1) || | 2976 if (EQ (charset, Vcharset_chinese_big5_1) || |
2977 EQ (charset, Vcharset_chinese_big5_2)) | 2977 EQ (charset, Vcharset_chinese_big5_2)) |
2978 { | 2978 { |
3126 o CSI '0' ']' -- end of the current direction | 3126 o CSI '0' ']' -- end of the current direction |
3127 o CSI '1' ']' -- start of left-to-right text | 3127 o CSI '1' ']' -- start of left-to-right text |
3128 o CSI '2' ']' -- start of right-to-left text | 3128 o CSI '2' ']' -- start of right-to-left text |
3129 The control character CSI (0x9B: control sequence introducer) is | 3129 The control character CSI (0x9B: control sequence introducer) is |
3130 abbreviated to the escape sequence ESC '[' in 7-bit environment. | 3130 abbreviated to the escape sequence ESC '[' in 7-bit environment. |
3131 | 3131 |
3132 Character composition specification takes the following format: | 3132 Character composition specification takes the following format: |
3133 o ESC '0' -- start character composition | 3133 o ESC '0' -- start character composition |
3134 o ESC '1' -- end character composition | 3134 o ESC '1' -- end character composition |
3135 Since these are not standard escape sequences of any ISO, the use | 3135 Since these are not standard escape sequences of any ISO, the use |
3136 of them for these meanings is restricted to Emacs only. */ | 3136 of them for these meanings is restricted to Emacs only. */ |
3137 | 3137 |
3138 static void | 3138 static void |
3139 reset_iso2022 (Lisp_Object coding_system, struct iso2022_decoder *iso) | 3139 reset_iso2022 (Lisp_Object coding_system, struct iso2022_decoder *iso) |
3140 { | 3140 { |
3141 int i; | 3141 int i; |
3142 | 3142 |
3143 for (i = 0; i < 4; i++) | 3143 for (i = 0; i < 4; i++) |
3144 { | 3144 { |
3145 if (!NILP (coding_system)) | 3145 if (!NILP (coding_system)) |
3146 iso->charset[i] = | 3146 iso->charset[i] = |
3147 XCODING_SYSTEM_ISO2022_INITIAL_CHARSET (coding_system, i); | 3147 XCODING_SYSTEM_ISO2022_INITIAL_CHARSET (coding_system, i); |
3230 { | 3230 { |
3231 case ISO_CODE_ESC: /* Start escape sequence */ | 3231 case ISO_CODE_ESC: /* Start escape sequence */ |
3232 *flags |= CODING_STATE_ESCAPE; | 3232 *flags |= CODING_STATE_ESCAPE; |
3233 iso->esc = ISO_ESC; | 3233 iso->esc = ISO_ESC; |
3234 goto not_done; | 3234 goto not_done; |
3235 | 3235 |
3236 case ISO_CODE_CSI: /* ISO6429 (specifying directionality) */ | 3236 case ISO_CODE_CSI: /* ISO6429 (specifying directionality) */ |
3237 *flags |= CODING_STATE_ESCAPE; | 3237 *flags |= CODING_STATE_ESCAPE; |
3238 iso->esc = ISO_ESC_5_11; | 3238 iso->esc = ISO_ESC_5_11; |
3239 goto not_done; | 3239 goto not_done; |
3240 | 3240 |
3291 case '0': | 3291 case '0': |
3292 iso->esc = ISO_ESC_START_COMPOSITE; | 3292 iso->esc = ISO_ESC_START_COMPOSITE; |
3293 *flags = (*flags & CODING_STATE_ISO2022_LOCK) | | 3293 *flags = (*flags & CODING_STATE_ISO2022_LOCK) | |
3294 CODING_STATE_COMPOSITE; | 3294 CODING_STATE_COMPOSITE; |
3295 return 1; | 3295 return 1; |
3296 | 3296 |
3297 case '1': | 3297 case '1': |
3298 iso->esc = ISO_ESC_END_COMPOSITE; | 3298 iso->esc = ISO_ESC_END_COMPOSITE; |
3299 *flags = (*flags & CODING_STATE_ISO2022_LOCK) & | 3299 *flags = (*flags & CODING_STATE_ISO2022_LOCK) & |
3300 ~CODING_STATE_COMPOSITE; | 3300 ~CODING_STATE_COMPOSITE; |
3301 return 1; | 3301 return 1; |
3456 else | 3456 else |
3457 { | 3457 { |
3458 /* Can this ever be reached? -slb */ | 3458 /* Can this ever be reached? -slb */ |
3459 abort(); | 3459 abort(); |
3460 } | 3460 } |
3461 | 3461 |
3462 cs = CHARSET_BY_ATTRIBUTES (type, c, | 3462 cs = CHARSET_BY_ATTRIBUTES (type, c, |
3463 *flags & CODING_STATE_R2L ? | 3463 *flags & CODING_STATE_R2L ? |
3464 CHARSET_RIGHT_TO_LEFT : | 3464 CHARSET_RIGHT_TO_LEFT : |
3465 CHARSET_LEFT_TO_RIGHT); | 3465 CHARSET_LEFT_TO_RIGHT); |
3466 goto designated; | 3466 goto designated; |
3783 dst = real_dst; | 3783 dst = real_dst; |
3784 len = set_charptr_emchar (comstr, emch); | 3784 len = set_charptr_emchar (comstr, emch); |
3785 Dynarr_add_many (dst, comstr, len); | 3785 Dynarr_add_many (dst, comstr, len); |
3786 break; | 3786 break; |
3787 } | 3787 } |
3788 | 3788 |
3789 case ISO_ESC_LITERAL: | 3789 case ISO_ESC_LITERAL: |
3790 DECODE_ADD_BINARY_CHAR (c, dst); | 3790 DECODE_ADD_BINARY_CHAR (c, dst); |
3791 break; | 3791 break; |
3792 | 3792 |
3793 default: | 3793 default: |
3893 XCHARSET_DIRECTION (charset) == CHARSET_LEFT_TO_RIGHT) | 3893 XCHARSET_DIRECTION (charset) == CHARSET_LEFT_TO_RIGHT) |
3894 || | 3894 || |
3895 (!(flags & CODING_STATE_R2L) && | 3895 (!(flags & CODING_STATE_R2L) && |
3896 XCHARSET_DIRECTION (charset) == CHARSET_RIGHT_TO_LEFT)) | 3896 XCHARSET_DIRECTION (charset) == CHARSET_RIGHT_TO_LEFT)) |
3897 { | 3897 { |
3898 Lisp_Object new_charset = | 3898 Lisp_Object new_charset = |
3899 XCHARSET_REVERSE_DIRECTION_CHARSET (charset); | 3899 XCHARSET_REVERSE_DIRECTION_CHARSET (charset); |
3900 if (!NILP (new_charset)) | 3900 if (!NILP (new_charset)) |
3901 charset = new_charset; | 3901 charset = new_charset; |
3902 } | 3902 } |
3903 | 3903 |
3906 { | 3906 { |
3907 case 1: /* ASCII */ | 3907 case 1: /* ASCII */ |
3908 DECODE_OUTPUT_PARTIAL_CHAR (ch); | 3908 DECODE_OUTPUT_PARTIAL_CHAR (ch); |
3909 Dynarr_add (dst, c & 0x7F); | 3909 Dynarr_add (dst, c & 0x7F); |
3910 break; | 3910 break; |
3911 | 3911 |
3912 case 2: /* one-byte official */ | 3912 case 2: /* one-byte official */ |
3913 DECODE_OUTPUT_PARTIAL_CHAR (ch); | 3913 DECODE_OUTPUT_PARTIAL_CHAR (ch); |
3914 Dynarr_add (dst, lb); | 3914 Dynarr_add (dst, lb); |
3915 Dynarr_add (dst, c | 0x80); | 3915 Dynarr_add (dst, c | 0x80); |
3916 break; | 3916 break; |
3917 | 3917 |
3918 case 3: /* one-byte private or two-byte official */ | 3918 case 3: /* one-byte private or two-byte official */ |
3919 if (XCHARSET_PRIVATE_P (charset)) | 3919 if (XCHARSET_PRIVATE_P (charset)) |
3920 { | 3920 { |
3921 DECODE_OUTPUT_PARTIAL_CHAR (ch); | 3921 DECODE_OUTPUT_PARTIAL_CHAR (ch); |
3922 Dynarr_add (dst, PRE_LEADING_BYTE_PRIVATE_1); | 3922 Dynarr_add (dst, PRE_LEADING_BYTE_PRIVATE_1); |
3934 } | 3934 } |
3935 else | 3935 else |
3936 ch = c; | 3936 ch = c; |
3937 } | 3937 } |
3938 break; | 3938 break; |
3939 | 3939 |
3940 default: /* two-byte private */ | 3940 default: /* two-byte private */ |
3941 if (ch) | 3941 if (ch) |
3942 { | 3942 { |
3943 Dynarr_add (dst, PRE_LEADING_BYTE_PRIVATE_2); | 3943 Dynarr_add (dst, PRE_LEADING_BYTE_PRIVATE_2); |
3944 Dynarr_add (dst, lb); | 3944 Dynarr_add (dst, lb); |
3997 str->codesys->iso2022.output_conv; | 3997 str->codesys->iso2022.output_conv; |
3998 | 3998 |
3999 if (dyn) | 3999 if (dyn) |
4000 { | 4000 { |
4001 int i; | 4001 int i; |
4002 | 4002 |
4003 for (i = 0; i < Dynarr_length (dyn); i++) | 4003 for (i = 0; i < Dynarr_length (dyn); i++) |
4004 { | 4004 { |
4005 struct charset_conversion_spec *spec = Dynarr_atp (dyn, i); | 4005 struct charset_conversion_spec *spec = Dynarr_atp (dyn, i); |
4006 if (EQ (charset, spec->from_charset)) | 4006 if (EQ (charset, spec->from_charset)) |
4007 charset = spec->to_charset; | 4007 charset = spec->to_charset; |
4136 | 4136 |
4137 else if (BUFBYTE_LEADING_BYTE_P (c) || BUFBYTE_LEADING_BYTE_P (ch)) | 4137 else if (BUFBYTE_LEADING_BYTE_P (c) || BUFBYTE_LEADING_BYTE_P (ch)) |
4138 { /* Processing Leading Byte */ | 4138 { /* Processing Leading Byte */ |
4139 ch = 0; | 4139 ch = 0; |
4140 charset = CHARSET_BY_LEADING_BYTE (c); | 4140 charset = CHARSET_BY_LEADING_BYTE (c); |
4141 if (c == PRE_LEADING_BYTE_PRIVATE_1 || | 4141 if (LEADING_BYTE_PREFIX_P(c)) |
4142 c == PRE_LEADING_BYTE_PRIVATE_2) | |
4143 ch = c; | 4142 ch = c; |
4144 else if (!EQ (charset, Vcharset_control_1) | 4143 else if (!EQ (charset, Vcharset_control_1) |
4145 && !EQ (charset, Vcharset_composite)) | 4144 && !EQ (charset, Vcharset_composite)) |
4146 { | 4145 { |
4147 int reg; | 4146 int reg; |
4336 Lisp_Object initial_charset = | 4335 Lisp_Object initial_charset = |
4337 CODING_SYSTEM_ISO2022_INITIAL_CHARSET (codesys, i); | 4336 CODING_SYSTEM_ISO2022_INITIAL_CHARSET (codesys, i); |
4338 iso2022_designate (initial_charset, i, str, dst); | 4337 iso2022_designate (initial_charset, i, str, dst); |
4339 } | 4338 } |
4340 } | 4339 } |
4341 | 4340 |
4342 CODING_STREAM_COMPOSE (str, flags, ch); | 4341 CODING_STREAM_COMPOSE (str, flags, ch); |
4343 str->iso2022.current_char_boundary = char_boundary; | 4342 str->iso2022.current_char_boundary = char_boundary; |
4344 str->iso2022.current_charset = charset; | 4343 str->iso2022.current_charset = charset; |
4345 str->iso2022.current_half = half; | 4344 str->iso2022.current_half = half; |
4346 | 4345 |
4368 eol_type = str->eol_type; | 4367 eol_type = str->eol_type; |
4369 | 4368 |
4370 while (n--) | 4369 while (n--) |
4371 { | 4370 { |
4372 c = *src++; | 4371 c = *src++; |
4373 | 4372 |
4374 DECODE_HANDLE_EOL_TYPE (eol_type, c, flags, dst); | 4373 DECODE_HANDLE_EOL_TYPE (eol_type, c, flags, dst); |
4375 DECODE_ADD_BINARY_CHAR (c, dst); | 4374 DECODE_ADD_BINARY_CHAR (c, dst); |
4376 label_continue_loop:; | 4375 label_continue_loop:; |
4377 } | 4376 } |
4378 | 4377 |
4448 | 4447 |
4449 #define PATHNAME_CODING_SYSTEM \ | 4448 #define PATHNAME_CODING_SYSTEM \ |
4450 ((NILP (Vpathname_coding_system) || \ | 4449 ((NILP (Vpathname_coding_system) || \ |
4451 (EQ ((Vpathname_coding_system), Qbinary))) ? \ | 4450 (EQ ((Vpathname_coding_system), Qbinary))) ? \ |
4452 Qnil : Fget_coding_system (Vpathname_coding_system)) | 4451 Qnil : Fget_coding_system (Vpathname_coding_system)) |
4453 | 4452 |
4454 /* #### not correct for all values of `fmt'! */ | 4453 /* #### not correct for all values of `fmt'! */ |
4455 #define FMT_CODING_SYSTEM(fmt) \ | 4454 #define FMT_CODING_SYSTEM(fmt) \ |
4456 (((fmt) == FORMAT_FILENAME) ? PATHNAME_CODING_SYSTEM : \ | 4455 (((fmt) == FORMAT_FILENAME) ? PATHNAME_CODING_SYSTEM : \ |
4457 ((fmt) == FORMAT_CTEXT ) ? Fget_coding_system (Qctext) : \ | 4456 ((fmt) == FORMAT_CTEXT ) ? Fget_coding_system (Qctext) : \ |
4458 ((fmt) == FORMAT_TERMINAL) ? PATHNAME_CODING_SYSTEM : \ | 4457 ((fmt) == FORMAT_TERMINAL) ? PATHNAME_CODING_SYSTEM : \ |
4470 conversion_out_dynarr = Dynarr_new (Extbyte); | 4469 conversion_out_dynarr = Dynarr_new (Extbyte); |
4471 else | 4470 else |
4472 Dynarr_reset (conversion_out_dynarr); | 4471 Dynarr_reset (conversion_out_dynarr); |
4473 | 4472 |
4474 if (NILP (coding_system)) | 4473 if (NILP (coding_system)) |
4475 { | 4474 { |
4476 CONST Bufbyte *end = ptr + len; | 4475 CONST Bufbyte *end = ptr + len; |
4477 | 4476 |
4478 for (; ptr < end;) | 4477 for (; ptr < end;) |
4479 { | 4478 { |
4480 Bufbyte c = | 4479 Bufbyte c = |
4484 '~'; | 4483 '~'; |
4485 | 4484 |
4486 Dynarr_add (conversion_out_dynarr, (Extbyte) c); | 4485 Dynarr_add (conversion_out_dynarr, (Extbyte) c); |
4487 INC_CHARPTR (ptr); | 4486 INC_CHARPTR (ptr); |
4488 } | 4487 } |
4489 | 4488 |
4490 #ifdef ERROR_CHECK_BUFPOS | 4489 #ifdef ERROR_CHECK_BUFPOS |
4491 assert (ptr == end); | 4490 assert (ptr == end); |
4492 #endif | 4491 #endif |
4493 } | 4492 } |
4494 else | 4493 else |
4526 Extcount len, | 4525 Extcount len, |
4527 Bytecount *len_out, | 4526 Bytecount *len_out, |
4528 enum external_data_format fmt) | 4527 enum external_data_format fmt) |
4529 { | 4528 { |
4530 Lisp_Object coding_system = FMT_CODING_SYSTEM (fmt); | 4529 Lisp_Object coding_system = FMT_CODING_SYSTEM (fmt); |
4531 | 4530 |
4532 if (!conversion_in_dynarr) | 4531 if (!conversion_in_dynarr) |
4533 conversion_in_dynarr = Dynarr_new (Bufbyte); | 4532 conversion_in_dynarr = Dynarr_new (Bufbyte); |
4534 else | 4533 else |
4535 Dynarr_reset (conversion_in_dynarr); | 4534 Dynarr_reset (conversion_in_dynarr); |
4536 | 4535 |
4549 make_fixed_buffer_input_stream ((unsigned char *) ptr, len); | 4548 make_fixed_buffer_input_stream ((unsigned char *) ptr, len); |
4550 Lisp_Object outstream = make_dynarr_output_stream | 4549 Lisp_Object outstream = make_dynarr_output_stream |
4551 ((unsigned_char_dynarr *) conversion_in_dynarr); | 4550 ((unsigned_char_dynarr *) conversion_in_dynarr); |
4552 struct gcpro gcpro1, gcpro2; | 4551 struct gcpro gcpro1, gcpro2; |
4553 char tempbuf[1024]; /* some random amount */ | 4552 char tempbuf[1024]; /* some random amount */ |
4554 | 4553 |
4555 outstream = | 4554 outstream = |
4556 make_decoding_output_stream (XLSTREAM (outstream), coding_system); | 4555 make_decoding_output_stream (XLSTREAM (outstream), coding_system); |
4557 GCPRO2 (instream, outstream); /* Necessary?? */ | 4556 GCPRO2 (instream, outstream); /* Necessary?? */ |
4558 while (1) | 4557 while (1) |
4559 { | 4558 { |
4601 DEFSUBR (Fcoding_category_list); | 4600 DEFSUBR (Fcoding_category_list); |
4602 DEFSUBR (Fset_coding_priority_list); | 4601 DEFSUBR (Fset_coding_priority_list); |
4603 DEFSUBR (Fcoding_priority_list); | 4602 DEFSUBR (Fcoding_priority_list); |
4604 DEFSUBR (Fset_coding_category_system); | 4603 DEFSUBR (Fset_coding_category_system); |
4605 DEFSUBR (Fcoding_category_system); | 4604 DEFSUBR (Fcoding_category_system); |
4606 | 4605 |
4607 DEFSUBR (Fdetect_coding_region); | 4606 DEFSUBR (Fdetect_coding_region); |
4608 DEFSUBR (Fdecode_coding_region); | 4607 DEFSUBR (Fdecode_coding_region); |
4609 DEFSUBR (Fencode_coding_region); | 4608 DEFSUBR (Fencode_coding_region); |
4610 DEFSUBR (Fdecode_shift_jis_char); | 4609 DEFSUBR (Fdecode_shift_jis_char); |
4611 DEFSUBR (Fencode_shift_jis_char); | 4610 DEFSUBR (Fencode_shift_jis_char); |
4702 for (i = 0; i <= CODING_CATEGORY_LAST; i++) | 4701 for (i = 0; i <= CODING_CATEGORY_LAST; i++) |
4703 { | 4702 { |
4704 coding_category_system[i] = Qnil; | 4703 coding_category_system[i] = Qnil; |
4705 coding_category_by_priority[i] = i; | 4704 coding_category_by_priority[i] = i; |
4706 } | 4705 } |
4707 | 4706 |
4708 DEFVAR_LISP ("keyboard-coding-system", &Vkeyboard_coding_system /* | 4707 DEFVAR_LISP ("keyboard-coding-system", &Vkeyboard_coding_system /* |
4709 Coding system used for TTY keyboard input. | 4708 Coding system used for TTY keyboard input. |
4710 Not used under a windowing system. | 4709 Not used under a windowing system. |
4711 */ ); | 4710 */ ); |
4712 Vkeyboard_coding_system = Qnil; | 4711 Vkeyboard_coding_system = Qnil; |