aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
authorJuanma Barranquero2010-07-07 11:38:03 +0200
committerJuanma Barranquero2010-07-07 11:38:03 +0200
commitcf84bb53567cf64b3dade9e9abeaef289371f0cc (patch)
tree93053d9c5d8de3754cf661b32a3859113d256192 /src/coding.c
parent1a4990fb03fb1e7e608269e299ae2caef5155168 (diff)
downloademacs-cf84bb53567cf64b3dade9e9abeaef289371f0cc.tar.gz
emacs-cf84bb53567cf64b3dade9e9abeaef289371f0cc.zip
* coding.c, sysdep.c: Convert some more functions to standard C.
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c124
1 files changed, 71 insertions, 53 deletions
diff --git a/src/coding.c b/src/coding.c
index f38beafed9f..f16d505b67a 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -154,9 +154,8 @@ STRUCT CODING_SYSTEM
154 154
155#if 0 155#if 0
156static int 156static int
157detect_coding_XXX (coding, detect_info) 157detect_coding_XXX (struct coding_system *coding,
158 struct coding_system *coding; 158 struct coding_detection_info *detect_info)
159 struct coding_detection_info *detect_info;
160{ 159{
161 const unsigned char *src = coding->source; 160 const unsigned char *src = coding->source;
162 const unsigned char *src_end = coding->source + coding->src_bytes; 161 const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -203,8 +202,7 @@ detect_coding_XXX (coding, detect_info)
203 202
204#if 0 203#if 0
205static void 204static void
206decode_coding_XXXX (coding) 205decode_coding_XXXX (struct coding_system *coding)
207 struct coding_system *coding;
208{ 206{
209 const unsigned char *src = coding->source + coding->consumed; 207 const unsigned char *src = coding->source + coding->consumed;
210 const unsigned char *src_end = coding->source + coding->src_bytes; 208 const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -261,8 +259,7 @@ decode_coding_XXXX (coding)
261 Below is a template of these functions. */ 259 Below is a template of these functions. */
262#if 0 260#if 0
263static void 261static void
264encode_coding_XXX (coding) 262encode_coding_XXX (struct coding_system *coding)
265 struct coding_system *coding;
266{ 263{
267 int multibytep = coding->dst_multibyte; 264 int multibytep = coding->dst_multibyte;
268 int *charbuf = coding->charbuf; 265 int *charbuf = coding->charbuf;
@@ -1165,7 +1162,8 @@ coding_alloc_by_realloc (struct coding_system *coding, EMACS_INT bytes)
1165} 1162}
1166 1163
1167static void 1164static void
1168coding_alloc_by_making_gap (struct coding_system *coding, EMACS_INT gap_head_used, EMACS_INT bytes) 1165coding_alloc_by_making_gap (struct coding_system *coding,
1166 EMACS_INT gap_head_used, EMACS_INT bytes)
1169{ 1167{
1170 if (EQ (coding->src_object, coding->dst_object)) 1168 if (EQ (coding->src_object, coding->dst_object))
1171 { 1169 {
@@ -1194,7 +1192,8 @@ coding_alloc_by_making_gap (struct coding_system *coding, EMACS_INT gap_head_use
1194 1192
1195 1193
1196static unsigned char * 1194static unsigned char *
1197alloc_destination (struct coding_system *coding, EMACS_INT nbytes, unsigned char *dst) 1195alloc_destination (struct coding_system *coding, EMACS_INT nbytes,
1196 unsigned char *dst)
1198{ 1197{
1199 EMACS_INT offset = dst - coding->destination; 1198 EMACS_INT offset = dst - coding->destination;
1200 1199
@@ -1292,7 +1291,8 @@ alloc_destination (struct coding_system *coding, EMACS_INT nbytes, unsigned char
1292#define UTF_8_BOM_3 0xBF 1291#define UTF_8_BOM_3 0xBF
1293 1292
1294static int 1293static int
1295detect_coding_utf_8 (struct coding_system *coding, struct coding_detection_info *detect_info) 1294detect_coding_utf_8 (struct coding_system *coding,
1295 struct coding_detection_info *detect_info)
1296{ 1296{
1297 const unsigned char *src = coding->source, *src_base; 1297 const unsigned char *src = coding->source, *src_base;
1298 const unsigned char *src_end = coding->source + coding->src_bytes; 1298 const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -1423,8 +1423,6 @@ decode_coding_utf_8 (struct coding_system *coding)
1423 } 1423 }
1424 CODING_UTF_8_BOM (coding) = utf_without_bom; 1424 CODING_UTF_8_BOM (coding) = utf_without_bom;
1425 1425
1426
1427
1428 while (1) 1426 while (1)
1429 { 1427 {
1430 int c, c1, c2, c3, c4, c5; 1428 int c, c1, c2, c3, c4, c5;
@@ -1610,7 +1608,8 @@ encode_coding_utf_8 (struct coding_system *coding)
1610 1608
1611 1609
1612static int 1610static int
1613detect_coding_utf_16 (struct coding_system *coding, struct coding_detection_info *detect_info) 1611detect_coding_utf_16 (struct coding_system *coding,
1612 struct coding_detection_info *detect_info)
1614{ 1613{
1615 const unsigned char *src = coding->source, *src_base = src; 1614 const unsigned char *src = coding->source, *src_base = src;
1616 const unsigned char *src_end = coding->source + coding->src_bytes; 1615 const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -1962,7 +1961,8 @@ char emacs_mule_bytes[256];
1962 else return 0. */ 1961 else return 0. */
1963 1962
1964static int 1963static int
1965detect_coding_emacs_mule (struct coding_system *coding, struct coding_detection_info *detect_info) 1964detect_coding_emacs_mule (struct coding_system *coding,
1965 struct coding_detection_info *detect_info)
1966{ 1966{
1967 const unsigned char *src = coding->source, *src_base; 1967 const unsigned char *src = coding->source, *src_base;
1968 const unsigned char *src_end = coding->source + coding->src_bytes; 1968 const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -2050,7 +2050,9 @@ detect_coding_emacs_mule (struct coding_system *coding, struct coding_detection_
2050 -1. If SRC is too short, return -2. */ 2050 -1. If SRC is too short, return -2. */
2051 2051
2052int 2052int
2053emacs_mule_char (struct coding_system *coding, const unsigned char *src, int *nbytes, int *nchars, int *id, struct composition_status *cmp_status) 2053emacs_mule_char (struct coding_system *coding, const unsigned char *src,
2054 int *nbytes, int *nchars, int *id,
2055 struct composition_status *cmp_status)
2054{ 2056{
2055 const unsigned char *src_end = coding->source + coding->src_bytes; 2057 const unsigned char *src_end = coding->source + coding->src_bytes;
2056 const unsigned char *src_base = src; 2058 const unsigned char *src_base = src;
@@ -2368,7 +2370,8 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src, int *nb
2368 2370
2369 2371
2370static int 2372static int
2371emacs_mule_finish_composition (int *charbuf, struct composition_status *cmp_status) 2373emacs_mule_finish_composition (int *charbuf,
2374 struct composition_status *cmp_status)
2372{ 2375{
2373 int idx = - cmp_status->length; 2376 int idx = - cmp_status->length;
2374 int new_chars; 2377 int new_chars;
@@ -3048,7 +3051,8 @@ setup_iso_safe_charsets (Lisp_Object attrs)
3048 If it is, return 1, else return 0. */ 3051 If it is, return 1, else return 0. */
3049 3052
3050static int 3053static int
3051detect_coding_iso_2022 (struct coding_system *coding, struct coding_detection_info *detect_info) 3054detect_coding_iso_2022 (struct coding_system *coding,
3055 struct coding_detection_info *detect_info)
3052{ 3056{
3053 const unsigned char *src = coding->source, *src_base = src; 3057 const unsigned char *src = coding->source, *src_base = src;
3054 const unsigned char *src_end = coding->source + coding->src_bytes; 3058 const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -4298,7 +4302,9 @@ decode_coding_iso_2022 (struct coding_system *coding)
4298 Return new DST. */ 4302 Return new DST. */
4299 4303
4300unsigned char * 4304unsigned char *
4301encode_invocation_designation (struct charset *charset, struct coding_system *coding, unsigned char *dst, int *p_nchars) 4305encode_invocation_designation (struct charset *charset,
4306 struct coding_system *coding,
4307 unsigned char *dst, int *p_nchars)
4302{ 4308{
4303 int multibytep = coding->dst_multibyte; 4309 int multibytep = coding->dst_multibyte;
4304 int produced_chars = *p_nchars; 4310 int produced_chars = *p_nchars;
@@ -4410,7 +4416,8 @@ encode_invocation_designation (struct charset *charset, struct coding_system *co
4410 find all the necessary designations. */ 4416 find all the necessary designations. */
4411 4417
4412static unsigned char * 4418static unsigned char *
4413encode_designation_at_bol (struct coding_system *coding, int *charbuf, int *charbuf_end, unsigned char *dst) 4419encode_designation_at_bol (struct coding_system *coding, int *charbuf,
4420 int *charbuf_end, unsigned char *dst)
4414{ 4421{
4415 struct charset *charset; 4422 struct charset *charset;
4416 /* Table of charsets to be designated to each graphic register. */ 4423 /* Table of charsets to be designated to each graphic register. */
@@ -4650,7 +4657,8 @@ encode_coding_iso_2022 (struct coding_system *coding)
4650 CATEGORY_MASK_SJIS, else return 0. */ 4657 CATEGORY_MASK_SJIS, else return 0. */
4651 4658
4652static int 4659static int
4653detect_coding_sjis (struct coding_system *coding, struct coding_detection_info *detect_info) 4660detect_coding_sjis (struct coding_system *coding,
4661 struct coding_detection_info *detect_info)
4654{ 4662{
4655 const unsigned char *src = coding->source, *src_base; 4663 const unsigned char *src = coding->source, *src_base;
4656 const unsigned char *src_end = coding->source + coding->src_bytes; 4664 const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -4706,7 +4714,8 @@ detect_coding_sjis (struct coding_system *coding, struct coding_detection_info *
4706 CATEGORY_MASK_BIG5, else return 0. */ 4714 CATEGORY_MASK_BIG5, else return 0. */
4707 4715
4708static int 4716static int
4709detect_coding_big5 (struct coding_system *coding, struct coding_detection_info *detect_info) 4717detect_coding_big5 (struct coding_system *coding,
4718 struct coding_detection_info *detect_info)
4710{ 4719{
4711 const unsigned char *src = coding->source, *src_base; 4720 const unsigned char *src = coding->source, *src_base;
4712 const unsigned char *src_end = coding->source + coding->src_bytes; 4721 const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -5144,7 +5153,8 @@ encode_coding_big5 (struct coding_system *coding)
5144 CATEGORY_MASK_CCL, else return 0. */ 5153 CATEGORY_MASK_CCL, else return 0. */
5145 5154
5146static int 5155static int
5147detect_coding_ccl (struct coding_system *coding, struct coding_detection_info *detect_info) 5156detect_coding_ccl (struct coding_system *coding,
5157 struct coding_detection_info *detect_info)
5148{ 5158{
5149 const unsigned char *src = coding->source, *src_base; 5159 const unsigned char *src = coding->source, *src_base;
5150 const unsigned char *src_end = coding->source + coding->src_bytes; 5160 const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -5423,7 +5433,8 @@ encode_coding_raw_text (struct coding_system *coding)
5423 is, return 1, else return 0. */ 5433 is, return 1, else return 0. */
5424 5434
5425static int 5435static int
5426detect_coding_charset (struct coding_system *coding, struct coding_detection_info *detect_info) 5436detect_coding_charset (struct coding_system *coding,
5437 struct coding_detection_info *detect_info)
5427{ 5438{
5428 const unsigned char *src = coding->source, *src_base; 5439 const unsigned char *src = coding->source, *src_base;
5429 const unsigned char *src_end = coding->source + coding->src_bytes; 5440 const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -6168,7 +6179,8 @@ coding_inherit_eol_type (Lisp_Object coding_system, Lisp_Object parent)
6168#define MAX_EOL_CHECK_COUNT 3 6179#define MAX_EOL_CHECK_COUNT 3
6169 6180
6170static int 6181static int
6171detect_eol (const unsigned char *source, EMACS_INT src_bytes, enum coding_category category) 6182detect_eol (const unsigned char *source, EMACS_INT src_bytes,
6183 enum coding_category category)
6172{ 6184{
6173 const unsigned char *src = source, *src_end = src + src_bytes; 6185 const unsigned char *src = source, *src_end = src + src_bytes;
6174 unsigned char c; 6186 unsigned char c;
@@ -6704,7 +6716,8 @@ get_translation (Lisp_Object trans, int *buf, int *buf_end)
6704 6716
6705 6717
6706static int 6718static int
6707produce_chars (struct coding_system *coding, Lisp_Object translation_table, int last_block) 6719produce_chars (struct coding_system *coding, Lisp_Object translation_table,
6720 int last_block)
6708{ 6721{
6709 unsigned char *dst = coding->destination + coding->produced; 6722 unsigned char *dst = coding->destination + coding->produced;
6710 unsigned char *dst_end = coding->destination + coding->dst_bytes; 6723 unsigned char *dst_end = coding->destination + coding->dst_bytes;
@@ -7174,7 +7187,9 @@ decode_coding (struct coding_system *coding)
7174 return BUF. */ 7187 return BUF. */
7175 7188
7176static INLINE int * 7189static INLINE int *
7177handle_composition_annotation (EMACS_INT pos, EMACS_INT limit, struct coding_system *coding, int *buf, EMACS_INT *stop) 7190handle_composition_annotation (EMACS_INT pos, EMACS_INT limit,
7191 struct coding_system *coding, int *buf,
7192 EMACS_INT *stop)
7178{ 7193{
7179 EMACS_INT start, end; 7194 EMACS_INT start, end;
7180 Lisp_Object prop; 7195 Lisp_Object prop;
@@ -7255,7 +7270,9 @@ handle_composition_annotation (EMACS_INT pos, EMACS_INT limit, struct coding_sys
7255 property value is non-nil (limiting by LIMIT), and return BUF. */ 7270 property value is non-nil (limiting by LIMIT), and return BUF. */
7256 7271
7257static INLINE int * 7272static INLINE int *
7258handle_charset_annotation (EMACS_INT pos, EMACS_INT limit, struct coding_system *coding, int *buf, EMACS_INT *stop) 7273handle_charset_annotation (EMACS_INT pos, EMACS_INT limit,
7274 struct coding_system *coding, int *buf,
7275 EMACS_INT *stop)
7259{ 7276{
7260 Lisp_Object val, next; 7277 Lisp_Object val, next;
7261 int id; 7278 int id;
@@ -7275,7 +7292,8 @@ handle_charset_annotation (EMACS_INT pos, EMACS_INT limit, struct coding_system
7275 7292
7276 7293
7277static void 7294static void
7278consume_chars (struct coding_system *coding, Lisp_Object translation_table, int max_lookup) 7295consume_chars (struct coding_system *coding, Lisp_Object translation_table,
7296 int max_lookup)
7279{ 7297{
7280 int *buf = coding->charbuf; 7298 int *buf = coding->charbuf;
7281 int *buf_end = coding->charbuf + coding->charbuf_size; 7299 int *buf_end = coding->charbuf + coding->charbuf_size;
@@ -7560,7 +7578,8 @@ code_conversion_save (int with_work_buf, int multibyte)
7560} 7578}
7561 7579
7562int 7580int
7563decode_coding_gap (struct coding_system *coding, EMACS_INT chars, EMACS_INT bytes) 7581decode_coding_gap (struct coding_system *coding,
7582 EMACS_INT chars, EMACS_INT bytes)
7564{ 7583{
7565 int count = SPECPDL_INDEX (); 7584 int count = SPECPDL_INDEX ();
7566 Lisp_Object attrs; 7585 Lisp_Object attrs;
@@ -7605,7 +7624,8 @@ decode_coding_gap (struct coding_system *coding, EMACS_INT chars, EMACS_INT byte
7605} 7624}
7606 7625
7607int 7626int
7608encode_coding_gap (struct coding_system *coding, EMACS_INT chars, EMACS_INT bytes) 7627encode_coding_gap (struct coding_system *coding,
7628 EMACS_INT chars, EMACS_INT bytes)
7609{ 7629{
7610 int count = SPECPDL_INDEX (); 7630 int count = SPECPDL_INDEX ();
7611 7631
@@ -7658,12 +7678,11 @@ encode_coding_gap (struct coding_system *coding, EMACS_INT chars, EMACS_INT byte
7658 */ 7678 */
7659 7679
7660void 7680void
7661decode_coding_object (coding, src_object, from, from_byte, to, to_byte, 7681decode_coding_object (struct coding_system *coding,
7662 dst_object) 7682 Lisp_Object src_object,
7663 struct coding_system *coding; 7683 EMACS_INT from, EMACS_INT from_byte,
7664 Lisp_Object src_object; 7684 EMACS_INT to, EMACS_INT to_byte,
7665 EMACS_INT from, from_byte, to, to_byte; 7685 Lisp_Object dst_object)
7666 Lisp_Object dst_object;
7667{ 7686{
7668 int count = SPECPDL_INDEX (); 7687 int count = SPECPDL_INDEX ();
7669 unsigned char *destination; 7688 unsigned char *destination;
@@ -7849,12 +7868,11 @@ decode_coding_object (coding, src_object, from, from_byte, to, to_byte,
7849 7868
7850 7869
7851void 7870void
7852encode_coding_object (coding, src_object, from, from_byte, to, to_byte, 7871encode_coding_object (struct coding_system *coding,
7853 dst_object) 7872 Lisp_Object src_object,
7854 struct coding_system *coding; 7873 EMACS_INT from, EMACS_INT from_byte,
7855 Lisp_Object src_object; 7874 EMACS_INT to, EMACS_INT to_byte,
7856 EMACS_INT from, from_byte, to, to_byte; 7875 Lisp_Object dst_object)
7857 Lisp_Object dst_object;
7858{ 7876{
7859 int count = SPECPDL_INDEX (); 7877 int count = SPECPDL_INDEX ();
7860 EMACS_INT chars = to - from; 7878 EMACS_INT chars = to - from;
@@ -8162,13 +8180,10 @@ function `define-coding-system'. */)
8162 detect only text-format. */ 8180 detect only text-format. */
8163 8181
8164Lisp_Object 8182Lisp_Object
8165detect_coding_system (src, src_chars, src_bytes, highest, multibytep, 8183detect_coding_system (const unsigned char *src,
8166 coding_system) 8184 EMACS_INT src_chars, EMACS_INT src_bytes,
8167 const unsigned char *src; 8185 int highest, int multibytep,
8168 EMACS_INT src_chars, src_bytes; 8186 Lisp_Object coding_system)
8169 int highest;
8170 int multibytep;
8171 Lisp_Object coding_system;
8172{ 8187{
8173 const unsigned char *src_end = src + src_bytes; 8188 const unsigned char *src_end = src + src_bytes;
8174 Lisp_Object attrs, eol_type; 8189 Lisp_Object attrs, eol_type;
@@ -8922,7 +8937,9 @@ is nil. */)
8922 8937
8923 8938
8924Lisp_Object 8939Lisp_Object
8925code_convert_region (Lisp_Object start, Lisp_Object end, Lisp_Object coding_system, Lisp_Object dst_object, int encodep, int norecord) 8940code_convert_region (Lisp_Object start, Lisp_Object end,
8941 Lisp_Object coding_system, Lisp_Object dst_object,
8942 int encodep, int norecord)
8926{ 8943{
8927 struct coding_system coding; 8944 struct coding_system coding;
8928 EMACS_INT from, from_byte, to, to_byte; 8945 EMACS_INT from, from_byte, to, to_byte;
@@ -9061,7 +9078,8 @@ code_convert_string (string, coding_system, dst_object,
9061 ENCODE_FILE, thus we ignore character composition. */ 9078 ENCODE_FILE, thus we ignore character composition. */
9062 9079
9063Lisp_Object 9080Lisp_Object
9064code_convert_string_norecord (Lisp_Object string, Lisp_Object coding_system, int encodep) 9081code_convert_string_norecord (Lisp_Object string, Lisp_Object coding_system,
9082 int encodep)
9065{ 9083{
9066 return code_convert_string (string, coding_system, Qt, encodep, 0, 1); 9084 return code_convert_string (string, coding_system, Qt, encodep, 0, 1);
9067} 9085}
@@ -10096,7 +10114,7 @@ usage: (define-coding-system-internal ...) */)
10096DEFUN ("coding-system-put", Fcoding_system_put, Scoding_system_put, 10114DEFUN ("coding-system-put", Fcoding_system_put, Scoding_system_put,
10097 3, 3, 0, 10115 3, 3, 0,
10098 doc: /* Change value in CODING-SYSTEM's property list PROP to VAL. */) 10116 doc: /* Change value in CODING-SYSTEM's property list PROP to VAL. */)
10099 (coding_system, prop, val) 10117 (coding_system, prop, val)
10100 Lisp_Object coding_system, prop, val; 10118 Lisp_Object coding_system, prop, val;
10101{ 10119{
10102 Lisp_Object spec, attrs; 10120 Lisp_Object spec, attrs;
@@ -10194,7 +10212,7 @@ DEFUN ("coding-system-base", Fcoding_system_base, Scoding_system_base,
10194 1, 1, 0, 10212 1, 1, 0,
10195 doc: /* Return the base of CODING-SYSTEM. 10213 doc: /* Return the base of CODING-SYSTEM.
10196Any alias or subsidiary coding system is not a base coding system. */) 10214Any alias or subsidiary coding system is not a base coding system. */)
10197 (coding_system) 10215 (coding_system)
10198 Lisp_Object coding_system; 10216 Lisp_Object coding_system;
10199{ 10217{
10200 Lisp_Object spec, attrs; 10218 Lisp_Object spec, attrs;