Merge r21-4-7-utf-2000-5.
[chise/xemacs-chise.git] / src / syntax.h
index 75ac2c3..a6526ae 100644 (file)
@@ -1,5 +1,6 @@
 /* Declarations having to do with XEmacs syntax tables.
    Copyright (C) 1985, 1992, 1993 Free Software Foundation, Inc.
+   Copyright (C) 2001 MORIOKA Tomohiko
 
 This file is part of XEmacs.
 
@@ -45,6 +46,10 @@ integers.  We can do this successfully because syntax tables are
 now an abstract type, where we control all access.
 */
 
+/* The standard syntax table is stored where it will automatically
+   be used in all new buffers.  */
+extern Lisp_Object Vstandard_syntax_table;
+
 enum syntaxcode
 {
   Swhitespace, /* whitespace character */
@@ -73,8 +78,33 @@ enum syntaxcode charset_syntax (struct buffer *buf, Lisp_Object charset,
 
 /* Return the syntax code for a particular character and mirror table. */
 
+#ifdef UTF2000
+INLINE_HEADER int SYNTAX_CODE_UNSAFE (Lisp_Char_Table *table, Emchar c);
+INLINE_HEADER int
+SYNTAX_CODE_UNSAFE (Lisp_Char_Table *table, Emchar c)
+{
+  int code = CHAR_TABLE_VALUE_UNSAFE (table, c);
+  int ret = Spunct;
+
+  if (CONSP (code))
+    code = XCAR (code);
+  ret = XINT (code);
+
+  if (ret == Sinherit)
+    {
+      code = CHAR_TABLE_VALUE_UNSAFE (XCHAR_TABLE
+                                     (Vstandard_syntax_table), c);
+      if (CONSP (code))
+       code = XCAR (code);
+      return XINT (code);
+    }
+  else
+    return ret;
+}
+#else
 #define SYNTAX_CODE_UNSAFE(table, c) \
    XINT (CHAR_TABLE_VALUE_UNSAFE (table, c))
+#endif
 
 INLINE_HEADER int SYNTAX_CODE (Lisp_Char_Table *table, Emchar c);
 INLINE_HEADER int
@@ -234,10 +264,6 @@ WORD_SYNTAX_P (Lisp_Char_Table *table, Emchar c)
 EXFUN (Fchar_syntax, 2);
 EXFUN (Fforward_word, 2);
 
-/* The standard syntax table is stored where it will automatically
-   be used in all new buffers.  */
-extern Lisp_Object Vstandard_syntax_table;
-
 /* This array, indexed by a character, contains the syntax code which
    that character signifies (as a char).
    For example, (enum syntaxcode) syntax_spec_code['w'] is Sword. */
@@ -263,7 +289,9 @@ extern struct buffer *regex_emacs_buffer;
    for looking up syntax properties.  */
 extern Lisp_Object regex_match_object;
 
+#ifndef UTF2000
 void update_syntax_table (Lisp_Char_Table *ct);
+#endif
 
 #ifdef emacs
 
@@ -356,6 +384,19 @@ void update_syntax_cache (int pos, int count, int init);
 
 #endif /* emacs */
 
+#ifdef UTF2000
+#define SETUP_SYNTAX_CACHE(FROM, COUNT)                                \
+  do {                                                         \
+    syntax_cache.buffer = current_buffer;                      \
+    syntax_cache.object = Qnil;                                        \
+    syntax_cache.current_syntax_table                          \
+      = current_buffer->syntax_table;                          \
+    syntax_cache.use_code = 0;                                 \
+    if (lookup_syntax_properties)                              \
+      update_syntax_cache ((COUNT) > 0 ? (FROM) : (FROM) - 1,  \
+                          (COUNT), 1);                         \
+  } while (0)
+#else
 #define SETUP_SYNTAX_CACHE(FROM, COUNT)                                \
   do {                                                         \
     syntax_cache.buffer = current_buffer;                      \
@@ -367,7 +408,21 @@ void update_syntax_cache (int pos, int count, int init);
       update_syntax_cache ((COUNT) > 0 ? (FROM) : (FROM) - 1,  \
                           (COUNT), 1);                         \
   } while (0)
+#endif
 
+#ifdef UTF2000
+#define SETUP_SYNTAX_CACHE_FOR_BUFFER(BUFFER, FROM, COUNT)     \
+  do {                                                         \
+    syntax_cache.buffer = (BUFFER);                            \
+    syntax_cache.object = Qnil;                                        \
+    syntax_cache.current_syntax_table =                                \
+      syntax_cache.buffer->syntax_table;                       \
+    syntax_cache.use_code = 0;                                 \
+    if (lookup_syntax_properties)                              \
+      update_syntax_cache ((FROM) + ((COUNT) > 0 ? 0 : -1),    \
+                          (COUNT), 1);                         \
+  } while (0)
+#else
 #define SETUP_SYNTAX_CACHE_FOR_BUFFER(BUFFER, FROM, COUNT)     \
   do {                                                         \
     syntax_cache.buffer = (BUFFER);                            \
@@ -379,7 +434,42 @@ void update_syntax_cache (int pos, int count, int init);
       update_syntax_cache ((FROM) + ((COUNT) > 0 ? 0 : -1),    \
                           (COUNT), 1);                         \
   } while (0)
+#endif
 
+#ifdef UTF2000
+#define SETUP_SYNTAX_CACHE_FOR_OBJECT(OBJECT, BUFFER, FROM, COUNT)     \
+  do {                                                                 \
+    syntax_cache.buffer = (BUFFER);                                    \
+    syntax_cache.object = (OBJECT);                                    \
+    if (NILP (syntax_cache.object))                                    \
+      {                                                                        \
+        /* do nothing */;                                              \
+      }                                                                        \
+    else if (EQ (syntax_cache.object, Qt))                             \
+      {                                                                        \
+        /* do nothing */;                                              \
+      }                                                                        \
+    else if (STRINGP (syntax_cache.object))                            \
+      {                                                                        \
+        /* do nothing */;                                              \
+      }                                                                        \
+    else if (BUFFERP (syntax_cache.object))                            \
+      {                                                                        \
+        syntax_cache.buffer = XBUFFER (syntax_cache.object);           \
+      }                                                                        \
+    else                                                               \
+      {                                                                        \
+        /* OBJECT must be buffer/string/t/nil */                       \
+        assert(0);                                                     \
+      }                                                                        \
+    syntax_cache.current_syntax_table                                  \
+      = syntax_cache.buffer->syntax_table;                             \
+    syntax_cache.use_code = 0;                                         \
+    if (lookup_syntax_properties)                                      \
+      update_syntax_cache ((FROM) + ((COUNT) > 0 ? 0 : -1),            \
+                          (COUNT), 1);                                 \
+  } while (0)
+#else
 #define SETUP_SYNTAX_CACHE_FOR_OBJECT(OBJECT, BUFFER, FROM, COUNT)     \
   do {                                                                 \
     syntax_cache.buffer = (BUFFER);                                    \
@@ -412,6 +502,7 @@ void update_syntax_cache (int pos, int count, int init);
       update_syntax_cache ((FROM) + ((COUNT) > 0 ? 0 : -1),            \
                           (COUNT), 1);                                 \
   } while (0)
+#endif
 
 #define SYNTAX_CODE_PREFIX(c) \
   ((c >> 7) & 1)