Mercurial > emacs
comparison src/coding.c @ 59168:0345f2b10f1d
(decode_coding_XXX, decode_composition_emacs_mule)
(decode_coding_emacs_mule, encode_coding_emacs_mule)
(decode_coding_iso2022, encode_designation_at_bol)
(encode_coding_iso2022, decode_coding_sjis_big5, decode_eol)
(decode_coding): Constify arguments and local vars.
| author | Dan Nicolaescu <dann@ics.uci.edu> |
|---|---|
| date | Tue, 28 Dec 2004 14:50:49 +0000 |
| parents | 8a2a99b47220 |
| children | 2eadf4401d2d |
comparison
equal
deleted
inserted
replaced
| 59167:a2a87e183a52 | 59168:0345f2b10f1d |
|---|---|
| 145 Below is a template for these functions. */ | 145 Below is a template for these functions. */ |
| 146 #if 0 | 146 #if 0 |
| 147 static void | 147 static void |
| 148 decode_coding_XXX (coding, source, destination, src_bytes, dst_bytes) | 148 decode_coding_XXX (coding, source, destination, src_bytes, dst_bytes) |
| 149 struct coding_system *coding; | 149 struct coding_system *coding; |
| 150 unsigned char *source, *destination; | 150 const unsigned char *source; |
| 151 unsigned char *destination; | |
| 151 int src_bytes, dst_bytes; | 152 int src_bytes, dst_bytes; |
| 152 { | 153 { |
| 153 ... | 154 ... |
| 154 } | 155 } |
| 155 #endif | 156 #endif |
| 798 */ | 799 */ |
| 799 static INLINE int | 800 static INLINE int |
| 800 decode_composition_emacs_mule (coding, src, src_end, | 801 decode_composition_emacs_mule (coding, src, src_end, |
| 801 destination, dst_end, dst_bytes) | 802 destination, dst_end, dst_bytes) |
| 802 struct coding_system *coding; | 803 struct coding_system *coding; |
| 803 unsigned char *src, *src_end, **destination, *dst_end; | 804 const unsigned char *src, *src_end; |
| 805 unsigned char **destination, *dst_end; | |
| 804 int dst_bytes; | 806 int dst_bytes; |
| 805 { | 807 { |
| 806 unsigned char *dst = *destination; | 808 unsigned char *dst = *destination; |
| 807 int method, data_len, nchars; | 809 int method, data_len, nchars; |
| 808 unsigned char *src_base = src++; | 810 const unsigned char *src_base = src++; |
| 809 /* Store components of composition. */ | 811 /* Store components of composition. */ |
| 810 int component[COMPOSITION_DATA_MAX_BUNCH_LENGTH]; | 812 int component[COMPOSITION_DATA_MAX_BUNCH_LENGTH]; |
| 811 int ncomponent; | 813 int ncomponent; |
| 812 /* Store multibyte form of characters to be composed. This is for | 814 /* Store multibyte form of characters to be composed. This is for |
| 813 Emacs 20 style composition sequence. */ | 815 Emacs 20 style composition sequence. */ |
| 944 /* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions". */ | 946 /* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions". */ |
| 945 | 947 |
| 946 static void | 948 static void |
| 947 decode_coding_emacs_mule (coding, source, destination, src_bytes, dst_bytes) | 949 decode_coding_emacs_mule (coding, source, destination, src_bytes, dst_bytes) |
| 948 struct coding_system *coding; | 950 struct coding_system *coding; |
| 949 unsigned char *source, *destination; | 951 const unsigned char *source; |
| 952 unsigned char *destination; | |
| 950 int src_bytes, dst_bytes; | 953 int src_bytes, dst_bytes; |
| 951 { | 954 { |
| 952 unsigned char *src = source; | 955 const unsigned char *src = source; |
| 953 unsigned char *src_end = source + src_bytes; | 956 const unsigned char *src_end = source + src_bytes; |
| 954 unsigned char *dst = destination; | 957 unsigned char *dst = destination; |
| 955 unsigned char *dst_end = destination + dst_bytes; | 958 unsigned char *dst_end = destination + dst_bytes; |
| 956 /* SRC_BASE remembers the start position in source in each loop. | 959 /* SRC_BASE remembers the start position in source in each loop. |
| 957 The loop will be exited when there's not enough source code, or | 960 The loop will be exited when there's not enough source code, or |
| 958 when there's not enough destination area to produce a | 961 when there's not enough destination area to produce a |
| 959 character. */ | 962 character. */ |
| 960 unsigned char *src_base; | 963 const unsigned char *src_base; |
| 961 | 964 |
| 962 coding->produced_char = 0; | 965 coding->produced_char = 0; |
| 963 while ((src_base = src) < src_end) | 966 while ((src_base = src) < src_end) |
| 964 { | 967 { |
| 965 unsigned char tmp[MAX_MULTIBYTE_LENGTH], *p; | 968 unsigned char tmp[MAX_MULTIBYTE_LENGTH]; |
| 969 const unsigned char *p; | |
| 966 int bytes; | 970 int bytes; |
| 967 | 971 |
| 968 if (*src == '\r') | 972 if (*src == '\r') |
| 969 { | 973 { |
| 970 int c = *src++; | 974 int c = *src++; |
| 1114 unsigned char *, int, int)); | 1118 unsigned char *, int, int)); |
| 1115 | 1119 |
| 1116 static void | 1120 static void |
| 1117 encode_coding_emacs_mule (coding, source, destination, src_bytes, dst_bytes) | 1121 encode_coding_emacs_mule (coding, source, destination, src_bytes, dst_bytes) |
| 1118 struct coding_system *coding; | 1122 struct coding_system *coding; |
| 1119 unsigned char *source, *destination; | 1123 const unsigned char *source; |
| 1124 unsigned char *destination; | |
| 1120 int src_bytes, dst_bytes; | 1125 int src_bytes, dst_bytes; |
| 1121 { | 1126 { |
| 1122 unsigned char *src = source; | 1127 const unsigned char *src = source; |
| 1123 unsigned char *src_end = source + src_bytes; | 1128 const unsigned char *src_end = source + src_bytes; |
| 1124 unsigned char *dst = destination; | 1129 unsigned char *dst = destination; |
| 1125 unsigned char *dst_end = destination + dst_bytes; | 1130 unsigned char *dst_end = destination + dst_bytes; |
| 1126 unsigned char *src_base; | 1131 const unsigned char *src_base; |
| 1127 int c; | 1132 int c; |
| 1128 int char_offset; | 1133 int char_offset; |
| 1129 int *data; | 1134 int *data; |
| 1130 | 1135 |
| 1131 Lisp_Object translation_table; | 1136 Lisp_Object translation_table; |
| 1808 /* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions". */ | 1813 /* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions". */ |
| 1809 | 1814 |
| 1810 static void | 1815 static void |
| 1811 decode_coding_iso2022 (coding, source, destination, src_bytes, dst_bytes) | 1816 decode_coding_iso2022 (coding, source, destination, src_bytes, dst_bytes) |
| 1812 struct coding_system *coding; | 1817 struct coding_system *coding; |
| 1813 unsigned char *source, *destination; | 1818 const unsigned char *source; |
| 1819 unsigned char *destination; | |
| 1814 int src_bytes, dst_bytes; | 1820 int src_bytes, dst_bytes; |
| 1815 { | 1821 { |
| 1816 unsigned char *src = source; | 1822 const unsigned char *src = source; |
| 1817 unsigned char *src_end = source + src_bytes; | 1823 const unsigned char *src_end = source + src_bytes; |
| 1818 unsigned char *dst = destination; | 1824 unsigned char *dst = destination; |
| 1819 unsigned char *dst_end = destination + dst_bytes; | 1825 unsigned char *dst_end = destination + dst_bytes; |
| 1820 /* Charsets invoked to graphic plane 0 and 1 respectively. */ | 1826 /* Charsets invoked to graphic plane 0 and 1 respectively. */ |
| 1821 int charset0 = CODING_SPEC_ISO_PLANE_CHARSET (coding, 0); | 1827 int charset0 = CODING_SPEC_ISO_PLANE_CHARSET (coding, 0); |
| 1822 int charset1 = CODING_SPEC_ISO_PLANE_CHARSET (coding, 1); | 1828 int charset1 = CODING_SPEC_ISO_PLANE_CHARSET (coding, 1); |
| 1823 /* SRC_BASE remembers the start position in source in each loop. | 1829 /* SRC_BASE remembers the start position in source in each loop. |
| 1824 The loop will be exited when there's not enough source code | 1830 The loop will be exited when there's not enough source code |
| 1825 (within macro ONE_MORE_BYTE), or when there's not enough | 1831 (within macro ONE_MORE_BYTE), or when there's not enough |
| 1826 destination area to produce a character (within macro | 1832 destination area to produce a character (within macro |
| 1827 EMIT_CHAR). */ | 1833 EMIT_CHAR). */ |
| 1828 unsigned char *src_base; | 1834 const unsigned char *src_base; |
| 1829 int c, charset; | 1835 int c, charset; |
| 1830 Lisp_Object translation_table; | 1836 Lisp_Object translation_table; |
| 1831 Lisp_Object safe_chars; | 1837 Lisp_Object safe_chars; |
| 1832 | 1838 |
| 1833 safe_chars = coding_safe_chars (coding->symbol); | 1839 safe_chars = coding_safe_chars (coding->symbol); |
| 2594 | 2600 |
| 2595 static unsigned char * | 2601 static unsigned char * |
| 2596 encode_designation_at_bol (coding, translation_table, src, src_end, dst) | 2602 encode_designation_at_bol (coding, translation_table, src, src_end, dst) |
| 2597 struct coding_system *coding; | 2603 struct coding_system *coding; |
| 2598 Lisp_Object translation_table; | 2604 Lisp_Object translation_table; |
| 2599 unsigned char *src, *src_end, *dst; | 2605 const unsigned char *src, *src_end; |
| 2606 unsigned char *dst; | |
| 2600 { | 2607 { |
| 2601 int charset, c, found = 0, reg; | 2608 int charset, c, found = 0, reg; |
| 2602 /* Table of charsets to be designated to each graphic register. */ | 2609 /* Table of charsets to be designated to each graphic register. */ |
| 2603 int r[4]; | 2610 int r[4]; |
| 2604 | 2611 |
| 2635 /* See the above "GENERAL NOTES on `encode_coding_XXX ()' functions". */ | 2642 /* See the above "GENERAL NOTES on `encode_coding_XXX ()' functions". */ |
| 2636 | 2643 |
| 2637 static void | 2644 static void |
| 2638 encode_coding_iso2022 (coding, source, destination, src_bytes, dst_bytes) | 2645 encode_coding_iso2022 (coding, source, destination, src_bytes, dst_bytes) |
| 2639 struct coding_system *coding; | 2646 struct coding_system *coding; |
| 2640 unsigned char *source, *destination; | 2647 const unsigned char *source; |
| 2648 unsigned char *destination; | |
| 2641 int src_bytes, dst_bytes; | 2649 int src_bytes, dst_bytes; |
| 2642 { | 2650 { |
| 2643 unsigned char *src = source; | 2651 const unsigned char *src = source; |
| 2644 unsigned char *src_end = source + src_bytes; | 2652 const unsigned char *src_end = source + src_bytes; |
| 2645 unsigned char *dst = destination; | 2653 unsigned char *dst = destination; |
| 2646 unsigned char *dst_end = destination + dst_bytes; | 2654 unsigned char *dst_end = destination + dst_bytes; |
| 2647 /* Since the maximum bytes produced by each loop is 20, we subtract 19 | 2655 /* Since the maximum bytes produced by each loop is 20, we subtract 19 |
| 2648 from DST_END to assure overflow checking is necessary only at the | 2656 from DST_END to assure overflow checking is necessary only at the |
| 2649 head of loop. */ | 2657 head of loop. */ |
| 2651 /* SRC_BASE remembers the start position in source in each loop. | 2659 /* SRC_BASE remembers the start position in source in each loop. |
| 2652 The loop will be exited when there's not enough source text to | 2660 The loop will be exited when there's not enough source text to |
| 2653 analyze multi-byte codes (within macro ONE_MORE_CHAR), or when | 2661 analyze multi-byte codes (within macro ONE_MORE_CHAR), or when |
| 2654 there's not enough destination area to produce encoded codes | 2662 there's not enough destination area to produce encoded codes |
| 2655 (within macro EMIT_BYTES). */ | 2663 (within macro EMIT_BYTES). */ |
| 2656 unsigned char *src_base; | 2664 const unsigned char *src_base; |
| 2657 int c; | 2665 int c; |
| 2658 Lisp_Object translation_table; | 2666 Lisp_Object translation_table; |
| 2659 Lisp_Object safe_chars; | 2667 Lisp_Object safe_chars; |
| 2660 | 2668 |
| 2661 if (coding->flags & CODING_FLAG_ISO_SAFE) | 2669 if (coding->flags & CODING_FLAG_ISO_SAFE) |
| 3045 | 3053 |
| 3046 static void | 3054 static void |
| 3047 decode_coding_sjis_big5 (coding, source, destination, | 3055 decode_coding_sjis_big5 (coding, source, destination, |
| 3048 src_bytes, dst_bytes, sjis_p) | 3056 src_bytes, dst_bytes, sjis_p) |
| 3049 struct coding_system *coding; | 3057 struct coding_system *coding; |
| 3050 unsigned char *source, *destination; | 3058 const unsigned char *source; |
| 3059 unsigned char *destination; | |
| 3051 int src_bytes, dst_bytes; | 3060 int src_bytes, dst_bytes; |
| 3052 int sjis_p; | 3061 int sjis_p; |
| 3053 { | 3062 { |
| 3054 unsigned char *src = source; | 3063 const unsigned char *src = source; |
| 3055 unsigned char *src_end = source + src_bytes; | 3064 const unsigned char *src_end = source + src_bytes; |
| 3056 unsigned char *dst = destination; | 3065 unsigned char *dst = destination; |
| 3057 unsigned char *dst_end = destination + dst_bytes; | 3066 unsigned char *dst_end = destination + dst_bytes; |
| 3058 /* SRC_BASE remembers the start position in source in each loop. | 3067 /* SRC_BASE remembers the start position in source in each loop. |
| 3059 The loop will be exited when there's not enough source code | 3068 The loop will be exited when there's not enough source code |
| 3060 (within macro ONE_MORE_BYTE), or when there's not enough | 3069 (within macro ONE_MORE_BYTE), or when there's not enough |
| 3061 destination area to produce a character (within macro | 3070 destination area to produce a character (within macro |
| 3062 EMIT_CHAR). */ | 3071 EMIT_CHAR). */ |
| 3063 unsigned char *src_base; | 3072 const unsigned char *src_base; |
| 3064 Lisp_Object translation_table; | 3073 Lisp_Object translation_table; |
| 3065 | 3074 |
| 3066 if (NILP (Venable_character_translation)) | 3075 if (NILP (Venable_character_translation)) |
| 3067 translation_table = Qnil; | 3076 translation_table = Qnil; |
| 3068 else | 3077 else |
| 3318 /* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions". */ | 3327 /* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions". */ |
| 3319 | 3328 |
| 3320 static void | 3329 static void |
| 3321 decode_eol (coding, source, destination, src_bytes, dst_bytes) | 3330 decode_eol (coding, source, destination, src_bytes, dst_bytes) |
| 3322 struct coding_system *coding; | 3331 struct coding_system *coding; |
| 3323 unsigned char *source, *destination; | 3332 const unsigned char *source; |
| 3333 unsigned char *destination; | |
| 3324 int src_bytes, dst_bytes; | 3334 int src_bytes, dst_bytes; |
| 3325 { | 3335 { |
| 3326 unsigned char *src = source; | 3336 const unsigned char *src = source; |
| 3327 unsigned char *dst = destination; | 3337 unsigned char *dst = destination; |
| 3328 unsigned char *src_end = src + src_bytes; | 3338 const unsigned char *src_end = src + src_bytes; |
| 3329 unsigned char *dst_end = dst + dst_bytes; | 3339 unsigned char *dst_end = dst + dst_bytes; |
| 3330 Lisp_Object translation_table; | 3340 Lisp_Object translation_table; |
| 3331 /* SRC_BASE remembers the start position in source in each loop. | 3341 /* SRC_BASE remembers the start position in source in each loop. |
| 3332 The loop will be exited when there's not enough source code | 3342 The loop will be exited when there's not enough source code |
| 3333 (within macro ONE_MORE_BYTE), or when there's not enough | 3343 (within macro ONE_MORE_BYTE), or when there's not enough |
| 3334 destination area to produce a character (within macro | 3344 destination area to produce a character (within macro |
| 3335 EMIT_CHAR). */ | 3345 EMIT_CHAR). */ |
| 3336 unsigned char *src_base; | 3346 const unsigned char *src_base; |
| 3337 int c; | 3347 int c; |
| 3338 | 3348 |
| 3339 translation_table = Qnil; | 3349 translation_table = Qnil; |
| 3340 switch (coding->eol_type) | 3350 switch (coding->eol_type) |
| 3341 { | 3351 { |
| 4858 unibyte. */ | 4868 unibyte. */ |
| 4859 | 4869 |
| 4860 int | 4870 int |
| 4861 decode_coding (coding, source, destination, src_bytes, dst_bytes) | 4871 decode_coding (coding, source, destination, src_bytes, dst_bytes) |
| 4862 struct coding_system *coding; | 4872 struct coding_system *coding; |
| 4863 const unsigned char *source; | 4873 const const unsigned char *source; |
| 4864 unsigned char *destination; | 4874 unsigned char *destination; |
| 4865 int src_bytes, dst_bytes; | 4875 int src_bytes, dst_bytes; |
| 4866 { | 4876 { |
| 4867 int extra = 0; | 4877 int extra = 0; |
| 4868 | 4878 |
