comparison src/mule-coding.c @ 181:bfd6434d15b3 r20-3b17

Import from CVS: tag r20-3b17
author cvs
date Mon, 13 Aug 2007 09:53:19 +0200
parents 9ad43877534d
children e121b013d1f0
comparison
equal deleted inserted replaced
180:add28d59e586 181:bfd6434d15b3
223 223
224 static Lisp_Object 224 static Lisp_Object
225 mark_coding_system (Lisp_Object obj, void (*markobj) (Lisp_Object)) 225 mark_coding_system (Lisp_Object obj, void (*markobj) (Lisp_Object))
226 { 226 {
227 struct Lisp_Coding_System *codesys = XCODING_SYSTEM (obj); 227 struct Lisp_Coding_System *codesys = XCODING_SYSTEM (obj);
228 int i;
229 228
230 (markobj) (CODING_SYSTEM_NAME (codesys)); 229 (markobj) (CODING_SYSTEM_NAME (codesys));
231 (markobj) (CODING_SYSTEM_DOC_STRING (codesys)); 230 (markobj) (CODING_SYSTEM_DOC_STRING (codesys));
232 (markobj) (CODING_SYSTEM_MNEMONIC (codesys)); 231 (markobj) (CODING_SYSTEM_MNEMONIC (codesys));
233 (markobj) (CODING_SYSTEM_EOL_LF (codesys)); 232 (markobj) (CODING_SYSTEM_EOL_LF (codesys));
234 (markobj) (CODING_SYSTEM_EOL_CRLF (codesys)); 233 (markobj) (CODING_SYSTEM_EOL_CRLF (codesys));
235 (markobj) (CODING_SYSTEM_EOL_CR (codesys)); 234 (markobj) (CODING_SYSTEM_EOL_CR (codesys));
235
236 switch (CODING_SYSTEM_TYPE (codesys)) 236 switch (CODING_SYSTEM_TYPE (codesys))
237 { 237 {
238 int i;
238 case CODESYS_ISO2022: 239 case CODESYS_ISO2022:
239 for (i = 0; i < 4; i++) 240 for (i = 0; i < 4; i++)
240 (markobj) (CODING_SYSTEM_ISO2022_INITIAL_CHARSET (codesys, i)); 241 (markobj) (CODING_SYSTEM_ISO2022_INITIAL_CHARSET (codesys, i));
241 if (codesys->iso2022.input_conv) 242 if (codesys->iso2022.input_conv)
242 { 243 {
1537 converting from some external format to internal format). 1538 converting from some external format to internal format).
1538 The decoding-stream object keeps track of the actual coding 1539 The decoding-stream object keeps track of the actual coding
1539 stream, the stream that is at the other end, and data that 1540 stream, the stream that is at the other end, and data that
1540 needs to be persistent across the lifetime of the stream. */ 1541 needs to be persistent across the lifetime of the stream. */
1541 1542
1542 /* Handle the EOL stuff related to just-read-in character C. EOL is 1543 /* Handle the EOL stuff related to just-read-in character C.
1543 the EOL type of the coding stream. FLAGS is the current value of 1544 EOL_TYPE is the EOL type of the coding stream.
1544 FLAGS in the coding stream, and may be modified by this macro. 1545 FLAGS is the current value of FLAGS in the coding stream, and may
1545 (The macro only looks at the CODING_STATE_CR flag.) DST is the 1546 be modified by this macro. (The macro only looks at the
1546 Dynarr to which the decoded bytes are to be written. You need to 1547 CODING_STATE_CR flag.) DST is the Dynarr to which the decoded
1547 also define a local goto label "label_continue_loop" that is at the 1548 bytes are to be written. You need to also define a local goto
1548 end of the main character-reading loop. 1549 label "label_continue_loop" that is at the end of the main
1550 character-reading loop.
1549 1551
1550 If C is a CR character, then this macro handles it entirely and 1552 If C is a CR character, then this macro handles it entirely and
1551 jumps to label_continue_loop. Otherwise, this macro does not add 1553 jumps to label_continue_loop. Otherwise, this macro does not add
1552 anything to DST, and continues normally. You should continue 1554 anything to DST, and continues normally. You should continue
1553 processing C normally after this macro. */ 1555 processing C normally after this macro. */
1554 1556
1555 #define DECODE_HANDLE_EOL_TYPE(eol, c, flags, dst) \ 1557 #define DECODE_HANDLE_EOL_TYPE(eol_type, c, flags, dst) \
1556 do { \ 1558 do { \
1557 if (c == '\r') \ 1559 if (c == '\r') \
1558 { \ 1560 { \
1559 if (eol == EOL_CR) \ 1561 if (eol_type == EOL_CR) \
1560 Dynarr_add (dst, '\n'); \ 1562 Dynarr_add (dst, '\n'); \
1561 else if (eol != EOL_CRLF || flags & CODING_STATE_CR) \ 1563 else if (eol_type != EOL_CRLF || flags & CODING_STATE_CR) \
1562 Dynarr_add (dst, c); \ 1564 Dynarr_add (dst, c); \
1563 else \ 1565 else \
1564 flags |= CODING_STATE_CR; \ 1566 flags |= CODING_STATE_CR; \
1565 goto label_continue_loop; \ 1567 goto label_continue_loop; \
1566 } \ 1568 } \
1567 else if (flags & CODING_STATE_CR) \ 1569 else if (flags & CODING_STATE_CR) \
1568 { /* eol == CODING_SYSTEM_EOL_CRLF */ \ 1570 { /* eol_type == CODING_SYSTEM_EOL_CRLF */ \
1569 if (c != '\n') \ 1571 if (c != '\n') \
1570 Dynarr_add (dst, '\r'); \ 1572 Dynarr_add (dst, '\r'); \
1571 flags &= ~CODING_STATE_CR; \ 1573 flags &= ~CODING_STATE_CR; \
1572 } \ 1574 } \
1573 } while (0) 1575 } while (0)
1883 make_decoding_output_stream (Lstream *stream, Lisp_Object codesys) 1885 make_decoding_output_stream (Lstream *stream, Lisp_Object codesys)
1884 { 1886 {
1885 return make_decoding_stream_1 (stream, codesys, "w"); 1887 return make_decoding_stream_1 (stream, codesys, "w");
1886 } 1888 }
1887 1889
1888 /* Note: the decode_coding_? functions all take the same 1890 /* Note: the decode_coding_* functions all take the same
1889 arguments as mule_decode(), which is to say some SRC data of 1891 arguments as mule_decode(), which is to say some SRC data of
1890 size N, which is to be stored into dynamic array DST. 1892 size N, which is to be stored into dynamic array DST.
1891 DECODING is the stream within which the decoding is 1893 DECODING is the stream within which the decoding is
1892 taking place, but no data is actually read from or 1894 taking place, but no data is actually read from or
1893 written to that stream; that is handled in decoding_reader() 1895 written to that stream; that is handled in decoding_reader()
2187 See the comment above. */ 2189 See the comment above. */
2188 str->flags |= CODING_STATE_END; 2190 str->flags |= CODING_STATE_END;
2189 mule_encode (stream, data, str->runoff, read_size); 2191 mule_encode (stream, data, str->runoff, read_size);
2190 } 2192 }
2191 2193
2192 if (data - orig_data == 0) 2194 if (data == orig_data)
2193 return error_occurred ? -1 : 0; 2195 return error_occurred ? -1 : 0;
2194 else 2196 else
2195 return data - orig_data; 2197 return data - orig_data;
2196 } 2198 }
2197 2199
2216 } 2218 }
2217 2219
2218 static void 2220 static void
2219 reset_encoding_stream (struct encoding_stream *str) 2221 reset_encoding_stream (struct encoding_stream *str)
2220 { 2222 {
2221 if (CODING_SYSTEM_TYPE (str->codesys) == CODESYS_ISO2022) 2223 switch (CODING_SYSTEM_TYPE (str->codesys))
2222 { 2224 {
2223 int i; 2225 case CODESYS_ISO2022:
2224 2226 {
2225 for (i = 0; i < 4; i++) 2227 int i;
2226 str->iso2022.charset[i] = 2228
2227 CODING_SYSTEM_ISO2022_INITIAL_CHARSET (str->codesys, i); 2229 for (i = 0; i < 4; i++)
2228 for (i = 0; i < 4; i++) 2230 {
2229 str->iso2022.force_charset_on_output[i] = 2231 str->iso2022.charset[i] =
2230 CODING_SYSTEM_ISO2022_FORCE_CHARSET_ON_OUTPUT (str->codesys, i); 2232 CODING_SYSTEM_ISO2022_INITIAL_CHARSET (str->codesys, i);
2231 str->iso2022.register_left = 0; 2233 str->iso2022.force_charset_on_output[i] =
2232 str->iso2022.register_right = 1; 2234 CODING_SYSTEM_ISO2022_FORCE_CHARSET_ON_OUTPUT (str->codesys, i);
2233 str->iso2022.current_charset = Qnil; 2235 }
2234 str->iso2022.current_half = 0; 2236 str->iso2022.register_left = 0;
2235 str->iso2022.current_char_boundary = 1; 2237 str->iso2022.register_right = 1;
2236 } 2238 str->iso2022.current_charset = Qnil;
2237 else if (CODING_SYSTEM_TYPE (str->codesys) == CODESYS_CCL) 2239 str->iso2022.current_half = 0;
2238 { 2240 str->iso2022.current_char_boundary = 1;
2241 break;
2242 }
2243 case CODESYS_CCL:
2239 set_ccl_program (&str->ccl, CODING_SYSTEM_CCL_ENCODE (str->codesys), 0, 0, 0); 2244 set_ccl_program (&str->ccl, CODING_SYSTEM_CCL_ENCODE (str->codesys), 0, 0, 0);
2240 } 2245 break;
2246 default:
2247 break;
2248 }
2249
2241 str->flags = str->ch = 0; 2250 str->flags = str->ch = 0;
2242 } 2251 }
2243 2252
2244 static int 2253 static int
2245 encoding_rewinder (Lstream *stream) 2254 encoding_rewinder (Lstream *stream)
2528 decode_coding_sjis (Lstream *decoding, CONST unsigned char *src, 2537 decode_coding_sjis (Lstream *decoding, CONST unsigned char *src,
2529 unsigned_char_dynarr *dst, unsigned int n) 2538 unsigned_char_dynarr *dst, unsigned int n)
2530 { 2539 {
2531 unsigned char c; 2540 unsigned char c;
2532 unsigned int flags, ch; 2541 unsigned int flags, ch;
2533 int eol; 2542 enum eol_type eol_type;
2534 struct decoding_stream *str = DECODING_STREAM_DATA (decoding); 2543 struct decoding_stream *str = DECODING_STREAM_DATA (decoding);
2535 2544
2536 CODING_STREAM_DECOMPOSE (str, flags, ch); 2545 CODING_STREAM_DECOMPOSE (str, flags, ch);
2537 eol = str->eol_type; 2546 eol_type = str->eol_type;
2538 2547
2539 while (n--) 2548 while (n--)
2540 { 2549 {
2541 c = *src++; 2550 c = *src++;
2542 2551
2559 } 2568 }
2560 ch = 0; 2569 ch = 0;
2561 } 2570 }
2562 else 2571 else
2563 { 2572 {
2564 DECODE_HANDLE_EOL_TYPE (eol, c, flags, dst); 2573 DECODE_HANDLE_EOL_TYPE (eol_type, c, flags, dst);
2565 if (BYTE_SJIS_TWO_BYTE_1_P (c)) 2574 if (BYTE_SJIS_TWO_BYTE_1_P (c))
2566 ch = c; 2575 ch = c;
2567 else if (BYTE_SJIS_KATAKANA_P (c)) 2576 else if (BYTE_SJIS_KATAKANA_P (c))
2568 { 2577 {
2569 Dynarr_add (dst, LEADING_BYTE_KATAKANA_JISX0201); 2578 Dynarr_add (dst, LEADING_BYTE_KATAKANA_JISX0201);
2587 unsigned_char_dynarr *dst, unsigned int n) 2596 unsigned_char_dynarr *dst, unsigned int n)
2588 { 2597 {
2589 unsigned char c; 2598 unsigned char c;
2590 struct encoding_stream *str = ENCODING_STREAM_DATA (encoding); 2599 struct encoding_stream *str = ENCODING_STREAM_DATA (encoding);
2591 unsigned int flags, ch; 2600 unsigned int flags, ch;
2592 int eol; 2601 enum eol_type eol_type;
2593 2602
2594 CODING_STREAM_DECOMPOSE (str, flags, ch); 2603 CODING_STREAM_DECOMPOSE (str, flags, ch);
2595 eol = CODING_SYSTEM_EOL_TYPE (str->codesys); 2604 eol_type = CODING_SYSTEM_EOL_TYPE (str->codesys);
2596 2605
2597 while (n--) 2606 while (n--)
2598 { 2607 {
2599 c = *src++; 2608 c = *src++;
2600 if (c == '\n') 2609 if (c == '\n')
2601 { 2610 {
2602 if (eol != EOL_LF && eol != EOL_AUTODETECT) 2611 if (eol_type != EOL_LF && eol_type != EOL_AUTODETECT)
2603 Dynarr_add (dst, '\r'); 2612 Dynarr_add (dst, '\r');
2604 if (eol != EOL_CR) 2613 if (eol_type != EOL_CR)
2605 Dynarr_add (dst, '\n'); 2614 Dynarr_add (dst, '\n');
2606 ch = 0; 2615 ch = 0;
2607 } 2616 }
2608 else if (BYTE_ASCII_P (c)) 2617 else if (BYTE_ASCII_P (c))
2609 { 2618 {
2816 static void 2825 static void
2817 decode_coding_big5 (Lstream *decoding, CONST unsigned char *src, 2826 decode_coding_big5 (Lstream *decoding, CONST unsigned char *src,
2818 unsigned_char_dynarr *dst, unsigned int n) 2827 unsigned_char_dynarr *dst, unsigned int n)
2819 { 2828 {
2820 unsigned char c; 2829 unsigned char c;
2821 unsigned int flags, ch, eol; 2830 unsigned int flags, ch;
2831 enum eol_type eol_type;
2822 struct decoding_stream *str = DECODING_STREAM_DATA (decoding); 2832 struct decoding_stream *str = DECODING_STREAM_DATA (decoding);
2823 2833
2824 CODING_STREAM_DECOMPOSE (str, flags, ch); 2834 CODING_STREAM_DECOMPOSE (str, flags, ch);
2825 eol = str->eol_type; 2835 eol_type = str->eol_type;
2826 2836
2827 while (n--) 2837 while (n--)
2828 { 2838 {
2829 c = *src++; 2839 c = *src++;
2830 if (ch) 2840 if (ch)
2845 } 2855 }
2846 ch = 0; 2856 ch = 0;
2847 } 2857 }
2848 else 2858 else
2849 { 2859 {
2850 DECODE_HANDLE_EOL_TYPE (eol, c, flags, dst); 2860 DECODE_HANDLE_EOL_TYPE (eol_type, c, flags, dst);
2851 if (BYTE_BIG5_TWO_BYTE_1_P (c)) 2861 if (BYTE_BIG5_TWO_BYTE_1_P (c))
2852 ch = c; 2862 ch = c;
2853 else 2863 else
2854 DECODE_ADD_BINARY_CHAR (c, dst); 2864 DECODE_ADD_BINARY_CHAR (c, dst);
2855 } 2865 }
2867 encode_coding_big5 (Lstream *encoding, CONST unsigned char *src, 2877 encode_coding_big5 (Lstream *encoding, CONST unsigned char *src,
2868 unsigned_char_dynarr *dst, unsigned int n) 2878 unsigned_char_dynarr *dst, unsigned int n)
2869 { 2879 {
2870 unsigned char c; 2880 unsigned char c;
2871 struct encoding_stream *str = ENCODING_STREAM_DATA (encoding); 2881 struct encoding_stream *str = ENCODING_STREAM_DATA (encoding);
2872 unsigned int flags, ch, eol; 2882 unsigned int flags, ch;
2883 enum eol_type eol_type;
2873 2884
2874 CODING_STREAM_DECOMPOSE (str, flags, ch); 2885 CODING_STREAM_DECOMPOSE (str, flags, ch);
2875 eol = CODING_SYSTEM_EOL_TYPE (str->codesys); 2886 eol_type = CODING_SYSTEM_EOL_TYPE (str->codesys);
2876 2887
2877 while (n--) 2888 while (n--)
2878 { 2889 {
2879 c = *src++; 2890 c = *src++;
2880 if (c == '\n') 2891 if (c == '\n')
2881 { 2892 {
2882 if (eol != EOL_LF && eol != EOL_AUTODETECT) 2893 if (eol_type != EOL_LF && eol_type != EOL_AUTODETECT)
2883 Dynarr_add (dst, '\r'); 2894 Dynarr_add (dst, '\r');
2884 if (eol != EOL_CR) 2895 if (eol_type != EOL_CR)
2885 Dynarr_add (dst, '\n'); 2896 Dynarr_add (dst, '\n');
2886 } 2897 }
2887 else if (BYTE_ASCII_P (c)) 2898 else if (BYTE_ASCII_P (c))
2888 { 2899 {
2889 /* ASCII. */ 2900 /* ASCII. */
3730 decode_coding_iso2022 (Lstream *decoding, CONST unsigned char *src, 3741 decode_coding_iso2022 (Lstream *decoding, CONST unsigned char *src,
3731 unsigned_char_dynarr *dst, unsigned int n) 3742 unsigned_char_dynarr *dst, unsigned int n)
3732 { 3743 {
3733 unsigned char c; 3744 unsigned char c;
3734 unsigned int flags, ch; 3745 unsigned int flags, ch;
3735 int eol; 3746 enum eol_type eol_type;
3736 struct decoding_stream *str = DECODING_STREAM_DATA (decoding); 3747 struct decoding_stream *str = DECODING_STREAM_DATA (decoding);
3737 Lisp_Object coding_system = Qnil; 3748 Lisp_Object coding_system = Qnil;
3738 unsigned_char_dynarr *real_dst = dst; 3749 unsigned_char_dynarr *real_dst = dst;
3739 3750
3740 CODING_STREAM_DECOMPOSE (str, flags, ch); 3751 CODING_STREAM_DECOMPOSE (str, flags, ch);
3741 eol = CODING_SYSTEM_EOL_TYPE (str->codesys); 3752 eol_type = str->eol_type;
3742 XSETCODING_SYSTEM (coding_system, str->codesys); 3753 XSETCODING_SYSTEM (coding_system, str->codesys);
3743 3754
3744 if (flags & CODING_STATE_COMPOSITE) 3755 if (flags & CODING_STATE_COMPOSITE)
3745 dst = str->iso2022.composite_chars; 3756 dst = str->iso2022.composite_chars;
3746 3757
3747 while (n--) 3758 while (n--)
3748 { 3759 {
3749 c = *src++; 3760 c = *src++;
3750 if (flags & CODING_STATE_ESCAPE) 3761 if (flags & CODING_STATE_ESCAPE)
3751 { /* Within ESC sequence */ 3762 { /* Within ESC sequence */
3752 int retval; 3763 int retval = parse_iso2022_esc (coding_system, &str->iso2022,
3753 3764 c, &flags, 1);
3754 retval = parse_iso2022_esc (coding_system, &str->iso2022,
3755 c, &flags, 1);
3756 3765
3757 if (retval) 3766 if (retval)
3758 { 3767 {
3759 switch (str->iso2022.esc) 3768 switch (str->iso2022.esc)
3760 { 3769 {
3838 } 3847 }
3839 3848
3840 /***** Now handle the control characters. *****/ 3849 /***** Now handle the control characters. *****/
3841 3850
3842 /* Handle CR/LF */ 3851 /* Handle CR/LF */
3843 DECODE_HANDLE_EOL_TYPE (eol, c, flags, dst); 3852 DECODE_HANDLE_EOL_TYPE (eol_type, c, flags, dst);
3844 3853
3845 flags &= CODING_STATE_ISO2022_LOCK; 3854 flags &= CODING_STATE_ISO2022_LOCK;
3846 3855
3847 if (!parse_iso2022_esc (coding_system, &str->iso2022, c, &flags, 1)) 3856 if (!parse_iso2022_esc (coding_system, &str->iso2022, c, &flags, 1))
3848 DECODE_ADD_BINARY_CHAR (c, dst); 3857 DECODE_ADD_BINARY_CHAR (c, dst);
3851 { /* Graphic characters */ 3860 { /* Graphic characters */
3852 Lisp_Object charset; 3861 Lisp_Object charset;
3853 int lb; 3862 int lb;
3854 int reg; 3863 int reg;
3855 3864
3856 DECODE_HANDLE_EOL_TYPE (eol, c, flags, dst); 3865 DECODE_HANDLE_EOL_TYPE (eol_type, c, flags, dst);
3857 3866
3858 /* Now determine the charset. */ 3867 /* Now determine the charset. */
3859 reg = ((flags & CODING_STATE_SS2) ? 2 3868 reg = ((flags & CODING_STATE_SS2) ? 2
3860 : (flags & CODING_STATE_SS3) ? 3 3869 : (flags & CODING_STATE_SS3) ? 3
3861 : !BYTE_ASCII_P (c) ? str->iso2022.register_right 3870 : !BYTE_ASCII_P (c) ? str->iso2022.register_right
4050 static void 4059 static void
4051 encode_coding_iso2022 (Lstream *encoding, CONST unsigned char *src, 4060 encode_coding_iso2022 (Lstream *encoding, CONST unsigned char *src,
4052 unsigned_char_dynarr *dst, unsigned int n) 4061 unsigned_char_dynarr *dst, unsigned int n)
4053 { 4062 {
4054 unsigned char charmask, c; 4063 unsigned char charmask, c;
4055 unsigned int flags, ch, eol; 4064 unsigned int flags, ch;
4065 enum eol_type eol_type;
4056 unsigned char char_boundary; 4066 unsigned char char_boundary;
4057 struct encoding_stream *str = ENCODING_STREAM_DATA (encoding); 4067 struct encoding_stream *str = ENCODING_STREAM_DATA (encoding);
4058 struct Lisp_Coding_System *codesys = str->codesys; 4068 struct Lisp_Coding_System *codesys = str->codesys;
4059 int i; 4069 int i;
4060 Lisp_Object charset; 4070 Lisp_Object charset;
4065 unsigned int saved_n = 0; 4075 unsigned int saved_n = 0;
4066 CONST unsigned char *saved_src = NULL; 4076 CONST unsigned char *saved_src = NULL;
4067 int in_composite = 0; 4077 int in_composite = 0;
4068 4078
4069 CODING_STREAM_DECOMPOSE (str, flags, ch); 4079 CODING_STREAM_DECOMPOSE (str, flags, ch);
4070 eol = CODING_SYSTEM_EOL_TYPE (str->codesys); 4080 eol_type = CODING_SYSTEM_EOL_TYPE (str->codesys);
4071 char_boundary = str->iso2022.current_char_boundary; 4081 char_boundary = str->iso2022.current_char_boundary;
4072 charset = str->iso2022.current_charset; 4082 charset = str->iso2022.current_charset;
4073 half = str->iso2022.current_half; 4083 half = str->iso2022.current_half;
4074 4084
4075 back_to_square_n: 4085 back_to_square_n:
4107 iso2022_designate (initial_charset, i, str, dst); 4117 iso2022_designate (initial_charset, i, str, dst);
4108 } 4118 }
4109 } 4119 }
4110 if (c == '\n') 4120 if (c == '\n')
4111 { 4121 {
4112 if (eol != EOL_LF && eol != EOL_AUTODETECT) 4122 if (eol_type != EOL_LF && eol_type != EOL_AUTODETECT)
4113 Dynarr_add (dst, '\r'); 4123 Dynarr_add (dst, '\r');
4114 if (eol != EOL_CR) 4124 if (eol_type != EOL_CR)
4115 Dynarr_add (dst, c); 4125 Dynarr_add (dst, c);
4116 } 4126 }
4117 else 4127 else
4118 { 4128 {
4119 if (CODING_SYSTEM_ISO2022_ESCAPE_QUOTED (codesys) 4129 if (CODING_SYSTEM_ISO2022_ESCAPE_QUOTED (codesys)
4349 decode_coding_no_conversion (Lstream *decoding, CONST unsigned char *src, 4359 decode_coding_no_conversion (Lstream *decoding, CONST unsigned char *src,
4350 unsigned_char_dynarr *dst, unsigned int n) 4360 unsigned_char_dynarr *dst, unsigned int n)
4351 { 4361 {
4352 unsigned char c; 4362 unsigned char c;
4353 unsigned int flags, ch; 4363 unsigned int flags, ch;
4354 int eol; 4364 enum eol_type eol_type;
4355 struct decoding_stream *str = DECODING_STREAM_DATA (decoding); 4365 struct decoding_stream *str = DECODING_STREAM_DATA (decoding);
4356 4366
4357 CODING_STREAM_DECOMPOSE (str, flags, ch); 4367 CODING_STREAM_DECOMPOSE (str, flags, ch);
4358 eol = str->eol_type; 4368 eol_type = str->eol_type;
4359 4369
4360 while (n--) 4370 while (n--)
4361 { 4371 {
4362 c = *src++; 4372 c = *src++;
4363 4373
4364 DECODE_HANDLE_EOL_TYPE (eol, c, flags, dst); 4374 DECODE_HANDLE_EOL_TYPE (eol_type, c, flags, dst);
4365 DECODE_ADD_BINARY_CHAR (c, dst); 4375 DECODE_ADD_BINARY_CHAR (c, dst);
4366 label_continue_loop:; 4376 label_continue_loop:;
4367 } 4377 }
4368 4378
4369 DECODE_HANDLE_END_OF_CONVERSION (flags, ch, dst); 4379 DECODE_HANDLE_END_OF_CONVERSION (flags, ch, dst);
4375 encode_coding_no_conversion (Lstream *encoding, CONST unsigned char *src, 4385 encode_coding_no_conversion (Lstream *encoding, CONST unsigned char *src,
4376 unsigned_char_dynarr *dst, unsigned int n) 4386 unsigned_char_dynarr *dst, unsigned int n)
4377 { 4387 {
4378 unsigned char c; 4388 unsigned char c;
4379 struct encoding_stream *str = ENCODING_STREAM_DATA (encoding); 4389 struct encoding_stream *str = ENCODING_STREAM_DATA (encoding);
4380 unsigned int flags, ch, eol; 4390 unsigned int flags, ch;
4391 enum eol_type eol_type;
4381 4392
4382 CODING_STREAM_DECOMPOSE (str, flags, ch); 4393 CODING_STREAM_DECOMPOSE (str, flags, ch);
4383 eol = CODING_SYSTEM_EOL_TYPE (str->codesys); 4394 eol_type = CODING_SYSTEM_EOL_TYPE (str->codesys);
4384 4395
4385 while (n--) 4396 while (n--)
4386 { 4397 {
4387 c = *src++; 4398 c = *src++;
4388 if (c == '\n') 4399 if (c == '\n')
4389 { 4400 {
4390 if (eol != EOL_LF && eol != EOL_AUTODETECT) 4401 if (eol_type != EOL_LF && eol_type != EOL_AUTODETECT)
4391 Dynarr_add (dst, '\r'); 4402 Dynarr_add (dst, '\r');
4392 if (eol != EOL_CR) 4403 if (eol_type != EOL_CR)
4393 Dynarr_add (dst, '\n'); 4404 Dynarr_add (dst, '\n');
4394 ch = 0; 4405 ch = 0;
4395 } 4406 }
4396 else if (BYTE_ASCII_P (c)) 4407 else if (BYTE_ASCII_P (c))
4397 { 4408 {