(detect_coding_utf_16): Fix previous change.
[bpt/emacs.git] / src / coding.c
index 23690bc..cde56d9 100644 (file)
@@ -1665,10 +1665,11 @@ detect_coding_utf_16 (coding, detect_info)
       e[c1] = 1;
       o[c2] = 1;
 
-      detect_info->rejected
-       |= (CATEGORY_MASK_UTF_16_BE | CATEGORY_MASK_UTF_16_LE);
+      detect_info->rejected |= (CATEGORY_MASK_UTF_16_AUTO
+                               |CATEGORY_MASK_UTF_16_BE
+                               | CATEGORY_MASK_UTF_16_LE);
 
-      while (1)
+      while (detect_info->rejected != CATEGORY_MASK_UTF_16)
        {
          TWO_MORE_BYTES (c1, c2);
          if (c2 < 0)
@@ -1678,17 +1679,16 @@ detect_coding_utf_16 (coding, detect_info)
              e[c1] = 1;
              e_num++;
              if (e_num >= 128)
-               break;
+               detect_info->rejected |= CATEGORY_MASK_UTF_16_BE_NOSIG;
            }
          if (! o[c2])
            {
-             o[c1] = 1;
+             o[c2] = 1;
              o_num++;
              if (o_num >= 128)
-               break;
+               detect_info->rejected |= CATEGORY_MASK_UTF_16_LE_NOSIG;
            }
        }
-      detect_info->rejected |= CATEGORY_MASK_UTF_16;
       return 0;
     }
 
@@ -6623,6 +6623,12 @@ get_translation_table (attrs, encodep, max_lookup)
   Lisp_Object standard, translation_table;
   Lisp_Object val;
 
+  if (NILP (Venable_character_translation))
+    {
+      if (max_lookup)
+       *max_lookup = 0;
+      return Qnil;
+    }
   if (encodep)
     translation_table = CODING_ATTR_ENCODE_TBL (attrs),
       standard = Vstandard_translation_table_for_encode;