Mercurial > hg > xemacs-beta
comparison src/mule-coding.c @ 207:e45d5e7c476e r20-4b2
Import from CVS: tag r20-4b2
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:03:52 +0200 |
parents | acd284d43ca1 |
children | 41ff10fd062f |
comparison
equal
deleted
inserted
replaced
206:d3e9274cbc4e | 207:e45d5e7c476e |
---|---|
570 DEFUN ("make-coding-system", Fmake_coding_system, 2, 4, 0, /* | 570 DEFUN ("make-coding-system", Fmake_coding_system, 2, 4, 0, /* |
571 Register symbol NAME as a coding system. | 571 Register symbol NAME as a coding system. |
572 | 572 |
573 TYPE describes the conversion method used and should be one of | 573 TYPE describes the conversion method used and should be one of |
574 | 574 |
575 nil or 'automatic-conversion | 575 nil or 'undecided |
576 Automatic conversion. XEmacs attempts to detect the coding system | 576 Automatic conversion. XEmacs attempts to detect the coding system |
577 used in the file. | 577 used in the file. |
578 'no-conversion | 578 'no-conversion |
579 No conversion. Use this for binary files and such. On output, | 579 No conversion. Use this for binary files and such. On output, |
580 graphic characters that are not in ASCII or Latin-1 will be | 580 graphic characters that are not in ASCII or Latin-1 will be |
740 Lisp_Object rest, key, value; | 740 Lisp_Object rest, key, value; |
741 enum coding_system_type ty; | 741 enum coding_system_type 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, Qundecided)) |
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; } |
750 else if (EQ (type, Qccl)) { ty = CODESYS_CCL; } | 750 else if (EQ (type, Qccl)) { ty = CODESYS_CCL; } |
942 */ | 942 */ |
943 (coding_system)) | 943 (coding_system)) |
944 { | 944 { |
945 switch (XCODING_SYSTEM_TYPE (Fget_coding_system (coding_system))) | 945 switch (XCODING_SYSTEM_TYPE (Fget_coding_system (coding_system))) |
946 { | 946 { |
947 case CODESYS_AUTODETECT: return Qautomatic_conversion; | 947 case CODESYS_AUTODETECT: return Qundecided; |
948 case CODESYS_SHIFT_JIS: return Qshift_jis; | 948 case CODESYS_SHIFT_JIS: return Qshift_jis; |
949 case CODESYS_ISO2022: return Qiso2022; | 949 case CODESYS_ISO2022: return Qiso2022; |
950 case CODESYS_BIG5: return Qbig5; | 950 case CODESYS_BIG5: return Qbig5; |
951 case CODESYS_CCL: return Qccl; | 951 case CODESYS_CCL: return Qccl; |
952 case CODESYS_NO_CONVERSION: return Qno_conversion; | 952 case CODESYS_NO_CONVERSION: return Qno_conversion; |
956 default: | 956 default: |
957 abort (); | 957 abort (); |
958 } | 958 } |
959 | 959 |
960 return Qnil; /* not reached */ | 960 return Qnil; /* not reached */ |
961 } | |
962 | |
963 Lisp_Object coding_system_charset (coding_system, gnum) | |
964 { | |
965 Lisp_Object cs | |
966 = XCODING_SYSTEM_ISO2022_INITIAL_CHARSET (coding_system, gnum); | |
967 | |
968 if (CHARSETP(cs)){ | |
969 return XCHARSET_NAME(cs); | |
970 } | |
971 else { | |
972 return Qnil; | |
973 } | |
974 } | |
975 | |
976 DEFUN ("coding-system-charset", Fcoding_system_charset, 2, 2, 0, /* | |
977 Return initial charset of CODING-SYSTEM designated to GNUM. | |
978 GNUM allows 0 .. 3. | |
979 */ | |
980 (coding_system, gnum)) | |
981 { | |
982 coding_system = Fget_coding_system (coding_system); | |
983 CHECK_INT (gnum); | |
984 | |
985 return coding_system_charset(coding_system, XINT (gnum)); | |
961 } | 986 } |
962 | 987 |
963 DEFUN ("coding-system-property", Fcoding_system_property, 2, 2, 0, /* | 988 DEFUN ("coding-system-property", Fcoding_system_property, 2, 2, 0, /* |
964 Return the PROP property of CODING-SYSTEM. | 989 Return the PROP property of CODING-SYSTEM. |
965 */ | 990 */ |
1023 return XCODING_SYSTEM_POST_READ_CONVERSION (coding_system); | 1048 return XCODING_SYSTEM_POST_READ_CONVERSION (coding_system); |
1024 else if (EQ (prop, Qpre_write_conversion)) | 1049 else if (EQ (prop, Qpre_write_conversion)) |
1025 return XCODING_SYSTEM_PRE_WRITE_CONVERSION (coding_system); | 1050 return XCODING_SYSTEM_PRE_WRITE_CONVERSION (coding_system); |
1026 else if (type == CODESYS_ISO2022) | 1051 else if (type == CODESYS_ISO2022) |
1027 { | 1052 { |
1028 #define INITIAL_CHARSET(charset_num) \ | 1053 if (EQ (prop, Qcharset_g0)) |
1029 (XCHARSET_NAME (XCODING_SYSTEM_ISO2022_INITIAL_CHARSET \ | 1054 return coding_system_charset (coding_system, 0); |
1030 (coding_system, charset_num))) | 1055 else if (EQ (prop, Qcharset_g1)) |
1031 | 1056 return coding_system_charset (coding_system, 1); |
1032 if (EQ (prop, Qcharset_g0)) return INITIAL_CHARSET (0); | 1057 else if (EQ (prop, Qcharset_g2)) |
1033 else if (EQ (prop, Qcharset_g1)) return INITIAL_CHARSET (1); | 1058 return coding_system_charset (coding_system, 2); |
1034 else if (EQ (prop, Qcharset_g2)) return INITIAL_CHARSET (2); | 1059 else if (EQ (prop, Qcharset_g3)) |
1035 else if (EQ (prop, Qcharset_g3)) return INITIAL_CHARSET (3); | 1060 return coding_system_charset (coding_system, 3); |
1036 | 1061 |
1037 #define FORCE_CHARSET(charset_num) \ | 1062 #define FORCE_CHARSET(charset_num) \ |
1038 (XCODING_SYSTEM_ISO2022_FORCE_CHARSET_ON_OUTPUT \ | 1063 (XCODING_SYSTEM_ISO2022_FORCE_CHARSET_ON_OUTPUT \ |
1039 (coding_system, charset_num) ? Qt : Qnil) | 1064 (coding_system, charset_num) ? Qt : Qnil) |
1040 | 1065 |
1257 case 7: /* bell */ | 1282 case 7: /* bell */ |
1258 case 8: /* backspace */ | 1283 case 8: /* backspace */ |
1259 case 11: /* vertical tab */ | 1284 case 11: /* vertical tab */ |
1260 case 12: /* form feed */ | 1285 case 12: /* form feed */ |
1261 case 26: /* MS-DOS C-z junk */ | 1286 case 26: /* MS-DOS C-z junk */ |
1287 case 31: /* '^_' -- for info */ | |
1262 return 1; | 1288 return 1; |
1263 default: | 1289 default: |
1264 return 0; | 1290 return 0; |
1265 } | 1291 } |
1266 } | 1292 } |
1467 Lstream_rewind (stream); | 1493 Lstream_rewind (stream); |
1468 } | 1494 } |
1469 | 1495 |
1470 DEFUN ("detect-coding-region", Fdetect_coding_region, 2, 3, 0, /* | 1496 DEFUN ("detect-coding-region", Fdetect_coding_region, 2, 3, 0, /* |
1471 Detect coding system of the text in the region between START and END. | 1497 Detect coding system of the text in the region between START and END. |
1472 Returned value is a list of possible coding systems ordered by | 1498 Returned a list of possible coding systems ordered by priority. |
1473 priority. If only ASCII characters are found, it returns | 1499 If only ASCII characters are found, it returns 'undecided or one of |
1474 'automatic-conversion or one of its subsidiary coding systems | 1500 its subsidiary coding systems according to a detected end-of-line |
1475 according to a detected end-of-line type. Optional arg BUFFER | 1501 type. Optional arg BUFFER defaults to the current buffer. |
1476 defaults to the current buffer. | |
1477 */ | 1502 */ |
1478 (start, end, buffer)) | 1503 (start, end, buffer)) |
1479 { | 1504 { |
1480 Lisp_Object val = Qnil; | 1505 Lisp_Object val = Qnil; |
1481 struct buffer *buf = decode_buffer (buffer, 0); | 1506 struct buffer *buf = decode_buffer (buffer, 0); |
1504 if (detect_coding_type (&decst, random_buffer, nread, 0)) | 1529 if (detect_coding_type (&decst, random_buffer, nread, 0)) |
1505 break; | 1530 break; |
1506 } | 1531 } |
1507 | 1532 |
1508 if (decst.mask == ~0) | 1533 if (decst.mask == ~0) |
1509 val = subsidiary_coding_system (Fget_coding_system (Qautomatic_conversion), | 1534 val = subsidiary_coding_system (Fget_coding_system (Qundecided), |
1510 decst.eol_type); | 1535 decst.eol_type); |
1511 else | 1536 else |
1512 { | 1537 { |
1513 int i; | 1538 int i; |
1514 | 1539 |
3612 case 7: /* bell */ | 3637 case 7: /* bell */ |
3613 case 8: /* backspace */ | 3638 case 8: /* backspace */ |
3614 case 11: /* vertical tab */ | 3639 case 11: /* vertical tab */ |
3615 case 12: /* form feed */ | 3640 case 12: /* form feed */ |
3616 case 26: /* MS-DOS C-z junk */ | 3641 case 26: /* MS-DOS C-z junk */ |
3642 case 31: /* '^_' -- for info */ | |
3617 goto label_continue_loop; | 3643 goto label_continue_loop; |
3618 | 3644 |
3619 default: | 3645 default: |
3620 break; | 3646 break; |
3621 } | 3647 } |
4604 DEFSUBR (Fcopy_coding_system); | 4630 DEFSUBR (Fcopy_coding_system); |
4605 DEFSUBR (Fsubsidiary_coding_system); | 4631 DEFSUBR (Fsubsidiary_coding_system); |
4606 | 4632 |
4607 DEFSUBR (Fcoding_system_type); | 4633 DEFSUBR (Fcoding_system_type); |
4608 DEFSUBR (Fcoding_system_doc_string); | 4634 DEFSUBR (Fcoding_system_doc_string); |
4635 DEFSUBR (Fcoding_system_charset); | |
4609 DEFSUBR (Fcoding_system_property); | 4636 DEFSUBR (Fcoding_system_property); |
4610 | 4637 |
4611 DEFSUBR (Fcoding_category_list); | 4638 DEFSUBR (Fcoding_category_list); |
4612 DEFSUBR (Fset_coding_priority_list); | 4639 DEFSUBR (Fset_coding_priority_list); |
4613 DEFSUBR (Fcoding_priority_list); | 4640 DEFSUBR (Fcoding_priority_list); |