]> code.delx.au - gnu-emacs/blobdiff - src/coding.c
(Fexpt): Manually check for overflows, so that a power
[gnu-emacs] / src / coding.c
index 24c6ef0b6b1d631ebb65341f599a3740a00abe51..b6299097d55ed857092da067a9fcfc889eb6386b 100644 (file)
@@ -1,7 +1,8 @@
 /* Coding system handler (conversion, detection, and etc).
    Copyright (C) 2001, 2002, 2003, 2004, 2005,
-                 2006 Free Software Foundation, Inc.
-   Copyright (C) 1995, 1997, 1998, 2002, 2003, 2004, 2005
+                 2006, 2007 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+     2005, 2006, 2007
      National Institute of Advanced Industrial Science and Technology (AIST)
      Registration Number H14PRO021
 
@@ -9,7 +10,7 @@ This file is part of GNU Emacs.
 
 GNU Emacs is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
+the Free Software Foundation; either version 3, or (at your option)
 any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
@@ -4334,10 +4335,10 @@ detect_coding (coding, src, src_bytes)
 
 static int
 detect_eol_type (source, src_bytes, skip)
-     unsigned char *source;
+     const unsigned char *source;
      int src_bytes, *skip;
 {
-  unsigned char *src = source, *src_end = src + src_bytes;
+  const unsigned char *src = source, *src_end = src + src_bytes;
   unsigned char c;
   int total = 0;               /* How many end-of-lines are found so far.  */
   int eol_type = CODING_EOL_UNDECIDED;
@@ -4383,10 +4384,10 @@ detect_eol_type (source, src_bytes, skip)
 
 static int
 detect_eol_type_in_2_octet_form (source, src_bytes, skip, big_endian_p)
-     unsigned char *source;
+     const unsigned char *source;
      int src_bytes, *skip, big_endian_p;
 {
-  unsigned char *src = source, *src_end = src + src_bytes;
+  const unsigned char *src = source, *src_end = src + src_bytes;
   unsigned int c1, c2;
   int total = 0;               /* How many end-of-lines are found so far.  */
   int eol_type = CODING_EOL_UNDECIDED;
@@ -5577,6 +5578,8 @@ code_convert_region (from, from_byte, to, to_byte, coding, encodep, replace)
       inhibit_modification_hooks = saved_inhibit_modification_hooks;
     }
 
+  coding->heading_ascii = 0;
+
   if (! encodep && CODING_REQUIRE_DETECTION (coding))
     {
       /* We must detect encoding of text and eol format.  */
@@ -6221,6 +6224,8 @@ decode_coding_string (str, coding, nocopy)
   saved_coding_symbol = coding->symbol;
   coding->src_multibyte = STRING_MULTIBYTE (str);
   coding->dst_multibyte = 1;
+  coding->heading_ascii = 0;
+
   if (CODING_REQUIRE_DETECTION (coding))
     {
       /* See the comments in code_convert_region.  */
@@ -6433,6 +6438,7 @@ encode_coding_string (str, coding, nocopy)
   /* Try to skip the heading and tailing ASCIIs.  We can't skip them
      if we must run CCL program or there are compositions to
      encode.  */
+  coding->heading_ascii = 0;
   if (coding->type != coding_type_ccl
       && (! coding->cmp_data || coding->cmp_data->used == 0))
     {
@@ -7270,7 +7276,7 @@ Return the corresponding character.  */)
 }
 
 DEFUN ("encode-sjis-char", Fencode_sjis_char, Sencode_sjis_char, 1, 1, 0,
-       doc: /* Encode a Japanese character CHAR to shift_jis encoding.
+       doc: /* Encode a Japanese character CH to shift_jis encoding.
 Return the corresponding code in SJIS.  */)
      (ch)
      Lisp_Object ch;
@@ -7330,7 +7336,7 @@ Return the corresponding character.  */)
 }
 
 DEFUN ("encode-big5-char", Fencode_big5_char, Sencode_big5_char, 1, 1, 0,
-       doc: /* Encode the Big5 character CHAR to BIG5 coding system.
+       doc: /* Encode the Big5 character CH to BIG5 coding system.
 Return the corresponding character code in Big5.  */)
      (ch)
      Lisp_Object ch;
@@ -7466,6 +7472,8 @@ They may specify a coding system, a cons of coding systems,
 or a function symbol to call.
 In the last case, we call the function with one argument,
 which is a list of all the arguments given to this function.
+If the function can't decide a coding system, it can return
+`undecided' so that the normal code-detection is performed.
 
 If OPERATION is `insert-file-contents', the argument corresponding to
 TARGET may be a cons (FILENAME . BUFFER).  In that case, FILENAME is a
@@ -7474,7 +7482,7 @@ contents (not yet decoded).  If `file-coding-system-alist' specifies a
 function to call for FILENAME, that function should examine the
 contents of BUFFER instead of reading the file.
 
-usage: (find-operation-coding-system OPERATION ARGUMENTS ...)  */)
+usage: (find-operation-coding-system OPERATION ARGUMENTS...)  */)
      (nargs, args)
      int nargs;
      Lisp_Object *args;
@@ -7967,7 +7975,9 @@ and the cdr part is used for encoding.
 If VAL is a function symbol, the function must return a coding system
 or a cons of coding systems which are used as above.  The function is
 called with an argument that is a list of the arguments with which
-`find-operation-coding-system' was called.
+`find-operation-coding-system' was called.  If the function can't decide
+a coding system, it can return `undecided' so that the normal
+code-detection is performed.
 
 See also the function `find-operation-coding-system'
 and the variable `auto-coding-alist'.  */);