$TERM is now set to dumb.
[bpt/emacs.git] / src / charset.h
index b49ed87..c20766f 100644 (file)
@@ -1,13 +1,16 @@
 /* Header for multibyte character handler.
-   Copyright (C) 1995, 1997, 1998 Electrotechnical Laboratory, JAPAN.
-   Licensed to the Free Software Foundation.
-   Copyright (C) 2001 Free Software Foundation, Inc.
+   Copyright (C) 2001, 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
 
 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,
@@ -17,8 +20,8 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with GNU Emacs; see the file COPYING.  If not, write to
-the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.  */
 
 #ifndef EMACS_CHARSET_H
 #define EMACS_CHARSET_H
@@ -129,6 +132,9 @@ extern int charset_katakana_jisx0201; /* JISX0201.Kana (Japanese Katakana) */
 extern int charset_latin_jisx0201; /* JISX0201.Roman (Japanese Roman) */
 extern int charset_big5_1;     /* Big5 Level 1 (Chinese Traditional) */
 extern int charset_big5_2;     /* Big5 Level 2 (Chinese Traditional) */
+extern int charset_mule_unicode_0100_24ff;
+extern int charset_mule_unicode_2500_33ff;
+extern int charset_mule_unicode_e000_ffff;
 
 /* Check if CH is an ASCII character or a base leading-code.
    Nowadays, any byte can be the first byte of a character in a
@@ -407,8 +413,8 @@ extern int width_by_char_head[256];
            | ((c1) <= 0 ? 0 : (((c1) & 0x7F) << 7))))))
 
 
-/* If GENERICP is nonzero, return nonzero iff C is a valid normal or
-   generic character.  If GENERICP is zero, return nonzero iff C is a
+/* If GENERICP is nonzero, return nonzero if C is a valid normal or
+   generic character.  If GENERICP is zero, return nonzero if C is a
    valid normal character.  */
 #define CHAR_VALID_P(c, genericp)      \
   ((c) >= 0                            \
@@ -444,7 +450,7 @@ extern int width_by_char_head[256];
 #define VALID_LEADING_CODE_P(code)     \
   (! NILP (CHARSET_TABLE_ENTRY (code)))
 
-/* Return 1 iff the byte sequence at unibyte string STR (LENGTH bytes)
+/* Return 1 if the byte sequence at unibyte string STR (LENGTH bytes)
    is valid as a multibyte form.  If valid, by a side effect, BYTES is
    set to the byte length of the multibyte form.  */
 
@@ -465,7 +471,7 @@ extern int width_by_char_head[256];
                     && VALID_LEADING_CODE_P (str[1]))))))))
 
 
-/* Return 1 iff the byte sequence at multibyte string STR is valid as
+/* Return 1 if the byte sequence at multibyte string STR is valid as
    a unibyte form.  By a side effect, BYTES is set to the byte length
    of one character at STR.  */
 
@@ -493,7 +499,7 @@ extern int width_by_char_head[256];
         c1 = CHAR_FIELD3 (c),                                              \
         c2 = -1)))
 
-/* Return 1 iff character C has valid printable glyph.  */
+/* Return 1 if character C has valid printable glyph.  */
 #define CHAR_PRINTABLE_P(c) (ASCII_BYTE_P (c) || char_printable_p (c))
 
 /* The charset of the character at STR is stored in CHARSET, and the
@@ -653,22 +659,34 @@ else
   } while (0)
 
 
-/* If P is after LIMIT, advance P to the previous character boundary.
-   It assumes that P is already at a character boundary of the sane
-   mulitbyte form whose beginning address is LIMIT.  */
+/* If P is after LIMIT, advance P to the previous character boundary.  */
 
 #define PREV_CHAR_BOUNDARY(p, limit)                                   \
   do {                                                                 \
     if ((p) > (limit))                                                 \
       {                                                                        \
        const unsigned char *p0 = (p);                                  \
+       const unsigned char *p_limit = max (limit, p0 - MAX_MULTIBYTE_LENGTH);\
        do {                                                            \
          p0--;                                                         \
-       } while (p0 >= limit && ! CHAR_HEAD_P (*p0));                   \
-       (p) = (BYTES_BY_CHAR_HEAD (*p0) == (p) - p0) ? p0 : (p) - 1;    \
+       } while (p0 >= p_limit && ! CHAR_HEAD_P (*p0));                 \
+       /* If BBCH(*p0) > p-p0, it means we were not on a boundary.  */ \
+       (p) = (BYTES_BY_CHAR_HEAD (*p0) >= (p) - p0) ? p0 : (p) - 1;    \
       }                                                                        \
   } while (0)
 
+#define AT_CHAR_BOUNDARY_P(result, p, limit)   \
+  do {                                         \
+    if (CHAR_HEAD_P (*(p)) || (p) <= limit)    \
+      /* Optimization for the common case. */  \
+      (result) = 1;                            \
+    else                                       \
+      {                                                \
+       const unsigned char *p_aux = (p)+1;     \
+       PREV_CHAR_BOUNDARY (p_aux, limit);      \
+       (result) = (p_aux == (p));              \
+      }                                                \
+} while (0)
 
 #ifdef emacs
 
@@ -820,7 +838,7 @@ while (0)
 /* This is the maximum byte length of multi-byte sequence.  */
 #define MAX_MULTIBYTE_LENGTH 4
 
-extern void invalid_character P_ ((int));
+extern void invalid_character P_ ((int)) NO_RETURN;
 
 extern int translate_char P_ ((Lisp_Object, int, int, int, int));
 extern int split_string P_ ((const unsigned char *, int, int *,