Commit 24a73b0a authored by Kenichi Handa's avatar Kenichi Handa

(enum iso_code_class_type): Delete ISO_carriage_return.

(CODING_GET_INFO): Delete argument eol_type.  Callers changed.
(decode_coding_utf_8): Don't do eol converion.
(detect_coding_utf_16): Check coding->src_chars, not
coding->src_bytes.  Add heuristics for those that have no
signature.
(decode_coding_emacs_mule): Don't do eol converion.
(decode_coding_iso_2022): Likewise.
(decode_coding_sjis): Likewise.
(decode_coding_big5): Likewise.
(decode_coding_charset): Likewise.
(adjust_coding_eol_type): Return a new coding system.
(detect_coding): Don't detect eol.  Fix for utf-16 detection.
(decode_eol): In case of CRLF->LF conversion, use del_range_2 on
each change.
(decode_coding): Pay attention to undo_list.  Do eol convesion for
all types of coding-systems (if necessary).
(Vcode_conversion_work_buf_list): Delete it.
(Vcode_conversion_reused_workbuf): Renamed from
Vcode_conversion_reused_work_buf.
(Vcode_conversion_workbuf_name): New variable.
(reused_workbuf_in_use): New variable.
(make_conversion_work_buffer): Delete the arg DEPTH.
(code_conversion_restore): Argument changed to cons.
(code_conversion_save): Delete the argument BUFFER.  Callers
changed.
(detect_coding_system): New argument src_chars.  Callers changed.
Fix for utf-16 detection.
(init_coding_once): Don't use ISO_carriage_return.
(syms_of_coding): Initialized Vcode_conversion_workbuf_name and
reused_workbuf_in_use.
parent 8a0e01e2
......@@ -491,7 +491,6 @@ enum iso_code_class_type
ISO_control_0, /* Control codes in the range
0x00..0x1F and 0x7F, except for the
following 5 codes. */
ISO_carriage_return, /* ISO_CODE_CR (0x0D) */
ISO_shift_out, /* ISO_CODE_SO (0x0E) */
ISO_shift_in, /* ISO_CODE_SI (0x0F) */
ISO_single_shift_2_7, /* ISO_CODE_SS2_7 (0x19) */
......@@ -710,13 +709,10 @@ static struct coding_system coding_categories[coding_category_max];
#define max(a, b) ((a) > (b) ? (a) : (b))
#endif
#define CODING_GET_INFO(coding, attrs, eol_type, charset_list) \
do { \
attrs = CODING_ID_ATTRS (coding->id); \
eol_type = CODING_ID_EOL_TYPE (coding->id); \
if (VECTORP (eol_type)) \
eol_type = Qunix; \
charset_list = CODING_ATTR_CHARSET_LIST (attrs); \
#define CODING_GET_INFO(coding, attrs, charset_list) \
do { \
(attrs) = CODING_ID_ATTRS ((coding)->id); \
(charset_list) = CODING_ATTR_CHARSET_LIST (attrs); \
} while (0)
......@@ -1132,9 +1128,9 @@ decode_coding_utf_8 (coding)
int *charbuf_end = charbuf + coding->charbuf_size;
int consumed_chars = 0, consumed_chars_base;
int multibytep = coding->src_multibyte;
Lisp_Object attr, eol_type, charset_list;
Lisp_Object attr, charset_list;
CODING_GET_INFO (coding, attr, eol_type, charset_list);
CODING_GET_INFO (coding, attr, charset_list);
while (1)
{
......@@ -1150,21 +1146,6 @@ decode_coding_utf_8 (coding)
if (UTF_8_1_OCTET_P(c1))
{
c = c1;
if (c == '\r')
{
if (EQ (eol_type, Qdos))
{
if (src == src_end)
{
coding->result = CODING_RESULT_INSUFFICIENT_SRC;
goto no_more_source;
}
if (*src == '\n')
ONE_MORE_BYTE (c);
}
else if (EQ (eol_type, Qmac))
c = '\n';
}
}
else
{
......@@ -1325,27 +1306,52 @@ detect_coding_utf_16 (coding, detect_info)
int c1, c2;
detect_info->checked |= CATEGORY_MASK_UTF_16;
if (coding->mode & CODING_MODE_LAST_BLOCK
&& (coding->src_bytes & 1))
&& (coding->src_chars & 1))
{
detect_info->rejected |= CATEGORY_MASK_UTF_16;
return 0;
}
ONE_MORE_BYTE (c1);
ONE_MORE_BYTE (c2);
if ((c1 == 0xFF) && (c2 == 0xFE))
{
detect_info->found |= (CATEGORY_MASK_UTF_16_LE
| CATEGORY_MASK_UTF_16_AUTO);
detect_info->rejected |= CATEGORY_MASK_UTF_16_BE;
detect_info->rejected |= (CATEGORY_MASK_UTF_16_BE
| CATEGORY_MASK_UTF_16_BE_NOSIG
| CATEGORY_MASK_UTF_16_LE_NOSIG);
}
else if ((c1 == 0xFE) && (c2 == 0xFF))
{
detect_info->found |= (CATEGORY_MASK_UTF_16_BE
| CATEGORY_MASK_UTF_16_AUTO);
detect_info->rejected |= CATEGORY_MASK_UTF_16_LE;
detect_info->rejected |= (CATEGORY_MASK_UTF_16_LE
| CATEGORY_MASK_UTF_16_BE_NOSIG
| CATEGORY_MASK_UTF_16_LE_NOSIG);
}
else
{
unsigned char b1[256], b2[256];
int b1_variants = 1, b2_variants = 1;
int n;
bzero (b1, 256), bzero (b2, 256);
b1[c1]++, b2[c2]++;
for (n = 0; n < 256 && src < src_end; n++)
{
ONE_MORE_BYTE (c1);
ONE_MORE_BYTE (c2);
if (! b1[c1++]) b1_variants++;
if (! b2[c2++]) b2_variants++;
}
if (b1_variants < b2_variants)
detect_info->found |= CATEGORY_MASK_UTF_16_BE_NOSIG;
else
detect_info->found |= CATEGORY_MASK_UTF_16_LE_NOSIG;
detect_info->rejected
|= (CATEGORY_MASK_UTF_16_BE | CATEGORY_MASK_UTF_16_LE);
}
no_more_source:
return 1;
......@@ -1365,9 +1371,9 @@ decode_coding_utf_16 (coding)
enum utf_16_bom_type bom = CODING_UTF_16_BOM (coding);
enum utf_16_endian_type endian = CODING_UTF_16_ENDIAN (coding);
int surrogate = CODING_UTF_16_SURROGATE (coding);
Lisp_Object attr, eol_type, charset_list;
Lisp_Object attr, charset_list;
CODING_GET_INFO (coding, attr, eol_type, charset_list);
CODING_GET_INFO (coding, attr, charset_list);
if (bom == utf_16_with_bom)
{
......@@ -1460,10 +1466,10 @@ encode_coding_utf_16 (coding)
enum utf_16_bom_type bom = CODING_UTF_16_BOM (coding);
int big_endian = CODING_UTF_16_ENDIAN (coding) == utf_16_big_endian;
int produced_chars = 0;
Lisp_Object attrs, eol_type, charset_list;
Lisp_Object attrs, charset_list;
int c;
CODING_GET_INFO (coding, attrs, eol_type, charset_list);
CODING_GET_INFO (coding, attrs, charset_list);
if (bom != utf_16_without_bom)
{
......@@ -1928,12 +1934,12 @@ decode_coding_emacs_mule (coding)
int *charbuf_end = charbuf + coding->charbuf_size - MAX_ANNOTATION_LENGTH;
int consumed_chars = 0, consumed_chars_base;
int multibytep = coding->src_multibyte;
Lisp_Object attrs, eol_type, charset_list;
Lisp_Object attrs, charset_list;
int char_offset = coding->produced_char;
int last_offset = char_offset;
int last_id = charset_ascii;
CODING_GET_INFO (coding, attrs, eol_type, charset_list);
CODING_GET_INFO (coding, attrs, charset_list);
while (1)
{
......@@ -1949,21 +1955,6 @@ decode_coding_emacs_mule (coding)
if (c < 0x80)
{
if (c == '\r')
{
if (EQ (eol_type, Qdos))
{
if (src == src_end)
{
coding->result = CODING_RESULT_INSUFFICIENT_SRC;
goto no_more_source;
}
if (*src == '\n')
ONE_MORE_BYTE (c);
}
else if (EQ (eol_type, Qmac))
c = '\n';
}
*charbuf++ = c;
char_offset++;
}
......@@ -2052,11 +2043,11 @@ encode_coding_emacs_mule (coding)
unsigned char *dst_end = coding->destination + coding->dst_bytes;
int safe_room = 8;
int produced_chars = 0;
Lisp_Object attrs, eol_type, charset_list;
Lisp_Object attrs, charset_list;
int c;
int preferred_charset_id = -1;
CODING_GET_INFO (coding, attrs, eol_type, charset_list);
CODING_GET_INFO (coding, attrs, charset_list);
if (! EQ (charset_list, Vemacs_mule_charset_list))
{
CODING_ATTR_CHARSET_LIST (attrs)
......@@ -2806,12 +2797,12 @@ decode_coding_iso_2022 (coding)
int components[MAX_COMPOSITION_COMPONENTS * 2 + 1];
int component_idx;
int component_len;
Lisp_Object attrs, eol_type, charset_list;
Lisp_Object attrs, charset_list;
int char_offset = coding->produced_char;
int last_offset = char_offset;
int last_id = charset_ascii;
CODING_GET_INFO (coding, attrs, eol_type, charset_list);
CODING_GET_INFO (coding, attrs, charset_list);
setup_iso_safe_charsets (attrs);
while (1)
......@@ -2877,24 +2868,6 @@ decode_coding_iso_2022 (coding)
charset = CHARSET_FROM_ID (charset_id_1);
break;
case ISO_carriage_return:
if (c1 == '\r')
{
if (EQ (eol_type, Qdos))
{
if (src == src_end)
{
coding->result = CODING_RESULT_INSUFFICIENT_SRC;
goto no_more_source;
}
if (*src == '\n')
ONE_MORE_BYTE (c1);
}
else if (EQ (eol_type, Qmac))
c1 = '\n';
}
/* fall through */
case ISO_control_0:
MAYBE_FINISH_COMPOSITION ();
charset = CHARSET_FROM_ID (charset_ascii);
......@@ -3648,7 +3621,11 @@ encode_coding_iso_2022 (coding)
int c;
int preferred_charset_id = -1;
CODING_GET_INFO (coding, attrs, eol_type, charset_list);
CODING_GET_INFO (coding, attrs, charset_list);
eol_type = CODING_ID_EOL_TYPE (coding->id);
if (VECTORP (eol_type))
eol_type = Qunix;
setup_iso_safe_charsets (attrs);
/* Charset list may have been changed. */
charset_list = CODING_ATTR_CHARSET_LIST (attrs); \
......@@ -3931,12 +3908,12 @@ decode_coding_sjis (coding)
int consumed_chars = 0, consumed_chars_base;
int multibytep = coding->src_multibyte;
struct charset *charset_roman, *charset_kanji, *charset_kana;
Lisp_Object attrs, eol_type, charset_list, val;
Lisp_Object attrs, charset_list, val;
int char_offset = coding->produced_char;
int last_offset = char_offset;
int last_id = charset_ascii;
CODING_GET_INFO (coding, attrs, eol_type, charset_list);
CODING_GET_INFO (coding, attrs, charset_list);
val = charset_list;
charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val);
......@@ -3946,6 +3923,7 @@ decode_coding_sjis (coding)
while (1)
{
int c, c1;
struct charset *charset;
src_base = src;
consumed_chars_base = consumed_chars;
......@@ -3955,60 +3933,40 @@ decode_coding_sjis (coding)
ONE_MORE_BYTE (c);
if (c == '\r')
{
if (EQ (eol_type, Qdos))
{
if (src == src_end)
{
coding->result = CODING_RESULT_INSUFFICIENT_SRC;
goto no_more_source;
}
if (*src == '\n')
ONE_MORE_BYTE (c);
}
else if (EQ (eol_type, Qmac))
c = '\n';
}
if (c < 0x80)
charset = charset_roman;
else
{
struct charset *charset;
if (c < 0x80)
charset = charset_roman;
else
if (c >= 0xF0)
goto invalid_code;
if (c < 0xA0 || c >= 0xE0)
{
if (c >= 0xF0)
goto invalid_code;
if (c < 0xA0 || c >= 0xE0)
{
/* SJIS -> JISX0208 */
ONE_MORE_BYTE (c1);
if (c1 < 0x40 || c1 == 0x7F || c1 > 0xFC)
goto invalid_code;
c = (c << 8) | c1;
SJIS_TO_JIS (c);
charset = charset_kanji;
}
else if (c > 0xA0)
{
/* SJIS -> JISX0201-Kana */
c &= 0x7F;
charset = charset_kana;
}
else
/* SJIS -> JISX0208 */
ONE_MORE_BYTE (c1);
if (c1 < 0x40 || c1 == 0x7F || c1 > 0xFC)
goto invalid_code;
c = (c << 8) | c1;
SJIS_TO_JIS (c);
charset = charset_kanji;
}
if (charset->id != charset_ascii
&& last_id != charset->id)
else if (c > 0xA0)
{
if (last_id != charset_ascii)
ADD_CHARSET_DATA (charbuf, last_offset, char_offset, last_id);
last_id = charset->id;
last_offset = char_offset;
/* SJIS -> JISX0201-Kana */
c &= 0x7F;
charset = charset_kana;
}
CODING_DECODE_CHAR (coding, src, src_base, src_end, charset, c, c);
else
goto invalid_code;
}
if (charset->id != charset_ascii
&& last_id != charset->id)
{
if (last_id != charset_ascii)
ADD_CHARSET_DATA (charbuf, last_offset, char_offset, last_id);
last_id = charset->id;
last_offset = char_offset;
}
CODING_DECODE_CHAR (coding, src, src_base, src_end, charset, c, c);
*charbuf++ = c;
char_offset++;
continue;
......@@ -4042,12 +4000,12 @@ decode_coding_big5 (coding)
int consumed_chars = 0, consumed_chars_base;
int multibytep = coding->src_multibyte;
struct charset *charset_roman, *charset_big5;
Lisp_Object attrs, eol_type, charset_list, val;
Lisp_Object attrs, charset_list, val;
int char_offset = coding->produced_char;
int last_offset = char_offset;
int last_id = charset_ascii;
CODING_GET_INFO (coding, attrs, eol_type, charset_list);
CODING_GET_INFO (coding, attrs, charset_list);
val = charset_list;
charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val);
charset_big5 = CHARSET_FROM_ID (XINT (XCAR (val)));
......@@ -4055,6 +4013,7 @@ decode_coding_big5 (coding)
while (1)
{
int c, c1;
struct charset *charset;
src_base = src;
consumed_chars_base = consumed_chars;
......@@ -4064,48 +4023,28 @@ decode_coding_big5 (coding)
ONE_MORE_BYTE (c);
if (c == '\r')
if (c < 0x80)
charset = charset_roman;
else
{
if (EQ (eol_type, Qdos))
{
if (src == src_end)
{
coding->result = CODING_RESULT_INSUFFICIENT_SRC;
goto no_more_source;
}
if (*src == '\n')
ONE_MORE_BYTE (c);
}
else if (EQ (eol_type, Qmac))
c = '\n';
/* BIG5 -> Big5 */
if (c < 0xA1 || c > 0xFE)
goto invalid_code;
ONE_MORE_BYTE (c1);
if (c1 < 0x40 || (c1 > 0x7E && c1 < 0xA1) || c1 > 0xFE)
goto invalid_code;
c = c << 8 | c1;
charset = charset_big5;
}
else
if (charset->id != charset_ascii
&& last_id != charset->id)
{
struct charset *charset;
if (c < 0x80)
charset = charset_roman;
else
{
/* BIG5 -> Big5 */
if (c < 0xA1 || c > 0xFE)
goto invalid_code;
ONE_MORE_BYTE (c1);
if (c1 < 0x40 || (c1 > 0x7E && c1 < 0xA1) || c1 > 0xFE)
goto invalid_code;
c = c << 8 | c1;
charset = charset_big5;
}
if (charset->id != charset_ascii
&& last_id != charset->id)
{
if (last_id != charset_ascii)
ADD_CHARSET_DATA (charbuf, last_offset, char_offset, last_id);
last_id = charset->id;
last_offset = char_offset;
}
CODING_DECODE_CHAR (coding, src, src_base, src_end, charset, c, c);
if (last_id != charset_ascii)
ADD_CHARSET_DATA (charbuf, last_offset, char_offset, last_id);
last_id = charset->id;
last_offset = char_offset;
}
CODING_DECODE_CHAR (coding, src, src_base, src_end, charset, c, c);
*charbuf++ = c;
char_offset++;
continue;
......@@ -4146,12 +4085,12 @@ encode_coding_sjis (coding)
unsigned char *dst_end = coding->destination + coding->dst_bytes;
int safe_room = 4;
int produced_chars = 0;
Lisp_Object attrs, eol_type, charset_list, val;
Lisp_Object attrs, charset_list, val;
int ascii_compatible;
struct charset *charset_roman, *charset_kanji, *charset_kana;
int c;
CODING_GET_INFO (coding, attrs, eol_type, charset_list);
CODING_GET_INFO (coding, attrs, charset_list);
val = charset_list;
charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val);
charset_kana = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val);
......@@ -4221,12 +4160,12 @@ encode_coding_big5 (coding)
unsigned char *dst_end = coding->destination + coding->dst_bytes;
int safe_room = 4;
int produced_chars = 0;
Lisp_Object attrs, eol_type, charset_list, val;
Lisp_Object attrs, charset_list, val;
int ascii_compatible;
struct charset *charset_roman, *charset_big5;
int c;
CODING_GET_INFO (coding, attrs, eol_type, charset_list);
CODING_GET_INFO (coding, attrs, charset_list);
val = charset_list;
charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val);
charset_big5 = CHARSET_FROM_ID (XINT (XCAR (val)));
......@@ -4340,9 +4279,9 @@ decode_coding_ccl (coding)
struct ccl_program ccl;
int source_charbuf[1024];
int source_byteidx[1024];
Lisp_Object attrs, eol_type, charset_list;
Lisp_Object attrs, charset_list;
CODING_GET_INFO (coding, attrs, eol_type, charset_list);
CODING_GET_INFO (coding, attrs, charset_list);
setup_ccl_program (&ccl, CODING_CCL_DECODER (coding));
while (src < src_end)
......@@ -4420,9 +4359,9 @@ encode_coding_ccl (coding)
unsigned char *adjusted_dst_end = dst_end - 1;
int destination_charbuf[1024];
int i, produced_chars = 0;
Lisp_Object attrs, eol_type, charset_list;
Lisp_Object attrs, charset_list;
CODING_GET_INFO (coding, attrs, eol_type, charset_list);
CODING_GET_INFO (coding, attrs, charset_list);
setup_ccl_program (&ccl, CODING_CCL_ENCODER (coding));
ccl.last_block = coding->mode & CODING_MODE_LAST_BLOCK;
......@@ -4621,17 +4560,22 @@ decode_coding_charset (coding)
int *charbuf_end = charbuf + coding->charbuf_size - MAX_ANNOTATION_LENGTH;
int consumed_chars = 0, consumed_chars_base;
int multibytep = coding->src_multibyte;
Lisp_Object attrs, eol_type, charset_list, valids;
Lisp_Object attrs, charset_list, valids;
int char_offset = coding->produced_char;
int last_offset = char_offset;
int last_id = charset_ascii;
CODING_GET_INFO (coding, attrs, eol_type, charset_list);
CODING_GET_INFO (coding, attrs, charset_list);
valids = AREF (attrs, coding_attr_charset_valids);
while (1)
{
int c;
Lisp_Object val;
struct charset *charset;
int dim;
int len = 1;
unsigned code;
src_base = src;
consumed_chars_base = consumed_chars;
......@@ -4640,37 +4584,32 @@ decode_coding_charset (coding)
break;
ONE_MORE_BYTE (c);
if (c == '\r')
code = c;
val = AREF (valids, c);
if (NILP (val))
goto invalid_code;
if (INTEGERP (val))
{
/* Here we assume that no charset maps '\r' to something
else. */
if (EQ (eol_type, Qdos))
charset = CHARSET_FROM_ID (XFASTINT (val));
dim = CHARSET_DIMENSION (charset);
while (len < dim)
{
if (src == src_end)
{
coding->result = CODING_RESULT_INSUFFICIENT_SRC;
goto no_more_source;
}
if (*src == '\n')
ONE_MORE_BYTE (c);
ONE_MORE_BYTE (c);
code = (code << 8) | c;
len++;
}
else if (EQ (eol_type, Qmac))
c = '\n';
CODING_DECODE_CHAR (coding, src, src_base, src_end,
charset, code, c);
}
else
{
Lisp_Object val;
struct charset *charset;
int dim;
int len = 1;
unsigned code = c;
val = AREF (valids, c);
if (NILP (val))
goto invalid_code;
if (INTEGERP (val))
/* VAL is a list of charset IDs. It is assured that the
list is sorted by charset dimensions (smaller one
comes first). */
while (CONSP (val))
{
charset = CHARSET_FROM_ID (XFASTINT (val));
charset = CHARSET_FROM_ID (XFASTINT (XCAR (val)));
dim = CHARSET_DIMENSION (charset);
while (len < dim)
{
......@@ -4678,42 +4617,24 @@ decode_coding_charset (coding)
code = (code << 8) | c;
len++;
}
CODING_DECODE_CHAR (coding, src, src_base, src_end,
charset, code, c);
}
else
{
/* VAL is a list of charset IDs. It is assured that the
list is sorted by charset dimensions (smaller one
comes first). */
while (CONSP (val))
{
charset = CHARSET_FROM_ID (XFASTINT (XCAR (val)));
dim = CHARSET_DIMENSION (charset);
while (len < dim)
{
ONE_MORE_BYTE (c);
code = (code << 8) | c;
len++;
}
CODING_DECODE_CHAR (coding, src, src_base,
src_end, charset, code, c);
if (c >= 0)
break;
val = XCDR (val);
}
}
if (c < 0)
goto invalid_code;
if (charset->id != charset_ascii
&& last_id != charset->id)
{
if (last_id != charset_ascii)
ADD_CHARSET_DATA (charbuf, last_offset, char_offset, last_id);
last_id = charset->id;
last_offset = char_offset;
CODING_DECODE_CHAR (coding, src, src_base,
src_end, charset, code, c);
if (c >= 0)
break;
val = XCDR (val);
}
}
if (c < 0)
goto invalid_code;
if (charset->id != charset_ascii
&& last_id != charset->id)
{
if (last_id != charset_ascii)
ADD_CHARSET_DATA (charbuf, last_offset, char_offset, last_id);
last_id = charset->id;
last_offset = char_offset;
}
*charbuf++ = c;
char_offset++;
continue;
......@@ -4746,11 +4667,11 @@ encode_coding_charset (coding)
unsigned char *dst_end = coding->destination + coding->dst_bytes;
int safe_room = MAX_MULTIBYTE_LENGTH;
int produced_chars = 0;
Lisp_Object attrs, eol_type, charset_list;
Lisp_Object attrs, charset_list;
int ascii_compatible;
int c;
CODING_GET_INFO (coding, attrs, eol_type, charset_list);
CODING_GET_INFO (coding, attrs, charset_list);
ascii_compatible = ! NILP (CODING_ATTR_ASCII_COMPAT (attrs));
while (charbuf < charbuf_end)
......@@ -5250,7 +5171,7 @@ detect_eol (source, src_bytes, category)
}
static void
static Lisp_Object
adjust_coding_eol_type (coding, eol_seen)
struct coding_system *coding;
int eol_seen;
......@@ -5259,11 +5180,21 @@ adjust_coding_eol_type (coding, eol_seen)
eol_type = CODING_ID_EOL_TYPE (coding->id);
if (eol_seen & EOL_SEEN_LF)
coding->id = CODING_SYSTEM_ID (AREF (eol_type, 0));
{
coding->id = CODING_SYSTEM_ID (AREF (eol_type, 0));
eol_type = Qunix;
}
else if (eol_seen & EOL_SEEN_CRLF)
coding->id = CODING_SYSTEM_ID (AREF (eol_type, 1));
{
coding->id = CODING_SYSTEM_ID (AREF (eol_type, 1));
eol_type = Qdos;
}
else if (eol_seen & EOL_SEEN_CR)
coding->id = CODING_SYSTEM_ID (AREF (eol_type, 2));
{
coding->id = CODING_SYSTEM_ID (AREF (eol_type, 2));
eol_type = Qmac;
}
return eol_type;
}
/* Detect how a text specified in CODING is encoded. If a coding
......@@ -5289,14 +5220,18 @@ detect_coding (coding)
{
int c, i;
for (src = coding->source; src < src_end; src++)
for (i = 0, src = coding->source; src < src_end; i++, src++)
{
c = *src;
if (c & 0x80 || (c < 0x20 && (c == ISO_CODE_ESC
if (c & 0x80 || (c < 0x20 && (c == 0
|| c == ISO_CODE_ESC
|| c == ISO_CODE_SI
|| c == ISO_CODE_SO)))
break;
}
/* Skipped bytes must be even for utf-16 detector. */
if (i % 2)
src--;
coding->head_ascii = src - (coding->source + coding->consumed);
if (coding->head_ascii < coding->src_bytes)
......@@ -5324,7 +5259,16 @@ detect_coding (coding)
}
else if ((*(this->detector)) (coding, &detect_info)
&& detect_info.found & (1 << category))
break;
{
if (category == coding_category_utf_16_auto)
{