Mercurial > hg > xemacs-beta
diff src/file-coding.c @ 337:fbbf69b4e8a7 r21-0-66
Import from CVS: tag r21-0-66
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:51:02 +0200 |
parents | 70ad99077275 |
children | 7c94d56991e1 |
line wrap: on
line diff
--- a/src/file-coding.c Mon Aug 13 10:50:41 2007 +0200 +++ b/src/file-coding.c Mon Aug 13 10:51:02 2007 +0200 @@ -103,8 +103,10 @@ /* Index for next byte to store in ISO escape sequence. */ int esc_bytes_index; +#ifdef ENABLE_COMPOSITE_CHARS /* Stuff seen so far when composing a string. */ unsigned_char_dynarr *composite_chars; +#endif /* If we saw an invalid designation sequence for a particular register, we flag it here and switch to ASCII. The next time we @@ -1890,9 +1892,11 @@ } Dynarr_free (str->runoff); #ifdef MULE +#ifdef ENABLE_COMPOSITE_CHARS if (str->iso2022.composite_chars) Dynarr_free (str->iso2022.composite_chars); #endif +#endif return Lstream_close (str->other_end); } @@ -3195,8 +3199,10 @@ iso->invalid_switch_dir = 0; iso->output_direction_sequence = 0; iso->output_literally = 0; +#ifdef ENABLE_COMPOSITE_CHARS if (iso->composite_chars) Dynarr_reset (iso->composite_chars); +#endif } static int @@ -3326,6 +3332,7 @@ /**** composite ****/ +#ifdef ENABLE_COMPOSITE_CHARS case '0': iso->esc = ISO_ESC_START_COMPOSITE; *flags = (*flags & CODING_STATE_ISO2022_LOCK) | @@ -3337,6 +3344,7 @@ *flags = (*flags & CODING_STATE_ISO2022_LOCK) & ~CODING_STATE_COMPOSITE; return 1; +#endif /* ENABLE_COMPOSITE_CHARS */ /**** directionality ****/ @@ -3785,14 +3793,18 @@ enum eol_type eol_type; struct decoding_stream *str = DECODING_STREAM_DATA (decoding); Lisp_Object coding_system; +#ifdef ENABLE_COMPOSITE_CHARS unsigned_char_dynarr *real_dst = dst; +#endif CODING_STREAM_DECOMPOSE (str, flags, ch); eol_type = str->eol_type; XSETCODING_SYSTEM (coding_system, str->codesys); +#ifdef ENABLE_COMPOSITE_CHARS if (flags & CODING_STATE_COMPOSITE) dst = str->iso2022.composite_chars; +#endif /* ENABLE_COMPOSITE_CHARS */ while (n--) { @@ -3806,6 +3818,7 @@ { switch (str->iso2022.esc) { +#ifdef ENABLE_COMPOSITE_CHARS case ISO_ESC_START_COMPOSITE: if (str->iso2022.composite_chars) Dynarr_reset (str->iso2022.composite_chars); @@ -3824,6 +3837,7 @@ Dynarr_add_many (dst, comstr, len); break; } +#endif /* ENABLE_COMPOSITE_CHARS */ case ISO_ESC_LITERAL: DECODE_ADD_BINARY_CHAR (c, dst); @@ -4109,11 +4123,13 @@ Lisp_Object charset; int half; +#ifdef ENABLE_COMPOSITE_CHARS /* flags for handling composite chars. We do a little switcharoo on the source while we're outputting the composite char. */ unsigned int saved_n = 0; CONST unsigned char *saved_src = NULL; int in_composite = 0; +#endif /* ENABLE_COMPOSITE_CHARS */ CODING_STREAM_DECOMPOSE (str, flags, ch); eol_type = CODING_SYSTEM_EOL_TYPE (str->codesys); @@ -4121,7 +4137,9 @@ charset = str->iso2022.current_charset; half = str->iso2022.current_half; +#ifdef ENABLE_COMPOSITE_CHARS back_to_square_n: +#endif while (n--) { c = *src++; @@ -4180,7 +4198,10 @@ if (LEADING_BYTE_PREFIX_P(c)) ch = c; else if (!EQ (charset, Vcharset_control_1) - && !EQ (charset, Vcharset_composite)) +#ifdef ENABLE_COMPOSITE_CHARS + && !EQ (charset, Vcharset_composite) +#endif + ) { int reg; @@ -4300,6 +4321,7 @@ } else if (ch) { +#ifdef ENABLE_COMPOSITE_CHARS if (EQ (charset, Vcharset_composite)) { if (in_composite) @@ -4323,6 +4345,7 @@ } } else +#endif /* ENABLE_COMPOSITE_CHARS */ { Dynarr_add (dst, ch & charmask); Dynarr_add (dst, c & charmask); @@ -4355,6 +4378,7 @@ } } +#ifdef ENABLE_COMPOSITE_CHARS if (in_composite) { n = saved_n; @@ -4364,6 +4388,7 @@ Dynarr_add (dst, '1'); /* end composing */ goto back_to_square_n; /* Wheeeeeeeee ..... */ } +#endif /* ENABLE_COMPOSITE_CHARS */ if (char_boundary && flags & CODING_STATE_END) { @@ -4489,27 +4514,25 @@ (EQ ((Vfile_name_coding_system), Qbinary))) ? \ Qnil : Fget_coding_system (Vfile_name_coding_system)) -/* #### not correct for all values of `fmt'! */ -#ifdef MULE -#define FMT_CODING_SYSTEM(fmt) \ - (((fmt) == FORMAT_FILENAME) ? FILE_NAME_CODING_SYSTEM : \ - ((fmt) == FORMAT_CTEXT ) ? Fget_coding_system (Qctext) : \ - ((fmt) == FORMAT_TERMINAL) ? FILE_NAME_CODING_SYSTEM : \ - Qnil) -#else -#define FMT_CODING_SYSTEM(fmt) \ - (((fmt) == FORMAT_FILENAME) ? FILE_NAME_CODING_SYSTEM : \ - ((fmt) == FORMAT_TERMINAL) ? FILE_NAME_CODING_SYSTEM : \ - Qnil) -#endif - Extbyte * convert_to_external_format (CONST Bufbyte *ptr, Bytecount len, Extcount *len_out, enum external_data_format fmt) { - Lisp_Object coding_system = FMT_CODING_SYSTEM (fmt); + Lisp_Object coding_system; + + /* #### not correct for all values of `fmt'! */ + if (fmt == FORMAT_FILENAME || fmt == FORMAT_TERMINAL) + coding_system = FILE_NAME_CODING_SYSTEM; +#ifdef MULE + else if (fmt == FORMAT_CTEXT) + coding_system = Fget_coding_system (Qctext); +#endif + else + coding_system = Qnil; + + /* Lisp_Object coding_system = FMT_CODING_SYSTEM (fmt); */ if (!conversion_out_dynarr) conversion_out_dynarr = Dynarr_new (Extbyte); @@ -4577,7 +4600,19 @@ Bytecount *len_out, enum external_data_format fmt) { - Lisp_Object coding_system = FMT_CODING_SYSTEM (fmt); + Lisp_Object coding_system; + + /* #### not correct for all values of `fmt'! */ + if (fmt == FORMAT_FILENAME || fmt == FORMAT_TERMINAL) + coding_system = FILE_NAME_CODING_SYSTEM; +#ifdef MULE + else if (fmt == FORMAT_CTEXT) + coding_system = Fget_coding_system (Qctext); +#endif + else + coding_system = Qnil; + + /* Lisp_Object coding_system = FMT_CODING_SYSTEM (fmt); */ if (!conversion_in_dynarr) conversion_in_dynarr = Dynarr_new (Bufbyte);