]> code.delx.au - gnu-emacs/commitdiff
Fix bug#16286 by the different way than 2014-01-26T00:32:30Z!eggert@cs.ucla.edu to...
authorKenichi Handa <handa@gnu.org>
Wed, 29 Jan 2014 13:21:25 +0000 (22:21 +0900)
committerKenichi Handa <handa@gnu.org>
Wed, 29 Jan 2014 13:21:25 +0000 (22:21 +0900)
src/ChangeLog
src/coding.c
src/coding.h
src/fileio.c

index 4ed9ef9d2cf1db6b9381f20e0d2077ce706bb09c..aa3a65ccb600d913b110e961f83ae4eaa3533d3a 100644 (file)
@@ -1,3 +1,16 @@
+2014-01-27  K. Handa  <handa@gnu.org>
+
+       Fix bug#16286 by the different way than revno:116158 to preserve
+       the code detection behavior of 24.3.
+
+       * coding.h (struct coding_system): New member detected_utf8_bytes.
+
+       * coding.c (detect_coding_utf_8): Set coding->detected_utf8_bytes.
+       (decode_coding_gap): Use short cut for UTF-8 file reading only
+       when coding->detected_utf8_bytes equals to coding->src_bytes.
+
+       * fileio.c (Finsert_file_contents): Cancel the previous change.
+
 2014-01-26  Jan Djärv  <jan.h.d@swipnet.se>
 
        * xterm.c (x_focus_changed): Check for non-X terminal-frame (Bug#16540)
index 01964eba4d3ec01ffb60ee033cd6a8d0da518eb2..654e39c0e3dd200b6dc5b25d524ad0ed03df60ec 100644 (file)
@@ -1300,6 +1300,7 @@ detect_coding_utf_8 (struct coding_system *coding,
           means that we found a valid non-ASCII characters.  */
        detect_info->found |= CATEGORY_MASK_UTF_8_AUTO | CATEGORY_MASK_UTF_8_NOSIG;
     }
+  coding->detected_utf8_bytes = src_base - coding->source;
   coding->detected_utf8_chars = nchars;
   return 1;
 }
@@ -7890,7 +7891,7 @@ decode_coding_gap (struct coding_system *coding,
   coding->dst_multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters));
 
   coding->head_ascii = -1;
-  coding->detected_utf8_chars = -1;
+  coding->detected_utf8_bytes = coding->detected_utf8_chars = -1;
   coding->eol_seen = EOL_SEEN_NONE;
   if (CODING_REQUIRE_DETECTION (coding))
     detect_coding (coding);
@@ -7907,7 +7908,8 @@ decode_coding_gap (struct coding_system *coding,
       if (chars != bytes)
        {
          /* There exists a non-ASCII byte.  */
-         if (EQ (CODING_ATTR_TYPE (attrs), Qutf_8))
+         if (EQ (CODING_ATTR_TYPE (attrs), Qutf_8)
+             && coding->detected_utf8_bytes == coding->src_bytes)
            {
              if (coding->detected_utf8_chars >= 0)
                chars = coding->detected_utf8_chars;
index c9c19762d80d4509cd0cc5c52d71c74903de2ad7..4e8b1056e434d67b275d78b9dd9a287f1d1e6625 100644 (file)
@@ -468,7 +468,9 @@ struct coding_system
      the eol format.  */
   ptrdiff_t head_ascii;
 
-  ptrdiff_t detected_utf8_chars;
+  /* How many bytes/chars at the source are detected as valid utf-8
+     sequence.  Set by detect_coding_utf_8.  */
+  ptrdiff_t detected_utf8_bytes, detected_utf8_chars;
 
   /* Used internally in coding.c.  See the comment of detect_ascii.  */
   int eol_seen;
index 22db4602249ba39ff0b2b3c2dcd39699e98991fd..d03a2bcf02f9c1a793d2b6a089097c20c23f4977 100644 (file)
@@ -4298,7 +4298,6 @@ by calling `format-decode', which see.  */)
       Z_BYTE -= inserted;
       ZV -= inserted;
       Z -= inserted;
-      coding.mode |= CODING_MODE_LAST_BLOCK;
       decode_coding_gap (&coding, inserted, inserted);
       inserted = coding.produced_char;
       coding_system = CODING_ID_NAME (coding.id);