]> code.delx.au - gnu-emacs/blobdiff - src/syntax.c
Merge from trunk.
[gnu-emacs] / src / syntax.c
index 2960a9c96a01e35f3674daafb90623c466de6503..71da13e7a6693ba94a6b4496b889705ad8d5f80b 100644 (file)
@@ -1,5 +1,5 @@
 /* GNU Emacs routines to deal with syntax tables; also word and list parsing.
-   Copyright (C) 1985, 1987, 1993-1995, 1997-1999, 2001-2011
+   Copyright (C) 1985, 1987, 1993-1995, 1997-1999, 2001-2012
                  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -94,8 +94,8 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
    string-ender-char to distinguish  comments/strings started by
    comment_fence and string_fence codes.  */
 
-#define ST_COMMENT_STYLE (SYNTAX_FLAGS_COMMENT_STYLE (~0, ~0) + 1)
-#define ST_STRING_STYLE (MAX_CHAR + 1)
+#define ST_COMMENT_STYLE (256 + 1)
+#define ST_STRING_STYLE (256 + 2)
 
 static Lisp_Object Qsyntax_table_p;
 static Lisp_Object Qsyntax_table, Qscan_error;
@@ -1264,7 +1264,7 @@ scan_words (register ptrdiff_t from, register EMACS_INT count)
       if (! NILP (Ffboundp (func)))
        {
          pos = call2 (func, make_number (from - 1), make_number (end));
-         if (RANGED_INTEGERP (from + 1, pos, ZV))
+         if (INTEGERP (pos) && from < XINT (pos) && XINT (pos) <= ZV)
            {
              from = XINT (pos);
              from_byte = CHAR_TO_BYTE (from);
@@ -1314,7 +1314,7 @@ scan_words (register ptrdiff_t from, register EMACS_INT count)
       if (! NILP (Ffboundp (func)))
        {
          pos = call2 (func, make_number (from), make_number (beg));
-         if (RANGED_INTEGERP (BEGV, pos, from - 1))
+         if (INTEGERP (pos) && BEGV <= XINT (pos) && XINT (pos) < from)
            {
              from = XINT (pos);
              from_byte = CHAR_TO_BYTE (from);
@@ -2251,7 +2251,7 @@ between them, return t; otherwise return nil.  */)
   int found;
   EMACS_INT count1;
   ptrdiff_t out_charpos, out_bytepos;
-  ptrdiff_t dummy;
+  EMACS_INT dummy;
 
   CHECK_NUMBER (count);
   count1 = XINT (count);
@@ -2473,7 +2473,7 @@ scan_lists (register EMACS_INT from, EMACS_INT count, EMACS_INT depth, int sexpf
   ptrdiff_t from_byte;
   ptrdiff_t out_bytepos, out_charpos;
   int temp;
-  ptrdiff_t dummy;
+  EMACS_INT dummy;
   int multibyte_symbol_p = sexpflag && multibyte_syntax_as_symbol;
 
   if (depth > 0) min_depth = 0;
@@ -2846,18 +2846,23 @@ scan_lists (register EMACS_INT from, EMACS_INT count, EMACS_INT depth, int sexpf
 
 DEFUN ("scan-lists", Fscan_lists, Sscan_lists, 3, 3, 0,
        doc: /* Scan from character number FROM by COUNT lists.
-Returns the character number of the position thus found.
+Scan forward if COUNT is positive, backward if COUNT is negative.
+Return the character number of the position thus found.
+
+A \"list", in this context, refers to a balanced parenthetical
+grouping, as determined by the syntax table.
 
-If DEPTH is nonzero, paren depth begins counting from that value,
-only places where the depth in parentheses becomes zero
-are candidates for stopping; COUNT such places are counted.
-Thus, a positive value for DEPTH means go out levels.
+If DEPTH is nonzero, treat that as the nesting depth of the starting
+point (i.e. the starting point is DEPTH parentheses deep).  This
+function scans over parentheses until the depth goes to zero COUNT
+times.  Hence, positive DEPTH moves out that number of levels of
+parentheses, while negative DEPTH moves to a deeper level.
 
 Comments are ignored if `parse-sexp-ignore-comments' is non-nil.
 
-If the beginning or end of (the accessible part of) the buffer is reached
-and the depth is wrong, an error is signaled.
-If the depth is right but the count is not used up, nil is returned.  */)
+If we reach the beginning or end of the accessible part of the buffer
+before we have scanned over COUNT lists, return nil if the depth at
+that point is zero, and signal a error if the depth is nonzero.  */)
   (Lisp_Object from, Lisp_Object count, Lisp_Object depth)
 {
   CHECK_NUMBER (from);
@@ -3493,7 +3498,7 @@ See the info node `(elisp)Syntax Properties' for a description of the
 
   DEFVAR_BOOL ("open-paren-in-column-0-is-defun-start",
               open_paren_in_column_0_is_defun_start,
-              doc: /* *Non-nil means an open paren in column 0 denotes the start of a defun.  */);
+              doc: /* Non-nil means an open paren in column 0 denotes the start of a defun.  */);
   open_paren_in_column_0_is_defun_start = 1;