This commit was generated by cvs2svn to compensate for changes in r5670,
[chise/xemacs-chise.git.1] / src / syntax.c
index a3bbcc2..9a1d56b 100644 (file)
@@ -27,6 +27,8 @@ Boston, MA 02111-1307, USA.  */
 #include "lisp.h"
 
 #include "buffer.h"
+#include "commands.h"
+#include "insdel.h"
 #include "syntax.h"
 
 /* Here is a comment from Ken'ichi HANDA <handa@etl.go.jp>
@@ -53,7 +55,6 @@ Sextword is a word-constituent but a word boundary may exist between
 two such characters.  */
 
 /* Mule 2.4 doesn't seem to have Sextword - I'm removing it -- mrb */
-/* Recovered by tomo */
 
 Lisp_Object Qsyntax_table_p;
 
@@ -74,9 +75,6 @@ int no_quit_in_re_search;
    and the like. */
 struct buffer *regex_emacs_buffer;
 
-/* Tell the regex routines whether buffer is used or not. */
-int regex_emacs_buffer_p;
-
 Lisp_Object Vstandard_syntax_table;
 
 Lisp_Object Vsyntax_designator_chars_string;
@@ -120,7 +118,7 @@ static Bufpos
 find_defun_start (struct buffer *buf, Bufpos pos)
 {
   Bufpos tem;
-  Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
+  struct Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
 
   /* Use previous finding, if it's valid and applies to this inquiry.  */
   if (buf == find_start_buffer
@@ -156,13 +154,12 @@ find_defun_start (struct buffer *buf, Bufpos pos)
 }
 \f
 DEFUN ("syntax-table-p", Fsyntax_table_p, 1, 1, 0, /*
-Return t if OBJECT is a syntax table.
+Return t if ARG is a syntax table.
 Any vector of 256 elements will do.
 */
-       (object))
+       (obj))
 {
-  return (CHAR_TABLEP (object)
-         && XCHAR_TABLE_TYPE (object) == CHAR_TABLE_TYPE_SYNTAX)
+  return CHAR_TABLEP (obj) && XCHAR_TABLE_TYPE (obj) == CHAR_TABLE_TYPE_SYNTAX
     ? Qt : Qnil;
 }
 
@@ -196,38 +193,39 @@ This is the one used for new buffers.
 }
 
 DEFUN ("copy-syntax-table", Fcopy_syntax_table, 0, 1, 0, /*
-Return a new syntax table which is a copy of SYNTAX-TABLE.
-SYNTAX-TABLE defaults to the standard syntax table.
+Construct a new syntax table and return it.
+It is a copy of the TABLE, which defaults to the standard syntax table.
 */
-       (syntax_table))
+       (table))
 {
   if (NILP (Vstandard_syntax_table))
     return Fmake_char_table (Qsyntax);
 
-  syntax_table = check_syntax_table (syntax_table, Vstandard_syntax_table);
-  return Fcopy_char_table (syntax_table);
+  table = check_syntax_table (table, Vstandard_syntax_table);
+  return Fcopy_char_table (table);
 }
 
 DEFUN ("set-syntax-table", Fset_syntax_table, 1, 2, 0, /*
-Select SYNTAX-TABLE as the new syntax table for BUFFER.
+Select a new syntax table for BUFFER.
+One argument, a syntax table.
 BUFFER defaults to the current buffer if omitted.
 */
-       (syntax_table, buffer))
+       (table, buffer))
 {
   struct buffer *buf = decode_buffer (buffer, 0);
-  syntax_table = check_syntax_table (syntax_table, Qnil);
-  buf->syntax_table = syntax_table;
-  buf->mirror_syntax_table = XCHAR_TABLE (syntax_table)->mirror_table;
+  table = check_syntax_table (table, Qnil);
+  buf->syntax_table = table;
+  buf->mirror_syntax_table = XCHAR_TABLE (table)->mirror_table;
   /* Indicate that this buffer now has a specified syntax table.  */
   buf->local_var_flags |= XINT (buffer_local_flags.syntax_table);
-  return syntax_table;
+  return table;
 }
 \f
 /* Convert a letter which signifies a syntax code
    into the code it signifies.
    This is used by modify-syntax-entry, and other things. */
 
-const unsigned char syntax_spec_code[0400] =
+CONST unsigned char syntax_spec_code[0400] =
 { 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
   0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
   0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
@@ -249,7 +247,7 @@ const unsigned char syntax_spec_code[0400] =
   0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377
 };
 
-const unsigned char syntax_code_spec[] =  " .w_()'\"$\\/<>@";
+CONST unsigned char syntax_code_spec[] =  " .w_()'\"$\\/<>@";
 
 DEFUN ("syntax-designator-chars", Fsyntax_designator_chars, 0, 0, 0, /*
 Return a string of the recognized syntax designator chars.
@@ -262,26 +260,25 @@ numbered starting at 0.
 }
 
 DEFUN ("char-syntax", Fchar_syntax, 1, 2, 0, /*
-Return the syntax code of CHARACTER, described by a character.
-For example, if CHARACTER is a word constituent,
-the character `?w' is returned.
+Return the syntax code of CHAR, described by a character.
+For example, if CHAR is a word constituent, the character `?w' is returned.
 The characters that correspond to various syntax codes
 are listed in the documentation of `modify-syntax-entry'.
-Optional second argument SYNTAX-TABLE defaults to the current buffer's
+Optional second argument TABLE defaults to the current buffer's
 syntax table.
 */
-       (character, syntax_table))
+       (ch, table))
 {
-  Lisp_Char_Table *mirrortab;
+  struct Lisp_Char_Table *mirrortab;
 
-  if (NILP (character))
+  if (NILP(ch))
     {
-      character = make_char ('\000');
+      ch = make_char('\000');
     }
-  CHECK_CHAR_COERCE_INT (character);
-  syntax_table = check_syntax_table (syntax_table, current_buffer->syntax_table);
-  mirrortab = XCHAR_TABLE (XCHAR_TABLE (syntax_table)->mirror_table);
-  return make_char (syntax_code_spec[(int) SYNTAX (mirrortab, XCHAR (character))]);
+  CHECK_CHAR_COERCE_INT (ch);
+  table = check_syntax_table (table, current_buffer->syntax_table);
+  mirrortab = XCHAR_TABLE (XCHAR_TABLE (table)->mirror_table);
+  return make_char (syntax_code_spec[(int) SYNTAX (mirrortab, XCHAR (ch))]);
 }
 
 #ifdef MULE
@@ -297,51 +294,50 @@ charset_syntax (struct buffer *buf, Lisp_Object charset, int *multi_p_out)
 #endif
 
 Lisp_Object
-syntax_match (Lisp_Object syntax_table, Emchar ch)
+syntax_match (Lisp_Object table, Emchar ch)
 {
-  Lisp_Object code = XCHAR_TABLE_VALUE_UNSAFE (syntax_table, ch);
+  Lisp_Object code = CHAR_TABLE_VALUE_UNSAFE (XCHAR_TABLE (table), ch);
   Lisp_Object code2 = code;
 
   if (CONSP (code))
     code2 = XCAR (code);
   if (SYNTAX_FROM_CODE (XINT (code2)) == Sinherit)
-    code = XCHAR_TABLE_VALUE_UNSAFE (Vstandard_syntax_table, ch);
+    code = CHAR_TABLE_VALUE_UNSAFE (XCHAR_TABLE (Vstandard_syntax_table),
+                                   ch);
 
   return CONSP (code) ? XCDR (code) : Qnil;
 }
 
 DEFUN ("matching-paren", Fmatching_paren, 1, 2, 0, /*
-Return the matching parenthesis of CHARACTER, or nil if none.
-Optional second argument SYNTAX-TABLE defaults to the current buffer's
+Return the matching parenthesis of CHAR, or nil if none.
+Optional second argument TABLE defaults to the current buffer's
 syntax table.
 */
-       (character, syntax_table))
+       (ch, table))
 {
-  Lisp_Char_Table *mirrortab;
+  struct Lisp_Char_Table *mirrortab;
   int code;
 
-  CHECK_CHAR_COERCE_INT (character);
-  syntax_table = check_syntax_table (syntax_table, current_buffer->syntax_table);
-  mirrortab = XCHAR_TABLE (XCHAR_TABLE (syntax_table)->mirror_table);
-  code = SYNTAX (mirrortab, XCHAR (character));
+  CHECK_CHAR_COERCE_INT (ch);
+  table = check_syntax_table (table, current_buffer->syntax_table);
+  mirrortab = XCHAR_TABLE (XCHAR_TABLE (table)->mirror_table);
+  code = SYNTAX (mirrortab, XCHAR (ch));
   if (code == Sopen || code == Sclose || code == Sstring)
-    return syntax_match (syntax_table, XCHAR (character));
+    return syntax_match (table, XCHAR (ch));
   return Qnil;
 }
 
 \f
 
-#ifdef MULE
-/* Return 1 if there is a word boundary between two word-constituent
-   characters C1 and C2 if they appear in this order, else return 0.
-   There is no word boundary between two word-constituent ASCII
-   characters.  */
-#define WORD_BOUNDARY_P(c1, c2)                        \
-  (!(CHAR_ASCII_P (c1) && CHAR_ASCII_P (c2))   \
-   && word_boundary_p (c1, c2))
-
-extern int word_boundary_p (Emchar c1, Emchar c2);
-#endif
+static int
+word_constituent_p (struct buffer *buf, Bufpos pos,
+                   struct Lisp_Char_Table *tab)
+{
+  enum syntaxcode code = SYNTAX_UNSAFE (tab, BUF_FETCH_CHAR (buf, pos));
+  return ((words_include_escapes &&
+          (code == Sescape || code == Scharquote))
+         || (code == Sword));
+}
 
 /* Return the position across COUNT words from FROM.
    If that many words cannot be found before the end of the buffer, return 0.
@@ -351,11 +347,7 @@ Bufpos
 scan_words (struct buffer *buf, Bufpos from, int count)
 {
   Bufpos limit = count > 0 ? BUF_ZV (buf) : BUF_BEGV (buf);
-  Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
-  Emchar ch0, ch1;
-  enum syntaxcode code;
-
-  /* #### is it really worth it to hand expand both cases? JV */
+  struct Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
   while (count > 0)
     {
       QUIT;
@@ -364,35 +356,15 @@ scan_words (struct buffer *buf, Bufpos from, int count)
        {
          if (from == limit)
            return 0;
-
-         ch0 = BUF_FETCH_CHAR (buf, from);
-         code = SYNTAX_UNSAFE (mirrortab, ch0);
-
-         from++;
-         if (words_include_escapes
-             && (code == Sescape || code == Scharquote))
-           break;
-         if (code == Sword)
+         if (word_constituent_p (buf, from, mirrortab))
            break;
+         from++;
        }
 
       QUIT;
 
-      while (from != limit)
+      while ((from != limit) && word_constituent_p (buf, from, mirrortab))
        {
-         ch1 = BUF_FETCH_CHAR (buf, from);
-         code = SYNTAX_UNSAFE (mirrortab, ch1);
-         if (!(words_include_escapes
-               && (code == Sescape || code == Scharquote)))
-           if (code != Sword
-#ifdef MULE
-               || WORD_BOUNDARY_P (ch0, ch1)
-#endif
-               )
-             break;
-#ifdef MULE
-         ch0 = ch1;
-#endif
          from++;
        }
       count--;
@@ -406,35 +378,15 @@ scan_words (struct buffer *buf, Bufpos from, int count)
        {
          if (from == limit)
            return 0;
-
-         ch1 = BUF_FETCH_CHAR (buf, from - 1);
-         code = SYNTAX_UNSAFE (mirrortab, ch1);
-
-         from--;
-         if (words_include_escapes
-             && (code == Sescape || code == Scharquote))
-           break;
-         if (code == Sword)
+         if (word_constituent_p (buf, from - 1, mirrortab))
            break;
+         from--;
        }
 
       QUIT;
 
-      while (from != limit)
+      while ((from != limit) && word_constituent_p (buf, from - 1, mirrortab))
        {
-         ch0 = BUF_FETCH_CHAR (buf, from - 1);
-         code = SYNTAX_UNSAFE (mirrortab, ch0);
-         if (!(words_include_escapes
-               && (code == Sescape || code == Scharquote)))
-           if (code != Sword
-#ifdef MULE
-               || WORD_BOUNDARY_P (ch0, ch1)
-#endif
-               )
-             break;
-#ifdef MULE
-         ch1 = ch0;
-#endif
          from--;
        }
       count++;
@@ -443,38 +395,25 @@ scan_words (struct buffer *buf, Bufpos from, int count)
   return from;
 }
 
-DEFUN ("forward-word", Fforward_word, 0, 2, "_p", /*
-Move point forward COUNT words (backward if COUNT is negative).
-Normally t is returned, but if an edge of the buffer is reached,
-point is left there and nil is returned.
-
-COUNT defaults to 1, and BUFFER defaults to the current buffer.
+DEFUN ("forward-word", Fforward_word, 1, 2, "_p", /*
+Move point forward ARG words (backward if ARG is negative).
+Normally returns t.
+If an edge of the buffer is reached, point is left there
+and nil is returned.
 */
        (count, buffer))
 {
   Bufpos val;
   struct buffer *buf = decode_buffer (buffer, 0);
-  EMACS_INT n;
-
-  if (NILP (count))
-    n = 1;
-  else
-    {
-      CHECK_INT (count);
-      n = XINT (count);
-    }
+  CHECK_INT (count);
 
-  val = scan_words (buf, BUF_PT (buf), n);
-  if (val)
-    {
-      BUF_SET_PT (buf, val);
-      return Qt;
-    }
-  else
+  if (!(val = scan_words (buf, BUF_PT (buf), XINT (count))))
     {
-      BUF_SET_PT (buf, n > 0 ? BUF_ZV (buf) : BUF_BEGV (buf));
+      BUF_SET_PT (buf, XINT (count) > 0 ? BUF_ZV (buf) : BUF_BEGV (buf));
       return Qnil;
     }
+  BUF_SET_PT (buf, val);
+  return Qt;
 }
 \f
 static void scan_sexps_forward (struct buffer *buf,
@@ -489,7 +428,7 @@ find_start_of_comment (struct buffer *buf, Bufpos from, Bufpos stop, int mask)
 {
   Emchar c;
   enum syntaxcode code;
-  Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
+  struct Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
 
   /* Look back, counting the parity of string-quotes,
      and recording the comment-starters seen.
@@ -623,7 +562,7 @@ static Bufpos
 find_end_of_comment (struct buffer *buf, Bufpos from, Bufpos stop, int mask)
 {
   int c;
-  Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
+  struct Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
 
   while (1)
     {
@@ -659,36 +598,31 @@ find_end_of_comment (struct buffer *buf, Bufpos from, Bufpos stop, int mask)
    ever complains about this function not working properly, take a look
    at those changes.  --ben */
 
-DEFUN ("forward-comment", Fforward_comment, 0, 2, 0, /*
-Move forward across up to COUNT comments, or backwards if COUNT is negative.
+DEFUN ("forward-comment", Fforward_comment, 1, 2, 0, /*
+Move forward across up to N comments.  If N is negative, move backward.
 Stop scanning if we find something other than a comment or whitespace.
 Set point to where scanning stops.
-If COUNT comments are found as expected, with nothing except whitespace
+If N comments are found as expected, with nothing except whitespace
 between them, return t; otherwise return nil.
 Point is set in either case.
-COUNT defaults to 1, and BUFFER defaults to the current buffer.
+Optional argument BUFFER defaults to the current buffer.
 */
-       (count, buffer))
+       (n, buffer))
 {
   Bufpos from;
   Bufpos stop;
   Emchar c;
   enum syntaxcode code;
-  EMACS_INT n;
+  int count;
   struct buffer *buf = decode_buffer (buffer, 0);
-  Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
+  struct Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
 
-  if (NILP (count))
-    n = 1;
-  else
-    {
-      CHECK_INT (count);
-      n = XINT (count);
-    }
+  CHECK_INT (n);
+  count = XINT (n);
 
   from = BUF_PT (buf);
 
-  while (n > 0)
+  while (count > 0)
     {
       QUIT;
 
@@ -757,10 +691,10 @@ COUNT defaults to 1, and BUFFER defaults to the current buffer.
        }
 
       /* End of comment reached */
-      n--;
+      count--;
     }
 
-  while (n < 0)
+  while (count < 0)
     {
       QUIT;
 
@@ -816,7 +750,7 @@ COUNT defaults to 1, and BUFFER defaults to the current buffer.
            }
        }
 
-      n++;
+      count++;
     }
 
   BUF_SET_PT (buf, from);
@@ -826,7 +760,7 @@ COUNT defaults to 1, and BUFFER defaults to the current buffer.
 \f
 Lisp_Object
 scan_lists (struct buffer *buf, Bufpos from, int count, int depth,
-           int sexpflag, int noerror)
+           int sexpflag, int no_error)
 {
   Bufpos stop;
   Emchar c;
@@ -835,7 +769,7 @@ scan_lists (struct buffer *buf, Bufpos from, int count, int depth,
   enum syntaxcode code;
   int min_depth = depth;    /* Err out if depth gets less than this. */
   Lisp_Object syntaxtab = buf->syntax_table;
-  Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
+  struct Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
 
   if (depth > 0) min_depth = 0;
 
@@ -946,7 +880,7 @@ scan_lists (struct buffer *buf, Bufpos from, int count, int depth,
            if (!--depth) goto done;
            if (depth < min_depth)
              {
-               if (noerror)
+               if (no_error)
                  return Qnil;
                error ("Containing expression ends prematurely");
              }
@@ -1045,7 +979,7 @@ scan_lists (struct buffer *buf, Bufpos from, int count, int depth,
          if (SYNTAX_PREFIX_UNSAFE (mirrortab, c))
            continue;
 
-         switch (quoted ? Sword : code)
+         switch (((quoted) ? Sword : code))
            {
            case Sword:
            case Ssymbol:
@@ -1091,7 +1025,7 @@ scan_lists (struct buffer *buf, Bufpos from, int count, int depth,
            if (!--depth) goto done2;
            if (depth < min_depth)
              {
-               if (noerror)
+               if (no_error)
                  return Qnil;
                error ("Containing expression ends prematurely");
              }
@@ -1143,7 +1077,7 @@ scan_lists (struct buffer *buf, Bufpos from, int count, int depth,
   return (make_int (from));
 
 lose:
-  if (!noerror)
+  if (!no_error)
     error ("Unbalanced parentheses");
   return Qnil;
 }
@@ -1154,7 +1088,7 @@ char_quoted (struct buffer *buf, Bufpos pos)
   enum syntaxcode code;
   Bufpos beg = BUF_BEGV (buf);
   int quoted = 0;
-  Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
+  struct Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
 
   while (pos > beg
         && ((code = SYNTAX (mirrortab, BUF_FETCH_CHAR (buf, pos - 1)))
@@ -1185,7 +1119,7 @@ of in the current buffer.
 If optional arg NOERROR is non-nil, scan-lists will return nil instead of
 signalling an error.
 */
-       (from, count, depth, buffer, noerror))
+       (from, count, depth, buffer, no_error))
 {
   struct buffer *buf;
 
@@ -1195,7 +1129,7 @@ signalling an error.
   buf = decode_buffer (buffer, 0);
 
   return scan_lists (buf, XINT (from), XINT (count), XINT (depth), 0,
-                    !NILP (noerror));
+                    !NILP (no_error));
 }
 
 DEFUN ("scan-sexps", Fscan_sexps, 2, 4, 0, /*
@@ -1216,13 +1150,13 @@ of in the current buffer.
 If optional arg NOERROR is non-nil, scan-sexps will return nil instead of
 signalling an error.
 */
-       (from, count, buffer, noerror))
+       (from, count, buffer, no_error))
 {
   struct buffer *buf = decode_buffer (buffer, 0);
   CHECK_INT (from);
   CHECK_INT (count);
 
-  return scan_lists (buf, XINT (from), XINT (count), 0, 1, !NILP (noerror));
+  return scan_lists (buf, XINT (from), XINT (count), 0, 1, !NILP (no_error));
 }
 
 DEFUN ("backward-prefix-chars", Fbackward_prefix_chars, 0, 1, 0, /*
@@ -1236,7 +1170,7 @@ Optional arg BUFFER defaults to the current buffer.
   struct buffer *buf = decode_buffer (buffer, 0);
   Bufpos beg = BUF_BEGV (buf);
   Bufpos pos = BUF_PT (buf);
-  Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
+  struct Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
 
   while (pos > beg && !char_quoted (buf, pos - 1)
         && (SYNTAX (mirrortab, BUF_FETCH_CHAR (buf, pos - 1)) == Squote
@@ -1276,7 +1210,7 @@ scan_sexps_forward (struct buffer *buf, struct lisp_parse_state *stateptr,
   Lisp_Object tem;
   int mask;                                 /* comment mask */
   Lisp_Object syntaxtab = buf->syntax_table;
-  Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
+  struct Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
 
   if (NILP (oldstate))
     {
@@ -1525,7 +1459,7 @@ DEFUN ("parse-partial-sexp", Fparse_partial_sexp, 2, 7, 0, /*
 Parse Lisp syntax starting at FROM until TO; return status of parse at TO.
 Parsing stops at TO or when certain criteria are met;
  point is set to where parsing stops.
-If fifth arg OLDSTATE is omitted or nil,
+If fifth arg STATE is omitted or nil,
  parsing assumes that FROM is the beginning of a function.
 Value is a list of eight elements describing final state of parsing:
  0. depth in parens.
@@ -1541,7 +1475,7 @@ If third arg TARGETDEPTH is non-nil, parsing stops if the depth
 in parentheses becomes equal to TARGETDEPTH.
 Fourth arg STOPBEFORE non-nil means stop when come to
  any character that starts a sexp.
-Fifth arg OLDSTATE is an eight-element list like what this function returns.
+Fifth arg STATE is an eight-element list like what this function returns.
 It is used to initialize the state of the parse.  Its second and third
 elements are ignored.
 Sixth arg COMMENTSTOP non-nil means stop at the start of a comment.
@@ -1629,7 +1563,7 @@ cmst_mapfun (struct chartab_range *range, Lisp_Object val, void *arg)
 }
 
 static void
-update_just_this_syntax_table (Lisp_Char_Table *ct)
+update_just_this_syntax_table (struct Lisp_Char_Table *ct)
 {
   struct chartab_range range;
   struct cmst_arg arg;
@@ -1647,7 +1581,7 @@ update_just_this_syntax_table (Lisp_Char_Table *ct)
    one. */
 
 void
-update_syntax_table (Lisp_Char_Table *ct)
+update_syntax_table (struct Lisp_Char_Table *ct)
 {
   /* Don't be stymied at startup. */
   if (CHAR_TABLEP (Vstandard_syntax_table)
@@ -1699,28 +1633,18 @@ vars_of_syntax (void)
   DEFVAR_BOOL ("parse-sexp-ignore-comments", &parse_sexp_ignore_comments /*
 Non-nil means `forward-sexp', etc., should treat comments as whitespace.
 */ );
-  parse_sexp_ignore_comments = 0;
 
+  words_include_escapes = 0;
   DEFVAR_BOOL ("words-include-escapes", &words_include_escapes /*
 Non-nil means `forward-word', etc., should treat escape chars part of words.
 */ );
-  words_include_escapes = 0;
 
   no_quit_in_re_search = 0;
 }
 
-static void
-define_standard_syntax (const char *p, enum syntaxcode syn)
-{
-  for (; *p; p++)
-    Fput_char_table (make_char (*p), make_int (syn), Vstandard_syntax_table);
-}
-
 void
 complex_vars_of_syntax (void)
 {
-  Emchar i;
-  const char *p;
   /* Set this now, so first buffer creation can refer to it. */
   /* Make it nil before calling copy-syntax-table
      so that copy-syntax-table will know not to try to copy from garbage */
@@ -1728,35 +1652,72 @@ complex_vars_of_syntax (void)
   Vstandard_syntax_table = Fcopy_syntax_table (Qnil);
   staticpro (&Vstandard_syntax_table);
 
-  Vsyntax_designator_chars_string = make_string_nocopy (syntax_code_spec,
-                                                       Smax);
+  Vsyntax_designator_chars_string = make_pure_string (syntax_code_spec,
+                                                     Smax, Qnil, 1);
   staticpro (&Vsyntax_designator_chars_string);
 
-  fill_char_table (XCHAR_TABLE (Vstandard_syntax_table), make_int (Spunct));
+  fill_char_table (XCHAR_TABLE (Vstandard_syntax_table),
+                  make_int (Spunct));
+
+  {
+    Emchar i;
 
-  for (i = 0; i <= 32; i++)    /* Control 0 plus SPACE */
-    Fput_char_table (make_char (i), make_int (Swhitespace),
+    for (i = 0; i <= 32; i++)
+      Fput_char_table (make_char (i), make_int ((int) Swhitespace),
+                      Vstandard_syntax_table);
+    for (i = 127; i <= 159; i++)
+      Fput_char_table (make_char (i), make_int ((int) Swhitespace),
+                      Vstandard_syntax_table);
+
+    for (i = 'a'; i <= 'z'; i++)
+      Fput_char_table (make_char (i), make_int ((int) Sword),
+                      Vstandard_syntax_table);
+    for (i = 'A'; i <= 'Z'; i++)
+      Fput_char_table (make_char (i), make_int ((int) Sword),
+                      Vstandard_syntax_table);
+    for (i = '0'; i <= '9'; i++)
+      Fput_char_table (make_char (i), make_int ((int) Sword),
+                      Vstandard_syntax_table);
+    Fput_char_table (make_char ('$'), make_int ((int) Sword),
                     Vstandard_syntax_table);
-  for (i = 127; i <= 159; i++) /* DEL plus Control 1 */
-    Fput_char_table (make_char (i), make_int (Swhitespace),
+    Fput_char_table (make_char ('%'), make_int ((int) Sword),
                     Vstandard_syntax_table);
 
-  define_standard_syntax ("abcdefghijklmnopqrstuvwxyz"
-                         "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-                         "0123456789"
-                         "$%", Sword);
-  define_standard_syntax ("\"", Sstring);
-  define_standard_syntax ("\\", Sescape);
-  define_standard_syntax ("_-+*/&|<>=", Ssymbol);
-  define_standard_syntax (".,;:?!#@~^'`", Spunct);
-
-  for (p = "()[]{}"; *p; p+=2)
     {
-      Fput_char_table (make_char (p[0]),
-                      Fcons (make_int (Sopen), make_char (p[1])),
+      Fput_char_table (make_char ('('), Fcons (make_int ((int) Sopen),
+                                              make_char (')')),
+                      Vstandard_syntax_table);
+      Fput_char_table (make_char (')'), Fcons (make_int ((int) Sclose),
+                                              make_char ('(')),
+                      Vstandard_syntax_table);
+      Fput_char_table (make_char ('['), Fcons (make_int ((int) Sopen),
+                                              make_char (']')),
                       Vstandard_syntax_table);
-      Fput_char_table (make_char (p[1]),
-                      Fcons (make_int (Sclose), make_char (p[0])),
+      Fput_char_table (make_char (']'), Fcons (make_int ((int) Sclose),
+                                              make_char ('[')),
                       Vstandard_syntax_table);
+      Fput_char_table (make_char ('{'), Fcons (make_int ((int) Sopen),
+                                              make_char ('}')),
+                      Vstandard_syntax_table);
+      Fput_char_table (make_char ('}'), Fcons (make_int ((int) Sclose),
+                                              make_char ('{')),
+                      Vstandard_syntax_table);
+    }
+
+    Fput_char_table (make_char ('"'), make_int ((int) Sstring),
+                    Vstandard_syntax_table);
+    Fput_char_table (make_char ('\\'), make_int ((int) Sescape),
+                    Vstandard_syntax_table);
+
+    {
+      CONST char *p;
+      for (p = "_-+*/&|<>="; *p; p++)
+       Fput_char_table (make_char (*p), make_int ((int) Ssymbol),
+                        Vstandard_syntax_table);
+
+      for (p = ".,;:?!#@~^'`"; *p; p++)
+       Fput_char_table (make_char (*p), make_int ((int) Spunct),
+                        Vstandard_syntax_table);
     }
+  }
 }