summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenichi Handa <handa@m17n.org>2009-07-08 02:28:31 +0000
committerKenichi Handa <handa@m17n.org>2009-07-08 02:28:31 +0000
commit38c829ca0d3eb288d8c3d5aed455108105dd9bec (patch)
tree057b9fe0a79f5c10aec9d1786825ed8595a46ede
parent2bbd6aa4a478b832602abd569ab3b7bb5e2c30c1 (diff)
downloademacs-38c829ca0d3eb288d8c3d5aed455108105dd9bec.tar.gz
(detect_coding_sjis): Handle shift_jis-2004 correctly.
(encode_coding_sjis): Fix the code range check.
-rw-r--r--src/ChangeLog7
-rw-r--r--src/coding.c12
2 files changed, 17 insertions, 2 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index deaed0fbc82..6007a436ca8 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
+2009-07-08 Kenichi Handa <handa@m17n.org>
+
+ * coding.h (JIS_TO_SJIS2): Fix the code range check.
+
+ * coding.c (detect_coding_sjis): Handle shift_jis-2004 correctly.
+ (encode_coding_sjis): Fix the code range check.
+
2009-07-07 Chong Yidong <cyd@stupidchicken.com>
* fileio.c (Fsubstitute_in_file_name, Ffile_name_directory)
diff --git a/src/coding.c b/src/coding.c
index 3fc43df636b..4ff1acab440 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -4671,6 +4671,12 @@ detect_coding_sjis (coding, detect_info)
int consumed_chars = 0;
int found = 0;
int c;
+ Lisp_Object attrs, charset_list;
+ int max_first_byte_of_2_byte_code;
+
+ CODING_GET_INFO (coding, attrs, charset_list);
+ max_first_byte_of_2_byte_code
+ = (XINT (Flength (charset_list)) > 3 ? 0xFC : 0xEF);
detect_info->checked |= CATEGORY_MASK_SJIS;
/* A coding system of this category is always ASCII compatible. */
@@ -4682,7 +4688,8 @@ detect_coding_sjis (coding, detect_info)
ONE_MORE_BYTE (c);
if (c < 0x80)
continue;
- if ((c >= 0x81 && c <= 0x9F) || (c >= 0xE0 && c <= 0xEF))
+ if ((c >= 0x81 && c <= 0x9F)
+ || (c >= 0xE0 && c <= max_first_byte_of_2_byte_code))
{
ONE_MORE_BYTE (c);
if (c < 0x40 || c == 0x7F || c > 0xFC)
@@ -5055,7 +5062,8 @@ encode_coding_sjis (coding)
int c1, c2;
c1 = code >> 8;
- if (c1 == 0x21 || (c1 >= 0x23 && c1 < 0x25)
+ if (c1 == 0x21 || (c1 >= 0x23 && c1 <= 0x25)
+ || c1 == 0x28
|| (c1 >= 0x2C && c1 <= 0x2F) || c1 >= 0x6E)
{
JIS_TO_SJIS2 (code);