Mercurial > hg > xemacs-beta
comparison src/mule-coding.c @ 272:c5d627a313b1 r21-0b34
Import from CVS: tag r21-0b34
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:28:48 +0200 |
parents | 11cf20601dec |
children | 70ad99077275 |
comparison
equal
deleted
inserted
replaced
271:c7b7086b0a39 | 272:c5d627a313b1 |
---|---|
140 literally because we didn't know about the invalid designation; | 140 literally because we didn't know about the invalid designation; |
141 but we have to do so now. */ | 141 but we have to do so now. */ |
142 unsigned int output_direction_sequence :1; | 142 unsigned int output_direction_sequence :1; |
143 }; | 143 }; |
144 | 144 |
145 Lisp_Object Fcopy_coding_system (Lisp_Object old_coding_system, | 145 EXFUN (Fcopy_coding_system, 2); |
146 Lisp_Object new_name); | |
147 struct detection_state; | 146 struct detection_state; |
148 static int detect_coding_sjis (struct detection_state *st, | 147 static int detect_coding_sjis (struct detection_state *st, |
149 CONST unsigned char *src, | 148 CONST unsigned char *src, |
150 unsigned int n); | 149 unsigned int n); |
151 static void decode_coding_sjis (Lstream *decoding, | 150 static void decode_coding_sjis (Lstream *decoding, |
214 | 213 |
215 /************************************************************************/ | 214 /************************************************************************/ |
216 /* Coding system functions */ | 215 /* Coding system functions */ |
217 /************************************************************************/ | 216 /************************************************************************/ |
218 | 217 |
219 static Lisp_Object mark_coding_system (Lisp_Object, void (*) (Lisp_Object)); | |
220 static void print_coding_system (Lisp_Object, Lisp_Object, int); | |
221 static void finalize_coding_system (void *header, int for_disksave); | |
222 | |
223 DEFINE_LRECORD_IMPLEMENTATION ("coding-system", coding_system, | |
224 mark_coding_system, print_coding_system, | |
225 finalize_coding_system, | |
226 0, 0, struct Lisp_Coding_System); | |
227 | |
228 static Lisp_Object | 218 static Lisp_Object |
229 mark_coding_system (Lisp_Object obj, void (*markobj) (Lisp_Object)) | 219 mark_coding_system (Lisp_Object obj, void (*markobj) (Lisp_Object)) |
230 { | 220 { |
231 struct Lisp_Coding_System *codesys = XCODING_SYSTEM (obj); | 221 struct Lisp_Coding_System *codesys = XCODING_SYSTEM (obj); |
232 | 222 |
319 break; | 309 break; |
320 } | 310 } |
321 } | 311 } |
322 } | 312 } |
323 | 313 |
314 DEFINE_LRECORD_IMPLEMENTATION ("coding-system", coding_system, | |
315 mark_coding_system, print_coding_system, | |
316 finalize_coding_system, | |
317 0, 0, struct Lisp_Coding_System); | |
318 | |
324 static enum eol_type | 319 static enum eol_type |
325 symbol_to_eol_type (Lisp_Object symbol) | 320 symbol_to_eol_type (Lisp_Object symbol) |
326 { | 321 { |
327 CHECK_SYMBOL (symbol); | 322 CHECK_SYMBOL (symbol); |
328 if (NILP (symbol)) return EOL_AUTODETECT; | 323 if (NILP (symbol)) return EOL_AUTODETECT; |
348 } | 343 } |
349 | 344 |
350 static void | 345 static void |
351 setup_eol_coding_systems (struct Lisp_Coding_System *codesys) | 346 setup_eol_coding_systems (struct Lisp_Coding_System *codesys) |
352 { | 347 { |
353 Lisp_Object codesys_obj = Qnil; | 348 Lisp_Object codesys_obj; |
354 int len = string_length (XSYMBOL (CODING_SYSTEM_NAME (codesys))->name); | 349 int len = string_length (XSYMBOL (CODING_SYSTEM_NAME (codesys))->name); |
355 char *codesys_name = (char *) alloca (len + 7); | 350 char *codesys_name = (char *) alloca (len + 7); |
356 Lisp_Object codesys_name_sym, sub_codesys_obj; | 351 Lisp_Object codesys_name_sym, sub_codesys_obj; |
357 | 352 |
358 /* kludge */ | 353 /* kludge */ |
374 DEFINE_SUB_CODESYS("dos", EOL_CRLF); | 369 DEFINE_SUB_CODESYS("dos", EOL_CRLF); |
375 DEFINE_SUB_CODESYS("mac", EOL_CR); | 370 DEFINE_SUB_CODESYS("mac", EOL_CR); |
376 } | 371 } |
377 | 372 |
378 DEFUN ("coding-system-p", Fcoding_system_p, 1, 1, 0, /* | 373 DEFUN ("coding-system-p", Fcoding_system_p, 1, 1, 0, /* |
379 T if OBJECT is a coding system. | 374 Return t if OBJECT is a coding system. |
380 A coding system is an object that defines how text containing multiple | 375 A coding system is an object that defines how text containing multiple |
381 character sets is encoded into a stream of (typically 8-bit) bytes. | 376 character sets is encoded into a stream of (typically 8-bit) bytes. |
382 The coding system is used to decode the stream into a series of | 377 The coding system is used to decode the stream into a series of |
383 characters (which may be from multiple charsets) when the text is read | 378 characters (which may be from multiple charsets) when the text is read |
384 from a file or process, and is used to encode the text back into the | 379 from a file or process, and is used to encode the text back into the |
967 static | 962 static |
968 Lisp_Object coding_system_charset (Lisp_Object coding_system, int gnum) | 963 Lisp_Object coding_system_charset (Lisp_Object coding_system, int gnum) |
969 { | 964 { |
970 Lisp_Object cs | 965 Lisp_Object cs |
971 = XCODING_SYSTEM_ISO2022_INITIAL_CHARSET (coding_system, gnum); | 966 = XCODING_SYSTEM_ISO2022_INITIAL_CHARSET (coding_system, gnum); |
972 | 967 |
973 if (CHARSETP(cs)){ | 968 return CHARSETP (cs) ? XCHARSET_NAME (cs) : Qnil; |
974 return XCHARSET_NAME(cs); | |
975 } | |
976 else { | |
977 return Qnil; | |
978 } | |
979 } | 969 } |
980 | 970 |
981 DEFUN ("coding-system-charset", Fcoding_system_charset, 2, 2, 0, /* | 971 DEFUN ("coding-system-charset", Fcoding_system_charset, 2, 2, 0, /* |
982 Return initial charset of CODING-SYSTEM designated to GNUM. | 972 Return initial charset of CODING-SYSTEM designated to GNUM. |
983 GNUM allows 0 .. 3. | 973 GNUM allows 0 .. 3. |
985 (coding_system, gnum)) | 975 (coding_system, gnum)) |
986 { | 976 { |
987 coding_system = Fget_coding_system (coding_system); | 977 coding_system = Fget_coding_system (coding_system); |
988 CHECK_INT (gnum); | 978 CHECK_INT (gnum); |
989 | 979 |
990 return coding_system_charset(coding_system, XINT (gnum)); | 980 return coding_system_charset (coding_system, XINT (gnum)); |
991 } | 981 } |
992 | 982 |
993 DEFUN ("coding-system-property", Fcoding_system_property, 2, 2, 0, /* | 983 DEFUN ("coding-system-property", Fcoding_system_property, 2, 2, 0, /* |
994 Return the PROP property of CODING-SYSTEM. | 984 Return the PROP property of CODING-SYSTEM. |
995 */ | 985 */ |
1240 enum eol_type eol_type; | 1230 enum eol_type eol_type; |
1241 int seen_non_ascii; | 1231 int seen_non_ascii; |
1242 int mask; | 1232 int mask; |
1243 | 1233 |
1244 struct | 1234 struct |
1245 { | 1235 { |
1246 int mask; | 1236 int mask; |
1247 int in_second_byte; | 1237 int in_second_byte; |
1248 } | 1238 } |
1249 big5; | 1239 big5; |
1250 | 1240 |
1251 struct | 1241 struct |
1252 { | 1242 { |
1253 int mask; | 1243 int mask; |
1254 int in_second_byte; | 1244 int in_second_byte; |
1255 } | 1245 } |
1256 shift_jis; | 1246 shift_jis; |
1257 | 1247 |
1258 struct | 1248 struct |
1259 { | 1249 { |
1260 int mask; | 1250 int mask; |
1261 int initted; | 1251 int initted; |
1262 struct iso2022_decoder iso; | 1252 struct iso2022_decoder iso; |
1263 unsigned int flags; | 1253 unsigned int flags; |
1264 int high_byte_count; | 1254 int high_byte_count; |
1265 unsigned int saw_single_shift:1; | 1255 unsigned int saw_single_shift:1; |
1266 } | 1256 } |
1267 iso2022; | 1257 iso2022; |
1268 | 1258 |
1269 struct | 1259 struct |
1270 { | 1260 { |
1271 int seen_anything; | 1261 int seen_anything; |
1272 int just_saw_cr; | 1262 int just_saw_cr; |
1273 } | 1263 } |
1274 eol; | 1264 eol; |
1275 }; | 1265 }; |
1276 | 1266 |
1277 static int | 1267 static int |
1278 acceptable_control_char_p (int c) | 1268 acceptable_control_char_p (int c) |
1461 struct detection_state decst; | 1451 struct detection_state decst; |
1462 | 1452 |
1463 if (*eol_type_in_out == EOL_AUTODETECT) | 1453 if (*eol_type_in_out == EOL_AUTODETECT) |
1464 *eol_type_in_out = XCODING_SYSTEM_EOL_TYPE (*codesys_in_out); | 1454 *eol_type_in_out = XCODING_SYSTEM_EOL_TYPE (*codesys_in_out); |
1465 | 1455 |
1466 memset (&decst, 0, sizeof (decst)); | 1456 xzero (decst); |
1467 decst.eol_type = *eol_type_in_out; | 1457 decst.eol_type = *eol_type_in_out; |
1468 decst.mask = ~0; | 1458 decst.mask = ~0; |
1469 | 1459 |
1470 /* If autodetection is called for, do it now. */ | 1460 /* If autodetection is called for, do it now. */ |
1471 if (XCODING_SYSTEM_TYPE (*codesys_in_out) == CODESYS_AUTODETECT || | 1461 if (XCODING_SYSTEM_TYPE (*codesys_in_out) == CODESYS_AUTODETECT || |
1519 lb_instream = make_lisp_buffer_input_stream (buf, b, e, 0); | 1509 lb_instream = make_lisp_buffer_input_stream (buf, b, e, 0); |
1520 lb_istr = XLSTREAM (lb_instream); | 1510 lb_istr = XLSTREAM (lb_instream); |
1521 instream = make_encoding_input_stream (lb_istr, Fget_coding_system (Qbinary)); | 1511 instream = make_encoding_input_stream (lb_istr, Fget_coding_system (Qbinary)); |
1522 istr = XLSTREAM (instream); | 1512 istr = XLSTREAM (instream); |
1523 GCPRO2 (instream, lb_instream); | 1513 GCPRO2 (instream, lb_instream); |
1524 memset (&decst, 0, sizeof (decst)); | 1514 xzero (decst); |
1525 decst.eol_type = EOL_AUTODETECT; | 1515 decst.eol_type = EOL_AUTODETECT; |
1526 decst.mask = ~0; | 1516 decst.mask = ~0; |
1527 while (1) | 1517 while (1) |
1528 { | 1518 { |
1529 unsigned char random_buffer[4096]; | 1519 unsigned char random_buffer[4096]; |
1687 struct ccl_program ccl; | 1677 struct ccl_program ccl; |
1688 | 1678 |
1689 struct detection_state decst; | 1679 struct detection_state decst; |
1690 }; | 1680 }; |
1691 | 1681 |
1692 static int decoding_reader (Lstream *stream, unsigned char *data, int size); | 1682 static int decoding_reader (Lstream *stream, unsigned char *data, size_t size); |
1693 static int decoding_writer (Lstream *stream, CONST unsigned char *data, int size); | 1683 static int decoding_writer (Lstream *stream, CONST unsigned char *data, size_t size); |
1694 static int decoding_rewinder (Lstream *stream); | 1684 static int decoding_rewinder (Lstream *stream); |
1695 static int decoding_seekable_p (Lstream *stream); | 1685 static int decoding_seekable_p (Lstream *stream); |
1696 static int decoding_flusher (Lstream *stream); | 1686 static int decoding_flusher (Lstream *stream); |
1697 static int decoding_closer (Lstream *stream); | 1687 static int decoding_closer (Lstream *stream); |
1698 static Lisp_Object decoding_marker (Lisp_Object stream, | 1688 static Lisp_Object decoding_marker (Lisp_Object stream, |
1721 | 1711 |
1722 /* Read SIZE bytes of data and store it into DATA. We are a decoding stream | 1712 /* Read SIZE bytes of data and store it into DATA. We are a decoding stream |
1723 so we read data from the other end, decode it, and store it into DATA. */ | 1713 so we read data from the other end, decode it, and store it into DATA. */ |
1724 | 1714 |
1725 static int | 1715 static int |
1726 decoding_reader (Lstream *stream, unsigned char *data, int size) | 1716 decoding_reader (Lstream *stream, unsigned char *data, size_t size) |
1727 { | 1717 { |
1728 struct decoding_stream *str = DECODING_STREAM_DATA (stream); | 1718 struct decoding_stream *str = DECODING_STREAM_DATA (stream); |
1729 unsigned char *orig_data = data; | 1719 unsigned char *orig_data = data; |
1730 int read_size; | 1720 int read_size; |
1731 int error_occurred = 0; | 1721 int error_occurred = 0; |
1741 { | 1731 { |
1742 /* Take data from the runoff if we can. Make sure to take at | 1732 /* Take data from the runoff if we can. Make sure to take at |
1743 most SIZE bytes, and delete the data from the runoff. */ | 1733 most SIZE bytes, and delete the data from the runoff. */ |
1744 if (Dynarr_length (str->runoff) > 0) | 1734 if (Dynarr_length (str->runoff) > 0) |
1745 { | 1735 { |
1746 int chunk = min (size, Dynarr_length (str->runoff)); | 1736 size_t chunk = min (size, (size_t) Dynarr_length (str->runoff)); |
1747 memcpy (data, Dynarr_atp (str->runoff, 0), chunk); | 1737 memcpy (data, Dynarr_atp (str->runoff, 0), chunk); |
1748 Dynarr_delete_many (str->runoff, 0, chunk); | 1738 Dynarr_delete_many (str->runoff, 0, chunk); |
1749 data += chunk; | 1739 data += chunk; |
1750 size -= chunk; | 1740 size -= chunk; |
1751 } | 1741 } |
1783 else | 1773 else |
1784 return data - orig_data; | 1774 return data - orig_data; |
1785 } | 1775 } |
1786 | 1776 |
1787 static int | 1777 static int |
1788 decoding_writer (Lstream *stream, CONST unsigned char *data, int size) | 1778 decoding_writer (Lstream *stream, CONST unsigned char *data, size_t size) |
1789 { | 1779 { |
1790 struct decoding_stream *str = DECODING_STREAM_DATA (stream); | 1780 struct decoding_stream *str = DECODING_STREAM_DATA (stream); |
1791 int retval; | 1781 int retval; |
1792 | 1782 |
1793 /* Decode all our data into the runoff, and then attempt to write | 1783 /* Decode all our data into the runoff, and then attempt to write |
1807 static void | 1797 static void |
1808 reset_decoding_stream (struct decoding_stream *str) | 1798 reset_decoding_stream (struct decoding_stream *str) |
1809 { | 1799 { |
1810 if (CODING_SYSTEM_TYPE (str->codesys) == CODESYS_ISO2022) | 1800 if (CODING_SYSTEM_TYPE (str->codesys) == CODESYS_ISO2022) |
1811 { | 1801 { |
1812 Lisp_Object coding_system = Qnil; | 1802 Lisp_Object coding_system; |
1813 XSETCODING_SYSTEM (coding_system, str->codesys); | 1803 XSETCODING_SYSTEM (coding_system, str->codesys); |
1814 reset_iso2022 (coding_system, &str->iso2022); | 1804 reset_iso2022 (coding_system, &str->iso2022); |
1815 } | 1805 } |
1816 else if (CODING_SYSTEM_TYPE (str->codesys) == CODESYS_CCL) | 1806 else if (CODING_SYSTEM_TYPE (str->codesys) == CODESYS_CCL) |
1817 { | 1807 { |
1860 } | 1850 } |
1861 | 1851 |
1862 Lisp_Object | 1852 Lisp_Object |
1863 decoding_stream_coding_system (Lstream *stream) | 1853 decoding_stream_coding_system (Lstream *stream) |
1864 { | 1854 { |
1865 Lisp_Object coding_system = Qnil; | 1855 Lisp_Object coding_system; |
1866 struct decoding_stream *str = DECODING_STREAM_DATA (stream); | 1856 struct decoding_stream *str = DECODING_STREAM_DATA (stream); |
1867 | 1857 |
1868 XSETCODING_SYSTEM (coding_system, str->codesys); | 1858 XSETCODING_SYSTEM (coding_system, str->codesys); |
1869 return subsidiary_coding_system (coding_system, str->eol_type); | 1859 return subsidiary_coding_system (coding_system, str->eol_type); |
1870 } | 1860 } |
1893 { | 1883 { |
1894 Lstream *lstr = Lstream_new (lstream_decoding, mode); | 1884 Lstream *lstr = Lstream_new (lstream_decoding, mode); |
1895 struct decoding_stream *str = DECODING_STREAM_DATA (lstr); | 1885 struct decoding_stream *str = DECODING_STREAM_DATA (lstr); |
1896 Lisp_Object obj; | 1886 Lisp_Object obj; |
1897 | 1887 |
1898 memset (str, 0, sizeof (*str)); | 1888 xzero (*str); |
1899 str->other_end = stream; | 1889 str->other_end = stream; |
1900 str->runoff = (unsigned_char_dynarr *) Dynarr_new (unsigned_char); | 1890 str->runoff = (unsigned_char_dynarr *) Dynarr_new (unsigned_char); |
1901 str->eol_type = EOL_AUTODETECT; | 1891 str->eol_type = EOL_AUTODETECT; |
1902 if (!strcmp (mode, "r") | 1892 if (!strcmp (mode, "r") |
1903 && Lstream_seekable_p (stream)) | 1893 && Lstream_seekable_p (stream)) |
1943 rewind, and start over. */ | 1933 rewind, and start over. */ |
1944 | 1934 |
1945 if (CODING_SYSTEM_TYPE (str->codesys) == CODESYS_AUTODETECT || | 1935 if (CODING_SYSTEM_TYPE (str->codesys) == CODESYS_AUTODETECT || |
1946 str->eol_type == EOL_AUTODETECT) | 1936 str->eol_type == EOL_AUTODETECT) |
1947 { | 1937 { |
1948 Lisp_Object codesys = Qnil; | 1938 Lisp_Object codesys; |
1949 | 1939 |
1950 XSETCODING_SYSTEM (codesys, str->codesys); | 1940 XSETCODING_SYSTEM (codesys, str->codesys); |
1951 detect_coding_type (&str->decst, src, n, | 1941 detect_coding_type (&str->decst, src, n, |
1952 CODING_SYSTEM_TYPE (str->codesys) != | 1942 CODING_SYSTEM_TYPE (str->codesys) != |
1953 CODESYS_AUTODETECT); | 1943 CODESYS_AUTODETECT); |
2125 /* Additional information (the state of the running CCL program) | 2115 /* Additional information (the state of the running CCL program) |
2126 used by the CCL encoder. */ | 2116 used by the CCL encoder. */ |
2127 struct ccl_program ccl; | 2117 struct ccl_program ccl; |
2128 }; | 2118 }; |
2129 | 2119 |
2130 static int encoding_reader (Lstream *stream, unsigned char *data, int size); | 2120 static int encoding_reader (Lstream *stream, unsigned char *data, size_t size); |
2131 static int encoding_writer (Lstream *stream, CONST unsigned char *data, | 2121 static int encoding_writer (Lstream *stream, CONST unsigned char *data, |
2132 int size); | 2122 size_t size); |
2133 static int encoding_rewinder (Lstream *stream); | 2123 static int encoding_rewinder (Lstream *stream); |
2134 static int encoding_seekable_p (Lstream *stream); | 2124 static int encoding_seekable_p (Lstream *stream); |
2135 static int encoding_flusher (Lstream *stream); | 2125 static int encoding_flusher (Lstream *stream); |
2136 static int encoding_closer (Lstream *stream); | 2126 static int encoding_closer (Lstream *stream); |
2137 static Lisp_Object encoding_marker (Lisp_Object stream, | 2127 static Lisp_Object encoding_marker (Lisp_Object stream, |
2160 | 2150 |
2161 /* Read SIZE bytes of data and store it into DATA. We are a encoding stream | 2151 /* Read SIZE bytes of data and store it into DATA. We are a encoding stream |
2162 so we read data from the other end, encode it, and store it into DATA. */ | 2152 so we read data from the other end, encode it, and store it into DATA. */ |
2163 | 2153 |
2164 static int | 2154 static int |
2165 encoding_reader (Lstream *stream, unsigned char *data, int size) | 2155 encoding_reader (Lstream *stream, unsigned char *data, size_t size) |
2166 { | 2156 { |
2167 struct encoding_stream *str = ENCODING_STREAM_DATA (stream); | 2157 struct encoding_stream *str = ENCODING_STREAM_DATA (stream); |
2168 unsigned char *orig_data = data; | 2158 unsigned char *orig_data = data; |
2169 int read_size; | 2159 int read_size; |
2170 int error_occurred = 0; | 2160 int error_occurred = 0; |
2180 { | 2170 { |
2181 /* Take data from the runoff if we can. Make sure to take at | 2171 /* Take data from the runoff if we can. Make sure to take at |
2182 most SIZE bytes, and delete the data from the runoff. */ | 2172 most SIZE bytes, and delete the data from the runoff. */ |
2183 if (Dynarr_length (str->runoff) > 0) | 2173 if (Dynarr_length (str->runoff) > 0) |
2184 { | 2174 { |
2185 int chunk = min (size, Dynarr_length (str->runoff)); | 2175 int chunk = min ((int) size, Dynarr_length (str->runoff)); |
2186 memcpy (data, Dynarr_atp (str->runoff, 0), chunk); | 2176 memcpy (data, Dynarr_atp (str->runoff, 0), chunk); |
2187 Dynarr_delete_many (str->runoff, 0, chunk); | 2177 Dynarr_delete_many (str->runoff, 0, chunk); |
2188 data += chunk; | 2178 data += chunk; |
2189 size -= chunk; | 2179 size -= chunk; |
2190 } | 2180 } |
2222 else | 2212 else |
2223 return data - orig_data; | 2213 return data - orig_data; |
2224 } | 2214 } |
2225 | 2215 |
2226 static int | 2216 static int |
2227 encoding_writer (Lstream *stream, CONST unsigned char *data, int size) | 2217 encoding_writer (Lstream *stream, CONST unsigned char *data, size_t size) |
2228 { | 2218 { |
2229 struct encoding_stream *str = ENCODING_STREAM_DATA (stream); | 2219 struct encoding_stream *str = ENCODING_STREAM_DATA (stream); |
2230 int retval; | 2220 int retval; |
2231 | 2221 |
2232 /* Encode all our data into the runoff, and then attempt to write | 2222 /* Encode all our data into the runoff, and then attempt to write |
2313 } | 2303 } |
2314 | 2304 |
2315 Lisp_Object | 2305 Lisp_Object |
2316 encoding_stream_coding_system (Lstream *stream) | 2306 encoding_stream_coding_system (Lstream *stream) |
2317 { | 2307 { |
2318 Lisp_Object coding_system = Qnil; | 2308 Lisp_Object coding_system; |
2319 struct encoding_stream *str = ENCODING_STREAM_DATA (stream); | 2309 struct encoding_stream *str = ENCODING_STREAM_DATA (stream); |
2320 | 2310 |
2321 XSETCODING_SYSTEM (coding_system, str->codesys); | 2311 XSETCODING_SYSTEM (coding_system, str->codesys); |
2322 return coding_system; | 2312 return coding_system; |
2323 } | 2313 } |
2337 { | 2327 { |
2338 Lstream *lstr = Lstream_new (lstream_encoding, mode); | 2328 Lstream *lstr = Lstream_new (lstream_encoding, mode); |
2339 struct encoding_stream *str = ENCODING_STREAM_DATA (lstr); | 2329 struct encoding_stream *str = ENCODING_STREAM_DATA (lstr); |
2340 Lisp_Object obj; | 2330 Lisp_Object obj; |
2341 | 2331 |
2342 memset (str, 0, sizeof (*str)); | 2332 xzero (*str); |
2343 str->runoff = Dynarr_new (unsigned_char); | 2333 str->runoff = Dynarr_new (unsigned_char); |
2344 str->other_end = stream; | 2334 str->other_end = stream; |
2345 set_encoding_stream_coding_system (lstr, codesys); | 2335 set_encoding_stream_coding_system (lstr, codesys); |
2346 XSETLSTREAM (obj, lstr); | 2336 XSETLSTREAM (obj, lstr); |
2347 return obj; | 2337 return obj; |
3736 { | 3726 { |
3737 unsigned char c; | 3727 unsigned char c; |
3738 unsigned int flags, ch; | 3728 unsigned int flags, ch; |
3739 enum eol_type eol_type; | 3729 enum eol_type eol_type; |
3740 struct decoding_stream *str = DECODING_STREAM_DATA (decoding); | 3730 struct decoding_stream *str = DECODING_STREAM_DATA (decoding); |
3741 Lisp_Object coding_system = Qnil; | 3731 Lisp_Object coding_system; |
3742 unsigned_char_dynarr *real_dst = dst; | 3732 unsigned_char_dynarr *real_dst = dst; |
3743 | 3733 |
3744 CODING_STREAM_DECOMPOSE (str, flags, ch); | 3734 CODING_STREAM_DECOMPOSE (str, flags, ch); |
3745 eol_type = str->eol_type; | 3735 eol_type = str->eol_type; |
3746 XSETCODING_SYSTEM (coding_system, str->codesys); | 3736 XSETCODING_SYSTEM (coding_system, str->codesys); |
3965 static void | 3955 static void |
3966 iso2022_designate (Lisp_Object charset, unsigned char reg, | 3956 iso2022_designate (Lisp_Object charset, unsigned char reg, |
3967 struct encoding_stream *str, unsigned_char_dynarr *dst) | 3957 struct encoding_stream *str, unsigned_char_dynarr *dst) |
3968 { | 3958 { |
3969 CONST char *inter94 = "()*+", *inter96= ",-./"; | 3959 CONST char *inter94 = "()*+", *inter96= ",-./"; |
3970 int type; | 3960 unsigned int type; |
3971 unsigned char final; | 3961 unsigned char final; |
3972 Lisp_Object old_charset = str->iso2022.charset[reg]; | 3962 Lisp_Object old_charset = str->iso2022.charset[reg]; |
3973 | 3963 |
3974 str->iso2022.charset[reg] = charset; | 3964 str->iso2022.charset[reg] = charset; |
3975 if (!CHARSETP (charset)) | 3965 if (!CHARSETP (charset)) |
4448 (((fmt) == FORMAT_FILENAME) ? FILE_NAME_CODING_SYSTEM : \ | 4438 (((fmt) == FORMAT_FILENAME) ? FILE_NAME_CODING_SYSTEM : \ |
4449 ((fmt) == FORMAT_CTEXT ) ? Fget_coding_system (Qctext) : \ | 4439 ((fmt) == FORMAT_CTEXT ) ? Fget_coding_system (Qctext) : \ |
4450 ((fmt) == FORMAT_TERMINAL) ? FILE_NAME_CODING_SYSTEM : \ | 4440 ((fmt) == FORMAT_TERMINAL) ? FILE_NAME_CODING_SYSTEM : \ |
4451 Qnil) | 4441 Qnil) |
4452 | 4442 |
4453 extern CONST Extbyte * | 4443 CONST Extbyte * |
4454 convert_to_external_format (CONST Bufbyte *ptr, | 4444 convert_to_external_format (CONST Bufbyte *ptr, |
4455 Bytecount len, | 4445 Bytecount len, |
4456 Extcount *len_out, | 4446 Extcount *len_out, |
4457 enum external_data_format fmt) | 4447 enum external_data_format fmt) |
4458 { | 4448 { |
4516 *len_out = Dynarr_length (conversion_out_dynarr); | 4506 *len_out = Dynarr_length (conversion_out_dynarr); |
4517 Dynarr_add (conversion_out_dynarr, 0); /* remember to zero-terminate! */ | 4507 Dynarr_add (conversion_out_dynarr, 0); /* remember to zero-terminate! */ |
4518 return Dynarr_atp (conversion_out_dynarr, 0); | 4508 return Dynarr_atp (conversion_out_dynarr, 0); |
4519 } | 4509 } |
4520 | 4510 |
4521 extern CONST Bufbyte * | 4511 CONST Bufbyte * |
4522 convert_from_external_format (CONST Extbyte *ptr, | 4512 convert_from_external_format (CONST Extbyte *ptr, |
4523 Extcount len, | 4513 Extcount len, |
4524 Bytecount *len_out, | 4514 Bytecount *len_out, |
4525 enum external_data_format fmt) | 4515 enum external_data_format fmt) |
4526 { | 4516 { |