]> code.delx.au - gnu-emacs/blobdiff - src/coding.c
(Version, mh-version): Update for release 8.0.
[gnu-emacs] / src / coding.c
index fa9a37b94527aa18d5ff205d678ca67cc020f640..bd96b5cc068a5fec9b7b08dd62d2caa6cdb39f34 100644 (file)
@@ -1,7 +1,9 @@
 /* Coding system handler (conversion, detection, and etc).
-   Copyright (C) 1995,97,1998,2002,2003  Electrotechnical Laboratory, JAPAN.
-   Licensed to the Free Software Foundation.
-   Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2001, 2002, 2003, 2004, 2005,
+                 2006 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1997, 1998, 2002, 2003, 2004, 2005
+     National Institute of Advanced Industrial Science and Technology (AIST)
+     Registration Number H14PRO021
 
 This file is part of GNU Emacs.
 
@@ -733,7 +735,7 @@ detect_coding_emacs_mule (src, src_end, multibytep)
          c = -1;                                               \
        else                                                    \
          {                                                     \
-           c -= 0xA0;                                          \
+           c -= 0x80;                                          \
            *p++ = c;                                           \
          }                                                     \
       }                                                                \
@@ -871,7 +873,7 @@ decode_composition_emacs_mule (coding, src, src_end,
          component[ncomponent] = c;
        }
     }
-  else
+  else if (c >= 0x80)
     {
       /* This may be an old Emacs 20 style format.  See the comment at
         the section 2 of this file.  */
@@ -923,6 +925,8 @@ decode_composition_emacs_mule (coding, src, src_end,
       else
        return 0;
     }
+  else
+    return 0;
 
   if (buf == bufp || dst + (bufp - buf) <= (dst_bytes ? dst_end : src))
     {
@@ -3603,6 +3607,8 @@ setup_coding_system (coding_system, coding)
     {
       coding->eol_type = CODING_EOL_UNDECIDED;
       coding->common_flags = CODING_REQUIRE_DETECTION_MASK;
+      if (system_eol_type != CODING_EOL_LF)
+       coding->common_flags |= CODING_REQUIRE_ENCODING_MASK;
     }
   else if (XFASTINT (eol_type) == 1)
     {
@@ -3918,9 +3924,12 @@ setup_coding_system (coding_system, coding)
   coding->type = coding_type_no_conversion;
   coding->category_idx = CODING_CATEGORY_IDX_BINARY;
   coding->common_flags = 0;
-  coding->eol_type = CODING_EOL_LF;
+  coding->eol_type = NILP (coding_system) ? system_eol_type : CODING_EOL_LF;
+  if (coding->eol_type != CODING_EOL_LF)
+    coding->common_flags
+      |= CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK;
   coding->pre_write_conversion = coding->post_read_conversion = Qnil;
-  return -1;
+  return NILP (coding_system) ? 0 : -1;
 }
 
 /* Free memory blocks allocated for storing composition information.  */
@@ -4994,6 +5003,8 @@ encode_coding (coding, source, destination, src_bytes, dst_bytes)
   coding->consumed = coding->consumed_char = 0;
   coding->errors = 0;
   coding->result = CODING_FINISH_NORMAL;
+  if (coding->eol_type == CODING_EOL_UNDECIDED)
+    coding->eol_type = system_eol_type;
 
   switch (coding->type)
     {
@@ -5250,6 +5261,8 @@ shrink_encoding_region (beg, end, coding, str)
   if (coding->type == coding_type_ccl
       || coding->eol_type == CODING_EOL_CRLF
       || coding->eol_type == CODING_EOL_CR
+      || (coding->eol_type == CODING_EOL_UNDECIDED
+         && system_eol_type != CODING_EOL_LF)
       || (coding->cmp_data && coding->cmp_data->used > 0))
     {
       /* We can't skip any data.  */
@@ -5360,10 +5373,15 @@ static Lisp_Object
 code_convert_region_unwind (arg)
      Lisp_Object arg;
 {
+  struct gcpro gcpro1;
+  GCPRO1 (arg);
+
   inhibit_pre_post_conversion = 0;
   Vlast_coding_system_used = XCAR (arg);
   for (arg = XCDR (arg); ! NILP (arg); arg = XCDR (arg))
     Fkill_buffer (XCAR (arg));
+
+  UNGCPRO;
   return Qnil;
 }
 
@@ -7100,7 +7118,7 @@ code_convert_region1 (start, end, coding_system, encodep)
   from = XFASTINT (start);
   to = XFASTINT (end);
 
-  if (NILP (coding_system))
+  if (NILP (coding_system) && system_eol_type == CODING_EOL_LF)
     return make_number (to - from);
 
   if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0)
@@ -7155,7 +7173,7 @@ code_convert_string1 (string, coding_system, nocopy, encodep)
   CHECK_STRING (string);
   CHECK_SYMBOL (coding_system);
 
-  if (NILP (coding_system))
+  if (NILP (coding_system) && system_eol_type == CODING_EOL_LF)
     return (NILP (nocopy) ? Fcopy_sequence (string) : string);
 
   if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0)
@@ -7214,7 +7232,7 @@ code_convert_string_norecord (string, coding_system, encodep)
   CHECK_STRING (string);
   CHECK_SYMBOL (coding_system);
 
-  if (NILP (coding_system))
+  if (NILP (coding_system) && system_eol_type == CODING_EOL_LF)
     return string;
 
   if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0)