Commit 220eeac9 authored by Kenichi Handa's avatar Kenichi Handa

Fix previous changes.

parent f56a4450
...@@ -744,44 +744,42 @@ static struct coding_system coding_categories[coding_category_max]; ...@@ -744,44 +744,42 @@ static struct coding_system coding_categories[coding_category_max];
} while (0) } while (0)
/* Safely get two bytes from the source text pointed by SRC which ends /* Safely get two bytes from the source text pointed by SRC which ends
at SRC_END, and set C1 and C2 to those bytes. If there are not at SRC_END, and set C1 and C2 to those bytes while skipping the
enough bytes in the source for C1, it jumps to `no_more_source'. heading multibyte characters. If there are not enough bytes in the
If there are not enough bytes in the source for C2, set C2 to -1. source, it jumps to `no_more_source'. If multibytep is nonzero and
If multibytep is nonzero and a multibyte character is found at SRC, a multibyte character is found for C2, set C2 to the negative value
set C1 and/or C2 to the negative value of the character code. The of the character code. The caller should declare and set these
caller should declare and set these variables appropriately in variables appropriately in advance:
advance:
src, src_end, multibytep src, src_end, multibytep
It is intended that this macro is used in detect_coding_utf_16. */ It is intended that this macro is used in detect_coding_utf_16. */
#define TWO_MORE_BYTES(c1, c2) \ #define TWO_MORE_BYTES(c1, c2) \
do { \ do { \
if (src == src_end) \ do { \
goto no_more_source; \ if (src == src_end) \
c1 = *src++; \ goto no_more_source; \
if (multibytep && (c1 & 0x80)) \ c1 = *src++; \
{ \ if (multibytep && (c1 & 0x80)) \
if ((c1 & 0xFE) == 0xC0) \ { \
c1 = ((c1 & 1) << 6) | *src++; \ if ((c1 & 0xFE) == 0xC0) \
else \ c1 = ((c1 & 1) << 6) | *src++; \
{ \ else \
c1 = c2 = -1; \ { \
break; \ src += BYTES_BY_CHAR_HEAD (c1) - 1; \
} \ c1 = -1; \
} \ } \
if (src == src_end) \ } \
c2 = -1; \ } while (c1 < 0); \
else \ if (src == src_end) \
{ \ goto no_more_source; \
c2 = *src++; \ c2 = *src++; \
if (multibytep && (c2 & 0x80)) \ if (multibytep && (c2 & 0x80)) \
{ \ { \
if ((c2 & 0xFE) == 0xC0) \ if ((c2 & 0xFE) == 0xC0) \
c2 = ((c2 & 1) << 6) | *src++; \ c2 = ((c2 & 1) << 6) | *src++; \
else \ else \
c2 = -1; \ c2 = -1; \
} \ } \
} \
} while (0) } while (0)
...@@ -1633,7 +1631,7 @@ detect_coding_utf_16 (coding, detect_info) ...@@ -1633,7 +1631,7 @@ detect_coding_utf_16 (coding, detect_info)
| CATEGORY_MASK_UTF_16_BE_NOSIG | CATEGORY_MASK_UTF_16_BE_NOSIG
| CATEGORY_MASK_UTF_16_LE_NOSIG); | CATEGORY_MASK_UTF_16_LE_NOSIG);
} }
else if (c1 < 0 || c2 < 0) else if (c2 < 0)
{ {
detect_info->rejected |= CATEGORY_MASK_UTF_16; detect_info->rejected |= CATEGORY_MASK_UTF_16;
return 0; return 0;
...@@ -1656,7 +1654,7 @@ detect_coding_utf_16 (coding, detect_info) ...@@ -1656,7 +1654,7 @@ detect_coding_utf_16 (coding, detect_info)
while (1) while (1)
{ {
TWO_MORE_BYTES (c1, c2); TWO_MORE_BYTES (c1, c2);
if (c1 < 0 || c2 < 0) if (c2 < 0)
break; break;
if (! e[c1]) if (! e[c1])
{ {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment