]> code.delx.au - gnu-emacs/blobdiff - src/character.h
* frame.c (x_set_alpha) [NS_IMPL_COCOA]: Call x_set_frame_alpha.
[gnu-emacs] / src / character.h
index ce36cdf85ff80861f24e30c94caa888bcf3f76dc..34e696e5083476acce1fb4eea34b672f75fc38c3 100644 (file)
@@ -68,6 +68,13 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
    ? (c) - 0x3FFF00            \
    : multibyte_char_to_unibyte (c, Qnil))
 
+/* Return the raw 8-bit byte for character C,
+   or -1 if C doesn't correspond to a byte.  */
+#define CHAR_TO_BYTE_SAFE(c)   \
+  (CHAR_BYTE8_P (c)            \
+   ? (c) - 0x3FFF00            \
+   : multibyte_char_to_unibyte_safe (c))
+
 /* Nonzero iff BYTE is the 1st byte of a multibyte form of a character
    that corresponds to a raw 8-bit byte.  */
 #define CHAR_BYTE8_HEAD_P(byte) ((byte) == 0xC0 || (byte) == 0xC1)
@@ -94,13 +101,14 @@ extern char unibyte_has_multibyte_table[256];
   } while (0)
 
 
-/* If C is not ASCII, make it multibyte.  It assumes C < 256.  */
-#define MAKE_CHAR_MULTIBYTE(c) ((c) = unibyte_to_multibyte_table[(c)])
+/* If C is not ASCII, make it multibyte.  Assumes C < 256.  */
+#define MAKE_CHAR_MULTIBYTE(c) \
+  (eassert ((c) >= 0 && (c) < 256), (c) = unibyte_to_multibyte_table[(c)])
 
 /* This is the maximum byte length of multibyte form.  */
 #define MAX_MULTIBYTE_LENGTH 5
 
-/* Return a Lisp character whose character code is C.  It assumes C is
+/* Return a Lisp character whose character code is C.  Assumes C is
    a valid character code.  */
 #define make_char(c) make_number (c)
 
@@ -110,8 +118,7 @@ extern char unibyte_has_multibyte_table[256];
 /* Nonzero iff X is a character.  */
 #define CHARACTERP(x) (NATNUMP (x) && XFASTINT (x) <= MAX_CHAR)
 
-/* Nonzero iff C is valid as a character code.  GENERICP is not used
-   now.  */
+/* Nonzero iff C is valid as a character code.  GENERICP is not used.  */
 #define CHAR_VALID_P(c, genericp) ((unsigned) (c) <= MAX_CHAR)
 
 /* Check if Lisp object X is a character or not.  */
@@ -192,9 +199,9 @@ extern char unibyte_has_multibyte_table[256];
    2)
 
 
-/* Store multibyte form of the character C in P.  The caller should
-   allocate at least MAX_MULTIBYTE_LENGTH bytes area at P in advance.
-   And, advance P to the end of the multibyte form.  */
+/* Store multibyte form of the character C in P and advance P to the
+   end of the multibyte form.  The caller should allocate at least
+   MAX_MULTIBYTE_LENGTH bytes area at P in advance.  */
 
 #define CHAR_STRING_ADVANCE(c, p)              \
   do {                                         \
@@ -225,8 +232,8 @@ extern char unibyte_has_multibyte_table[256];
        (ASCII_BYTE_P (byte) || LEADING_CODE_P (byte))  */
 #define CHAR_HEAD_P(byte) (((byte) & 0xC0) != 0x80)
 
-/* Just kept for backward compatibility.  This macro will be removed
-   in the future.  */
+/* Kept for backward compatibility.  This macro will be removed in the
+   future.  */
 #define BASE_LEADING_CODE_P LEADING_CODE_P
 
 /* How many bytes a character that starts with BYTE occupies in a
@@ -257,7 +264,7 @@ extern char unibyte_has_multibyte_table[256];
   (bytes) = BYTES_BY_CHAR_HEAD (*(str))
 
 /* The byte length of multibyte form at unibyte string P ending at
-   PEND.  If STR doesn't point a valid multibyte form, return 0.  */
+   PEND.  If STR doesn't point to a valid multibyte form, return 0.  */
 
 #define MULTIBYTE_LENGTH(p, pend)                              \
   (p >= pend ? 0                                               \
@@ -273,7 +280,7 @@ extern char unibyte_has_multibyte_table[256];
    : 0)
 
 
-/* Like MULTIBYTE_LENGTH but don't check the ending address.  */
+/* Like MULTIBYTE_LENGTH, but don't check the ending address.  */
 
 #define MULTIBYTE_LENGTH_NO_CHECK(p)                   \
   (!((p)[0] & 0x80) ? 1                                        \
@@ -287,8 +294,8 @@ extern char unibyte_has_multibyte_table[256];
    : (p)[0] == 0xF8 && ((p)[1] & 0xF0) == 0x80 ? 5     \
    : 0)
 
-/* If P is before LIMIT, advance P to the next character boundary.  It
-   assumes that P is already at a character boundary of the sane
+/* If P is before LIMIT, advance P to the next character boundary.
+   Assumes that P is already at a character boundary of the same
    mulitbyte form whose end address is LIMIT.  */
 
 #define NEXT_CHAR_BOUNDARY(p, limit)   \
@@ -299,7 +306,7 @@ extern char unibyte_has_multibyte_table[256];
 
 
 /* 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
+   Assumes that P is already at a character boundary of the same
    mulitbyte form whose beginning address is LIMIT.  */
 
 #define PREV_CHAR_BOUNDARY(p, limit)                                   \
@@ -332,7 +339,7 @@ extern char unibyte_has_multibyte_table[256];
    : string_char ((p), NULL, NULL))
 
 
-/* Like STRING_CHAR but set ACTUAL_LEN to the length of multibyte
+/* Like STRING_CHAR, but set ACTUAL_LEN to the length of multibyte
    form.  The argument LEN is ignored.  It will be removed in the
    future.  */
 
@@ -352,7 +359,7 @@ extern char unibyte_has_multibyte_table[256];
    : string_char ((p), NULL, &actual_len))
 
 
-/* Like STRING_CHAR but advance P to the end of multibyte form.  */
+/* Like STRING_CHAR, but advance P to the end of multibyte form.  */
 
 #define STRING_CHAR_ADVANCE(p)                                 \
   (!((p)[0] & 0x80)                                            \
@@ -397,8 +404,8 @@ extern char unibyte_has_multibyte_table[256];
     }                                                                  \
   while (0)
 
-/* Like FETCH_STRING_CHAR_ADVANCE but return a multibyte character eve
-   if STRING is unibyte.  */
+/* Like FETCH_STRING_CHAR_ADVANCE, but return a multibyte character
+   even if STRING is unibyte.  */
 
 #define FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE(OUTPUT, STRING, CHARIDX, BYTEIDX) \
   do                                                                          \
@@ -422,7 +429,7 @@ extern char unibyte_has_multibyte_table[256];
   while (0)
 
 
-/* Like FETCH_STRING_CHAR_ADVANCE but assumes STRING is multibyte.  */
+/* Like FETCH_STRING_CHAR_ADVANCE, but assumes STRING is multibyte.  */
 
 #define FETCH_STRING_CHAR_ADVANCE_NO_CHECK(OUTPUT, STRING, CHARIDX, BYTEIDX) \
   do                                                                        \
@@ -437,7 +444,7 @@ extern char unibyte_has_multibyte_table[256];
   while (0)
 
 
-/* Like FETCH_STRING_CHAR_ADVANCE but fetch character from the current
+/* Like FETCH_STRING_CHAR_ADVANCE, but fetch character from the current
    buffer.  */
 
 #define FETCH_CHAR_ADVANCE(OUTPUT, CHARIDX, BYTEIDX)           \
@@ -461,7 +468,7 @@ extern char unibyte_has_multibyte_table[256];
   while (0)
 
 
-/* Like FETCH_CHAR_ADVANCE but assumes the current buffer is multibyte.  */
+/* Like FETCH_CHAR_ADVANCE, but assumes the current buffer is multibyte.  */
 
 #define FETCH_CHAR_ADVANCE_NO_CHECK(OUTPUT, CHARIDX, BYTEIDX)  \
   do                                                           \
@@ -476,7 +483,7 @@ extern char unibyte_has_multibyte_table[256];
   while (0)
 
 
-/* Increase the buffer byte position POS_BYTE of the current buffer to
+/* Increment the buffer byte position POS_BYTE of the current buffer to
    the next character boundary.  No range checking of POS.  */
 
 #define INC_POS(pos_byte)                              \
@@ -486,7 +493,7 @@ extern char unibyte_has_multibyte_table[256];
   } while (0)
 
 
-/* Decrease the buffer byte position POS_BYTE of the current buffer to
+/* Decrement the buffer byte position POS_BYTE of the current buffer to
    the previous character boundary.  No range checking of POS.  */
 
 #define DEC_POS(pos_byte)                      \
@@ -533,7 +540,7 @@ extern char unibyte_has_multibyte_table[256];
   while (0)
 
 
-/* Increase the buffer byte position POS_BYTE of the current buffer to
+/* Increment the buffer byte position POS_BYTE of the current buffer to
    the next character boundary.  This macro relies on the fact that
    *GPT_ADDR and *Z_ADDR are always accessible and the values are
    '\0'.  No range checking of POS_BYTE.  */
@@ -545,7 +552,7 @@ extern char unibyte_has_multibyte_table[256];
   } while (0)
 
 
-/* Decrease the buffer byte position POS_BYTE of the current buffer to
+/* Decrement the buffer byte position POS_BYTE of the current buffer to
    the previous character boundary.  No range checking of POS_BYTE.  */
 
 #define BUF_DEC_POS(buf, pos_byte)                                     \
@@ -567,30 +574,22 @@ extern char unibyte_has_multibyte_table[256];
 /* If C is a character to be unified with a Unicode character, return
    the unified Unicode character.  */
 
-#define MAYBE_UNIFY_CHAR(c)                                    \
-  if (c > MAX_UNICODE_CHAR                                     \
-      && CHAR_TABLE_P (Vchar_unify_table))                     \
-    {                                                          \
-      Lisp_Object val;                                         \
-      int unified;                                             \
-                                                               \
-      val = CHAR_TABLE_REF (Vchar_unify_table, c);             \
-      if (! NILP (val))                                                \
-       {                                                       \
-         if (SYMBOLP (val))                                    \
-           {                                                   \
-             Funify_charset (val, Qnil, Qnil);                 \
-             val = CHAR_TABLE_REF (Vchar_unify_table, c);      \
-           }                                                   \
-         if ((unified = XINT (val)) >= 0)                      \
-           c = unified;                                        \
-       }                                                       \
-    }                                                          \
-  else
+#define MAYBE_UNIFY_CHAR(c)                            \
+  do {                                                 \
+    if (c > MAX_UNICODE_CHAR && c <= MAX_5_BYTE_CHAR)  \
+      {                                                        \
+       Lisp_Object val;                                \
+       val = CHAR_TABLE_REF (Vchar_unify_table, c);    \
+       if (INTEGERP (val))                             \
+         c = XINT (val);                               \
+       else if (! NILP (val))                          \
+         c = maybe_unify_char (c, val);                \
+      }                                                        \
+  } while (0)
 
 
 /* Return the width of ASCII character C.  The width is measured by
-   how many columns occupied on the screen when displayed in the
+   how many columns C will occupy on the screen when displayed in the
    current buffer.  */
 
 #define ASCII_CHAR_WIDTH(c)                                            \
@@ -603,7 +602,7 @@ extern char unibyte_has_multibyte_table[256];
       : ((NILP (current_buffer->ctl_arrow) ? 4 : 2))))
 
 /* Return the width of character C.  The width is measured by how many
-   columns occupied on the screen when displayed in the current
+   columns C will occupy on the screen when displayed in the current
    buffer.  */
 
 #define CHAR_WIDTH(c)          \
@@ -624,6 +623,8 @@ extern int parse_str_to_multibyte P_ ((unsigned char *, int));
 extern int str_as_multibyte P_ ((unsigned char *, int, int, int *));
 extern int str_to_multibyte P_ ((unsigned char *, int, int));
 extern int str_as_unibyte P_ ((unsigned char *, int));
+extern EMACS_INT str_to_unibyte P_ ((const unsigned char *, unsigned char *,
+                                    EMACS_INT, int));
 extern int strwidth P_ ((unsigned char *, int));
 extern int c_string_width P_ ((const unsigned char *, int, int, int *, int *));
 extern int lisp_string_width P_ ((Lisp_Object, int, int *, int *));
@@ -635,6 +636,7 @@ extern Lisp_Object Vtranslation_table_vector;
 extern Lisp_Object Vchar_width_table;
 extern Lisp_Object Vchar_direction_table;
 extern Lisp_Object Vchar_unify_table;
+extern Lisp_Object Vunicode_category_table;
 
 extern Lisp_Object string_escape_byte8 P_ ((Lisp_Object));