Index: ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/ChangeLog,v
retrieving revision 1.241.2.13.2.8
diff -u -r1.241.2.13.2.8 ChangeLog
--- ChangeLog	2002/08/24 04:51:38	1.241.2.13.2.8
+++ ChangeLog	2002/09/02 20:33:43
@@ -1,3 +1,11 @@
+2002-09-01  Andy Piper  <andy@xemacs.org>
+
+	* configure.in (AC_INIT_PARSE_ARGS):
+	* configure.in (with_syntax_tables): New.
+	* configure.in (USAGE_ERROR):
+	* configure.in (XE_COMPUTE_RUNPATH): Make the use of syntax [text]
+	properties a compile time option.
+
 2002-08-23  Stephen J. Turnbull  <stephen@xemacs.org>
 
 	* XEmacs 21.4.9 "Informed Management" is released.
Index: configure.in
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/configure.in,v
retrieving revision 1.151.2.4.2.6
diff -u -r1.151.2.4.2.6 configure.in
--- configure.in	2002/08/24 04:52:07	1.151.2.4.2.6
+++ configure.in	2002/09/02 20:33:59
@@ -351,6 +351,7 @@
 with_widgets=''
 with_dialogs=''
 with_file_coding=''
+with_syntax_text_properties=''
 cpp='' cppflags='' libs='' ldflags=''
 extra_includes=''
 dynamic=''
@@ -380,6 +381,8 @@
 with_dragndrop="no"
 dnl Too annoying, even if mandated by IPv6 (and I'm not even sure of that)
 with_ipv6_cname="no"
+dnl Too slow, way too slow.
+with_syntax_text_properties="no"
 
 dnl ------------------
 dnl Options Processing
@@ -492,6 +495,7 @@
 	with_i18n3	| \
 	with_mule	| \
 	with_file_coding| \
+	with_syntax_text_properties| \
 	with_canna	| \
 	with_wnn	| \
 	with_wnn6	| \
@@ -4828,6 +4832,7 @@
 test "$use_union_type"     = "yes" && AC_DEFINE(USE_UNION_TYPE)
 test "$pdump"              = "yes" && AC_DEFINE(PDUMP)
 test "$with_ipv6_cname"    = "yes" && AC_DEFINE(IPV6_CANONICALIZE)
+test "$with_syntax_text_properties"    = "yes" && AC_DEFINE(SYNTAX_TEXT_PROPERTIES)
 
 dnl -------------------------------
 dnl Report on what we decided to do
@@ -5042,6 +5047,7 @@
 test "$with_tooltalk" = yes && echo "  Compiling in support for ToolTalk."
 test "$with_workshop" = yes && echo "  Compiling in support for Sun WorkShop."
 test "$with_socks" = yes && echo "  Compiling in support for SOCKS."
+test "$with_syntax_text_properties" = yes && echo "  Compiling in support for syntax [text] properties."
 test "$with_dnet" = yes && echo "  Compiling in support for DNET."
 test "$with_modules" = "yes" && echo "  Compiling in support for dynamic shared object modules."
 test "$use_union_type" = yes && echo "  Using the union type for Lisp_Objects."
Index: lisp/ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lisp/ChangeLog,v
retrieving revision 1.266.2.13.2.25
diff -u -r1.266.2.13.2.25 ChangeLog
--- lisp/ChangeLog	2002/08/24 04:46:54	1.266.2.13.2.25
+++ lisp/ChangeLog	2002/09/02 20:34:02
@@ -1,3 +1,14 @@
+2002-09-01  Andy Piper  <andy@xemacs.org>
+
+	* font-lock.el:
+	* font-lock.el (font-lock-remove-face):
+	* font-lock.el (font-lock-default-fontify-region):
+	* font-lock.el (font-lock-fontify-syntactically-region): New.
+	* font-lock.el (font-lock-fontify-syntactically-region-1): New.
+	* font-lock.el (font-lock-fontify-syntactically-region-2):
+	New. Make the use of syntax [text] properties a compile-time
+	option.
+
 2002-06-03  Andy Piper  <andy@xemacs.org>
 
 	* dialog-items.el (make-search-dialog): align various subcontrols
Index: lisp/files.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lisp/files.el,v
retrieving revision 1.39.2.2.2.6
diff -u -r1.39.2.2.2.6 files.el
--- lisp/files.el	2002/08/24 04:46:57	1.39.2.2.2.6
+++ lisp/files.el	2002/09/02 20:34:06
@@ -2707,6 +2707,7 @@
       (funcall revert-buffer-function ignore-auto noconfirm)
     (let* ((opoint (point))
 	   (newbuf nil)
+	   (found nil)
 	   (delay-prompt nil)
 	   (auto-save-p (and (not ignore-auto)
                              (recent-auto-save-p)
@@ -2721,10 +2722,9 @@
 	     (error "Buffer does not seem to be associated with any file"))
 	    ((or noconfirm
 		 (and (not (buffer-modified-p))
-		      (let (found)
-			(dolist (rx revert-without-query found)
-			  (when (string-match rx file-name)
-			    (setq found t)))))
+		      (dolist (rx revert-without-query found)
+			(when (string-match rx file-name)
+			  (setq found t))))
 		 ;; If we will call revert-buffer-internal, delay prompting
 		 (and (not auto-save-p)
 		      (not (buffer-modified-p))
@@ -2738,7 +2738,7 @@
 			(and (setq newbuf (revert-buffer-internal
 					   file-name))
 			     ;; ... and if different, prompt
-			     (or noconfirm
+			     (or noconfirm found
 				 (and delay-prompt
 				      (yes-or-no-p 
 				       (format "Revert buffer from file %s? "
Index: lisp/font-lock.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lisp/font-lock.el,v
retrieving revision 1.13.2.2.2.1
diff -u -r1.13.2.2.2.1 font-lock.el
--- lisp/font-lock.el	2002/08/24 04:46:58	1.13.2.2.2.1
+++ lisp/font-lock.el	2002/09/02 20:34:07
@@ -1019,7 +1019,7 @@
   ;; Remove any syntax highlighting on the characters in the range.
   (put-nonduplicable-text-property start end 'face nil)
   (put-nonduplicable-text-property start end 'font-lock nil)
-  (if lookup-syntax-properties
+  (if (and (featurep 'syntax-text-properties) lookup-syntax-properties)
       (put-nonduplicable-text-property start end 'syntax-table nil)))
 
 (defsubst font-lock-set-syntax (start end syntax)
@@ -1165,11 +1165,15 @@
 	  ;; Use the fontification syntax table, if any.
 	  (if font-lock-syntax-table (set-syntax-table font-lock-syntax-table))
 	  ;; Now do the fontification.
-	  (font-lock-unfontify-region beg end)
-	  (when font-lock-syntactic-keywords
-	    (font-lock-fontify-syntactic-keywords-region beg end))
-	  (unless font-lock-keywords-only
-	    (font-lock-fontify-syntactically-region beg end loudly))
+	  (if (not (featurep 'syntax-text-properties))
+	      (if font-lock-keywords-only
+		  (font-lock-unfontify-region beg end)
+		(font-lock-fontify-syntactically-region beg end loudly))
+	    (font-lock-unfontify-region beg end)
+	    (when font-lock-syntactic-keywords
+	      (font-lock-fontify-syntactic-keywords-region beg end))
+	    (unless font-lock-keywords-only
+	      (font-lock-fontify-syntactically-region beg end loudly)))
 	  (font-lock-fontify-keywords-region beg end loudly))
       ;; Clean up.
       (set-syntax-table old-syntax-table)
@@ -1319,6 +1323,59 @@
     ;; in add-log, but I think this encompasses more modes.
     (string-match "lisp\\|scheme" (symbol-name mode))))
 
+(defsubst font-lock-fontify-syntactically-region (start end &optional loudly)
+  (if (featurep 'syntax-text-properties)
+      (font-lock-fontify-syntactically-region-2 start end loudly)
+    (font-lock-fontify-syntactically-region-1 start end loudly)))
+
+;; This is the original XEmacs version
+(defun font-lock-fontify-syntactically-region-1 (start end &optional loudly)
+  "Put proper face on each string and comment between START and END.
+START should be at the beginning of a line."
+  (if font-lock-keywords-only
+      nil
+    (when (and font-lock-verbose
+	       (>= (- end start) font-lock-message-threshold))
+      (progress-feedback-with-label 'font-lock
+				    "Fontifying %s... (syntactically)" 5
+				    (buffer-name)))
+    (font-lock-unfontify-region start end loudly)
+    (goto-char start)
+    (if (> end (point-max)) (setq end (point-max)))
+    (let ((lisp-like (font-lock-lisp-like major-mode)))
+      (syntactically-sectionize
+       #'(lambda (s e context depth)
+	   (let (face)
+	     (cond ((eq context 'string)
+		    (setq face
+			  ;; #### It would be nice if we handled
+			  ;; Python and other non-Lisp languages with
+			  ;; docstrings correctly.
+			  (if (and lisp-like (= depth 1))
+			      ;; really we should only use this if
+			      ;;  in position 3 depth 1, but that's
+			      ;;  too expensive to compute.
+			      'font-lock-doc-string-face
+			    'font-lock-string-face)))
+		   ((or (eq context 'comment)
+			(eq context 'block-comment))
+		    (setq face 'font-lock-comment-face)
+;		 ;; Don't fontify whitespace at the beginning of lines;
+;		 ;;  otherwise comment blocks may not line up with code.
+;		 ;; (This is sometimes a good idea, sometimes not; in any
+;		 ;; event it should be in C for speed --jwz)
+;		 (save-excursion
+;		     (goto-char s)
+;		     (while (prog1 (search-forward "\n" (1- e) 'move)
+;			      (setq face 'font-lock-comment-face)
+;			      (setq e (point)))
+;		       (skip-chars-forward " \t\n")
+;		       (setq s (point)))
+		   ))
+	     (font-lock-set-face s e face)))
+       start end)
+      )))
+
 ;; fontify-syntactically-region used to use syntactically-sectionize, which
 ;; was supposedly much faster than the FSF version because it was written in
 ;; C. However, the FSF version uses parse-partial-sexp, which is also
@@ -1326,7 +1383,7 @@
 ;; syntactically-sectionize code to be slower overall. So here's the FSF
 ;; version, modified to support font-lock-doc-string-face.
 ;; -- mct 2000-12-29
-(defun font-lock-fontify-syntactically-region (start end &optional loudly)
+(defun font-lock-fontify-syntactically-region-2 (start end &optional loudly)
   "Put proper face on each string and comment between START and END.
 START should be at the beginning of a line."
   (if font-lock-keywords-only
Index: src/ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/ChangeLog,v
retrieving revision 1.290.2.15.2.31
diff -u -r1.290.2.15.2.31 ChangeLog
--- src/ChangeLog	2002/08/24 04:47:30	1.290.2.15.2.31
+++ src/ChangeLog	2002/09/02 20:34:34
@@ -1,3 +1,41 @@
+2002-09-01  Andy Piper  <andy@xemacs.org>
+
+	* config.h.in:
+	* dired.c:
+	* dired.c (Fdirectory_files):
+	* font-lock.c:
+	* font-lock.c (syntactic_context):
+	* font-lock.c (setup_context_cache):
+	* font-lock.c (context_to_symbol):
+	* font-lock.c (Fsyntactically_sectionize):
+	* regex.c:
+	* regex.c (re_compile_fastmap):
+	* regex.c (re_search_2):
+	* regex.c (re_match_2):
+	* search.c (looking_at_1):
+	* search.c (string_match_1):
+	* search.c (fast_string_match):
+	* search.c (skip_chars):
+	* search.c (search_buffer):
+	* syntax.c:
+	* syntax.c (struct lisp_parse_state):
+	* syntax.c (find_defun_start):
+	* syntax.c (syntax_spec_code):
+	* syntax.c (scan_words):
+	* syntax.c (find_start_of_comment):
+	* syntax.c (find_end_of_comment):
+	* syntax.c (Fforward_comment):
+	* syntax.c (scan_lists):
+	* syntax.c (char_quoted):
+	* syntax.c (Fbackward_prefix_chars):
+	* syntax.c (scan_sexps_forward):
+	* syntax.c (Fparse_partial_sexp):
+	* syntax.c (syms_of_syntax):
+	* syntax.c (vars_of_syntax):
+	* syntax.h:
+	* syntax.h (syntaxcode): Make the use of syntax [text] properties
+	a compile-time option.
+
 2002-06-03  Andy Piper  <andy@xemacs.org>
 
 	* frame.c (frame_conversion_internal): add conversion appropriate
Index: src/config.h.in
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/config.h.in,v
retrieving revision 1.61.2.1.4.1
diff -u -r1.61.2.1.4.1 config.h.in
--- src/config.h.in	2002/04/27 22:34:10	1.61.2.1.4.1
+++ src/config.h.in	2002/09/02 20:34:35
@@ -566,6 +566,9 @@
 /* Define this if you want file coding support */
 #undef FILE_CODING
 
+/* Define this if you want syntax [text] property support */
+#undef SYNTAX_TEXT_PROPERTIES
+
 /* Do we want to use X window input methods for use with Mule? (requires X11R5)
    If so, use raw Xlib or higher level Motif interface? */
 #undef HAVE_XIM
Index: src/dired.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/dired.c,v
retrieving revision 1.19.8.2
diff -u -r1.19.8.2 dired.c
--- src/dired.c	2002/05/04 21:31:17	1.19.8.2
+++ src/dired.c	2002/09/02 20:34:37
@@ -33,8 +33,11 @@
 #include "elhash.h"
 #include "regex.h"
 #include "opaque.h"
+#ifdef SYNTAX_TEXT_PROPERTIES
 #include "syntax.h"
+#endif /* SYNTAX_TEXT_PROPERTIES */
 
+
 Lisp_Object Vcompletion_ignored_extensions;
 Lisp_Object Qdirectory_files;
 Lisp_Object Qfile_name_completion;
@@ -124,9 +127,10 @@
   if (!d)
     report_file_error ("Opening directory", list1 (directory));
 
+#ifdef SYNTAX_TEXT_PROPERTIES
   regex_match_object = Qt;
   regex_emacs_buffer = current_buffer;
-
+#endif /* SYNTAX_TEXT_PROPERTIES */
   record_unwind_protect (close_directory_unwind, make_opaque_ptr ((void *)d));
 
   /* Loop reading blocks */
Index: src/font-lock.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/font-lock.c,v
retrieving revision 1.5.8.1
diff -u -r1.5.8.1 font-lock.c
--- src/font-lock.c	2002/08/24 04:47:42	1.5.8.1
+++ src/font-lock.c	2002/09/02 20:34:40
@@ -59,9 +59,13 @@
   context_none,
   context_string,
   context_comment,
+#ifndef SYNTAX_TEXT_PROPERTIES
+  context_block_comment
+#else /* SYNTAX_TEXT_PROPERTIES */
   context_block_comment,
   context_generic_comment,
   context_generic_string
+#endif /* SYNTAX_TEXT_PROPERTIES */
 };
 
 enum block_comment_context
@@ -335,8 +339,10 @@
       context_cache.style = comment_style_none;
       context_cache.scontext = '\000';
       context_cache.depth = 0;
+#ifdef SYNTAX_TEXT_PROPERTIES
       /* #### shouldn't this be checking the character's syntax instead of
          explicitly testing for backslash characters? */
+#endif /* SYNTAX_TEXT_PROPERTIES */
       context_cache.backslash_p = ((pt > 1) &&
 				   (BUF_FETCH_CHAR (buf, pt - 1) == '\\'));
       /* Note that the BOL context cache may not be at the beginning
@@ -391,13 +397,37 @@
   }
 }
 
+#ifndef SYNTAX_TEXT_PROPERTIES
+#define SYNTAX_START_STYLE(table, c1, c2)				 \
+  (SYNTAX_STYLES_MATCH_START_P (table, c1, c2, SYNTAX_COMMENT_STYLE_A) ? \
+   comment_style_a :							 \
+   SYNTAX_STYLES_MATCH_START_P (table, c1, c2, SYNTAX_COMMENT_STYLE_B) ? \
+   comment_style_b :							 \
+   comment_style_none)
+#else /* SYNTAX_TEXT_PROPERTIES */
 #define SYNTAX_START_STYLE(c1, c2)					\
   (SYNTAX_CODES_MATCH_START_P (c1, c2, SYNTAX_COMMENT_STYLE_A) ?	\
    comment_style_a :							\
    SYNTAX_CODES_MATCH_START_P (c1, c2, SYNTAX_COMMENT_STYLE_B) ?	\
    comment_style_b :							\
    comment_style_none)
+#endif /* SYNTAX_TEXT_PROPERTIES */
 
+#ifndef SYNTAX_TEXT_PROPERTIES
+#define SYNTAX_END_STYLE(table, c1, c2)					\
+  (SYNTAX_STYLES_MATCH_END_P (table, c1, c2, SYNTAX_COMMENT_STYLE_A) ?	\
+     comment_style_a :							\
+   SYNTAX_STYLES_MATCH_END_P (table, c1, c2, SYNTAX_COMMENT_STYLE_B) ?	\
+     comment_style_b :							\
+     comment_style_none)
+  
+#define SINGLE_SYNTAX_STYLE(table, c)					\
+      (SYNTAX_STYLES_MATCH_1CHAR_P (table, c, SYNTAX_COMMENT_STYLE_A) ?	\
+         comment_style_a :						\
+       SYNTAX_STYLES_MATCH_1CHAR_P (table, c, SYNTAX_COMMENT_STYLE_B) ?	\
+         comment_style_b :						\
+         comment_style_none)
+#else /* SYNTAX_TEXT_PROPERTIES */
 #define SYNTAX_END_STYLE(c1, c2)				\
   (SYNTAX_CODES_MATCH_END_P (c1, c2, SYNTAX_COMMENT_STYLE_A) ?	\
    comment_style_a :						\
@@ -413,6 +443,7 @@
        SYNTAX_CODE_MATCHES_1CHAR_P (c, SYNTAX_COMMENT_STYLE_B) ?	\
        comment_style_b :						\
        comment_style_none))
+#endif /* SYNTAX_TEXT_PROPERTIES */
 
 /* Set up context_cache for position PT in BUF. */
 
@@ -420,27 +451,39 @@
 find_context (struct buffer *buf, Bufpos pt)
 {
   /* This function can GC */
-#ifndef emacs
+#if !defined(SYNTAX_TEXT_PROPERTIES) || !defined(emacs)
   Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
   Lisp_Object syntaxtab = buf->syntax_table;
-#endif
+#endif /* SYNTAX_TEXT_PROPERTIES */
   Emchar prev_c, c;
+#ifdef SYNTAX_TEXT_PROPERTIES
   int prev_syncode, syncode;
+#endif /* SYNTAX_TEXT_PROPERTIES */
   Bufpos target = pt;
   setup_context_cache (buf, pt);
   pt = context_cache.cur_point;
 
+#ifdef SYNTAX_TEXT_PROPERTIES
   SETUP_SYNTAX_CACHE (pt - 1, 1);
+#endif /* SYNTAX_TEXT_PROPERTIES */
   if (pt > BUF_BEGV (buf))
+#ifndef SYNTAX_TEXT_PROPERTIES
+    c = BUF_FETCH_CHAR (buf, pt - 1);
+#else /* SYNTAX_TEXT_PROPERTIES */
     {
       c = BUF_FETCH_CHAR (buf, pt - 1);
       syncode = SYNTAX_CODE_FROM_CACHE (mirrortab, c);
     }
+#endif /* SYNTAX_TEXT_PROPERTIES */
   else
+#ifndef SYNTAX_TEXT_PROPERTIES
+    c = '\n'; /* to get bol_context_cache at point-min */
+#else /* SYNTAX_TEXT_PROPERTIES */
     {
       c = '\n'; /* to get bol_context_cache at point-min */
       syncode = Swhitespace;
     }
+#endif /* SYNTAX_TEXT_PROPERTIES */
 
   for (; pt < target; pt++, context_cache.cur_point = pt)
     {
@@ -475,11 +518,17 @@
 	    }
 	}
 
+#ifdef SYNTAX_TEXT_PROPERTIES
       UPDATE_SYNTAX_CACHE_FORWARD (pt);
+#endif /* SYNTAX_TEXT_PROPERTIES */
       prev_c = c;
+#ifdef SYNTAX_TEXT_PROPERTIES
       prev_syncode = syncode;
+#endif /* SYNTAX_TEXT_PROPERTIES */
       c = BUF_FETCH_CHAR (buf, pt);
+#ifdef SYNTAX_TEXT_PROPERTIES
       syncode = SYNTAX_CODE_FROM_CACHE (mirrortab, c);
+#endif /* SYNTAX_TEXT_PROPERTIES */
 
       if (prev_c == '\n')
 	bol_context_cache = context_cache;
@@ -490,7 +539,11 @@
 	  continue;
 	}
 
+#ifndef SYNTAX_TEXT_PROPERTIES
+      switch (SYNTAX (mirrortab, c))
+#else /* SYNTAX_TEXT_PROPERTIES */
       switch (SYNTAX_FROM_CACHE (mirrortab, c))
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	{
 	case Sescape:
 	  context_cache.backslash_p = 1;
@@ -511,13 +564,21 @@
 	    {
 	      context_cache.context = context_comment;
 	      context_cache.ccontext = ccontext_none;
+#ifndef SYNTAX_TEXT_PROPERTIES
+	      context_cache.style = SINGLE_SYNTAX_STYLE (mirrortab, c);
+#else /* SYNTAX_TEXT_PROPERTIES */
 	      context_cache.style = SINGLE_SYNTAX_STYLE (syncode);
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	      if (context_cache.style == comment_style_none) abort ();
 	    }
 	  break;
 
 	case Sendcomment:
+#ifndef SYNTAX_TEXT_PROPERTIES
+	  if (context_cache.style != SINGLE_SYNTAX_STYLE (mirrortab, c))
+#else /* SYNTAX_TEXT_PROPERTIES */
 	  if (context_cache.style != SINGLE_SYNTAX_STYLE (syncode))
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	    ;
 	  else if (context_cache.context == context_comment)
 	    {
@@ -544,8 +605,12 @@
 	      }
             else if (context_cache.context == context_none)
 	      {
+#ifndef SYNTAX_TEXT_PROPERTIES
+		Lisp_Object stringtermobj = syntax_match (syntaxtab, c);
+#else /* SYNTAX_TEXT_PROPERTIES */
 		Lisp_Object stringtermobj =
 		  syntax_match (syntax_cache.current_syntax_table, c);
+#endif /* SYNTAX_TEXT_PROPERTIES */
 		Emchar stringterm;
 
 		if (CHARP (stringtermobj))
@@ -558,6 +623,7 @@
 	      }
             break;
           }
+#ifdef SYNTAX_TEXT_PROPERTIES
 
 	case Scomment_fence:
 	  {
@@ -587,6 +653,7 @@
 	    break;
 	  }
 
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	default:
 	  ;
 	}
@@ -595,18 +662,34 @@
 	 Now we've got to hack multi-char sequences that start
 	 and end block comments.
        */
+#ifndef SYNTAX_TEXT_PROPERTIES
+      if ((SYNTAX_COMMENT_BITS (mirrortab, c) &
+#else /* SYNTAX_TEXT_PROPERTIES */
       if ((SYNTAX_CODE_COMMENT_BITS (syncode) &
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	   SYNTAX_SECOND_CHAR_START) &&
 	  context_cache.context == context_none &&
 	  context_cache.ccontext == ccontext_start1 &&
+#ifndef SYNTAX_TEXT_PROPERTIES
+	  SYNTAX_START_P (mirrortab, prev_c, c) /* the two chars match */
+#else /* SYNTAX_TEXT_PROPERTIES */
 	  SYNTAX_CODES_START_P (prev_syncode, syncode) /* the two chars match */
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	  )
 	{
 	  context_cache.ccontext = ccontext_start2;
+#ifndef SYNTAX_TEXT_PROPERTIES
+	  context_cache.style = SYNTAX_START_STYLE (mirrortab, prev_c, c);
+#else /* SYNTAX_TEXT_PROPERTIES */
 	  context_cache.style = SYNTAX_START_STYLE (prev_syncode, syncode);
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	  if (context_cache.style == comment_style_none) abort ();
 	}
+#ifndef SYNTAX_TEXT_PROPERTIES
+      else if ((SYNTAX_COMMENT_BITS (mirrortab, c) &
+#else /* SYNTAX_TEXT_PROPERTIES */
       else if ((SYNTAX_CODE_COMMENT_BITS (syncode) &
+#endif /* SYNTAX_TEXT_PROPERTIES */
 		SYNTAX_FIRST_CHAR_START) &&
 	       context_cache.context == context_none &&
 	       (context_cache.ccontext == ccontext_none ||
@@ -615,30 +698,56 @@
 	  context_cache.ccontext = ccontext_start1;
 	  context_cache.style = comment_style_none; /* should be this already*/
 	}
+#ifndef SYNTAX_TEXT_PROPERTIES
+      else if ((SYNTAX_COMMENT_BITS (mirrortab, c) &
+#else /* SYNTAX_TEXT_PROPERTIES */
       else if ((SYNTAX_CODE_COMMENT_BITS (syncode) &
+#endif /* SYNTAX_TEXT_PROPERTIES */
 		SYNTAX_SECOND_CHAR_END) &&
 	       context_cache.context == context_block_comment &&
 	       context_cache.ccontext == ccontext_end1 &&
+#ifndef SYNTAX_TEXT_PROPERTIES
+	       SYNTAX_END_P (mirrortab, prev_c, c) &&
+#else /* SYNTAX_TEXT_PROPERTIES */
 	       SYNTAX_CODES_END_P (prev_syncode, syncode) &&
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	       /* the two chars match */
 	       context_cache.style ==
+#ifndef SYNTAX_TEXT_PROPERTIES
+	       SYNTAX_END_STYLE (mirrortab, prev_c, c)
+#else /* SYNTAX_TEXT_PROPERTIES */
 	       SYNTAX_END_STYLE (prev_syncode, syncode)
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	       )
 	{
 	  context_cache.context = context_none;
 	  context_cache.ccontext = ccontext_none;
 	  context_cache.style = comment_style_none;
 	}
+#ifndef SYNTAX_TEXT_PROPERTIES
+      else if ((SYNTAX_COMMENT_BITS (mirrortab, c) &
+#else /* SYNTAX_TEXT_PROPERTIES */
       else if ((SYNTAX_CODE_COMMENT_BITS (syncode) &
+#endif /* SYNTAX_TEXT_PROPERTIES */
 		SYNTAX_FIRST_CHAR_END) &&
 	       context_cache.context == context_block_comment &&
+#ifndef SYNTAX_TEXT_PROPERTIES
+	       (context_cache.style ==
+		SYNTAX_END_STYLE (mirrortab, c,
+				  BUF_FETCH_CHAR (buf, pt+1))) &&
+#else /* SYNTAX_TEXT_PROPERTIES */
 	       context_cache.style == SINGLE_SYNTAX_STYLE (syncode) &&
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	       (context_cache.ccontext == ccontext_start2 ||
 		context_cache.ccontext == ccontext_end1))
+#ifndef SYNTAX_TEXT_PROPERTIES
+	/* #### is it right to check for end1 here?? */
+#else /* SYNTAX_TEXT_PROPERTIES */
 	/* #### is it right to check for end1 here?? 
 	   yes, because this might be a repetition of the first char
 	   of a comment-end sequence. ie, '/xxx foo xxx/' or
 	   '/xxx foo x/', where 'x' = '*' -- mct */
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	{
 	  if (context_cache.style == comment_style_none) abort ();
 	  context_cache.ccontext = ccontext_end1;
@@ -677,12 +786,19 @@
 {
   switch (context)
     {
+#ifndef SYNTAX_TEXT_PROPERTIES
+    case context_none:		return Qnil;
+    case context_string:	return Qstring;
+    case context_comment:	return Qcomment;
+    case context_block_comment:	return Qblock_comment;
+#else /* SYNTAX_TEXT_PROPERTIES */
     case context_none:			return Qnil;
     case context_string:		return Qstring;
     case context_comment:		return Qcomment;
     case context_block_comment:		return Qblock_comment;
     case context_generic_comment:	return Qblock_comment;
     case context_generic_string:	return Qstring;
+#endif /* SYNTAX_TEXT_PROPERTIES */
     default: abort (); return Qnil; /* suppress compiler warning */
     }
 }
@@ -773,9 +889,13 @@
       if (this_context == context_block_comment &&
 	  context_cache.ccontext == ccontext_start2)
 	estart -= 2;
+#ifndef SYNTAX_TEXT_PROPERTIES
+      else if (this_context == context_comment)
+#else /* SYNTAX_TEXT_PROPERTIES */
       else if (this_context == context_comment
 	       || this_context == context_generic_comment
 	       )
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	estart -= 1;
 
       edepth = context_cache.depth;
@@ -791,9 +911,13 @@
 	 a part of the comment.
        */
       if ((this_context == context_block_comment ||
+#ifndef SYNTAX_TEXT_PROPERTIES
+	   this_context == context_comment)
+#else /* SYNTAX_TEXT_PROPERTIES */
 	   this_context == context_comment
 	   || this_context == context_generic_comment
 	   )
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	  && pt < e)
 	eend++;
 
Index: src/regex.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/regex.c,v
retrieving revision 1.25.2.2
diff -u -r1.25.2.2 regex.c
--- src/regex.c	2001/05/17 13:37:45	1.25.2.2
+++ src/regex.c	2002/09/02 20:34:46
@@ -47,6 +47,7 @@
 #define _GNU_SOURCE 1
 #endif
 
+#ifdef SYNTAX_TEXT_PROPERTIES
 #ifdef emacs
 /* Converts the pointer to the char to BEG-based offset from the start.	 */
 #define PTR_TO_OFFSET(d) (MATCHING_IN_FIRST_STRING			\
@@ -55,6 +56,7 @@
 #define PTR_TO_OFFSET(d) 0
 #endif
 
+#endif /* SYNTAX_TEXT_PROPERTIES */
 /* We assume non-Mule if emacs isn't defined. */
 #ifndef emacs
 #undef MULE
@@ -190,8 +192,10 @@
 #endif /* SYNTAX_TABLE */
 
 #define SYNTAX_UNSAFE(ignored, c) re_syntax_table[c]
+#ifdef SYNTAX_TEXT_PROPERTIES
 #undef SYNTAX_FROM_CACHE
 #define SYNTAX_FROM_CACHE SYNTAX_UNSAFE
+#endif /* SYNTAX_TEXT_PROPERTIES */
 
 #define RE_TRANSLATE(c) translate[(unsigned char) (c)]
 #define TRANSLATE_P(tr) tr
@@ -3637,6 +3641,7 @@
 	  }
 
 #ifdef emacs
+#ifdef SYNTAX_TEXT_PROPERTIES
 	case wordbound:
 	case notwordbound:
 	case wordbeg:
@@ -3647,12 +3652,11 @@
 	     aborting optimizations.  */
 	  bufp->can_be_null = 1;
 	  goto done;
-
-#ifdef emacs
-#if 0   /* Removed during syntax-table properties patch -- 2000/12/07 mct */
+#else
+	  /* Removed during syntax-table properties patch -- 2000/12/07 mct */
         case syntaxspec:
 	  k = *p++;
-#endif
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	  matchsyntax:
 #ifdef MULE
 	  for (j = 0; j < 0x80; j++)
@@ -3692,7 +3696,8 @@
 	  break;
 
 
-#if 0   /* Removed during syntax-table properties patch -- 2000/12/07 mct */
+#ifndef SYNTAX_TEXT_PROPERTIES
+	  /* Removed during syntax-table properties patch -- 2000/12/07 mct */
 	case notsyntaxspec:
 	  k = *p++;
 #endif
@@ -3733,7 +3738,6 @@
 	      fastmap[j] = 1;
 #endif /* MULE */
 	  break;
-#endif /* emacs */
 
 #ifdef MULE
 /* 97/2/17 jhod category patch */
@@ -3752,7 +3756,7 @@
 	case at_dot:
 	case after_dot:
           continue;
-#endif /* not emacs */
+#endif /* emacs */
 
 
         case no_op:
@@ -3760,7 +3764,7 @@
         case endline:
 	case begbuf:
 	case endbuf:
-#ifndef emacs
+#if !defined(emacs) || !defined(SYNTAX_TEXT_PROPERTIES)
 	case wordbound:
 	case notwordbound:
 	case wordbeg:
@@ -4006,6 +4010,7 @@
 	}
     }
 
+#ifdef SYNTAX_TEXT_PROPERTIES
 #ifdef emacs
   /* In a forward search for something that starts with \=.
      don't keep searching past point.  */
@@ -4018,6 +4023,7 @@
     }
 #endif /* emacs */
 
+#endif /* SYNTAX_TEXT_PROPERTIES */
   /* Update the fastmap now if not correct already.  */
   if (fastmap && !bufp->fastmap_accurate)
     if (re_compile_fastmap (bufp) == -2)
@@ -4039,6 +4045,7 @@
   }
 #endif
 
+#ifdef SYNTAX_TEXT_PROPERTIES
 #ifdef emacs
     SETUP_SYNTAX_CACHE_FOR_OBJECT (regex_match_object,
 				   regex_emacs_buffer,
@@ -4048,6 +4055,7 @@
 				   1);
 #endif
 
+#endif /* SYNTAX_TEXT_PROPERTIES */
   /* Loop through the string, looking for a place to start matching.  */
   for (;;)
     {
@@ -4311,6 +4319,11 @@
 	    int size1, const char *string2, int size2, int pos,
 	    struct re_registers *regs, int stop)
 {
+#ifndef SYNTAX_TEXT_PROPERTIES
+  int result = re_match_2_internal (bufp, (re_char *) string1, size1,
+				    (re_char *) string2, size2,
+				    pos, regs, stop);
+#else /* SYNTAX_TEXT_PROPERTIES */
   int result;
 
 #ifdef emacs
@@ -4326,6 +4339,7 @@
 				(re_char *) string2, size2,
 				pos, regs, stop);
 
+#endif /* SYNTAX_TEXT_PROPERTIES */
   alloca (0);
   return result;
 }
@@ -5543,20 +5557,33 @@
 	      result = 1;
 	    else
 	      {
+#ifndef SYNTAX_TEXT_PROPERTIES
+		const unsigned char *d_before =
+		  (const unsigned char *) POS_BEFORE_GAP_UNSAFE (d);
+		const unsigned char *d_after =
+		  (const unsigned char *) POS_AFTER_GAP_UNSAFE (d);
+#else /* SYNTAX_TEXT_PROPERTIES */
 		re_char *d_before = POS_BEFORE_GAP_UNSAFE (d);
 		re_char *d_after = POS_AFTER_GAP_UNSAFE (d);
 
 		/* emch1 is the character before d, syn1 is the syntax of emch1,
 		   emch2 is the character at d, and syn2 is the syntax of emch2. */
+#endif /* SYNTAX_TEXT_PROPERTIES */
 		Emchar emch1, emch2;
+#ifdef SYNTAX_TEXT_PROPERTIES
 		int syn1, syn2;
 #ifdef emacs
 		int pos_before;
 #endif
+#endif /* SYNTAX_TEXT_PROPERTIES */
 
 		DEC_CHARPTR (d_before);
 		emch1 = charptr_emchar (d_before);
 		emch2 = charptr_emchar (d_after);
+#ifndef SYNTAX_TEXT_PROPERTIES
+		result = (WORDCHAR_P_UNSAFE (emch1) !=
+			  WORDCHAR_P_UNSAFE (emch2));
+#else /* SYNTAX_TEXT_PROPERTIES */
 
 #ifdef emacs
 		pos_before = SYNTAX_CACHE_BYTE_TO_CHAR (PTR_TO_OFFSET (d)) - 1;
@@ -5571,6 +5598,7 @@
 					  emch2);
 
 		result = ((syn1 == Sword) != (syn2 == Sword));
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	      }
 	    if (result == should_succeed)
 	      break;
@@ -5584,8 +5612,10 @@
 
 	case wordbeg:
           DEBUG_PRINT1 ("EXECUTING wordbeg.\n");
+#ifdef SYNTAX_TEXT_PROPERTIES
 	  if (AT_STRINGS_END (d))
 	    goto fail;
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	  {
 	    /* XEmacs: this originally read:
 
@@ -5593,33 +5623,52 @@
 	      break;
 
 	      */
+#ifndef SYNTAX_TEXT_PROPERTIES
+	    const unsigned char *dtmp =
+	      (const unsigned char *) POS_AFTER_GAP_UNSAFE (d);
+#else /* SYNTAX_TEXT_PROPERTIES */
 	    re_char *dtmp = POS_AFTER_GAP_UNSAFE (d);
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	    Emchar emch = charptr_emchar (dtmp);
+#ifndef SYNTAX_TEXT_PROPERTIES
+	    if (!WORDCHAR_P_UNSAFE (emch))
+#else /* SYNTAX_TEXT_PROPERTIES */
 #ifdef emacs
 	    int charpos = SYNTAX_CACHE_BYTE_TO_CHAR (PTR_TO_OFFSET (d));
 	    UPDATE_SYNTAX_CACHE (charpos);
 #endif
 	    if (SYNTAX_FROM_CACHE (XCHAR_TABLE (regex_emacs_buffer->mirror_syntax_table),
 				   emch) != Sword)
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	      goto fail;
 	    if (AT_STRINGS_BEG (d))
 	      break;
+#ifndef SYNTAX_TEXT_PROPERTIES
+	    dtmp = (const unsigned char *) POS_BEFORE_GAP_UNSAFE (d);
+#else /* SYNTAX_TEXT_PROPERTIES */
 	    dtmp = POS_BEFORE_GAP_UNSAFE (d);
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	    DEC_CHARPTR (dtmp);
 	    emch = charptr_emchar (dtmp);
+#ifndef SYNTAX_TEXT_PROPERTIES
+	    if (!WORDCHAR_P_UNSAFE (emch))
+#else /* SYNTAX_TEXT_PROPERTIES */
 #ifdef emacs
 	    UPDATE_SYNTAX_CACHE_BACKWARD (charpos - 1);
 #endif
 	    if (SYNTAX_FROM_CACHE (XCHAR_TABLE (regex_emacs_buffer->mirror_syntax_table),
 				   emch) != Sword)
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	      break;
 	    goto fail;
 	  }
 
 	case wordend:
           DEBUG_PRINT1 ("EXECUTING wordend.\n");
+#ifdef SYNTAX_TEXT_PROPERTIES
 	  if (AT_STRINGS_BEG (d))
 	    goto fail;
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	  {
 	    /* XEmacs: this originally read:
 
@@ -5629,27 +5678,49 @@
 
 	      The or condition is incorrect (reversed).
 	      */
+#ifndef SYNTAX_TEXT_PROPERTIES
+	    const unsigned char *dtmp;
+#else /* SYNTAX_TEXT_PROPERTIES */
 	    re_char *dtmp;
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	    Emchar emch;
+#ifndef SYNTAX_TEXT_PROPERTIES
+	    if (AT_STRINGS_BEG (d))
+	      goto fail;
+	    dtmp = (const unsigned char *) POS_BEFORE_GAP_UNSAFE (d);
+#else /* SYNTAX_TEXT_PROPERTIES */
 #ifdef emacs
 	    int charpos = SYNTAX_CACHE_BYTE_TO_CHAR (PTR_TO_OFFSET (d)) - 1;
 	    UPDATE_SYNTAX_CACHE (charpos);
 #endif
 	    dtmp = POS_BEFORE_GAP_UNSAFE (d);
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	    DEC_CHARPTR (dtmp);
 	    emch = charptr_emchar (dtmp);
+#ifndef SYNTAX_TEXT_PROPERTIES
+	    if (!WORDCHAR_P_UNSAFE (emch))
+#else /* SYNTAX_TEXT_PROPERTIES */
 	    if (SYNTAX_FROM_CACHE (XCHAR_TABLE (regex_emacs_buffer->mirror_syntax_table),
 				   emch) != Sword)
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	      goto fail;
 	    if (AT_STRINGS_END (d))
 	      break;
+#ifndef SYNTAX_TEXT_PROPERTIES
+	    dtmp = (const unsigned char *) POS_AFTER_GAP_UNSAFE (d);
+#else /* SYNTAX_TEXT_PROPERTIES */
 	    dtmp = POS_AFTER_GAP_UNSAFE (d);
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	    emch = charptr_emchar (dtmp);
+#ifndef SYNTAX_TEXT_PROPERTIES
+	    if (!WORDCHAR_P_UNSAFE (emch))
+#else /* SYNTAX_TEXT_PROPERTIES */
 #ifdef emacs
 	    UPDATE_SYNTAX_CACHE_FORWARD (charpos + 1);
 #endif
 	    if (SYNTAX_FROM_CACHE (XCHAR_TABLE (regex_emacs_buffer->mirror_syntax_table),
 				   emch) != Sword)
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	      break;
 	    goto fail;
 	  }
@@ -5657,7 +5728,11 @@
 #ifdef emacs
   	case before_dot:
           DEBUG_PRINT1 ("EXECUTING before_dot.\n");
+#ifndef SYNTAX_TEXT_PROPERTIES
+ 	  if (!regex_emacs_buffer_p
+#else /* SYNTAX_TEXT_PROPERTIES */
  	  if (! (NILP (regex_match_object) || BUFFERP (regex_match_object))
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	      || (BUF_PTR_BYTE_POS (regex_emacs_buffer, (unsigned char *) d)
 		  >= BUF_PT (regex_emacs_buffer)))
   	    goto fail;
@@ -5665,7 +5740,11 @@
 
   	case at_dot:
           DEBUG_PRINT1 ("EXECUTING at_dot.\n");
+#ifndef SYNTAX_TEXT_PROPERTIES
+ 	  if (!regex_emacs_buffer_p
+#else /* SYNTAX_TEXT_PROPERTIES */
  	  if (! (NILP (regex_match_object) || BUFFERP (regex_match_object))
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	      || (BUF_PTR_BYTE_POS (regex_emacs_buffer, (unsigned char *) d)
 		  != BUF_PT (regex_emacs_buffer)))
   	    goto fail;
@@ -5673,7 +5752,11 @@
 
   	case after_dot:
           DEBUG_PRINT1 ("EXECUTING after_dot.\n");
+#ifndef SYNTAX_TEXT_PROPERTIES
+          if (!regex_emacs_buffer_p
+#else /* SYNTAX_TEXT_PROPERTIES */
           if (! (NILP (regex_match_object) || BUFFERP (regex_match_object))
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	      || (BUF_PTR_BYTE_POS (regex_emacs_buffer, (unsigned char *) d)
 		  <= BUF_PT (regex_emacs_buffer)))
   	    goto fail;
@@ -5703,6 +5786,7 @@
 	    Emchar emch;
 
 	    REGEX_PREFETCH ();
+#ifdef SYNTAX_TEXT_PROPERTIES
 #ifdef emacs
 	    {
 	      int charpos = SYNTAX_CACHE_BYTE_TO_CHAR (PTR_TO_OFFSET (d));
@@ -5710,9 +5794,16 @@
 	    }
 #endif
 
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	    emch = charptr_emchar ((const Bufbyte *) d);
+#ifndef SYNTAX_TEXT_PROPERTIES
+	    matches = (SYNTAX_UNSAFE
+		       (XCHAR_TABLE (regex_emacs_buffer->mirror_syntax_table),
+			emch) == (enum syntaxcode) mcnt);
+#else /* SYNTAX_TEXT_PROPERTIES */
 	    matches = (SYNTAX_FROM_CACHE (regex_emacs_buffer->mirror_syntax_table,
 			emch) == (enum syntaxcode) mcnt);
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	    INC_CHARPTR (d);
 	    if (matches != should_succeed)
 	      goto fail;
Index: src/search.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/search.c,v
retrieving revision 1.17.2.1.4.2
diff -u -r1.17.2.1.4.2 search.c
--- src/search.c	2002/08/24 04:47:52	1.17.2.1.4.2
+++ src/search.c	2002/09/02 20:34:47
@@ -313,8 +313,13 @@
   s1 = p2 - p1;
   s2 = BI_BUF_ZV (buf) - p2;
 
+#ifdef SYNTAX_TEXT_PROPERTIES
   regex_match_object = Qnil;
+#endif /* SYNTAX_TEXT_PROPERTIES */
   regex_emacs_buffer = buf;
+#ifndef SYNTAX_TEXT_PROPERTIES
+  regex_emacs_buffer_p = 1;
+#endif /* ! SYNTAX_TEXT_PROPERTIES */
   i = re_match_2 (bufp, (char *) BI_BUF_BYTE_ADDRESS (buf, p1),
 		  s1, (char *) BI_BUF_BYTE_ADDRESS (buf, p2), s2,
 		  BI_BUF_PT (buf) - BI_BUF_BEGV (buf), &search_regs,
@@ -404,8 +409,13 @@
   QUIT;
   {
     Bytecount bis = charcount_to_bytecount (XSTRING_DATA (string), s);
+#ifdef SYNTAX_TEXT_PROPERTIES
     regex_match_object = string;
+#endif /* SYNTAX_TEXT_PROPERTIES */
     regex_emacs_buffer = buf;
+#ifndef SYNTAX_TEXT_PROPERTIES
+    regex_emacs_buffer_p = 0;
+#endif /* ! SYNTAX_TEXT_PROPERTIES */
     val = re_search (bufp, (char *) XSTRING_DATA (string),
 		     XSTRING_LENGTH (string), bis,
 		     XSTRING_LENGTH (string) - bis,
@@ -496,8 +506,13 @@
     }
 
   /* #### evil current-buffer dependency */
+#ifdef SYNTAX_TEXT_PROPERTIES
   regex_match_object = reloc;
+#endif /* SYNTAX_TEXT_PROPERTIES */
   regex_emacs_buffer = current_buffer;
+#ifndef SYNTAX_TEXT_PROPERTIES
+  regex_emacs_buffer_p = 0;
+#endif /* ! SYNTAX_TEXT_PROPERTIES */
   val = re_search (bufp, (char *) newnonreloc + offset, length, 0,
 		   length, 0);
 
@@ -786,9 +801,9 @@
   unsigned char fastmap[0400];
   int negate = 0;
   REGISTER int i;
-#ifndef emacs
+#if !defined(SYNTAX_TEXT_PROPERTIES) || !defined(emacs)
   Lisp_Char_Table *syntax_table = XCHAR_TABLE (buf->mirror_syntax_table);
-#endif
+#endif /* SYNTAX_TEXT_PROPERTIES */
   Bufpos limit;
 
   if (NILP (lim))
@@ -888,7 +903,9 @@
 
     if (syntaxp)
       {
+#ifdef SYNTAX_TEXT_PROPERTIES
 	SETUP_SYNTAX_CACHE_FOR_BUFFER (buf, pos, forwardp ? 1 : -1);
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	/* All syntax designators are normal chars so nothing strange
 	   to worry about */
 	if (forwardp)
@@ -896,15 +913,23 @@
 	    if (pos < limit)
 	      while (fastmap[(unsigned char)
 			     syntax_code_spec
+#ifndef SYNTAX_TEXT_PROPERTIES
+			     [(int) SYNTAX (syntax_table,
+					    BUF_FETCH_CHAR
+					    (buf, BUF_PT (buf)))]])
+#else /* SYNTAX_TEXT_PROPERTIES */
 			     [(int) SYNTAX_FROM_CACHE
 			      (syntax_table,
 			       BI_BUF_FETCH_CHAR (buf, pos_byte))]])
+#endif /* SYNTAX_TEXT_PROPERTIES */
 		{
 		  pos++;
 		  INC_BYTIND (buf, pos_byte);
 		  if (pos >= limit)
 		    break;
+#ifdef SYNTAX_TEXT_PROPERTIES
 		  UPDATE_SYNTAX_CACHE_FORWARD (pos);
+#endif /* SYNTAX_TEXT_PROPERTIES */
 		}
 	  }
 	else
@@ -914,12 +939,20 @@
 		Bufpos savepos = pos_byte;
 		pos--;
 		DEC_BYTIND (buf, pos_byte);
+#ifdef SYNTAX_TEXT_PROPERTIES
 		UPDATE_SYNTAX_CACHE_BACKWARD (pos);
+#endif /* SYNTAX_TEXT_PROPERTIES */
 		if (!fastmap[(unsigned char)
 			     syntax_code_spec
+#ifndef SYNTAX_TEXT_PROPERTIES
+			     [(int) SYNTAX (syntax_table,
+					    BUF_FETCH_CHAR
+					    (buf, BUF_PT (buf)))]])
+#else /* SYNTAX_TEXT_PROPERTIES */
 			     [(int) SYNTAX_FROM_CACHE
 			      (syntax_table,
 			       BI_BUF_FETCH_CHAR (buf, pos_byte))]])
+#endif /* SYNTAX_TEXT_PROPERTIES */
 		  {
 		    pos++;
 		    pos_byte = savepos;
@@ -1196,13 +1229,18 @@
       p2 = BI_BUF_CEILING_OF (buf, p1);
       s1 = p2 - p1;
       s2 = BI_BUF_ZV (buf) - p2;
+#ifdef SYNTAX_TEXT_PROPERTIES
       regex_match_object = Qnil;
+#endif /* SYNTAX_TEXT_PROPERTIES */
 
       while (n < 0)
 	{
 	  Bytecount val;
 	  QUIT;
           regex_emacs_buffer = buf;
+#ifndef SYNTAX_TEXT_PROPERTIES
+	  regex_emacs_buffer_p = 1;
+#endif /* ! SYNTAX_TEXT_PROPERTIES */
 	  val = re_search_2 (bufp,
 			     (char *) BI_BUF_BYTE_ADDRESS (buf, p1), s1,
 			     (char *) BI_BUF_BYTE_ADDRESS (buf, p2), s2,
@@ -1241,6 +1279,9 @@
 	  Bytecount val;
 	  QUIT;
           regex_emacs_buffer = buf;
+#ifndef SYNTAX_TEXT_PROPERTIES
+	  regex_emacs_buffer_p = 1;
+#endif /* ! SYNTAX_TEXT_PROPERTIES */
           val = re_search_2 (bufp,
 			     (char *) BI_BUF_BYTE_ADDRESS (buf, p1), s1,
 			     (char *) BI_BUF_BYTE_ADDRESS (buf, p2), s2,
Index: src/syntax.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/syntax.c,v
retrieving revision 1.9.2.1
diff -u -r1.9.2.1 syntax.c
--- src/syntax.c	2001/07/25 07:45:37	1.9.2.1
+++ src/syntax.c	2002/09/02 20:34:48
@@ -28,7 +28,9 @@
 
 #include "buffer.h"
 #include "syntax.h"
+#ifdef SYNTAX_TEXT_PROPERTIES
 #include "extents.h"
+#endif /* SYNTAX_TEXT_PROPERTIES */
 
 /* Here is a comment from Ken'ichi HANDA <handa@etl.go.jp>
    explaining the purpose of the Sextword syntax category:
@@ -56,12 +58,15 @@
 /* Mule 2.4 doesn't seem to have Sextword - I'm removing it -- mrb */
 /* Recovered by tomo */
 
+#ifdef SYNTAX_TEXT_PROPERTIES
 #define ST_COMMENT_STYLE 0x101
 #define ST_STRING_STYLE  0x102
 
 Lisp_Object Qsyntax_table;
+Lisp_Object Qsyntax_text_properties;
 int lookup_syntax_properties;
 
+#endif /* SYNTAX_TEXT_PROPERTIES */
 Lisp_Object Qsyntax_table_p;
 
 int words_include_escapes;
@@ -81,9 +86,14 @@
    and the like. */
 struct buffer *regex_emacs_buffer;
 
+#ifndef SYNTAX_TEXT_PROPERTIES
+/* Tell the regex routines whether buffer is used or not. */
+int regex_emacs_buffer_p;
+#else /* SYNTAX_TEXT_PROPERTIES */
 /* In Emacs, this is the string or buffer in which we
    are matching.  It is used for looking up syntax properties.	*/
 Lisp_Object regex_match_object;
+#endif /* SYNTAX_TEXT_PROPERTIES */
 
 Lisp_Object Vstandard_syntax_table;
 
@@ -104,9 +114,13 @@
   Bufpos prevlevelstart;/* Char number of start of containing expression */
   Bufpos location;	/* Char number at which parsing stopped */
   int mindepth;		/* Minimum depth seen while scanning  */
+#ifndef SYNTAX_TEXT_PROPERTIES
+  Bufpos comstart;	/* Position just after last comment starter  */
+#else /* SYNTAX_TEXT_PROPERTIES */
   Bufpos comstr_start;	/* Position just after last comment/string starter  */
   Lisp_Object levelstarts;	/* Char numbers of starts-of-expression
                                    of levels (starting from outermost).  */
+#endif /* SYNTAX_TEXT_PROPERTIES */
 };
 
 /* These variables are a cache for finding the start of a defun.
@@ -130,6 +144,9 @@
 find_defun_start (struct buffer *buf, Bufpos pos)
 {
   Bufpos tem;
+#ifndef SYNTAX_TEXT_PROPERTIES
+  Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
+#endif /* ! SYNTAX_TEXT_PROPERTIES */
 
   /* Use previous finding, if it's valid and applies to this inquiry.  */
   if (buf == find_start_buffer
@@ -145,13 +162,21 @@
   /* Back up to start of line.  */
   tem = find_next_newline (buf, pos, -1);
 
+#ifdef SYNTAX_TEXT_PROPERTIES
   SETUP_SYNTAX_CACHE (tem, 1);
+#endif /* SYNTAX_TEXT_PROPERTIES */
   while (tem > BUF_BEGV (buf))
     {
+#ifdef SYNTAX_TEXT_PROPERTIES
       UPDATE_SYNTAX_CACHE_BACKWARD(tem);
 
+#endif /* SYNTAX_TEXT_PROPERTIES */
       /* Open-paren at start of line means we found our defun-start.  */
+#ifndef SYNTAX_TEXT_PROPERTIES
+      if (SYNTAX (mirrortab, BUF_FETCH_CHAR (buf, tem)) == Sopen)
+#else /* SYNTAX_TEXT_PROPERTIES */
       if (SYNTAX_FROM_CACHE (mirrortab, BUF_FETCH_CHAR (buf, tem)) == Sopen)
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	break;
       /* Move to beg of previous line.  */
       tem = find_next_newline (buf, tem, -2);
@@ -235,6 +260,7 @@
   return syntax_table;
 }
 
+#ifdef SYNTAX_TEXT_PROPERTIES
 /* The current syntax state */
 struct syntax_cache syntax_cache;
 
@@ -333,6 +359,7 @@
     }
 }
 
+#endif /* SYNTAX_TEXT_PROPERTIES */
 /* Convert a letter which signifies a syntax code
    into the code it signifies.
    This is used by modify-syntax-entry, and other things. */
@@ -356,10 +383,18 @@
   0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,   /* `, a, ... */
   0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
   0377, 0377, 0377, 0377, 0377, 0377, 0377, (char) Sword,
+#ifndef SYNTAX_TEXT_PROPERTIES
+  0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377
+#else /* SYNTAX_TEXT_PROPERTIES */
   0377, 0377, 0377, 0377, (char) Sstring_fence, 0377, 0377, 0377
+#endif /* SYNTAX_TEXT_PROPERTIES */
 };
 
+#ifndef SYNTAX_TEXT_PROPERTIES
+const unsigned char syntax_code_spec[] =  " .w_()'\"$\\/<>@";
+#else /* SYNTAX_TEXT_PROPERTIES */
 const unsigned char syntax_code_spec[] =  " .w_()'\"$\\/<>@!|";
+#endif /* SYNTAX_TEXT_PROPERTIES */
 
 DEFUN ("syntax-designator-chars", Fsyntax_designator_chars, 0, 0, 0, /*
 Return a string of the recognized syntax designator chars.
@@ -461,11 +496,16 @@
 scan_words (struct buffer *buf, Bufpos from, int count)
 {
   Bufpos limit = count > 0 ? BUF_ZV (buf) : BUF_BEGV (buf);
+#ifndef SYNTAX_TEXT_PROPERTIES
+  Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
+#endif /* ! SYNTAX_TEXT_PROPERTIES */
   Emchar ch0, ch1;
   enum syntaxcode code;
 
+#ifdef SYNTAX_TEXT_PROPERTIES
   SETUP_SYNTAX_CACHE_FOR_BUFFER (buf, from, count);
 
+#endif /* SYNTAX_TEXT_PROPERTIES */
   /* #### is it really worth it to hand expand both cases? JV */
   while (count > 0)
     {
@@ -476,9 +516,15 @@
 	  if (from == limit)
 	    return 0;
 
+#ifdef SYNTAX_TEXT_PROPERTIES
 	  UPDATE_SYNTAX_CACHE_FORWARD (from);
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	  ch0 = BUF_FETCH_CHAR (buf, from);
+#ifndef SYNTAX_TEXT_PROPERTIES
+	  code = SYNTAX_UNSAFE (mirrortab, ch0);
+#else /* SYNTAX_TEXT_PROPERTIES */
 	  code = SYNTAX_FROM_CACHE (mirrortab, ch0);
+#endif /* SYNTAX_TEXT_PROPERTIES */
 
 	  from++;
 	  if (words_include_escapes
@@ -492,9 +538,15 @@
 
       while (from != limit)
 	{
+#ifdef SYNTAX_TEXT_PROPERTIES
 	  UPDATE_SYNTAX_CACHE_FORWARD (from);
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	  ch1 = BUF_FETCH_CHAR (buf, from);
+#ifndef SYNTAX_TEXT_PROPERTIES
+	  code = SYNTAX_UNSAFE (mirrortab, ch1);
+#else /* SYNTAX_TEXT_PROPERTIES */
 	  code = SYNTAX_FROM_CACHE (mirrortab, ch1);
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	  if (!(words_include_escapes
 		&& (code == Sescape || code == Scharquote)))
 	    if (code != Sword
@@ -520,11 +572,20 @@
 	  if (from == limit)
 	    return 0;
 
+#ifdef SYNTAX_TEXT_PROPERTIES
 	  UPDATE_SYNTAX_CACHE_BACKWARD (from - 1);
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	  ch1 = BUF_FETCH_CHAR (buf, from - 1);
+#ifndef SYNTAX_TEXT_PROPERTIES
+	  code = SYNTAX_UNSAFE (mirrortab, ch1);
+
+#else /* SYNTAX_TEXT_PROPERTIES */
 	  code = SYNTAX_FROM_CACHE (mirrortab, ch1);
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	  from--;
+#ifdef SYNTAX_TEXT_PROPERTIES
 
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	  if (words_include_escapes
 	      && (code == Sescape || code == Scharquote))
 	    break;
@@ -536,10 +597,16 @@
 
       while (from != limit)
 	{
+#ifdef SYNTAX_TEXT_PROPERTIES
 	  UPDATE_SYNTAX_CACHE_BACKWARD (from - 1);
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	  ch0 = BUF_FETCH_CHAR (buf, from - 1);
+#ifndef SYNTAX_TEXT_PROPERTIES
+	  code = SYNTAX_UNSAFE (mirrortab, ch0);
+#else /* SYNTAX_TEXT_PROPERTIES */
 	  code = SYNTAX_FROM_CACHE (mirrortab, ch0);
 
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	  if (!(words_include_escapes
 		&& (code == Sescape || code == Scharquote)))
 	    if (code != Sword
@@ -611,6 +678,9 @@
 {
   Emchar c;
   enum syntaxcode code;
+#ifndef SYNTAX_TEXT_PROPERTIES
+  Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
+#endif /* ! SYNTAX_TEXT_PROPERTIES */
 
   /* Look back, counting the parity of string-quotes,
      and recording the comment-starters seen.
@@ -636,32 +706,76 @@
      that determines quote parity to the comment-end.  */
   while (from != stop)
     {
+#ifdef SYNTAX_TEXT_PROPERTIES
       int syncode;
 
+#endif /* SYNTAX_TEXT_PROPERTIES */
       /* Move back and examine a character.  */
       from--;
+#ifdef SYNTAX_TEXT_PROPERTIES
       UPDATE_SYNTAX_CACHE_BACKWARD (from);
+#endif /* SYNTAX_TEXT_PROPERTIES */
 
       c = BUF_FETCH_CHAR (buf, from);
+#ifndef SYNTAX_TEXT_PROPERTIES
+      code = SYNTAX_UNSAFE (mirrortab, c);
+#else /* SYNTAX_TEXT_PROPERTIES */
       code = SYNTAX_FROM_CACHE (mirrortab, c);
       syncode = SYNTAX_CODE_FROM_CACHE (mirrortab, c);
+#endif /* SYNTAX_TEXT_PROPERTIES */
 
       /* is this a 1-char comment end sequence? if so, try
 	 to see if style matches previously extracted mask */
       if (code == Sendcomment)
 	{
+#ifndef SYNTAX_TEXT_PROPERTIES
+	  styles_match_p = SYNTAX_STYLES_MATCH_1CHAR_P (mirrortab, c, mask);
+	}
+
+      /* otherwise, is this a 2-char comment end sequence? */
+      else if (from >= stop
+	       && SYNTAX_END_P (mirrortab, c, BUF_FETCH_CHAR (buf, from+1)))
+	{
+	  code = Sendcomment;
+#endif /* ! SYNTAX_TEXT_PROPERTIES */
 	  styles_match_p =
+#ifndef SYNTAX_TEXT_PROPERTIES
+	    SYNTAX_STYLES_MATCH_END_P (mirrortab, c,
+				       BUF_FETCH_CHAR (buf, from+1),
+				       mask);
+#else /* SYNTAX_TEXT_PROPERTIES */
 	    SYNTAX_CODE_COMMENT_1CHAR_MASK (syncode) & mask;
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	}
 
       /* or are we looking at a 1-char comment start sequence
 	 of the style matching mask? */
+#ifndef SYNTAX_TEXT_PROPERTIES
+      else if (code == Scomment
+	       && SYNTAX_STYLES_MATCH_1CHAR_P (mirrortab, c, mask))
+  	{
+	  styles_match_p = 1;
+  	}
+  
+      /* or possibly, a 2-char comment start sequence */
+      else if (from >= stop
+	       && SYNTAX_STYLES_MATCH_START_P (mirrortab, c,
+					       BUF_FETCH_CHAR (buf, from+1),
+					       mask))
+#else /* SYNTAX_TEXT_PROPERTIES */
       else if (code == Scomment)
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	{
+#ifndef SYNTAX_TEXT_PROPERTIES
+	  code = Scomment;
+	  styles_match_p = 1;
+#else /* SYNTAX_TEXT_PROPERTIES */
 	  styles_match_p =
 	    SYNTAX_CODE_COMMENT_1CHAR_MASK (syncode) & mask;
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	}
 
+#ifdef SYNTAX_TEXT_PROPERTIES
       /* otherwise, is this a 2-char comment end or start sequence? */
       else if (from > stop)
 	do
@@ -711,6 +825,7 @@
 	      }
 	  } while (0);
 
+#endif /* SYNTAX_TEXT_PROPERTIES */
       /* Ignore escaped characters.  */
       if (char_quoted (buf, from))
 	continue;
@@ -727,6 +842,7 @@
 	    string_lossage = 1;
 	}
 
+#ifdef SYNTAX_TEXT_PROPERTIES
       if (code == Sstring_fence || code == Scomment_fence)
 	{
 	  parity ^= 1;
@@ -740,6 +856,7 @@
 	    string_lossage = 1;
 	}
 
+#endif /* SYNTAX_TEXT_PROPERTIES */
       /* Record comment-starters according to that
 	 quote-parity to the comment-end.  */
       if (code == Scomment && styles_match_p)
@@ -781,11 +898,17 @@
       scan_sexps_forward (buf, &state, find_defun_start (buf, comment_end),
 			  comment_end - 1, -10000, 0, Qnil, 0);
       if (state.incomment)
+#ifndef SYNTAX_TEXT_PROPERTIES
+	from = state.comstart;
+#else /* SYNTAX_TEXT_PROPERTIES */
 	from = state.comstr_start;
+#endif /* SYNTAX_TEXT_PROPERTIES */
       else
 	/* We can't grok this as a comment; scan it normally.  */
 	from = comment_end;
+#ifdef SYNTAX_TEXT_PROPERTIES
       UPDATE_SYNTAX_CACHE_FORWARD (from - 1);
+#endif /* SYNTAX_TEXT_PROPERTIES */
     }
   return from;
 }
@@ -794,7 +917,11 @@
 find_end_of_comment (struct buffer *buf, Bufpos from, Bufpos stop, int comstyle)
 {
   int c;
+#ifndef SYNTAX_TEXT_PROPERTIES
+  Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
+#else /* SYNTAX_TEXT_PROPERTIES */
   int prev_code;
+#endif /* SYNTAX_TEXT_PROPERTIES */
   /* mask to match comment styles against; for ST_COMMENT_STYLE, this
      will get set to SYNTAX_COMMENT_STYLE_B, but never get checked */
   int mask = comstyle ? SYNTAX_COMMENT_STYLE_B : SYNTAX_COMMENT_STYLE_A;
@@ -807,9 +934,15 @@
 	{
 	  return -1;
 	}
+#ifdef SYNTAX_TEXT_PROPERTIES
 
       UPDATE_SYNTAX_CACHE_FORWARD (from);
+#endif /* SYNTAX_TEXT_PROPERTIES */
       c = BUF_FETCH_CHAR (buf, from);
+#ifndef SYNTAX_TEXT_PROPERTIES
+      if (SYNTAX_UNSAFE (mirrortab, c) == Sendcomment
+	  && SYNTAX_STYLES_MATCH_1CHAR_P (mirrortab, c, mask))
+#else /* SYNTAX_TEXT_PROPERTIES */
 
       /* Test for generic comments */
       if (comstyle == ST_COMMENT_STYLE)
@@ -829,33 +962,51 @@
 	if (SYNTAX_FROM_CACHE (mirrortab, c) == Sendcomment
 	    && SYNTAX_CODE_MATCHES_1CHAR_P
 	    (SYNTAX_CODE_FROM_CACHE (mirrortab, c), mask))
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	/* we have encountered a comment end of the same style
 	   as the comment sequence which began this comment
 	   section */
+#ifndef SYNTAX_TEXT_PROPERTIES
+	break;
+#else /* SYNTAX_TEXT_PROPERTIES */
 	  {
 	    from++;
 	    UPDATE_SYNTAX_CACHE_FORWARD (from);
 	    break;
 	  }
+#endif /* SYNTAX_TEXT_PROPERTIES */
 
+#ifdef SYNTAX_TEXT_PROPERTIES
       prev_code = SYNTAX_CODE_FROM_CACHE (mirrortab, c);
+#endif /* SYNTAX_TEXT_PROPERTIES */
       from++;
+#ifdef SYNTAX_TEXT_PROPERTIES
       UPDATE_SYNTAX_CACHE_FORWARD (from);
+#endif /* SYNTAX_TEXT_PROPERTIES */
       if (from < stop
+#ifndef SYNTAX_TEXT_PROPERTIES
+	  && SYNTAX_STYLES_MATCH_END_P (mirrortab, c,
+					BUF_FETCH_CHAR (buf, from), mask))
+#else /* SYNTAX_TEXT_PROPERTIES */
 	  && SYNTAX_CODES_MATCH_END_P
 	  (prev_code,
 	   SYNTAX_CODE_FROM_CACHE (mirrortab, BUF_FETCH_CHAR (buf, from)),
 	   mask)
 
 	  )
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	/* we have encountered a comment end of the same style
 	   as the comment sequence which began this comment
 	   section */
+#ifndef SYNTAX_TEXT_PROPERTIES
+	{ from++; break; }
+#else /* SYNTAX_TEXT_PROPERTIES */
 	{
 	  from++;
 	  UPDATE_SYNTAX_CACHE_FORWARD (from);
 	  break;
 	}
+#endif /* SYNTAX_TEXT_PROPERTIES */
     }
   return from;
 }
@@ -883,9 +1034,14 @@
   Bufpos stop;
   Emchar c;
   enum syntaxcode code;
+#ifdef SYNTAX_TEXT_PROPERTIES
   int syncode;
+#endif /* SYNTAX_TEXT_PROPERTIES */
   EMACS_INT n;
   struct buffer *buf = decode_buffer (buffer, 0);
+#ifndef SYNTAX_TEXT_PROPERTIES
+  Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
+#endif /* ! SYNTAX_TEXT_PROPERTIES */
 
   if (NILP (count))
     n = 1;
@@ -897,7 +1053,9 @@
 
   from = BUF_PT (buf);
 
+#ifdef SYNTAX_TEXT_PROPERTIES
   SETUP_SYNTAX_CACHE (from, n);
+#endif /* SYNTAX_TEXT_PROPERTIES */
   while (n > 0)
     {
       QUIT;
@@ -913,10 +1071,16 @@
 	      continue;
 	    }
 
+#ifdef SYNTAX_TEXT_PROPERTIES
 	  UPDATE_SYNTAX_CACHE_FORWARD (from);
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	  c = BUF_FETCH_CHAR (buf, from);
+#ifndef SYNTAX_TEXT_PROPERTIES
+	  code = SYNTAX (mirrortab, c);
+#else /* SYNTAX_TEXT_PROPERTIES */
 	  code = SYNTAX_FROM_CACHE (mirrortab, c);
 	  syncode = SYNTAX_CODE_FROM_CACHE (mirrortab, c);
+#endif /* SYNTAX_TEXT_PROPERTIES */
 
 	  if (code == Scomment)
 	    {
@@ -925,13 +1089,34 @@
 		 we must record the comment style this character begins
 		 so that later, only a comment end of the same style actually
 		 ends the comment section */
+#ifndef SYNTAX_TEXT_PROPERTIES
+	      comstyle = SYNTAX_COMMENT_1CHAR_MASK (mirrortab, c)
+#else /* SYNTAX_TEXT_PROPERTIES */
 	      comstyle = SYNTAX_CODE_COMMENT_1CHAR_MASK (syncode)
+#endif /* SYNTAX_TEXT_PROPERTIES */
 		== SYNTAX_COMMENT_STYLE_A ? 0 : 1;
 	    }
 
+#ifndef SYNTAX_TEXT_PROPERTIES
+	  else if (from < stop
+		   && SYNTAX_START_P (mirrortab, c, BUF_FETCH_CHAR (buf, from+1)))
+#else /* SYNTAX_TEXT_PROPERTIES */
 	  else if (code == Scomment_fence)
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	    {
+#ifndef SYNTAX_TEXT_PROPERTIES
+	      /* we have encountered a 2char comment start sequence and we
+		 are ignoring all text inside comments. we must record
+		 the comment style this sequence begins so that later,
+		 only a comment end of the same style actually ends
+		 the comment section */
+	      code = Scomment;
+	      comstyle = SYNTAX_COMMENT_MASK_START (mirrortab, c,
+						BUF_FETCH_CHAR (buf, from+1))
+		== SYNTAX_COMMENT_STYLE_A ? 0 : 1;
+#endif /* ! SYNTAX_TEXT_PROPERTIES */
 	      from++;
+#ifdef SYNTAX_TEXT_PROPERTIES
 	      code = Scomment;
 	      comstyle = ST_COMMENT_STYLE;
  	    }
@@ -958,6 +1143,7 @@
 		    == SYNTAX_COMMENT_STYLE_A ? 0 : 1;
 		  from++;
 		}
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	    }
 
 	  if (code == Scomment)
@@ -995,7 +1181,7 @@
       stop = BUF_BEGV (buf);
       while (from > stop)
 	{
-          int comstyle = 0;     /* mask for finding matching comment style */
+	  int comstyle = 0;     /* mask for finding matching comment style */
 
 	  from--;
 	  if (char_quoted (buf, from))
@@ -1005,21 +1191,46 @@
 	    }
 
 	  c = BUF_FETCH_CHAR (buf, from);
+#ifndef SYNTAX_TEXT_PROPERTIES
+	  code = SYNTAX (mirrortab, c);
+#else /* SYNTAX_TEXT_PROPERTIES */
 	  code = SYNTAX_FROM_CACHE (mirrortab, c);
 	  syncode = SYNTAX_CODE_FROM_CACHE (mirrortab, c);
+#endif /* SYNTAX_TEXT_PROPERTIES */
 
 	  if (code == Sendcomment)
 	    {
 	      /* we have found a single char end comment. we must record
 		 the comment style encountered so that later, we can match
 		 only the proper comment begin sequence of the same style */
+#ifndef SYNTAX_TEXT_PROPERTIES
+	      comstyle = SYNTAX_COMMENT_1CHAR_MASK (mirrortab, c)
+		== SYNTAX_COMMENT_STYLE_A ? 0 : 1;
+#else /* SYNTAX_TEXT_PROPERTIES */
 	      comstyle = SYNTAX_CODE_COMMENT_1CHAR_MASK (syncode)
 		== SYNTAX_COMMENT_STYLE_A ? 0 : 1;
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	    }
 
+#ifndef SYNTAX_TEXT_PROPERTIES
+	  else if (from > stop
+		   && SYNTAX_END_P (mirrortab, BUF_FETCH_CHAR (buf, from - 1), c)
+		   && !char_quoted (buf, from - 1))
+#else /* SYNTAX_TEXT_PROPERTIES */
 	  else if (code == Scomment_fence)
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	    {
+	      /* We must record the comment style encountered so that
+		 later, we can match only the proper comment begin
+		 sequence of the same style.  */
 	      code = Sendcomment;
+#ifndef SYNTAX_TEXT_PROPERTIES
+	      comstyle = SYNTAX_COMMENT_MASK_END (mirrortab,
+					      BUF_FETCH_CHAR (buf, from - 1),
+					      c)
+		== SYNTAX_COMMENT_STYLE_A ? 0 : 1;
+	      from--;
+#else /* SYNTAX_TEXT_PROPERTIES */
 	      comstyle = ST_COMMENT_STYLE;
 	    }
 
@@ -1041,6 +1252,7 @@
 		    (prev_syncode, syncode) == SYNTAX_COMMENT_STYLE_A ? 0 : 1;
 		  from--;
 		}
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	    }
 
 	  if (code == Sendcomment)
@@ -1050,8 +1262,13 @@
             }
 
 	  else if (code != Swhitespace
+#ifndef SYNTAX_TEXT_PROPERTIES
+		   && SYNTAX (mirrortab, c) != Scomment
+		   && SYNTAX (mirrortab, c) != Sendcomment)
+#else /* SYNTAX_TEXT_PROPERTIES */
 		   && code != Scomment
 		   && code != Sendcomment)
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	    {
 	      BUF_SET_PT (buf, from + 1);
 	      return Qnil;
@@ -1075,12 +1292,20 @@
   int quoted;
   int mathexit = 0;
   enum syntaxcode code;
+#ifdef SYNTAX_TEXT_PROPERTIES
   int syncode;
+#endif /* SYNTAX_TEXT_PROPERTIES */
   int min_depth = depth;    /* Err out if depth gets less than this. */
+#ifndef SYNTAX_TEXT_PROPERTIES
+  Lisp_Object syntaxtab = buf->syntax_table;
+  Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
+#endif /* ! SYNTAX_TEXT_PROPERTIES */
 
   if (depth > 0) min_depth = 0;
 
+#ifdef SYNTAX_TEXT_PROPERTIES
   SETUP_SYNTAX_CACHE_FOR_BUFFER (buf, from, count);
+#endif /* SYNTAX_TEXT_PROPERTIES */
   while (count > 0)
     {
       QUIT;
@@ -1090,24 +1315,40 @@
 	{
           int comstyle = 0;     /* mask for finding matching comment style */
 
+#ifdef SYNTAX_TEXT_PROPERTIES
 	  UPDATE_SYNTAX_CACHE_FORWARD (from);
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	  c = BUF_FETCH_CHAR (buf, from);
+#ifndef SYNTAX_TEXT_PROPERTIES
+	  code = SYNTAX_UNSAFE (mirrortab, c);
+#else /* SYNTAX_TEXT_PROPERTIES */
 	  code = SYNTAX_FROM_CACHE (mirrortab, c);
 	  syncode = SYNTAX_CODE_FROM_CACHE (mirrortab, c);
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	  from++;
 
 	  /* a 1-char comment start sequence */
 	  if (code == Scomment && parse_sexp_ignore_comments)
 	    {
+#ifndef SYNTAX_TEXT_PROPERTIES
+	      comstyle = SYNTAX_COMMENT_1CHAR_MASK (mirrortab, c) ==
+		SYNTAX_COMMENT_STYLE_A ? 0 : 1;
+#else /* SYNTAX_TEXT_PROPERTIES */
 	      comstyle = SYNTAX_CODE_COMMENT_1CHAR_MASK (syncode) ==
 		SYNTAX_COMMENT_STYLE_A ? 0 : 1;
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	    }
 
 	  /* else, a 2-char comment start sequence? */
 	  else if (from < stop
+#ifndef SYNTAX_TEXT_PROPERTIES
+		   && SYNTAX_START_P (mirrortab, c, BUF_FETCH_CHAR (buf, from))
+#else /* SYNTAX_TEXT_PROPERTIES */
 		   && SYNTAX_CODE_START_FIRST_P (syncode)
+#endif /* SYNTAX_TEXT_PROPERTIES */
 		   && parse_sexp_ignore_comments)
 	    {
+#ifdef SYNTAX_TEXT_PROPERTIES
 	      int next_syncode;
 	      UPDATE_SYNTAX_CACHE_FORWARD (from);
 	      next_syncode =
@@ -1115,20 +1356,33 @@
 
 	      if (SYNTAX_CODES_START_P (syncode, next_syncode))
 		{
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	      /* we have encountered a comment start sequence and we
 		 are ignoring all text inside comments. we must record
 		 the comment style this sequence begins so that later,
 		 only a comment end of the same style actually ends
 		 the comment section */
 	      code = Scomment;
-		  comstyle = SYNTAX_CODES_COMMENT_MASK_START
-		    (syncode, next_syncode) == SYNTAX_COMMENT_STYLE_A ? 0 : 1;
+#ifndef SYNTAX_TEXT_PROPERTIES
+	      comstyle = SYNTAX_COMMENT_MASK_START (mirrortab, c,
+						    BUF_FETCH_CHAR (buf, from))
+		== SYNTAX_COMMENT_STYLE_A ? 0 : 1;
+#else /* SYNTAX_TEXT_PROPERTIES */
+	      comstyle = SYNTAX_CODES_COMMENT_MASK_START
+		(syncode, next_syncode) == SYNTAX_COMMENT_STYLE_A ? 0 : 1;
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	      from++;
 	    }
+#ifdef SYNTAX_TEXT_PROPERTIES
 	    }
 	  UPDATE_SYNTAX_CACHE_FORWARD (from);
+#endif /* SYNTAX_TEXT_PROPERTIES */
 
+#ifndef SYNTAX_TEXT_PROPERTIES
+	  if (SYNTAX_PREFIX_UNSAFE (mirrortab, c))
+#else /* SYNTAX_TEXT_PROPERTIES */
 	  if (SYNTAX_CODE_PREFIX (syncode))
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	    continue;
 
 	  switch (code)
@@ -1144,9 +1398,13 @@
 	      /* This word counts as a sexp; return at end of it. */
 	      while (from < stop)
 		{
+#ifndef SYNTAX_TEXT_PROPERTIES
+		  switch (SYNTAX (mirrortab, BUF_FETCH_CHAR (buf, from)))
+#else /* SYNTAX_TEXT_PROPERTIES */
 		  UPDATE_SYNTAX_CACHE_FORWARD (from);
 		  switch (SYNTAX_FROM_CACHE (mirrortab,
 					     BUF_FETCH_CHAR (buf, from)))
+#endif /* SYNTAX_TEXT_PROPERTIES */
 		    {
 		    case Scharquote:
 		    case Sescape:
@@ -1164,12 +1422,16 @@
 		}
 	      goto done;
 
+#ifdef SYNTAX_TEXT_PROPERTIES
 	    case Scomment_fence:
 	      comstyle = ST_COMMENT_STYLE;
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	    case Scomment:
 	      if (!parse_sexp_ignore_comments)
 		break;
+#ifdef SYNTAX_TEXT_PROPERTIES
 	      UPDATE_SYNTAX_CACHE_FORWARD (from);
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	      {
 		Bufpos newfrom =
 		  find_end_of_comment (buf, from, stop, comstyle);
@@ -1212,38 +1474,57 @@
 	      }
 	    break;
 
+#ifdef SYNTAX_TEXT_PROPERTIES
 	    case Sstring_fence:
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	    case Sstring:
               {
+#ifdef SYNTAX_TEXT_PROPERTIES
 		Emchar stringterm;
 
 		if (code != Sstring_fence)
 		  {
+#endif /* SYNTAX_TEXT_PROPERTIES */
 		/* XEmacs change: call syntax_match on character */
-                Emchar ch = BUF_FETCH_CHAR (buf, from - 1);
+		    Emchar ch = BUF_FETCH_CHAR (buf, from - 1);
+#ifndef SYNTAX_TEXT_PROPERTIES
+		    Lisp_Object stermobj = syntax_match (syntaxtab, ch);
+		    Emchar stringterm;
+#else /* SYNTAX_TEXT_PROPERTIES */
 		    Lisp_Object stermobj =
 		      syntax_match (syntax_cache.current_syntax_table, ch);
+#endif /* SYNTAX_TEXT_PROPERTIES */
 
-		if (CHARP (stermobj))
-		  stringterm = XCHAR (stermobj);
-		else
-		  stringterm = ch;
+		    if (CHARP (stermobj))
+		      stringterm = XCHAR (stermobj);
+		    else
+		      stringterm = ch;
+#ifdef SYNTAX_TEXT_PROPERTIES
 		  }
 		else
 		  stringterm = '\0'; /* avoid compiler warnings */
+#endif /* SYNTAX_TEXT_PROPERTIES */
 
                 while (1)
 		  {
 		    if (from >= stop)
 		      goto lose;
+#ifndef SYNTAX_TEXT_PROPERTIES
+		    if (BUF_FETCH_CHAR (buf, from) == stringterm)
+#else /* SYNTAX_TEXT_PROPERTIES */
 		    UPDATE_SYNTAX_CACHE_FORWARD (from);
 		    c = BUF_FETCH_CHAR (buf, from);
 		    if (code == Sstring
 			? c == stringterm
 			: SYNTAX_FROM_CACHE (mirrortab, c) == Sstring_fence)
+#endif /* SYNTAX_TEXT_PROPERTIES */
 		      break;
+#ifndef SYNTAX_TEXT_PROPERTIES
+		    switch (SYNTAX (mirrortab, BUF_FETCH_CHAR (buf, from)))
+#else /* SYNTAX_TEXT_PROPERTIES */
 
 		    switch (SYNTAX_FROM_CACHE (mirrortab, c))
+#endif /* SYNTAX_TEXT_PROPERTIES */
 		      {
 		      case Scharquote:
 		      case Sescape:
@@ -1282,35 +1563,55 @@
       stop = BUF_BEGV (buf);
       while (from > stop)
 	{
-          int comstyle = 0;     /* mask for finding matching comment style */
+	  int comstyle = 0;     /* mask for finding matching comment style */
 
 	  from--;
+#ifdef SYNTAX_TEXT_PROPERTIES
 	  UPDATE_SYNTAX_CACHE_BACKWARD (from);
-          quoted = char_quoted (buf, from);
+#endif /* SYNTAX_TEXT_PROPERTIES */
+	  quoted = char_quoted (buf, from);
 	  if (quoted)
+#ifdef SYNTAX_TEXT_PROPERTIES
 	    {
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	    from--;
+#ifdef SYNTAX_TEXT_PROPERTIES
 	      UPDATE_SYNTAX_CACHE_BACKWARD (from);
 	    }
+#endif /* SYNTAX_TEXT_PROPERTIES */
 
 	  c = BUF_FETCH_CHAR (buf, from);
+#ifndef SYNTAX_TEXT_PROPERTIES
+	  code = SYNTAX_UNSAFE (mirrortab, c);
+#else /* SYNTAX_TEXT_PROPERTIES */
 	  code = SYNTAX_FROM_CACHE (mirrortab, c);
 	  syncode = SYNTAX_CODE_FROM_CACHE (mirrortab, c);
+#endif /* SYNTAX_TEXT_PROPERTIES */
 
 	  if (code == Sendcomment && parse_sexp_ignore_comments)
 	    {
 	      /* we have found a single char end comment. we must record
 		 the comment style encountered so that later, we can match
 		 only the proper comment begin sequence of the same style */
+#ifndef SYNTAX_TEXT_PROPERTIES
+	      comstyle = SYNTAX_COMMENT_1CHAR_MASK (mirrortab, c)
+		== SYNTAX_COMMENT_STYLE_A ? 0 : 1;
+#else /* SYNTAX_TEXT_PROPERTIES */
 	      comstyle = SYNTAX_CODE_COMMENT_1CHAR_MASK (syncode)
 		== SYNTAX_COMMENT_STYLE_A ? 0 : 1;
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	    }
 
 	  else if (from > stop
+#ifndef SYNTAX_TEXT_PROPERTIES
+		   && SYNTAX_END_P (mirrortab, BUF_FETCH_CHAR (buf, from-1), c)
+#else /* SYNTAX_TEXT_PROPERTIES */
 		   && SYNTAX_CODE_END_SECOND_P (syncode)
+#endif /* SYNTAX_TEXT_PROPERTIES */
 		   && !char_quoted (buf, from - 1)
 		   && parse_sexp_ignore_comments)
 	    {
+#ifdef SYNTAX_TEXT_PROPERTIES
 	      int prev_syncode;
 	      UPDATE_SYNTAX_CACHE_BACKWARD (from - 1);
 	      prev_syncode = SYNTAX_CODE_FROM_CACHE
@@ -1318,17 +1619,31 @@
 
 	      if (SYNTAX_CODES_END_P (prev_syncode, syncode))
 		{
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	      /* we must record the comment style encountered so that
 		 later, we can match only the proper comment begin
 		 sequence of the same style */
 	      code = Sendcomment;
-		  comstyle = SYNTAX_CODES_COMMENT_MASK_END
-		    (prev_syncode, syncode) == SYNTAX_COMMENT_STYLE_A ? 0 : 1;
+#ifndef SYNTAX_TEXT_PROPERTIES
+	      comstyle = SYNTAX_COMMENT_MASK_END (mirrortab,
+						  BUF_FETCH_CHAR (buf, from - 1),
+						  c)
+		== SYNTAX_COMMENT_STYLE_A ? 0 : 1;
+#else /* SYNTAX_TEXT_PROPERTIES */
+	      comstyle = SYNTAX_CODES_COMMENT_MASK_END
+		(prev_syncode, syncode) == SYNTAX_COMMENT_STYLE_A ? 0 : 1;
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	      from--;
 	    }
+#ifdef SYNTAX_TEXT_PROPERTIES
 	    }
+#endif /* SYNTAX_TEXT_PROPERTIES */
 
+#ifndef SYNTAX_TEXT_PROPERTIES
+	  if (SYNTAX_PREFIX_UNSAFE (mirrortab, c))
+#else /* SYNTAX_TEXT_PROPERTIES */
 	  if (SYNTAX_CODE_PREFIX (syncode))
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	    continue;
 
 	  switch (quoted ? Sword : code)
@@ -1340,15 +1655,23 @@
 		 passing it. */
 	      while (from > stop)
 		{
+#ifndef SYNTAX_TEXT_PROPERTIES
+		  enum syntaxcode syncode;
+#else /* SYNTAX_TEXT_PROPERTIES */
 		  UPDATE_SYNTAX_CACHE_BACKWARD (from);
+#endif /* SYNTAX_TEXT_PROPERTIES */
 		  quoted = char_quoted (buf, from - 1);
 
 		  if (quoted)
 		    from--;
 		  if (! (quoted
                          || (syncode =
+#ifndef SYNTAX_TEXT_PROPERTIES
+			     SYNTAX (mirrortab, BUF_FETCH_CHAR (buf, from - 1)))
+#else /* SYNTAX_TEXT_PROPERTIES */
 			     SYNTAX_FROM_CACHE (mirrortab,
 						BUF_FETCH_CHAR (buf, from - 1)))
+#endif /* SYNTAX_TEXT_PROPERTIES */
 			 == Sword
 			 || syncode == Ssymbol
 			 || syncode == Squote))
@@ -1384,36 +1707,53 @@
 	      }
 	    break;
 
+#ifdef SYNTAX_TEXT_PROPERTIES
 	    case Scomment_fence:
 	      comstyle = ST_COMMENT_STYLE;
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	    case Sendcomment:
 	      if (parse_sexp_ignore_comments)
 		from = find_start_of_comment (buf, from, stop, comstyle);
 	      break;
 
+#ifdef SYNTAX_TEXT_PROPERTIES
 	    case Sstring_fence:
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	    case Sstring:
               {
+#ifdef SYNTAX_TEXT_PROPERTIES
 		Emchar stringterm;
 
 		if (code != Sstring_fence)
 		  {
+#endif /* SYNTAX_TEXT_PROPERTIES */
 		/* XEmacs change: call syntax_match() on character */
-                Emchar ch = BUF_FETCH_CHAR (buf, from);
+		    Emchar ch = BUF_FETCH_CHAR (buf, from);
+#ifndef SYNTAX_TEXT_PROPERTIES
+		    Lisp_Object stermobj = syntax_match (syntaxtab, ch);
+		    Emchar stringterm;
+#else /* SYNTAX_TEXT_PROPERTIES */
 		    Lisp_Object stermobj =
 		      syntax_match (syntax_cache.current_syntax_table, ch);
+#endif /* SYNTAX_TEXT_PROPERTIES */
 
 		if (CHARP (stermobj))
 		  stringterm = XCHAR (stermobj);
 		else
 		  stringterm = ch;
+#ifdef SYNTAX_TEXT_PROPERTIES
 		  }
 		else
 		  stringterm = '\0'; /* avoid compiler warnings */
+#endif /* SYNTAX_TEXT_PROPERTIES */
 
                 while (1)
 		  {
 		    if (from == stop) goto lose;
+#ifndef SYNTAX_TEXT_PROPERTIES
+		    if (!char_quoted (buf, from - 1)
+			&& stringterm == BUF_FETCH_CHAR (buf, from - 1))
+#else /* SYNTAX_TEXT_PROPERTIES */
 
 		    UPDATE_SYNTAX_CACHE_BACKWARD (from - 1);
 		    c = BUF_FETCH_CHAR (buf, from - 1);
@@ -1423,9 +1763,12 @@
 			 : SYNTAX_FROM_CACHE (mirrortab, c) == Sstring_fence)
 			&& !char_quoted (buf, from - 1))
 		      {
+#endif /* SYNTAX_TEXT_PROPERTIES */
 		      break;
+#ifdef SYNTAX_TEXT_PROPERTIES
 		      }
 
+#endif /* SYNTAX_TEXT_PROPERTIES */
 		    from--;
 		  }
                 from--;
@@ -1460,13 +1803,24 @@
   enum syntaxcode code;
   Bufpos beg = BUF_BEGV (buf);
   int quoted = 0;
+#ifndef SYNTAX_TEXT_PROPERTIES
+  Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
+#else /* SYNTAX_TEXT_PROPERTIES */
   Bufpos startpos = pos;
 
   while (pos > beg)
     {
       UPDATE_SYNTAX_CACHE_BACKWARD (pos - 1);
       code = SYNTAX_FROM_CACHE (mirrortab, BUF_FETCH_CHAR (buf, pos - 1));
+#endif /* SYNTAX_TEXT_PROPERTIES */
 
+#ifndef SYNTAX_TEXT_PROPERTIES
+  while (pos > beg
+	 && ((code = SYNTAX (mirrortab, BUF_FETCH_CHAR (buf, pos - 1)))
+	     == Scharquote
+	     || code == Sescape))
+    pos--, quoted = !quoted;
+#else /* SYNTAX_TEXT_PROPERTIES */
       if (code != Scharquote && code != Sescape)
 	break;
       pos--;
@@ -1474,6 +1828,7 @@
     }
 
   UPDATE_SYNTAX_CACHE (startpos);
+#endif /* SYNTAX_TEXT_PROPERTIES */
   return quoted;
 }
 
@@ -1549,18 +1904,24 @@
   struct buffer *buf = decode_buffer (buffer, 0);
   Bufpos beg = BUF_BEGV (buf);
   Bufpos pos = BUF_PT (buf);
-#ifndef emacs
+#if !defined(emacs) || !defined(SYNTAX_TEXT_PROPERTIES)
   Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
 #endif
+#ifdef SYNTAX_TEXT_PROPERTIES
   Emchar c = '\0'; /* initialize to avoid compiler warnings */
 
-
   SETUP_SYNTAX_CACHE_FOR_BUFFER (buf, pos, -1);
+#endif /* SYNTAX_TEXT_PROPERTIES */
 
   while (pos > beg && !char_quoted (buf, pos - 1)
+#ifndef SYNTAX_TEXT_PROPERTIES
+	 && (SYNTAX (mirrortab, BUF_FETCH_CHAR (buf, pos - 1)) == Squote
+	     || SYNTAX_PREFIX (mirrortab, BUF_FETCH_CHAR (buf, pos - 1))))
+#else /* SYNTAX_TEXT_PROPERTIES */
 	 /* Previous statement updates syntax table.  */
 	 && (SYNTAX_FROM_CACHE (mirrortab, c = BUF_FETCH_CHAR (buf, pos - 1)) == Squote
 	     || SYNTAX_CODE_PREFIX (SYNTAX_CODE_FROM_CACHE (mirrortab, c))))
+#endif /* SYNTAX_TEXT_PROPERTIES */
     pos--;
 
   BUF_SET_PT (buf, pos);
@@ -1593,17 +1954,27 @@
 			   when the depth becomes negative.  */
   int mindepth;		/* Lowest DEPTH value seen.  */
   int start_quoted = 0;		/* Nonzero means starting after a char quote */
+#ifdef SYNTAX_TEXT_PROPERTIES
   int boundary_stop = commentstop == -1;
+#endif /* SYNTAX_TEXT_PROPERTIES */
   Lisp_Object tem;
+#ifndef SYNTAX_TEXT_PROPERTIES
+  Lisp_Object syntaxtab = buf->syntax_table;
+  Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
+#endif /* ! SYNTAX_TEXT_PROPERTIES */
 
+#ifdef SYNTAX_TEXT_PROPERTIES
   SETUP_SYNTAX_CACHE (from, 1);
+#endif /* SYNTAX_TEXT_PROPERTIES */
   if (NILP (oldstate))
     {
       depth = 0;
       state.instring = -1;
       state.incomment = 0;
       state.comstyle = 0;	/* comment style a by default */
+#ifdef SYNTAX_TEXT_PROPERTIES
       state.comstr_start = -1;	/* no comment/string seen.  */
+#endif /* SYNTAX_TEXT_PROPERTIES */
     }
   else
     {
@@ -1617,12 +1988,21 @@
       oldstate = Fcdr (oldstate);
       oldstate = Fcdr (oldstate);
       tem = Fcar (oldstate);    /* elt 3, instring */
+#ifndef SYNTAX_TEXT_PROPERTIES
+      state.instring = !NILP (tem) ? XINT (tem) : -1;
+#else /* SYNTAX_TEXT_PROPERTIES */
       state.instring = ( !NILP (tem) 
 			 ? ( INTP (tem) ? XINT (tem) : ST_STRING_STYLE) 
 			 : -1);
+#endif /* SYNTAX_TEXT_PROPERTIES */
 
+#ifndef SYNTAX_TEXT_PROPERTIES
+      oldstate = Fcdr (oldstate); /* elt 4, incomment */
+      tem = Fcar (oldstate);
+#else /* SYNTAX_TEXT_PROPERTIES */
       oldstate = Fcdr (oldstate);
       tem = Fcar (oldstate);    /* elt 4, incomment */
+#endif /* SYNTAX_TEXT_PROPERTIES */
       state.incomment = !NILP (tem);
 
       oldstate = Fcdr (oldstate);
@@ -1634,6 +2014,7 @@
 	 we are in a generic comment */
       oldstate = Fcdr (oldstate);
       oldstate = Fcdr (oldstate);
+#ifdef SYNTAX_TEXT_PROPERTIES
       tem = Fcar (oldstate);    /* elt 7, comment style a/b/fence */
       state.comstyle = NILP (tem) ? 0 : ( EQ (tem, Qsyntax_table)
 					  ? ST_COMMENT_STYLE : 1 );
@@ -1644,7 +2025,12 @@
 
       /* elt 9, char numbers of starts-of-expression of levels
          (starting from outermost). */
+#endif /* SYNTAX_TEXT_PROPERTIES */
       oldstate = Fcdr (oldstate);
+#ifndef SYNTAX_TEXT_PROPERTIES
+      tem = Fcar (oldstate);    /* elt 8, comment style a */
+      state.comstyle = !NILP (tem);
+#else /* SYNTAX_TEXT_PROPERTIES */
       tem = Fcar (oldstate);    /* elt 9, intermediate data for
 				   continuation of parsing (subject
 				   to change). */
@@ -1657,6 +2043,7 @@
 	  curlevel->last = -1;
 	  tem = Fcdr (tem);
 	}
+#endif /* SYNTAX_TEXT_PROPERTIES */
     }
   state.quoted = 0;
   mindepth = depth;
@@ -1676,20 +2063,36 @@
 
   while (from < end)
     {
+#ifdef SYNTAX_TEXT_PROPERTIES
       Emchar c;
       int syncode;
 
+#endif /* SYNTAX_TEXT_PROPERTIES */
       QUIT;
 
+#ifndef SYNTAX_TEXT_PROPERTIES
+      code = SYNTAX (mirrortab, BUF_FETCH_CHAR (buf, from));
+#else /* SYNTAX_TEXT_PROPERTIES */
       UPDATE_SYNTAX_CACHE_FORWARD (from);
       c = BUF_FETCH_CHAR (buf, from);
       code = SYNTAX_FROM_CACHE (mirrortab, c);
       syncode = SYNTAX_CODE_FROM_CACHE (mirrortab, c);
+#endif /* SYNTAX_TEXT_PROPERTIES */
       from++;
 
+#ifndef SYNTAX_TEXT_PROPERTIES
+      if (code == Scomment)
+	{
+#endif /* ! SYNTAX_TEXT_PROPERTIES */
 	  /* record the comment style we have entered so that only the
 	     comment-ender sequence (or single char) of the same style
 	     actually terminates the comment section. */
+#ifndef SYNTAX_TEXT_PROPERTIES
+	  state.comstyle = SYNTAX_COMMENT_1CHAR_MASK (mirrortab,
+						      BUF_FETCH_CHAR (buf, from-1))
+	    == SYNTAX_COMMENT_STYLE_A ? 0 : 1;
+	  state.comstart = from - 1;
+#else /* SYNTAX_TEXT_PROPERTIES */
       if (code == Scomment)
 	{
 	  state.comstyle =
@@ -1704,9 +2107,14 @@
 	  state.comstyle = ST_COMMENT_STYLE;
 	  state.comstr_start = from - 1;
 	  code = Scomment;
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	}
 
       else if (from < end &&
+#ifndef SYNTAX_TEXT_PROPERTIES
+	       SYNTAX_START_P (mirrortab, BUF_FETCH_CHAR (buf, from-1),
+			       BUF_FETCH_CHAR (buf, from)))
+#else /* SYNTAX_TEXT_PROPERTIES */
 	       SYNTAX_CODE_START_FIRST_P (syncode))
 	{
 	  int next_syncode;
@@ -1715,17 +2123,37 @@
 	    SYNTAX_CODE_FROM_CACHE (mirrortab, BUF_FETCH_CHAR (buf, from));
 
 	  if (SYNTAX_CODES_START_P (syncode, next_syncode))
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	{
+#ifndef SYNTAX_TEXT_PROPERTIES
+	  /* Record the comment style we have entered so that only
+	     the comment-end sequence of the same style actually
+	     terminates the comment section.  */
+#endif /* ! SYNTAX_TEXT_PROPERTIES */
 	  code = Scomment;
+#ifndef SYNTAX_TEXT_PROPERTIES
+	  state.comstyle = SYNTAX_COMMENT_MASK_START (mirrortab,
+						      BUF_FETCH_CHAR (buf, from-1),
+						      BUF_FETCH_CHAR (buf, from))
+	    == SYNTAX_COMMENT_STYLE_A ? 0 : 1;
+	  state.comstart = from-1;
+#else /* SYNTAX_TEXT_PROPERTIES */
 	      state.comstyle = SYNTAX_CODES_COMMENT_MASK_START
 		(syncode, next_syncode) == SYNTAX_COMMENT_STYLE_A ? 0 : 1;
 	      state.comstr_start = from - 1;
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	  from++;
+#ifdef SYNTAX_TEXT_PROPERTIES
 	      UPDATE_SYNTAX_CACHE_FORWARD (from);
 	    }
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	}
 
+#ifndef SYNTAX_TEXT_PROPERTIES
+      if (SYNTAX_PREFIX (mirrortab, BUF_FETCH_CHAR (buf, from - 1)))
+#else /* SYNTAX_TEXT_PROPERTIES */
       if (SYNTAX_CODE_PREFIX (syncode))
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	continue;
       switch (code)
 	{
@@ -1745,8 +2173,12 @@
 	symstarted:
 	  while (from < end)
 	    {
+#ifndef SYNTAX_TEXT_PROPERTIES
+	      switch (SYNTAX (mirrortab, BUF_FETCH_CHAR (buf, from)))
+#else /* SYNTAX_TEXT_PROPERTIES */
 	      UPDATE_SYNTAX_CACHE_FORWARD (from);
 	      switch (SYNTAX_FROM_CACHE (mirrortab, BUF_FETCH_CHAR (buf, from)))
+#endif /* SYNTAX_TEXT_PROPERTIES */
 		{
 		case Scharquote:
 		case Sescape:
@@ -1768,11 +2200,19 @@
 
 	case Scomment:
 	  state.incomment = 1;
+#ifdef SYNTAX_TEXT_PROPERTIES
 	  if (commentstop || boundary_stop) goto done;
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	startincomment:
+#ifndef SYNTAX_TEXT_PROPERTIES
+	  if (commentstop)
+#else /* SYNTAX_TEXT_PROPERTIES */
 	  if (commentstop == 1)
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	    goto done;
+#ifdef SYNTAX_TEXT_PROPERTIES
 	  UPDATE_SYNTAX_CACHE_FORWARD (from);
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	  {
 	    Bufpos newfrom = find_end_of_comment (buf, from, end, state.comstyle);
 	    if (newfrom < 0)
@@ -1785,7 +2225,9 @@
 	  }
 	  state.incomment = 0;
 	  state.comstyle = 0;		     /* reset the comment style */
+#ifdef SYNTAX_TEXT_PROPERTIES
 	  if (boundary_stop) goto done;
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	  break;
 
 	case Sopen:
@@ -1811,33 +2253,58 @@
 	  break;
 
 	case Sstring:
+#ifndef SYNTAX_TEXT_PROPERTIES
+          {
+            Emchar ch;
+#else /* SYNTAX_TEXT_PROPERTIES */
 	case Sstring_fence:
 	  state.comstr_start = from - 1;
+#endif /* SYNTAX_TEXT_PROPERTIES */
             if (stopbefore) goto stop; /* this arg means stop at sexp start */
             curlevel->last = from - 1;
+#ifndef SYNTAX_TEXT_PROPERTIES
+	    /* XEmacs change: call syntax_match() on character */
+            ch = BUF_FETCH_CHAR (buf, from - 1);
+#else /* SYNTAX_TEXT_PROPERTIES */
 	  if (code == Sstring_fence)
 	    {
 	      state.instring = ST_STRING_STYLE;
 	    }
 	  else
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	    {
+#ifndef SYNTAX_TEXT_PROPERTIES
+	      Lisp_Object stermobj = syntax_match (syntaxtab, ch);
+#else /* SYNTAX_TEXT_PROPERTIES */
 	      /* XEmacs change: call syntax_match() on character */
 	      Emchar ch = BUF_FETCH_CHAR (buf, from - 1);
 	      Lisp_Object stermobj =
 		syntax_match (syntax_cache.current_syntax_table, ch);
+#endif /* SYNTAX_TEXT_PROPERTIES */
 
 	      if (CHARP (stermobj))
 		state.instring = XCHAR (stermobj);
 	      else
 		state.instring = ch;
+#ifndef SYNTAX_TEXT_PROPERTIES
+	    }
+#endif /* ! SYNTAX_TEXT_PROPERTIES */
           }
+#ifdef SYNTAX_TEXT_PROPERTIES
 	  if (boundary_stop) goto done;
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	startinstring:
 	  while (1)
 	    {
+#ifdef SYNTAX_TEXT_PROPERTIES
 	      enum syntaxcode temp_code;
 
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	      if (from >= end) goto done;
+#ifndef SYNTAX_TEXT_PROPERTIES
+	      if (BUF_FETCH_CHAR (buf, from) == state.instring) break;
+	      switch (SYNTAX (mirrortab, BUF_FETCH_CHAR (buf, from)))
+#else /* SYNTAX_TEXT_PROPERTIES */
 
 	      UPDATE_SYNTAX_CACHE_FORWARD (from);
 	      c = BUF_FETCH_CHAR (buf, from);
@@ -1849,11 +2316,14 @@
 		  c == state.instring) break;
 
 	      switch (temp_code)
+#endif /* SYNTAX_TEXT_PROPERTIES */
 		{
+#ifdef SYNTAX_TEXT_PROPERTIES
 		case Sstring_fence:
 		  if (state.instring == ST_STRING_STYLE)
 		    goto string_end;
 		  break;
+#endif /* SYNTAX_TEXT_PROPERTIES */
 		case Scharquote:
 		case Sescape:
                   {
@@ -1867,11 +2337,15 @@
 		}
 	      from++;
 	    }
+#ifdef SYNTAX_TEXT_PROPERTIES
 	string_end:
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	  state.instring = -1;
 	  curlevel->prev = curlevel->last;
 	  from++;
+#ifdef SYNTAX_TEXT_PROPERTIES
 	  if (boundary_stop) goto done;
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	  break;
 
 	case Smath:
@@ -1881,7 +2355,9 @@
         case Spunct:
         case Squote:
         case Sendcomment:
+#ifdef SYNTAX_TEXT_PROPERTIES
 	case Scomment_fence:
+#endif /* SYNTAX_TEXT_PROPERTIES */
 	case Sinherit:
         case Smax:
           break;
@@ -1902,10 +2378,12 @@
   state.prevlevelstart
     = (curlevel == levelstart) ? -1 : (curlevel - 1)->last;
   state.location = from;
+#ifdef SYNTAX_TEXT_PROPERTIES
   state.levelstarts = Qnil;
   while (--curlevel >= levelstart)
     state.levelstarts = Fcons (make_int (curlevel->last),
 			       state.levelstarts);
+#endif /* SYNTAX_TEXT_PROPERTIES */
 
   *stateptr = state;
 }
@@ -1961,24 +2439,37 @@
   get_buffer_range_char (buf, from, to, &start, &end, 0);
   scan_sexps_forward (buf, &state, start, end,
 		      target, !NILP (stopbefore), oldstate,
+#ifndef SYNTAX_TEXT_PROPERTIES
+		      !NILP (commentstop));
+
+#else /* SYNTAX_TEXT_PROPERTIES */
 		      (NILP (commentstop)
 		       ? 0 : (EQ (commentstop, Qsyntax_table) ? -1 : 1)));
+#endif /* SYNTAX_TEXT_PROPERTIES */
   BUF_SET_PT (buf, state.location);
 
   /* reverse order */
   val = Qnil;
+#ifndef SYNTAX_TEXT_PROPERTIES
+  val = Fcons (state.comstyle  ? Qt : Qnil, val);
+#else /* SYNTAX_TEXT_PROPERTIES */
   val = Fcons (state.levelstarts, val);
   val = Fcons ((state.incomment || (state.instring >= 0))
 	       ? make_int (state.comstr_start) : Qnil, val);
   val = Fcons (state.comstyle  ? (state.comstyle == ST_COMMENT_STYLE
 				  ? Qsyntax_table : Qt) : Qnil, val);
+#endif /* SYNTAX_TEXT_PROPERTIES */
   val = Fcons (make_int (state.mindepth),   val);
   val = Fcons (state.quoted    ? Qt : Qnil, val);
   val = Fcons (state.incomment ? Qt : Qnil, val);
+#ifndef SYNTAX_TEXT_PROPERTIES
+  val = Fcons (state.instring       < 0 ? Qnil : make_int (state.instring),       val);
+#else /* SYNTAX_TEXT_PROPERTIES */
   val = Fcons (state.instring < 0
 	       ? Qnil
 	       : (state.instring == ST_STRING_STYLE
 		  ? Qt : make_int (state.instring)), val);
+#endif /* SYNTAX_TEXT_PROPERTIES */
   val = Fcons (state.thislevelstart < 0 ? Qnil : make_int (state.thislevelstart), val);
   val = Fcons (state.prevlevelstart < 0 ? Qnil : make_int (state.prevlevelstart), val);
   val = Fcons (make_int (state.depth), val);
@@ -2075,7 +2566,10 @@
 syms_of_syntax (void)
 {
   defsymbol (&Qsyntax_table_p, "syntax-table-p");
+#ifdef SYNTAX_TEXT_PROPERTIES
   defsymbol (&Qsyntax_table, "syntax-table");
+  defsymbol (&Qsyntax_text_properties, "syntax-text-properties");
+#endif /* SYNTAX_TEXT_PROPERTIES */
 
   DEFSUBR (Fsyntax_table_p);
   DEFSUBR (Fsyntax_table);
@@ -2105,6 +2599,7 @@
 */ );
   parse_sexp_ignore_comments = 0;
 
+#ifdef SYNTAX_TEXT_PROPERTIES
   DEFVAR_BOOL ("lookup-syntax-properties", &lookup_syntax_properties /*
 Non-nil means `forward-sexp', etc., grant `syntax-table' property.
 The value of this property should be either a syntax table, or a cons
@@ -2114,6 +2609,8 @@
 */ );
   lookup_syntax_properties = 1;
 
+  Fprovide (Qsyntax_text_properties);
+#endif /* SYNTAX_TEXT_PROPERTIES */
   DEFVAR_BOOL ("words-include-escapes", &words_include_escapes /*
 Non-nil means `forward-word', etc., should treat escape chars part of words.
 */ );
Index: src/syntax.h
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/syntax.h,v
retrieving revision 1.5
diff -u -r1.5 syntax.h
--- src/syntax.h	2001/04/12 18:24:21	1.5
+++ src/syntax.h	2002/09/02 20:34:48
@@ -61,10 +61,12 @@
   Scomment,	/* a comment-starting character */
   Sendcomment,	/* a comment-ending character */
   Sinherit,	/* use the standard syntax table for this character */
+#ifdef SYNTAX_TEXT_PROPERTIES
   Scomment_fence, /* Starts/ends comment which is delimited on the
 		     other side by a char with the same syntaxcode.  */
   Sstring_fence,  /* Starts/ends string which is delimited on the
 		     other side by a char with the same syntaxcode.  */
+#endif /* SYNTAX_TEXT_PROPERTIES */
   Smax	 /* Upper bound on codes that are meaningful */
 };
 
@@ -258,13 +260,18 @@
 
 extern int no_quit_in_re_search;
 extern struct buffer *regex_emacs_buffer;
+#ifndef SYNTAX_TEXT_PROPERTIES
+extern int regex_emacs_buffer_p;
+#else /* SYNTAX_TEXT_PROPERTIES */
 
 /* This is the string or buffer in which we are matching.  It is used
    for looking up syntax properties.  */
 extern Lisp_Object regex_match_object;
+#endif /* SYNTAX_TEXT_PROPERTIES */
 
 void update_syntax_table (Lisp_Char_Table *ct);
 
+#ifdef SYNTAX_TEXT_PROPERTIES
 #ifdef emacs
 
 extern int lookup_syntax_properties;
@@ -473,4 +480,5 @@
        : 0)))
 
 
+#endif /* SYNTAX_TEXT_PROPERTIES */
 #endif /* INCLUDED_syntax_h_ */
