]> code.delx.au - gnu-emacs/blobdiff - src/syntax.c
CEDET (development tools) package merged.
[gnu-emacs] / src / syntax.c
index 87cf2da2e39515522dbb861d02c01f0a7ad0bd83..6fa20c458bab9dc3653afb242200baf9e25cb732 100644 (file)
@@ -1,6 +1,6 @@
 /* GNU Emacs routines to deal with syntax tables; also word and list parsing.
    Copyright (C) 1985, 1987, 1993, 1994, 1995, 1997, 1998, 1999, 2001,
-                 2002, 2003, 2004, 2005, 2006, 2007, 2008
+                 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
                  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -65,18 +65,20 @@ int open_paren_in_column_0_is_defun_start;
 
 struct lisp_parse_state
   {
-    int depth;         /* Depth at end of parsing.  */
-    int instring;      /* -1 if not within string, else desired terminator.  */
-    int incomment;     /* -1 if in unnestable comment else comment nesting */
-    int comstyle;      /* comment style a=0, or b=1, or ST_COMMENT_STYLE.  */
-    int quoted;                /* Nonzero if just after an escape char at end of parsing */
-    int thislevelstart;        /* Char number of most recent start-of-expression at current level */
-    int prevlevelstart; /* Char number of start of containing expression */
-    int location;      /* Char number at which parsing stopped.  */
-    int mindepth;      /* Minimum depth seen while scanning.  */
-    int comstr_start;  /* Position just after last comment/string starter.  */
-    Lisp_Object levelstarts;   /* Char numbers of starts-of-expression
-                                  of levels (starting from outermost).  */
+    int depth;    /* Depth at end of parsing.  */
+    int instring;  /* -1 if not within string, else desired terminator.  */
+    int incomment; /* -1 if in unnestable comment else comment nesting */
+    int comstyle;  /* comment style a=0, or b=1, or ST_COMMENT_STYLE.  */
+    int quoted;           /* Nonzero if just after an escape char at end of parsing */
+    int mindepth;  /* Minimum depth seen while scanning.  */
+    /* Char number of most recent start-of-expression at current level */
+    EMACS_INT thislevelstart;
+    /* Char number of start of containing expression */
+    EMACS_INT prevlevelstart;
+    EMACS_INT location;             /* Char number at which parsing stopped.  */
+    EMACS_INT comstr_start;  /* Position of last comment/string starter.  */
+    Lisp_Object levelstarts; /* Char numbers of starts-of-expression
+                               of levels (starting from outermost).  */
   };
 \f
 /* These variables are a cache for finding the start of a defun.
@@ -95,10 +97,6 @@ static EMACS_INT find_start_begv;
 static int find_start_modiff;
 
 
-static int find_defun_start P_ ((EMACS_INT, EMACS_INT));
-static int back_comment P_ ((EMACS_INT, EMACS_INT, EMACS_INT, int, int,
-                            EMACS_INT *, EMACS_INT *));
-static int char_quoted P_ ((int, int));
 static Lisp_Object skip_chars P_ ((int, Lisp_Object, Lisp_Object, int));
 static Lisp_Object skip_syntaxes P_ ((int, Lisp_Object, Lisp_Object));
 static Lisp_Object scan_lists P_ ((EMACS_INT, EMACS_INT, EMACS_INT, int));
@@ -290,13 +288,12 @@ update_syntax_table (charpos, count, init, object)
    or after.  On return global syntax data is good for lookup at CHARPOS. */
 
 static int
-char_quoted (charpos, bytepos)
-     register int charpos, bytepos;
+char_quoted (EMACS_INT charpos, EMACS_INT bytepos)
 {
   register enum syntaxcode code;
-  register int beg = BEGV;
+  register EMACS_INT beg = BEGV;
   register int quoted = 0;
-  int orig = charpos;
+  EMACS_INT orig = charpos;
 
   while (charpos > beg)
     {
@@ -319,9 +316,9 @@ char_quoted (charpos, bytepos)
 /* Return the bytepos one character after BYTEPOS.
    We assume that BYTEPOS is not at the end of the buffer.  */
 
-INLINE int
+INLINE EMACS_INT
 inc_bytepos (bytepos)
-     int bytepos;
+     EMACS_INT bytepos;
 {
   if (NILP (current_buffer->enable_multibyte_characters))
     return bytepos + 1;
@@ -333,9 +330,9 @@ inc_bytepos (bytepos)
 /* Return the bytepos one character before BYTEPOS.
    We assume that BYTEPOS is not at the start of the buffer.  */
 
-INLINE int
+INLINE EMACS_INT
 dec_bytepos (bytepos)
-     int bytepos;
+     EMACS_INT bytepos;
 {
   if (NILP (current_buffer->enable_multibyte_characters))
     return bytepos - 1;
@@ -358,7 +355,7 @@ dec_bytepos (bytepos)
    valid on return from the subroutine, so the caller should explicitly
    update the global data.  */
 
-static int
+static EMACS_INT
 find_defun_start (pos, pos_byte)
      EMACS_INT pos, pos_byte;
 {
@@ -854,8 +851,8 @@ static Lisp_Object Vsyntax_code_object;
 \f
 DEFUN ("char-syntax", Fchar_syntax, Schar_syntax, 1, 1, 0,
        doc: /* Return the syntax code of CHARACTER, described by a character.
-For example, if CHARACTER is a word constituent,
-the character `w' is returned.
+For example, if CHARACTER is a word constituent, the
+character `w' (119) is returned.
 The characters that correspond to various syntax codes
 are listed in the documentation of `modify-syntax-entry'.  */)
      (character)
@@ -971,7 +968,7 @@ DEFUN ("modify-syntax-entry", Fmodify_syntax_entry, Smodify_syntax_entry, 2, 3,
 The syntax is changed only for table SYNTAX-TABLE, which defaults to
  the current buffer's syntax table.
 CHAR may be a cons (MIN . MAX), in which case, syntaxes of all characters
-in the range MIN and MAX are changed.
+in the range MIN to MAX are changed.
 The first character of NEWENTRY should be one of the following:
   Space or -  whitespace syntax.    w   word constituent.
   _           symbol constituent.   .   punctuation.
@@ -1004,7 +1001,7 @@ this flag:
  p means CHAR is a prefix character for `backward-prefix-chars';
    such characters are treated as whitespace when they occur
    between expressions.
-usage: (modify-syntax-entry CHAR NEWENTRY &optional SYNTAX-TABLE) */)
+usage: (modify-syntax-entry CHAR NEWENTRY &optional SYNTAX-TABLE)  */)
      (c, newentry, syntax_table)
      Lisp_Object c, newentry, syntax_table;
 {
@@ -1251,7 +1248,7 @@ scan_words (from, count)
              if ((code != Sword
                   && (! words_include_escapes
                       || (code != Sescape && code != Scharquote)))
-                 || ! EQ (CHAR_TABLE_REF (Vchar_script_table, ch1), script))
+                 || word_boundary_p (ch0, ch1))
                break;
              INC_BOTH (from, from_byte);
              ch0 = ch1;
@@ -1304,7 +1301,7 @@ scan_words (from, count)
              if ((code != Sword
                   && (! words_include_escapes
                       || (code != Sescape && code != Scharquote)))
-                 || ! EQ (CHAR_TABLE_REF (Vchar_script_table, ch0), script))
+                 || word_boundary_p (ch0, ch1))
                {
                  INC_BOTH (from, from_byte);
                  break;
@@ -1356,7 +1353,7 @@ DEFUN ("skip-chars-forward", Fskip_chars_forward, Sskip_chars_forward, 1, 2, 0,
        doc: /* Move point forward, stopping before a char not in STRING, or at pos LIM.
 STRING is like the inside of a `[...]' in a regular expression
 except that `]' is never special and `\\' quotes `^', `-' or `\\'
- (but not as the end of a range; quoting is never needed there).
+ (but not at the end of a range; quoting is never needed there).
 Thus, with arg "a-zA-Z", this skips letters stopping before first nonletter.
 With arg "^a-zA-Z", skips nonletters stopping before first letter.
 Char classes, e.g. `[:alpha:]', are supported.