diff options
| author | Ken Raeburn | 2002-07-19 14:26:57 +0000 |
|---|---|---|
| committer | Ken Raeburn | 2002-07-19 14:26:57 +0000 |
| commit | a424431367c0101b53efbfeb67b96f36df908944 (patch) | |
| tree | 1f38201c8d378ea9d67e9f330ab2b4cba7b517cc /src/coding.c | |
| parent | a9fb257eeaf98a488cace0453490cc5863a600c6 (diff) | |
| download | emacs-a424431367c0101b53efbfeb67b96f36df908944.tar.gz emacs-a424431367c0101b53efbfeb67b96f36df908944.zip | |
(encode_eol, detect_coding, detect_eol):
(decode_coding, encode_coding, detect_coding_system): Source
strings now treated as const.
(decode_coding_string, encode_coding_string): Use STRING_COPYIN to
modify Lisp string contents.
Diffstat (limited to 'src/coding.c')
| -rw-r--r-- | src/coding.c | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/src/coding.c b/src/coding.c index 23ccfbce390..b7bc5e6b4f2 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -1061,7 +1061,7 @@ decode_coding_emacs_mule (coding, source, destination, src_bytes, dst_bytes) | |||
| 1061 | } while (0) | 1061 | } while (0) |
| 1062 | 1062 | ||
| 1063 | 1063 | ||
| 1064 | static void encode_eol P_ ((struct coding_system *, unsigned char *, | 1064 | static void encode_eol P_ ((struct coding_system *, const unsigned char *, |
| 1065 | unsigned char *, int, int)); | 1065 | unsigned char *, int, int)); |
| 1066 | 1066 | ||
| 1067 | static void | 1067 | static void |
| @@ -3236,12 +3236,13 @@ decode_eol (coding, source, destination, src_bytes, dst_bytes) | |||
| 3236 | static void | 3236 | static void |
| 3237 | encode_eol (coding, source, destination, src_bytes, dst_bytes) | 3237 | encode_eol (coding, source, destination, src_bytes, dst_bytes) |
| 3238 | struct coding_system *coding; | 3238 | struct coding_system *coding; |
| 3239 | unsigned char *source, *destination; | 3239 | const unsigned char *source; |
| 3240 | unsigned char *destination; | ||
| 3240 | int src_bytes, dst_bytes; | 3241 | int src_bytes, dst_bytes; |
| 3241 | { | 3242 | { |
| 3242 | unsigned char *src = source; | 3243 | const unsigned char *src = source; |
| 3243 | unsigned char *dst = destination; | 3244 | unsigned char *dst = destination; |
| 3244 | unsigned char *src_end = src + src_bytes; | 3245 | const unsigned char *src_end = src + src_bytes; |
| 3245 | unsigned char *dst_end = dst + dst_bytes; | 3246 | unsigned char *dst_end = dst + dst_bytes; |
| 3246 | Lisp_Object translation_table; | 3247 | Lisp_Object translation_table; |
| 3247 | /* SRC_BASE remembers the start position in source in each loop. | 3248 | /* SRC_BASE remembers the start position in source in each loop. |
| @@ -3249,7 +3250,8 @@ encode_eol (coding, source, destination, src_bytes, dst_bytes) | |||
| 3249 | analyze multi-byte codes (within macro ONE_MORE_CHAR), or when | 3250 | analyze multi-byte codes (within macro ONE_MORE_CHAR), or when |
| 3250 | there's not enough destination area to produce encoded codes | 3251 | there's not enough destination area to produce encoded codes |
| 3251 | (within macro EMIT_BYTES). */ | 3252 | (within macro EMIT_BYTES). */ |
| 3252 | unsigned char *src_base; | 3253 | const unsigned char *src_base; |
| 3254 | unsigned char *tmp; | ||
| 3253 | int c; | 3255 | int c; |
| 3254 | int selective_display = coding->mode & CODING_MODE_SELECTIVE_DISPLAY; | 3256 | int selective_display = coding->mode & CODING_MODE_SELECTIVE_DISPLAY; |
| 3255 | 3257 | ||
| @@ -3299,13 +3301,13 @@ encode_eol (coding, source, destination, src_bytes, dst_bytes) | |||
| 3299 | } | 3301 | } |
| 3300 | if (coding->eol_type == CODING_EOL_CR) | 3302 | if (coding->eol_type == CODING_EOL_CR) |
| 3301 | { | 3303 | { |
| 3302 | for (src = destination; src < dst; src++) | 3304 | for (tmp = destination; tmp < dst; tmp++) |
| 3303 | if (*src == '\n') *src = '\r'; | 3305 | if (*tmp == '\n') *tmp = '\r'; |
| 3304 | } | 3306 | } |
| 3305 | else if (selective_display) | 3307 | else if (selective_display) |
| 3306 | { | 3308 | { |
| 3307 | for (src = destination; src < dst; src++) | 3309 | for (tmp = destination; tmp < dst; tmp++) |
| 3308 | if (*src == '\r') *src = '\n'; | 3310 | if (*tmp == '\r') *tmp = '\n'; |
| 3309 | } | 3311 | } |
| 3310 | } | 3312 | } |
| 3311 | if (coding->src_multibyte) | 3313 | if (coding->src_multibyte) |
| @@ -4094,7 +4096,7 @@ detect_coding_mask (source, src_bytes, priorities, skip, multibytep) | |||
| 4094 | void | 4096 | void |
| 4095 | detect_coding (coding, src, src_bytes) | 4097 | detect_coding (coding, src, src_bytes) |
| 4096 | struct coding_system *coding; | 4098 | struct coding_system *coding; |
| 4097 | unsigned char *src; | 4099 | const unsigned char *src; |
| 4098 | int src_bytes; | 4100 | int src_bytes; |
| 4099 | { | 4101 | { |
| 4100 | unsigned int idx; | 4102 | unsigned int idx; |
| @@ -4267,7 +4269,7 @@ detect_eol_type_in_2_octet_form (source, src_bytes, skip, big_endian_p) | |||
| 4267 | void | 4269 | void |
| 4268 | detect_eol (coding, src, src_bytes) | 4270 | detect_eol (coding, src, src_bytes) |
| 4269 | struct coding_system *coding; | 4271 | struct coding_system *coding; |
| 4270 | unsigned char *src; | 4272 | const unsigned char *src; |
| 4271 | int src_bytes; | 4273 | int src_bytes; |
| 4272 | { | 4274 | { |
| 4273 | Lisp_Object val; | 4275 | Lisp_Object val; |
| @@ -4685,7 +4687,8 @@ decode_eol_post_ccl (coding, ptr, bytes) | |||
| 4685 | int | 4687 | int |
| 4686 | decode_coding (coding, source, destination, src_bytes, dst_bytes) | 4688 | decode_coding (coding, source, destination, src_bytes, dst_bytes) |
| 4687 | struct coding_system *coding; | 4689 | struct coding_system *coding; |
| 4688 | unsigned char *source, *destination; | 4690 | const unsigned char *source; |
| 4691 | unsigned char *destination; | ||
| 4689 | int src_bytes, dst_bytes; | 4692 | int src_bytes, dst_bytes; |
| 4690 | { | 4693 | { |
| 4691 | int extra = 0; | 4694 | int extra = 0; |
| @@ -4764,7 +4767,7 @@ decode_coding (coding, source, destination, src_bytes, dst_bytes) | |||
| 4764 | if (coding->mode & CODING_MODE_LAST_BLOCK | 4767 | if (coding->mode & CODING_MODE_LAST_BLOCK |
| 4765 | && coding->result == CODING_FINISH_INSUFFICIENT_SRC) | 4768 | && coding->result == CODING_FINISH_INSUFFICIENT_SRC) |
| 4766 | { | 4769 | { |
| 4767 | unsigned char *src = source + coding->consumed; | 4770 | const unsigned char *src = source + coding->consumed; |
| 4768 | unsigned char *dst = destination + coding->produced; | 4771 | unsigned char *dst = destination + coding->produced; |
| 4769 | 4772 | ||
| 4770 | src_bytes -= coding->consumed; | 4773 | src_bytes -= coding->consumed; |
| @@ -4798,7 +4801,8 @@ decode_coding (coding, source, destination, src_bytes, dst_bytes) | |||
| 4798 | int | 4801 | int |
| 4799 | encode_coding (coding, source, destination, src_bytes, dst_bytes) | 4802 | encode_coding (coding, source, destination, src_bytes, dst_bytes) |
| 4800 | struct coding_system *coding; | 4803 | struct coding_system *coding; |
| 4801 | unsigned char *source, *destination; | 4804 | const unsigned char *source; |
| 4805 | unsigned char *destination; | ||
| 4802 | int src_bytes, dst_bytes; | 4806 | int src_bytes, dst_bytes; |
| 4803 | { | 4807 | { |
| 4804 | coding->produced = coding->produced_char = 0; | 4808 | coding->produced = coding->produced_char = 0; |
| @@ -4840,7 +4844,7 @@ encode_coding (coding, source, destination, src_bytes, dst_bytes) | |||
| 4840 | if (coding->mode & CODING_MODE_LAST_BLOCK | 4844 | if (coding->mode & CODING_MODE_LAST_BLOCK |
| 4841 | && coding->result == CODING_FINISH_INSUFFICIENT_SRC) | 4845 | && coding->result == CODING_FINISH_INSUFFICIENT_SRC) |
| 4842 | { | 4846 | { |
| 4843 | unsigned char *src = source + coding->consumed; | 4847 | const unsigned char *src = source + coding->consumed; |
| 4844 | unsigned char *dst = destination + coding->produced; | 4848 | unsigned char *dst = destination + coding->produced; |
| 4845 | 4849 | ||
| 4846 | if (coding->type == coding_type_iso2022) | 4850 | if (coding->type == coding_type_iso2022) |
| @@ -6014,12 +6018,12 @@ decode_coding_string (str, coding, nocopy) | |||
| 6014 | else | 6018 | else |
| 6015 | newstr = make_uninit_string (produced + shrinked_bytes); | 6019 | newstr = make_uninit_string (produced + shrinked_bytes); |
| 6016 | if (from > 0) | 6020 | if (from > 0) |
| 6017 | bcopy (SDATA (str), SDATA (newstr), from); | 6021 | STRING_COPYIN (newstr, 0, SDATA (str), from); |
| 6018 | bcopy (buf.data, SDATA (newstr) + from, produced); | 6022 | STRING_COPYIN (newstr, from, buf.data, produced); |
| 6019 | if (shrinked_bytes > from) | 6023 | if (shrinked_bytes > from) |
| 6020 | bcopy (SDATA (str) + to_byte, | 6024 | STRING_COPYIN (newstr, from + produced, |
| 6021 | SDATA (newstr) + from + produced, | 6025 | SDATA (str) + to_byte, |
| 6022 | shrinked_bytes - from); | 6026 | shrinked_bytes - from); |
| 6023 | free_conversion_buffer (&buf); | 6027 | free_conversion_buffer (&buf); |
| 6024 | 6028 | ||
| 6025 | if (coding->cmp_data && coding->cmp_data->used) | 6029 | if (coding->cmp_data && coding->cmp_data->used) |
| @@ -6114,12 +6118,12 @@ encode_coding_string (str, coding, nocopy) | |||
| 6114 | 6118 | ||
| 6115 | newstr = make_uninit_string (produced + shrinked_bytes); | 6119 | newstr = make_uninit_string (produced + shrinked_bytes); |
| 6116 | if (from > 0) | 6120 | if (from > 0) |
| 6117 | bcopy (SDATA (str), SDATA (newstr), from); | 6121 | STRING_COPYIN (newstr, 0, SDATA (str), from); |
| 6118 | bcopy (buf.data, SDATA (newstr) + from, produced); | 6122 | STRING_COPYIN (newstr, from, buf.data, produced); |
| 6119 | if (shrinked_bytes > from) | 6123 | if (shrinked_bytes > from) |
| 6120 | bcopy (SDATA (str) + to_byte, | 6124 | STRING_COPYIN (newstr, from + produced, |
| 6121 | SDATA (newstr) + from + produced, | 6125 | SDATA (str) + to_byte, |
| 6122 | shrinked_bytes - from); | 6126 | shrinked_bytes - from); |
| 6123 | 6127 | ||
| 6124 | free_conversion_buffer (&buf); | 6128 | free_conversion_buffer (&buf); |
| 6125 | coding_free_composition_data (coding); | 6129 | coding_free_composition_data (coding); |
| @@ -6197,7 +6201,7 @@ The value of property should be a vector of length 5. */) | |||
| 6197 | 6201 | ||
| 6198 | Lisp_Object | 6202 | Lisp_Object |
| 6199 | detect_coding_system (src, src_bytes, highest, multibytep) | 6203 | detect_coding_system (src, src_bytes, highest, multibytep) |
| 6200 | unsigned char *src; | 6204 | const unsigned char *src; |
| 6201 | int src_bytes, highest; | 6205 | int src_bytes, highest; |
| 6202 | int multibytep; | 6206 | int multibytep; |
| 6203 | { | 6207 | { |