annotate src/syntax.c @ 5581:56144c8593a8

Mechanically change INT to FIXNUM in our sources. src/ChangeLog addition: 2011-10-09 Aidan Kehoe <kehoea@parhasard.net> [...] Mechanically change INT (where it refers to non-bignum Lisp integers) to FIXNUM in our sources. Done for the following functions, enums, and macros: Lisp_Type_Int_Even, Lisp_Type_Int_Odd, INT_GCBITS, INT_VALBITS, make_int(), INTP(), XINT(), CHECK_INT(), XREALINT(), INT_PLUS(), INT_MINUS(), EMACS_INT_MAX (to MOST_POSITIVE_FIXNUM), EMACS_INT_MIN (to MOST_NEGATIVE_FIXNUM), NUMBER_FITS_IN_AN_EMACS_INT() to NUMBER_FITS_IN_A_FIXNUM(), XFLOATINT, XCHAR_OR_INT, INT_OR_FLOAT. The EMACS_INT typedef was not changed, it does not describe non-bignum Lisp integers. Script that did the change available in http://mid.gmane.org/20067.17650.181273.12014@parhasard.net . modules/ChangeLog addition: 2011-10-09 Aidan Kehoe <kehoea@parhasard.net> [...] Mechanically change INT to FIXNUM, where the usage describes non-bignum Lisp integers. See the src/ChangeLog entry for more details. man/ChangeLog addition: 2011-10-09 Aidan Kehoe <kehoea@parhasard.net> * internals/internals.texi (How Lisp Objects Are Represented in C): * internals/internals.texi (Integers and Characters): Mechanically change INT to FIXNUM, where the usage describes non-bignum Lisp integers.
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 09 Oct 2011 09:51:57 +0100
parents 85210c453a97
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* XEmacs routines to deal with syntax tables; also word and list parsing.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1985-1994 Free Software Foundation, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 Copyright (C) 1995 Sun Microsystems, Inc.
5169
6c6d78781d59 cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents: 5127
diff changeset
4 Copyright (C) 2001, 2002, 2003, 2010 Ben Wing.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5169
diff changeset
8 XEmacs is free software: you can redistribute it and/or modify it
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5169
diff changeset
10 Free Software Foundation, either version 3 of the License, or (at your
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5169
diff changeset
11 option) any later version.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5169
diff changeset
19 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 /* Synched up with: FSF 19.28. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 /* This file has been Mule-ized. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 #include "buffer.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 #include "syntax.h"
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
30 #include "extents.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
32 #define ST_COMMENT_STYLE 0x101
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
33 #define ST_STRING_STYLE 0x102
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
34
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
35 Lisp_Object Qsyntax_table;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
36 int lookup_syntax_properties;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
37
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 Lisp_Object Qsyntax_table_p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 int words_include_escapes;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 int parse_sexp_ignore_comments;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43
5544
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
44 /* Tell the regex routines not to QUIT. Normally there is a QUIT each
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
45 iteration in re_search_2(). We do it this way rather than change
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
46 the arguments to re_search_2() in an attempt to maintain some call
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
47 compatibility with other versions of the regex code.
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
48 #### Surely this is no longer a consideration. Last sync was 19.28! */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 int no_quit_in_re_search;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50
5544
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
51 /* The standard syntax table is automatically used in all new buffers. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 Lisp_Object Vstandard_syntax_table;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 Lisp_Object Vsyntax_designator_chars_string;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
56 Lisp_Object Vtemp_table_for_use_updating_syntax_tables;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
57
1296
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
58 /* A value that is guaranteed not be in a syntax table. */
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
59 Lisp_Object Vbogus_syntax_table_value;
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
60
4912
e99033b7e05c use more specific `scan-error' in scan-lists to be GNU compatible
Ben Wing <ben@xemacs.org>
parents: 4759
diff changeset
61 Lisp_Object Qscan_error;
e99033b7e05c use more specific `scan-error' in scan-lists to be GNU compatible
Ben Wing <ben@xemacs.org>
parents: 4759
diff changeset
62
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
63 static void syntax_cache_table_was_changed (struct buffer *buf);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
64
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 /* This is the internal form of the parse state used in parse-partial-sexp. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 struct lisp_parse_state
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 int depth; /* Depth at end of parsing */
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
70 Ichar instring; /* -1 if not within string, else desired terminator */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 int incomment; /* Nonzero if within a comment at end of parsing */
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
72 int comstyle; /* comment style a=0, or b=1, or ST_COMMENT_STYLE */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 int quoted; /* Nonzero if just after an escape char at end of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 parsing */
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 627
diff changeset
75 Charbpos thislevelstart;/* Char number of most recent start-of-expression
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 at current level */
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 627
diff changeset
77 Charbpos prevlevelstart;/* Char number of start of containing expression */
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 627
diff changeset
78 Charbpos location; /* Char number at which parsing stopped */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 int mindepth; /* Minimum depth seen while scanning */
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
80 Charbpos comstr_start;/* Position just after last comment/string starter */
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
81 Lisp_Object levelstarts;/* Char numbers of starts-of-expression
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
82 of levels (starting from outermost). */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 };
5544
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
84
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 /* These variables are a cache for finding the start of a defun.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 find_start_pos is the place for which the defun start was found.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 find_start_value is the defun start position found for it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 find_start_buffer is the buffer it was found in.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 find_start_begv is the BEGV value when it was found.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 find_start_modiff is the value of MODIFF when it was found. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 627
diff changeset
93 static Charbpos find_start_pos;
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 627
diff changeset
94 static Charbpos find_start_value;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 static struct buffer *find_start_buffer;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 627
diff changeset
96 static Charbpos find_start_begv;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 static int find_start_modiff;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 /* Find a defun-start that is the last one before POS (or nearly the last).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 We record what we find, so that another call in the same area
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 can return the same value right away. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 627
diff changeset
103 static Charbpos
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 627
diff changeset
104 find_defun_start (struct buffer *buf, Charbpos pos)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 {
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 627
diff changeset
106 Charbpos tem;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
107 struct syntax_cache *scache;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
108
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 /* Use previous finding, if it's valid and applies to this inquiry. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 if (buf == find_start_buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 /* Reuse the defun-start even if POS is a little farther on.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 POS might be in the next defun, but that's ok.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 Our value may not be the best possible, but will still be usable. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 && pos <= find_start_pos + 1000
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 && pos >= find_start_value
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 && BUF_BEGV (buf) == find_start_begv
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 && BUF_MODIFF (buf) == find_start_modiff)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 return find_start_value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 /* Back up to start of line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 tem = find_next_newline (buf, pos, -1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
123 scache = setup_buffer_syntax_cache (buf, tem, 1);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 while (tem > BUF_BEGV (buf))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
126 UPDATE_SYNTAX_CACHE_BACKWARD (scache, tem);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
127
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 /* Open-paren at start of line means we found our defun-start. */
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
129 if (SYNTAX_FROM_CACHE (scache, BUF_FETCH_CHAR (buf, tem)) == Sopen)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 /* Move to beg of previous line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 tem = find_next_newline (buf, tem, -2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 /* Record what we found, for the next try. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 find_start_value = tem;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 find_start_buffer = buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 find_start_modiff = BUF_MODIFF (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 find_start_begv = BUF_BEGV (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 find_start_pos = pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 return find_start_value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 DEFUN ("syntax-table-p", Fsyntax_table_p, 1, 1, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
146 Return t if OBJECT is a syntax table.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
148 (object))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
150 return (CHAR_TABLEP (object)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
151 && XCHAR_TABLE_TYPE (object) == CHAR_TABLE_TYPE_SYNTAX)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 ? Qt : Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 check_syntax_table (Lisp_Object obj, Lisp_Object default_)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 if (NILP (obj))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 obj = default_;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 while (NILP (Fsyntax_table_p (obj)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 obj = wrong_type_argument (Qsyntax_table_p, obj);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 return obj;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 DEFUN ("syntax-table", Fsyntax_table, 0, 1, 0, /*
5544
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
166 Return the current syntax table of BUFFER.
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
167 BUFFER defaults to the current buffer.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 (buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 return decode_buffer (buffer, 0)->syntax_table;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
174 #ifdef DEBUG_XEMACS
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
175
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
176 DEFUN ("mirror-syntax-table", Fmirror_syntax_table, 0, 1, 0, /*
5544
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
177 Return the current mirror syntax table of BUFFER.
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
178 BUFFER defaults to the current buffer. Only useful in debugging internals.
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
179 */
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
180 (buffer))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
181 {
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
182 return decode_buffer (buffer, 0)->mirror_syntax_table;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
183 }
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
184
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
185 DEFUN ("syntax-cache-info", Fsyntax_cache_info, 0, 1, 0, /*
5544
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
186 Return a list (START END PREV_CHANGE NEXT_CHANGE) for BUFFER's syntax cache.
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
187 BUFFER defaults to the current buffer.
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
188
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
189 The elements correspond to members of struct syntax_cache of the same names.
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
190 START and END should be markers. PREV_CHANGE and NEXT_CHANGE are integers.
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
191 Only useful in debugging internals.
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
192 */
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
193 (buffer))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
194 {
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
195 struct buffer *buf = decode_buffer (buffer, 0);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
196 struct syntax_cache *cache = buf->syntax_cache;
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
197 return list4 (cache->start, cache->end, make_fixnum (cache->prev_change),
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
198 make_fixnum (cache->next_change));
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
199 }
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
200
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
201 #endif /* DEBUG_XEMACS */
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
202
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 DEFUN ("standard-syntax-table", Fstandard_syntax_table, 0, 0, 0, /*
5544
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
204 Return the standard syntax table, used for new buffers.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 ())
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 return Vstandard_syntax_table;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 DEFUN ("copy-syntax-table", Fcopy_syntax_table, 0, 1, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
212 Return a new syntax table which is a copy of SYNTAX-TABLE.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
213 SYNTAX-TABLE defaults to the standard syntax table.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
215 (syntax_table))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 if (NILP (Vstandard_syntax_table))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 return Fmake_char_table (Qsyntax);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
220 syntax_table = check_syntax_table (syntax_table, Vstandard_syntax_table);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
221 return Fcopy_char_table (syntax_table);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 DEFUN ("set-syntax-table", Fset_syntax_table, 1, 2, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
225 Select SYNTAX-TABLE as the new syntax table for BUFFER.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 BUFFER defaults to the current buffer if omitted.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
228 (syntax_table, buffer))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 struct buffer *buf = decode_buffer (buffer, 0);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
231 syntax_table = check_syntax_table (syntax_table, Qnil);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
232 buf->syntax_table = syntax_table;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
233 buf->mirror_syntax_table = XCHAR_TABLE (syntax_table)->mirror_table;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
234 syntax_cache_table_was_changed (buf);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 /* Indicate that this buffer now has a specified syntax table. */
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
236 buf->local_var_flags |= XFIXNUM (buffer_local_flags.syntax_table);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
237 return syntax_table;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 }
3252
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
239
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
240
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241
3252
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
242 /*
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
243 * Syntax caching
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
244 */
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
245
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
246 /* syntax_cache object implementation */
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
247
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
248 static const struct memory_description syntax_cache_description_1 [] = {
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
249 { XD_LISP_OBJECT, offsetof (struct syntax_cache, object) },
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
250 { XD_LISP_OBJECT, offsetof (struct syntax_cache, buffer) },
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
251 { XD_LISP_OBJECT, offsetof (struct syntax_cache, syntax_table) },
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
252 { XD_LISP_OBJECT, offsetof (struct syntax_cache, mirror_table) },
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
253 { XD_LISP_OBJECT, offsetof (struct syntax_cache, start) },
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
254 { XD_LISP_OBJECT, offsetof (struct syntax_cache, end) },
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
255 { XD_END }
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
256 };
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
257
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
258 #ifdef NEW_GC
5118
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 4759
diff changeset
259 DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT ("syntax-cache", syntax_cache,
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 4759
diff changeset
260 0, syntax_cache_description_1,
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 4759
diff changeset
261 Lisp_Syntax_Cache);
3252
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
262 #else /* not NEW_GC */
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
263
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
264 const struct sized_memory_description syntax_cache_description = {
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
265 sizeof (struct syntax_cache),
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
266 syntax_cache_description_1
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
267 };
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
268 #endif /* not NEW_GC */
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
269
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
270 /* static syntax cache utilities */
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
271
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
272 static void
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
273 syntax_cache_table_was_changed (struct buffer *buf)
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
274 {
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
275 struct syntax_cache *cache = buf->syntax_cache;
5552
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
276 if (cache->source == syntax_source_buffer_table)
3252
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
277 {
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
278 cache->syntax_table =
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
279 BUFFER_SYNTAX_TABLE (buf);
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
280 cache->mirror_table =
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
281 BUFFER_MIRROR_SYNTAX_TABLE (buf);
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
282 }
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
283 }
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
284
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
285 static void
5543
fbe90e6f7a43 Initialize start and end properly (to new markers, not Qnil).
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5542
diff changeset
286 reset_syntax_cache_range (struct syntax_cache *cache, /* initialized cache */
5552
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
287 int valid_everywhere) /* non-zero if we can assume
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
288 syntax-table properties
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
289 never need be respected
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
290 in the life of the cache */
3252
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
291 {
5552
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
292 if (BUFFERP (cache->object))
5543
fbe90e6f7a43 Initialize start and end properly (to new markers, not Qnil).
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5542
diff changeset
293 {
fbe90e6f7a43 Initialize start and end properly (to new markers, not Qnil).
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5542
diff changeset
294 /* make known region zero-length and reset insertion behavior */
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
295 Fset_marker (cache->start, make_fixnum (1), cache->object);
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
296 Fset_marker (cache->end, make_fixnum (1), cache->object);
5545
69de75c48efa Alan Mackenzie's syntax cache bounds fix.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5544
diff changeset
297 Fset_marker_insertion_type (cache->start, Qnil);
69de75c48efa Alan Mackenzie's syntax cache bounds fix.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5544
diff changeset
298 Fset_marker_insertion_type (cache->end, Qt);
5543
fbe90e6f7a43 Initialize start and end properly (to new markers, not Qnil).
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5542
diff changeset
299 }
5552
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
300 /* #### Should reset "cache->source" here?
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
301 If so, also reset tables. */
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
302 if (valid_everywhere)
5543
fbe90e6f7a43 Initialize start and end properly (to new markers, not Qnil).
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5542
diff changeset
303 {
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
304 cache->prev_change = MOST_NEGATIVE_FIXNUM;
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
305 cache->next_change = MOST_POSITIVE_FIXNUM;
5543
fbe90e6f7a43 Initialize start and end properly (to new markers, not Qnil).
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5542
diff changeset
306 }
5552
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
307 else /* valid nowhere */
5543
fbe90e6f7a43 Initialize start and end properly (to new markers, not Qnil).
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5542
diff changeset
308 {
fbe90e6f7a43 Initialize start and end properly (to new markers, not Qnil).
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5542
diff changeset
309 cache->prev_change = -1;
fbe90e6f7a43 Initialize start and end properly (to new markers, not Qnil).
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5542
diff changeset
310 cache->next_change = -1;
fbe90e6f7a43 Initialize start and end properly (to new markers, not Qnil).
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5542
diff changeset
311 }
3252
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
312 }
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
313
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
314 static void
5552
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
315 init_syntax_cache (struct syntax_cache *cache, /* xzero'ed memory */
5543
fbe90e6f7a43 Initialize start and end properly (to new markers, not Qnil).
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5542
diff changeset
316 Lisp_Object object, /* string or buffer */
5552
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
317 struct buffer *buffer) /* buffer; if OBJECT is a
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
318 buffer, this is the same */
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
319 {
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
320 cache->object = object;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
321 cache->buffer = buffer;
5552
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
322
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
323 cache->source = syntax_source_buffer_table;
1296
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
324 cache->syntax_table =
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
325 BUFFER_SYNTAX_TABLE (cache->buffer);
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
326 cache->mirror_table =
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
327 BUFFER_MIRROR_SYNTAX_TABLE (cache->buffer);
5552
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
328
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
329 /* Qnil avoids GC'ing markers, which are useless for strings. */
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
330 cache->start = BUFFERP (object) ? Fmake_marker () : Qnil;
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
331 cache->end = BUFFERP (object) ? Fmake_marker () : Qnil;
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
332
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
333 reset_syntax_cache_range (cache, 0);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
334 }
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
335
3252
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
336 /* external syntax cache API */
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
337
5552
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
338 /* At this time (hg rev 5551:dab422055bab) setup_syntax_cache() is called
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
339 directly once in setup_buffer_syntax_cache and twice in regex.c. The
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
340 calls in regex.c are obfuscated, so it's hard to tell, but it looks like
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
341 they can be called with OBJECT being a buffer.
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
342
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
343 "You are in a confusing maze of initializations, all alike."
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
344
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
345 reset_syntax_cache_range (3 uses in setup_syntax_cache,
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
346 signal_syntax_cache_extent_changed, and init_buffer_syntax_cache)
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
347 reinitializes:
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
348 1. if BUFFERP(OBJECT), marker positions to 1 (giving a null range)
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
349 2. if BUFFERP(OBJECT), marker movement type
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
350 3. cache range per VALID_EVERYWHERE
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
351
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
352 init_syntax_cache (2 uses in init_buffer_syntax_cache and
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
353 setup_syntax_cache) initializes:
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
354 1. source to syntax_source_buffer_table
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
355 2. syntax_table and mirror_syntax table to BUFFER's tables
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
356 3. marker members to BUFFERP(OBJECT) ? markers w/o position : Qnil
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
357 4. cache range with VALID_EVERYWHERE==0
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
358 5. object and buffer to corresponding arguments.
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
359
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
360 init_buffer_syntax_cache (1 use in buffer.c) initializes:
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
361 0. allocation of buffer's cache memory (done by allocator)
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
362 1. cache memory to zero (done by allocator)
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
363 2. cache to buffer's cache
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
364 3. cache members by init_syntax_cache with object==buffer==BUF.
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
365
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
366 setup_buffer_syntax_cache (1 call in font-lock.c, 1 use in search.c,
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
367 and 7 uses in this file) initializes:
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
368 0. buffer's syntax cache by calling setup_syntax_cache.
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
369
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
370 setup_buffer_syntax_cache and setup_syntax_cache are called by functions
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
371 that analyze text using character syntax. They are called repeatedly on
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
372 the same cache. init_syntax_cache and init_buffer_syntax_cache are
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
373 conceptually called once for each cache. reset_syntax_cache_range may
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
374 be called repeatedly on the same cache. The last three are for internal
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
375 use by the syntax setup code and buffer initialization. */
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
376
3250
2b8bb4938bb4 [xemacs-hg @ 2006-02-21 11:33:41 by stephent]
stephent
parents: 3152
diff changeset
377 struct syntax_cache * /* return CACHE or the cache of OBJECT */
5544
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
378 setup_syntax_cache (struct syntax_cache *cache, /* may be NULL only if
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
379 OBJECT is a buffer */
3250
2b8bb4938bb4 [xemacs-hg @ 2006-02-21 11:33:41 by stephent]
stephent
parents: 3152
diff changeset
380 Lisp_Object object, /* the object (if any) cache
2b8bb4938bb4 [xemacs-hg @ 2006-02-21 11:33:41 by stephent]
stephent
parents: 3152
diff changeset
381 is associated with */
2b8bb4938bb4 [xemacs-hg @ 2006-02-21 11:33:41 by stephent]
stephent
parents: 3152
diff changeset
382 struct buffer *buffer, /* the buffer to use as source
2b8bb4938bb4 [xemacs-hg @ 2006-02-21 11:33:41 by stephent]
stephent
parents: 3152
diff changeset
383 of the syntax table */
5552
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
384 Charxpos from, /* initial position of cache */
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
385 int count) /* direction? see code */
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
386 {
5552
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
387 /* If OBJECT is a buffer, use its cache; else use CACHE and initialize it.
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
388 Invalidate the cache if the syntax-table property is being respected;
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
389 else make it valid for the whole object. */
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
390 if (BUFFERP (object))
3250
2b8bb4938bb4 [xemacs-hg @ 2006-02-21 11:33:41 by stephent]
stephent
parents: 3152
diff changeset
391 {
2b8bb4938bb4 [xemacs-hg @ 2006-02-21 11:33:41 by stephent]
stephent
parents: 3152
diff changeset
392 cache = XBUFFER (object)->syntax_cache;
5552
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
393 if (!lookup_syntax_properties)
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
394 reset_syntax_cache_range (cache, 1);
3250
2b8bb4938bb4 [xemacs-hg @ 2006-02-21 11:33:41 by stephent]
stephent
parents: 3152
diff changeset
395 }
2b8bb4938bb4 [xemacs-hg @ 2006-02-21 11:33:41 by stephent]
stephent
parents: 3152
diff changeset
396 else
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
397 {
5543
fbe90e6f7a43 Initialize start and end properly (to new markers, not Qnil).
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5542
diff changeset
398 xzero (*cache);
fbe90e6f7a43 Initialize start and end properly (to new markers, not Qnil).
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5542
diff changeset
399 init_syntax_cache (cache, object, buffer);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
400 }
5552
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
401
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
402 if (lookup_syntax_properties)
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
403 {
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
404 if (count <= 0)
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
405 {
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
406 --from;
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
407 from = buffer_or_string_clip_to_accessible_char (cache->object,
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
408 from);
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
409 }
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
410 /* If lookup_syntax_properties && BUFFERP (object), this
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
411 optimization may matter. */
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
412 if (!(from >= cache->prev_change && from < cache->next_change))
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
413 update_syntax_cache (cache, from, count);
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
414 }
5543
fbe90e6f7a43 Initialize start and end properly (to new markers, not Qnil).
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5542
diff changeset
415
1296
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
416 #ifdef NOT_WORTH_THE_EFFORT
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
417 update_mirror_syntax_if_dirty (cache->mirror_table);
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
418 #endif /* NOT_WORTH_THE_EFFORT */
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
419 return cache;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
420 }
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
421
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
422 struct syntax_cache *
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
423 setup_buffer_syntax_cache (struct buffer *buffer, Charxpos from, int count)
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
424 {
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
425 return setup_syntax_cache (NULL, wrap_buffer (buffer), buffer, from, count);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
426 }
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
427
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
428 /*
5544
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
429 Update syntax_cache CACHE to an appropriate setting for position CPOS.
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
430
5544
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
431 The sign of COUNT gives the relative position of CPOS wrt the
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
432 previously valid interval. (not currently used)
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
433
5544
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
434 `syntax_cache.*_change' are the next and previous positions at which
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
435 syntax_code and c_s_t will need to be recalculated.
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
436
5544
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
437 #### Currently this code uses `get-char-property', which will return
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
438 the "last smallest" extent at a given position. In cases where
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
439 overlapping extents are defined, this code will simply use whatever
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
440 is returned by get-char-property. */
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
441
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
442 void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2167
diff changeset
443 update_syntax_cache (struct syntax_cache *cache, Charxpos cpos,
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2167
diff changeset
444 int UNUSED (count))
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
445 {
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
446 Lisp_Object tmp_table;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
447 Bytexpos pos;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
448 Bytexpos lim;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
449 Bytexpos next, prev;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
450 int at_begin = 0, at_end = 0;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
451
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
452 if (NILP (cache->object))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
453 return;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
454
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
455 pos = buffer_or_string_charxpos_to_bytexpos (cache->object, cpos);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
456
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
457 tmp_table = get_char_property (pos, Qsyntax_table, cache->object,
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
458 EXTENT_AT_AFTER, 0);
2506
8c96bdabcaf9 [xemacs-hg @ 2005-01-26 05:11:01 by ben]
ben
parents: 2297
diff changeset
459 lim = next_previous_single_property_change (pos, Qsyntax_table,
8c96bdabcaf9 [xemacs-hg @ 2005-01-26 05:11:01 by ben]
ben
parents: 2297
diff changeset
460 cache->object, -1, 1, 0);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
461 if (lim < 0)
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
462 {
5545
69de75c48efa Alan Mackenzie's syntax cache bounds fix.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5544
diff changeset
463 next = buffer_or_string_accessible_end_byte (cache->object);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
464 at_begin = 1;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
465 }
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
466 else
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
467 next = lim;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
468
5545
69de75c48efa Alan Mackenzie's syntax cache bounds fix.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5544
diff changeset
469 if (pos < buffer_or_string_accessible_end_byte (cache->object))
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
470 pos = next_bytexpos (cache->object, pos);
2506
8c96bdabcaf9 [xemacs-hg @ 2005-01-26 05:11:01 by ben]
ben
parents: 2297
diff changeset
471 lim = next_previous_single_property_change (pos, Qsyntax_table,
8c96bdabcaf9 [xemacs-hg @ 2005-01-26 05:11:01 by ben]
ben
parents: 2297
diff changeset
472 cache->object, -1, 0, 0);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
473 if (lim < 0)
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
474 {
5545
69de75c48efa Alan Mackenzie's syntax cache bounds fix.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5544
diff changeset
475 prev = buffer_or_string_accessible_begin_byte (cache->object);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
476 at_end = 1;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
477 }
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
478 else
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
479 prev = lim;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
480
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
481 cache->prev_change =
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
482 buffer_or_string_bytexpos_to_charxpos (cache->object, prev);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
483 cache->next_change =
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
484 buffer_or_string_bytexpos_to_charxpos (cache->object, next);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
485
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
486 if (BUFFERP (cache->object))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
487 {
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
488 /* If we are at the beginning or end of buffer, check to see if there's
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
489 a zero-length `syntax-table' extent there (highly unlikely); if not,
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
490 then we can safely make the end closed, so it will take in newly
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
491 inserted text. (If such an extent is inserted, we will be informed
3250
2b8bb4938bb4 [xemacs-hg @ 2006-02-21 11:33:41 by stephent]
stephent
parents: 3152
diff changeset
492 through signal_syntax_cache_extent_changed().) */
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
493 Fset_marker (cache->start, make_fixnum (cache->prev_change), cache->object);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
494 Fset_marker_insertion_type
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
495 (cache->start,
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
496 at_begin && NILP (extent_at (prev, cache->object, Qsyntax_table,
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
497 NULL, EXTENT_AT_AT, 0))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
498 ? Qnil : Qt);
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
499 Fset_marker (cache->end, make_fixnum (cache->next_change), cache->object);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
500 Fset_marker_insertion_type
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
501 (cache->end,
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
502 at_end && NILP (extent_at (next, cache->object, Qsyntax_table,
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
503 NULL, EXTENT_AT_AT, 0))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
504 ? Qt : Qnil);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
505 }
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
506
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
507 if (!NILP (Fsyntax_table_p (tmp_table)))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
508 {
5552
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
509 cache->source = syntax_source_property_table;
1296
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
510 cache->syntax_table = tmp_table;
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
511 cache->mirror_table = XCHAR_TABLE (tmp_table)->mirror_table;
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
512 #ifdef NOT_WORTH_THE_EFFORT
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
513 update_mirror_syntax_if_dirty (cache->mirror_table);
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
514 #endif /* NOT_WORTH_THE_EFFORT */
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
515 }
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
516 else if (CONSP (tmp_table) && FIXNUMP (XCAR (tmp_table)))
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
517 {
5552
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
518 cache->source = syntax_source_property_code;
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
519 cache->syntax_code = XFIXNUM (XCAR (tmp_table));
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
520 }
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
521 else
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
522 {
5552
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
523 cache->source = syntax_source_buffer_table;
1296
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
524 cache->syntax_table = BUFFER_SYNTAX_TABLE (cache->buffer);
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
525 cache->mirror_table = BUFFER_MIRROR_SYNTAX_TABLE (cache->buffer);
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
526 #ifdef NOT_WORTH_THE_EFFORT
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
527 update_mirror_syntax_if_dirty (cache->mirror_table);
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
528 #endif /* NOT_WORTH_THE_EFFORT */
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
529 }
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
530 }
3252
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
531
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
532 /* buffer-specific APIs used in buffer.c
5544
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
533 #### Really unclean; the syntax cache should just be a LISP object. */
3252
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
534
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
535 void
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
536 mark_buffer_syntax_cache (struct buffer *buf)
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
537 {
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
538 struct syntax_cache *cache = buf->syntax_cache;
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
539 if (!cache) /* Vbuffer_defaults and such don't have caches */
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
540 return;
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
541 mark_object (cache->object);
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
542 if (cache->buffer)
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
543 mark_object (wrap_buffer (cache->buffer));
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
544 mark_object (cache->syntax_table);
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
545 mark_object (cache->mirror_table);
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
546 mark_object (cache->start);
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
547 mark_object (cache->end);
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
548 }
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
549
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
550 void
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
551 init_buffer_syntax_cache (struct buffer *buf)
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
552 {
5552
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
553 struct syntax_cache *cache;
3252
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
554 #ifdef NEW_GC
5552
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
555 cache = XSYNTAX_CACHE (ALLOC_NORMAL_LISP_OBJECT (syntax_cache));
3252
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
556 #else /* not NEW_GC */
5552
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
557 cache = xnew_and_zero (struct syntax_cache);
3252
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
558 #endif /* not NEW_GC */
5543
fbe90e6f7a43 Initialize start and end properly (to new markers, not Qnil).
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5542
diff changeset
559
5552
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
560 init_syntax_cache (cache, wrap_buffer (buf), buf);
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
561 buf->syntax_cache = cache;
3252
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
562 }
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
563
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
564 /* finalize the syntax cache for BUF */
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
565
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
566 void
4710
3a87551bfeb5 Fixes for a number of minor warnings issued by gcc. See xemacs-patches message
Jerry James <james@xemacs.org>
parents: 4653
diff changeset
567 uninit_buffer_syntax_cache (struct buffer *UNUSED_IF_NEW_GC (buf))
3252
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
568 {
4141
77138fc618a9 [xemacs-hg @ 2007-08-24 13:03:04 by crestani]
crestani
parents: 4117
diff changeset
569 #ifndef NEW_GC
5169
6c6d78781d59 cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents: 5127
diff changeset
570 if (buf->syntax_cache)
6c6d78781d59 cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents: 5127
diff changeset
571 {
6c6d78781d59 cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents: 5127
diff changeset
572 xfree (buf->syntax_cache);
6c6d78781d59 cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents: 5127
diff changeset
573 buf->syntax_cache = 0;
6c6d78781d59 cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents: 5127
diff changeset
574 }
4141
77138fc618a9 [xemacs-hg @ 2007-08-24 13:03:04 by crestani]
crestani
parents: 4117
diff changeset
575 #endif /* not NEW_GC */
3252
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
576 }
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
577
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
578 /* extent-specific APIs used in extents.c and insdel.c */
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
579
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
580 /* The syntax-table property on the range covered by EXTENT may be changing,
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
581 either because EXTENT has a syntax-table property and is being attached
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
582 or detached (this includes having its endpoints changed), or because
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
583 the value of EXTENT's syntax-table property is changing. */
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
584
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
585 void
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
586 signal_syntax_cache_extent_changed (EXTENT extent)
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
587 {
5552
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
588 Lisp_Object object = Fextent_object (wrap_extent (extent));
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
589 if (BUFFERP (object))
3252
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
590 {
5552
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
591 struct syntax_cache *cache = XBUFFER (object)->syntax_cache;
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
592 Bytexpos extent_start = extent_endpoint_byte (extent, 0);
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
593 Bytexpos extent_end = extent_endpoint_byte (extent, 1);
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
594 Bytexpos cache_start = byte_marker_position (cache->start);
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
595 Bytexpos cache_end = byte_marker_position (cache->end);
3252
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
596 /* If the extent is entirely before or entirely after the cache
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
597 range, it doesn't overlap. Otherwise, invalidate the range. */
5552
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
598 if (!(extent_end < cache_start || extent_start > cache_end))
85210c453a97 Fix performance regression in refactored syntax cache setup.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5545
diff changeset
599 reset_syntax_cache_range (cache, 0);
3252
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
600 }
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
601 }
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
602
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
603 /* Extents have been adjusted for insertion or deletion, so we need to
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
604 refetch the start and end position of the extent */
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
605 void
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
606 signal_syntax_cache_extent_adjust (struct buffer *buf)
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
607 {
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
608 struct syntax_cache *cache = buf->syntax_cache;
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
609 /* If the cache was invalid before, leave it that way. We only want
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
610 to update the limits of validity when they were actually valid. */
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
611 if (cache->prev_change < 0)
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
612 return;
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
613 cache->prev_change = marker_position (cache->start);
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
614 cache->next_change = marker_position (cache->end);
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
615 }
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
616
a66d0a29e183 [xemacs-hg @ 2006-02-22 03:30:06 by stephent]
stephent
parents: 3250
diff changeset
617
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
618
5544
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
619 /* Convert an ASCII character which represents a syntax class
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
620 into the corresponding syntax code.
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
621 This is used by (search.c) skip_chars and (regex.c) regex_compile.
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
622 regex_compile indexes with `c' of type int, but promises that it
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
623 is positive.
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
624 #### skip_chars indexes with an Ichar, a signed type. Presumably
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
625 this is guaranteed non-negative. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626
5542
dab422055bab Correct array bound for syntax_code_spec.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5402
diff changeset
627 const unsigned char syntax_spec_code[0200] =
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 { 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 (char) Swhitespace, 0377, (char) Sstring, 0377,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 (char) Smath, 0377, 0377, (char) Squote,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 (char) Sopen, (char) Sclose, 0377, 0377,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 0377, (char) Swhitespace, (char) Spunct, (char) Scharquote,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 0377, 0377, 0377, 0377,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 (char) Scomment, 0377, (char) Sendcomment, 0377,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 (char) Sinherit, 0377, 0377, 0377, 0377, 0377, 0377, 0377, /* @, A ... */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 0377, 0377, 0377, 0377, 0377, 0377, 0377, (char) Sword,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 0377, 0377, 0377, 0377, (char) Sescape, 0377, 0377, (char) Ssymbol,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377, /* `, a, ... */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 0377, 0377, 0377, 0377, 0377, 0377, 0377, (char) Sword,
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
646 0377, 0377, 0377, 0377, (char) Sstring_fence, 0377, 0377, 0377
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648
5544
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
649 /* The inverse mapping for syntax_spec_code. */
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
650 const unsigned char syntax_code_spec[] = " .w_()'\"$\\/<>@!|";
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 DEFUN ("syntax-designator-chars", Fsyntax_designator_chars, 0, 0, 0, /*
5544
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
653 Return the string of the recognized syntax designator chars.
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
654 The chars are indexed by their internal syntax codes, starting at 0.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 ())
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 return Vsyntax_designator_chars_string;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 DEFUN ("char-syntax", Fchar_syntax, 1, 2, 0, /*
5544
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
662 Return the syntax code of CHARACTER, designated by a character.
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
663 Optional SYNTAX-TABLE defaults to the current buffer's syntax table.
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
664 See `modify-syntax-entry' for the designators of the defined syntax codes.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
666 (character, syntax_table))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
668 Lisp_Object mirrortab;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
670 if (NILP (character))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
672 character = make_char ('\000');
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 }
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
674 CHECK_CHAR_COERCE_INT (character);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
675 syntax_table = check_syntax_table (syntax_table,
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
676 current_buffer->syntax_table);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
677 mirrortab = XCHAR_TABLE (syntax_table)->mirror_table;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
678 return make_char (syntax_code_spec[(int) SYNTAX (mirrortab,
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
679 XCHAR (character))]);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684 enum syntaxcode
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2167
diff changeset
685 charset_syntax (struct buffer *UNUSED (buf), Lisp_Object UNUSED (charset),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2167
diff changeset
686 int *multi_p_out)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 *multi_p_out = 1;
5544
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
689 /* !!#### get this right
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
690 Maybe not worth it until we have Unicode inside. */
3152
b85f5d7d9d82 [xemacs-hg @ 2005-12-18 22:55:51 by aidan]
aidan
parents: 3092
diff changeset
691 return Sword;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695
5544
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
696 /* #### Outside of this file, only used once, in font-lock.c. Make static?
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
697 If so, remove prototype from syntax.h. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698 Lisp_Object
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
699 syntax_match (Lisp_Object syntax_table, Ichar ch)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
701 Lisp_Object code = get_char_table (ch, syntax_table);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702 Lisp_Object code2 = code;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704 if (CONSP (code))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705 code2 = XCAR (code);
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
706 if (SYNTAX_FROM_CODE (XFIXNUM (code2)) == Sinherit)
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
707 code = get_char_table (ch, Vstandard_syntax_table);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709 return CONSP (code) ? XCDR (code) : Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 DEFUN ("matching-paren", Fmatching_paren, 1, 2, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
713 Return the matching parenthesis of CHARACTER, or nil if none.
5544
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
714 Optional SYNTAX-TABLE defaults to the current buffer's syntax table.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
716 (character, syntax_table))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
718 Lisp_Object mirrortab;
1315
70921960b980 [xemacs-hg @ 2003-02-20 08:19:28 by ben]
ben
parents: 1296
diff changeset
719 enum syntaxcode code;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
721 CHECK_CHAR_COERCE_INT (character);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
722 syntax_table = check_syntax_table (syntax_table,
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
723 current_buffer->syntax_table);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
724 mirrortab = XCHAR_TABLE (syntax_table)->mirror_table;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
725 code = SYNTAX (mirrortab, XCHAR (character));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726 if (code == Sopen || code == Sclose || code == Sstring)
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
727 return syntax_match (syntax_table, XCHAR (character));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734 /* Return 1 if there is a word boundary between two word-constituent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735 characters C1 and C2 if they appear in this order, else return 0.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736 There is no word boundary between two word-constituent ASCII
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 characters. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738 #define WORD_BOUNDARY_P(c1, c2) \
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
739 (!(ichar_ascii_p (c1) && ichar_ascii_p (c2)) \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740 && word_boundary_p (c1, c2))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743 /* Return the position across COUNT words from FROM.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744 If that many words cannot be found before the end of the buffer, return 0.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745 COUNT negative means scan backward and stop at word beginning. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 627
diff changeset
747 Charbpos
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 627
diff changeset
748 scan_words (struct buffer *buf, Charbpos from, int count)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749 {
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 627
diff changeset
750 Charbpos limit = count > 0 ? BUF_ZV (buf) : BUF_BEGV (buf);
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
751 Ichar ch0, ch1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 enum syntaxcode code;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
753 struct syntax_cache *scache = setup_buffer_syntax_cache (buf, from, count);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
754
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755 /* #### is it really worth it to hand expand both cases? JV */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756 while (count > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758 QUIT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762 if (from == limit)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
765 UPDATE_SYNTAX_CACHE_FORWARD (scache, from);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766 ch0 = BUF_FETCH_CHAR (buf, from);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
767 code = SYNTAX_FROM_CACHE (scache, ch0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
769 from++;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770 if (words_include_escapes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771 && (code == Sescape || code == Scharquote))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773 if (code == Sword)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777 QUIT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
778
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779 while (from != limit)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
781 UPDATE_SYNTAX_CACHE_FORWARD (scache, from);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
782 ch1 = BUF_FETCH_CHAR (buf, from);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
783 code = SYNTAX_FROM_CACHE (scache, ch1);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
784 if (!(words_include_escapes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
785 && (code == Sescape || code == Scharquote)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786 if (code != Sword
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
787 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
788 || WORD_BOUNDARY_P (ch0, ch1)
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
789 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
792 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
793 ch0 = ch1;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
794 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795 from++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
797 count--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800 while (count < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802 QUIT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
803
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
804 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
805 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
806 if (from == limit)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
807 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
808
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
809 UPDATE_SYNTAX_CACHE_BACKWARD (scache, from - 1);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
810 ch1 = BUF_FETCH_CHAR (buf, from - 1);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
811 code = SYNTAX_FROM_CACHE (scache, ch1);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
812 from--;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
813
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
814 if (words_include_escapes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815 && (code == Sescape || code == Scharquote))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
816 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817 if (code == Sword)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
819 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
820
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
821 QUIT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
822
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
823 while (from != limit)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
824 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
825 UPDATE_SYNTAX_CACHE_BACKWARD (scache, from - 1);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
826 ch0 = BUF_FETCH_CHAR (buf, from - 1);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
827 code = SYNTAX_FROM_CACHE (scache, ch0);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
828
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
829 if (!(words_include_escapes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830 && (code == Sescape || code == Scharquote)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
831 if (code != Sword
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
832 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
833 || WORD_BOUNDARY_P (ch0, ch1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
834 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
835 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
836 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
837 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
838 ch1 = ch0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
840 from--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
841 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
842 count++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
843 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
844
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
845 return from;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
846 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
848 DEFUN ("forward-word", Fforward_word, 0, 2, "_p", /*
5544
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
849 Move point forward COUNT words in BUFFER (backward if COUNT is negative).
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
850 COUNT defaults to 1, and BUFFER defaults to the current buffer.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
851
5544
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
852 Return t if the motion successfully crosses COUNT words, otherwise nil (if
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
853 the motion would cross the buffer boundary).
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
854
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
855 The characters that are moved over are added to the region if the region
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
856 is active, the Shift key is held down, a motion key is used to invoke this
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
857 command, and `shifted-motion-keys-select-region' is non-nil; see
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 460
diff changeset
858 the documentation for this variable for more details.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
859 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
860 (count, buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
861 {
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 627
diff changeset
862 Charbpos val;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
863 struct buffer *buf = decode_buffer (buffer, 0);
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
864 EMACS_INT n;
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
865
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
866 if (NILP (count))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
867 n = 1;
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
868 else
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
869 {
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
870 CHECK_FIXNUM (count);
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
871 n = XFIXNUM (count);
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
872 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
873
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
874 val = scan_words (buf, BUF_PT (buf), n);
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
875 if (val)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
876 {
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
877 BUF_SET_PT (buf, val);
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
878 return Qt;
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
879 }
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
880 else
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
881 {
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
882 BUF_SET_PT (buf, n > 0 ? BUF_ZV (buf) : BUF_BEGV (buf));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
884 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
885 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887 static void scan_sexps_forward (struct buffer *buf,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
888 struct lisp_parse_state *,
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 627
diff changeset
889 Charbpos from, Charbpos end,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
890 int targetdepth, int stopbefore,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
891 Lisp_Object oldstate,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
892 int commentstop);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
893
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
894 static int
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 627
diff changeset
895 find_start_of_comment (struct buffer *buf, Charbpos from, Charbpos stop,
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
896 int comstyle)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
897 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
898 Ichar c;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
899 enum syntaxcode code;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
900
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
901 /* Look back, counting the parity of string-quotes,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
902 and recording the comment-starters seen.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
903 When we reach a safe place, assume that's not in a string;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
904 then step the main scan to the earliest comment-starter seen
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905 an even number of string quotes away from the safe place.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
906
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907 OFROM[I] is position of the earliest comment-starter seen
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
908 which is I+2X quotes from the comment-end.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909 PARITY is current parity of quotes from the comment end. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
910 int parity = 0;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
911 Ichar my_stringend = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
912 int string_lossage = 0;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 627
diff changeset
913 Charbpos comment_end = from;
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 627
diff changeset
914 Charbpos comstart_pos = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
915 int comstart_parity = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916 int styles_match_p = 0;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
917 /* mask to match comment styles against; for ST_COMMENT_STYLE, this
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
918 will get set to SYNTAX_COMMENT_STYLE_B, but never get checked */
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
919 int mask = comstyle ? SYNTAX_COMMENT_STYLE_B : SYNTAX_COMMENT_STYLE_A;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
920 struct syntax_cache *scache = buf->syntax_cache;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
922 /* At beginning of range to scan, we're outside of strings;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
923 that determines quote parity to the comment-end. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
924 while (from != stop)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
925 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
926 int syncode;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
927
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
928 /* Move back and examine a character. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
929 from--;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
930 UPDATE_SYNTAX_CACHE_BACKWARD (scache, from);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
931
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
932 c = BUF_FETCH_CHAR (buf, from);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
933 syncode = SYNTAX_CODE_FROM_CACHE (scache, c);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
934 code = SYNTAX_FROM_CODE (syncode);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
935
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936 /* is this a 1-char comment end sequence? if so, try
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937 to see if style matches previously extracted mask */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
938 if (code == Sendcomment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
939 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
940 styles_match_p =
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
941 SYNTAX_CODE_COMMENT_1CHAR_MASK (syncode) & mask;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
942 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
943
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
944 /* or are we looking at a 1-char comment start sequence
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
945 of the style matching mask? */
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
946 else if (code == Scomment)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
947 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
948 styles_match_p =
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
949 SYNTAX_CODE_COMMENT_1CHAR_MASK (syncode) & mask;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
950 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
951
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
952 /* otherwise, is this a 2-char comment end or start sequence? */
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
953 else if (from > stop)
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
954 do
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
955 {
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
956 /* 2-char comment end sequence? */
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
957 if (SYNTAX_CODE_END_SECOND_P (syncode))
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
958 {
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
959 int prev_syncode;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
960 UPDATE_SYNTAX_CACHE_BACKWARD (scache, from - 1);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
961 prev_syncode =
1315
70921960b980 [xemacs-hg @ 2003-02-20 08:19:28 by ben]
ben
parents: 1296
diff changeset
962 SYNTAX_CODE_FROM_CACHE (scache,
70921960b980 [xemacs-hg @ 2003-02-20 08:19:28 by ben]
ben
parents: 1296
diff changeset
963 BUF_FETCH_CHAR (buf, from - 1));
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
964
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
965 if (SYNTAX_CODES_END_P (prev_syncode, syncode))
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
966 {
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
967 code = Sendcomment;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
968 styles_match_p =
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
969 SYNTAX_CODES_COMMENT_MASK_END (prev_syncode,
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
970 syncode) & mask;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
971 from--;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
972 UPDATE_SYNTAX_CACHE_BACKWARD (scache, from);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
973 c = BUF_FETCH_CHAR (buf, from);
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
974
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
975 /* Found a comment-end sequence, so skip past the
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
976 check for a comment-start */
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
977 break;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
978 }
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
979 }
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
980
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
981 /* 2-char comment start sequence? */
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
982 if (SYNTAX_CODE_START_SECOND_P (syncode))
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
983 {
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
984 int prev_syncode;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
985 UPDATE_SYNTAX_CACHE_BACKWARD (scache, from - 1);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
986 prev_syncode =
1315
70921960b980 [xemacs-hg @ 2003-02-20 08:19:28 by ben]
ben
parents: 1296
diff changeset
987 SYNTAX_CODE_FROM_CACHE (scache,
70921960b980 [xemacs-hg @ 2003-02-20 08:19:28 by ben]
ben
parents: 1296
diff changeset
988 BUF_FETCH_CHAR (buf, from - 1));
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
989
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
990 if (SYNTAX_CODES_START_P (prev_syncode, syncode))
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
991 {
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
992 code = Scomment;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
993 styles_match_p =
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
994 SYNTAX_CODES_COMMENT_MASK_START (prev_syncode,
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
995 syncode) & mask;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
996 from--;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
997 UPDATE_SYNTAX_CACHE_BACKWARD (scache, from);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
998 c = BUF_FETCH_CHAR (buf, from);
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
999 }
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1000 }
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1001 } while (0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1002
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1003 /* Ignore escaped characters. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1004 if (char_quoted (buf, from))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1005 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1006
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1007 /* Track parity of quotes. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1008 if (code == Sstring)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1009 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1010 parity ^= 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1011 if (my_stringend == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1012 my_stringend = c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1013 /* If we have two kinds of string delimiters.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1014 There's no way to grok this scanning backwards. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1015 else if (my_stringend != c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1016 string_lossage = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1017 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1018
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1019 if (code == Sstring_fence || code == Scomment_fence)
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1020 {
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1021 parity ^= 1;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1022 if (my_stringend == 0)
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1023 my_stringend =
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1024 code == Sstring_fence ? ST_STRING_STYLE : ST_COMMENT_STYLE;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1025 /* If we have two kinds of string delimiters.
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1026 There's no way to grok this scanning backwards. */
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1027 else if (my_stringend != (code == Sstring_fence
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1028 ? ST_STRING_STYLE : ST_COMMENT_STYLE))
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1029 string_lossage = 1;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1030 }
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1031
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1032 /* Record comment-starters according to that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1033 quote-parity to the comment-end. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1034 if (code == Scomment && styles_match_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1035 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1036 comstart_parity = parity;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1037 comstart_pos = from;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1038 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1039
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1040 /* If we find another earlier comment-ender,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1041 any comment-starts earlier than that don't count
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1042 (because they go with the earlier comment-ender). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1043 if (code == Sendcomment && styles_match_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1044 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1045
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1046 /* Assume a defun-start point is outside of strings. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1047 if (code == Sopen
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1048 && (from == stop || BUF_FETCH_CHAR (buf, from - 1) == '\n'))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1049 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1050 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1051
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1052 if (comstart_pos == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1053 from = comment_end;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1054 /* If the earliest comment starter
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1055 is followed by uniform paired string quotes or none,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1056 we know it can't be inside a string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1057 since if it were then the comment ender would be inside one.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1058 So it does start a comment. Skip back to it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1059 else if (comstart_parity == 0 && !string_lossage)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1060 from = comstart_pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1061 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1062 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1063 /* We had two kinds of string delimiters mixed up
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1064 together. Decode this going forwards.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1065 Scan fwd from the previous comment ender
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1066 to the one in question; this records where we
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1067 last passed a comment starter. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1068
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1069 struct lisp_parse_state state;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1070 scan_sexps_forward (buf, &state, find_defun_start (buf, comment_end),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1071 comment_end - 1, -10000, 0, Qnil, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1072 if (state.incomment)
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1073 from = state.comstr_start;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1074 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1075 /* We can't grok this as a comment; scan it normally. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1076 from = comment_end;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1077 UPDATE_SYNTAX_CACHE_FORWARD (scache, from - 1);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1078 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1079 return from;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1080 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1081
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 627
diff changeset
1082 static Charbpos
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1083 find_end_of_comment (struct buffer *buf, Charbpos from, Charbpos stop,
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1084 int comstyle)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1085 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1086 int c;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1087 int prev_code;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1088 /* mask to match comment styles against; for ST_COMMENT_STYLE, this
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1089 will get set to SYNTAX_COMMENT_STYLE_B, but never get checked */
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1090 int mask = comstyle ? SYNTAX_COMMENT_STYLE_B : SYNTAX_COMMENT_STYLE_A;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1091 struct syntax_cache *scache = buf->syntax_cache;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1092
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1093 /* This is only called by functions which have already set up the
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1094 syntax_cache and are keeping it up-to-date */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1095 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1096 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1097 if (from == stop)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1098 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1099 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1100 }
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1101
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1102 UPDATE_SYNTAX_CACHE_FORWARD (scache, from);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1103 c = BUF_FETCH_CHAR (buf, from);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1104
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1105 /* Test for generic comments */
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1106 if (comstyle == ST_COMMENT_STYLE)
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1107 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1108 if (SYNTAX_FROM_CACHE (scache, c) == Scomment_fence)
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1109 {
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1110 from++;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1111 UPDATE_SYNTAX_CACHE_FORWARD (scache, from);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1112 break;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1113 }
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1114 from++;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1115 continue; /* No need to test other comment styles in a
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1116 generic comment */
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1117 }
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1118 else
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1119
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1120 if (SYNTAX_FROM_CACHE (scache, c) == Sendcomment
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1121 && SYNTAX_CODE_MATCHES_1CHAR_P
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1122 (SYNTAX_CODE_FROM_CACHE (scache, c), mask))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1123 /* we have encountered a comment end of the same style
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1124 as the comment sequence which began this comment
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1125 section */
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1126 {
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1127 from++;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1128 UPDATE_SYNTAX_CACHE_FORWARD (scache, from);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1129 break;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1130 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1131
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1132 prev_code = SYNTAX_CODE_FROM_CACHE (scache, c);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1133 from++;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1134 UPDATE_SYNTAX_CACHE_FORWARD (scache, from);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1135 if (from < stop
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1136 && SYNTAX_CODES_MATCH_END_P
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1137 (prev_code,
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1138 SYNTAX_CODE_FROM_CACHE (scache, BUF_FETCH_CHAR (buf, from)),
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1139 mask)
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1140
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1141 )
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1142 /* we have encountered a comment end of the same style
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1143 as the comment sequence which began this comment
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1144 section */
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1145 {
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1146 from++;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1147 UPDATE_SYNTAX_CACHE_FORWARD (scache, from);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1148 break;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1149 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1150 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1151 return from;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1152 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1153
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1154
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1155 /* #### between FSF 19.23 and 19.28 there are some changes to the logic
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1156 in this function (and minor changes to find_start_of_comment(),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1157 above, which is part of Fforward_comment() in FSF). Attempts to port
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1158 that logic made this function break, so I'm leaving it out. If anyone
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1159 ever complains about this function not working properly, take a look
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1160 at those changes. --ben */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1161
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
1162 DEFUN ("forward-comment", Fforward_comment, 0, 2, 0, /*
5544
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
1163 Move forward across COUNT comments in BUFFER (backwards if COUNT is negative).
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
1164 COUNT defaults to 1, and BUFFER defaults to the current buffer.
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
1165
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1166 Stop scanning if we find something other than a comment or whitespace.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1167 Set point to where scanning stops.
5544
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
1168 Return t if the motion successfully crosses COUNT comments, otherwise nil (if
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
1169 the motion would cross the buffer boundary or encounters a noncomment token).
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1170 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1171 (count, buffer))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1172 {
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 627
diff changeset
1173 Charbpos from;
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 627
diff changeset
1174 Charbpos stop;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
1175 Ichar c;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1176 enum syntaxcode code;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1177 int syncode;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1178 EMACS_INT n;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1179 struct buffer *buf = decode_buffer (buffer, 0);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1180 struct syntax_cache *scache;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1181
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
1182 if (NILP (count))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
1183 n = 1;
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
1184 else
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
1185 {
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
1186 CHECK_FIXNUM (count);
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
1187 n = XFIXNUM (count);
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
1188 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1189
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1190 from = BUF_PT (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1191
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1192 scache = setup_buffer_syntax_cache (buf, from, n);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1193 while (n > 0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1194 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1195 QUIT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1196
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1197 stop = BUF_ZV (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1198 while (from < stop)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1199 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1200 int comstyle = 0; /* mask for finding matching comment style */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1201
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1202 if (char_quoted (buf, from))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1203 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1204 from++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1205 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1206 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1207
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1208 UPDATE_SYNTAX_CACHE_FORWARD (scache, from);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1209 c = BUF_FETCH_CHAR (buf, from);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1210 syncode = SYNTAX_CODE_FROM_CACHE (scache, c);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1211 code = SYNTAX_FROM_CODE (syncode);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1212
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1213 if (code == Scomment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1214 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1215 /* we have encountered a single character comment start
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1216 sequence, and we are ignoring all text inside comments.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1217 we must record the comment style this character begins
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1218 so that later, only a comment end of the same style actually
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1219 ends the comment section */
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1220 comstyle = SYNTAX_CODE_COMMENT_1CHAR_MASK (syncode)
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1221 == SYNTAX_COMMENT_STYLE_A ? 0 : 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1222 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1223
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1224 else if (code == Scomment_fence)
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1225 {
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1226 from++;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1227 code = Scomment;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1228 comstyle = ST_COMMENT_STYLE;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1229 }
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1230
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1231 else if (from < stop
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1232 && SYNTAX_CODE_START_FIRST_P (syncode))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1233 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1234 int next_syncode;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1235 UPDATE_SYNTAX_CACHE_FORWARD (scache, from + 1);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1236 next_syncode =
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1237 SYNTAX_CODE_FROM_CACHE (scache, BUF_FETCH_CHAR (buf, from + 1));
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1238
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1239 if (SYNTAX_CODES_START_P (syncode, next_syncode))
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1240 {
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1241 /* we have encountered a 2char comment start sequence and we
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1242 are ignoring all text inside comments. we must record
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1243 the comment style this sequence begins so that later,
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1244 only a comment end of the same style actually ends
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1245 the comment section */
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1246 code = Scomment;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1247 comstyle =
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1248 SYNTAX_CODES_COMMENT_MASK_START (syncode, next_syncode)
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1249 == SYNTAX_COMMENT_STYLE_A ? 0 : 1;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1250 from++;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1251 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1252 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1253
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1254 if (code == Scomment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1255 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1256 Charbpos newfrom = find_end_of_comment (buf, from, stop,
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1257 comstyle);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1258 if (newfrom < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1259 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1260 /* we stopped because from==stop */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1261 BUF_SET_PT (buf, stop);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1262 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1263 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1264 from = newfrom;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1265
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1266 /* We have skipped one comment. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1267 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1268 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1269 else if (code != Swhitespace
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1270 && code != Sendcomment
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1271 && code != Scomment )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1272 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1273 BUF_SET_PT (buf, from);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1274 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1275 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1276 from++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1277 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1278
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1279 /* End of comment reached */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1280 n--;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1281 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1282
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1283 while (n < 0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1284 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1285 QUIT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1286
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1287 stop = BUF_BEGV (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1288 while (from > stop)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1289 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1290 int comstyle = 0; /* mask for finding matching comment style */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1291
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1292 from--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1293 if (char_quoted (buf, from))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1294 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1295 from--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1296 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1297 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1298
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1299 c = BUF_FETCH_CHAR (buf, from);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1300 syncode = SYNTAX_CODE_FROM_CACHE (scache, c);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1301 code = SYNTAX_FROM_CODE (syncode);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1302
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1303 if (code == Sendcomment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1304 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1305 /* we have found a single char end comment. we must record
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1306 the comment style encountered so that later, we can match
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1307 only the proper comment begin sequence of the same style */
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1308 comstyle = SYNTAX_CODE_COMMENT_1CHAR_MASK (syncode)
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1309 == SYNTAX_COMMENT_STYLE_A ? 0 : 1;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1310 }
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1311
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1312 else if (code == Scomment_fence)
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1313 {
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1314 code = Sendcomment;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1315 comstyle = ST_COMMENT_STYLE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1316 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1317
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1318 else if (from > stop
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1319 && SYNTAX_CODE_END_SECOND_P (syncode))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1320 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1321 int prev_syncode;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1322 UPDATE_SYNTAX_CACHE_BACKWARD (scache, from - 1);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1323 prev_syncode =
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1324 SYNTAX_CODE_FROM_CACHE (scache, BUF_FETCH_CHAR (buf, from - 1));
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1325 if (SYNTAX_CODES_END_P (prev_syncode, syncode))
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1326 {
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1327 /* We must record the comment style encountered so that
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1328 later, we can match only the proper comment begin
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1329 sequence of the same style. */
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1330 code = Sendcomment;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1331 comstyle = SYNTAX_CODES_COMMENT_MASK_END
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1332 (prev_syncode, syncode) == SYNTAX_COMMENT_STYLE_A ? 0 : 1;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1333 from--;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1334 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1335 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1336
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1337 if (code == Sendcomment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1338 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1339 from = find_start_of_comment (buf, from, stop, comstyle);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1340 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1341 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1342
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1343 else if (code != Swhitespace
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1344 && code != Scomment
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1345 && code != Sendcomment)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1346 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1347 BUF_SET_PT (buf, from + 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1348 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1349 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1350 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1351
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1352 n++;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1353 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1354
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1355 BUF_SET_PT (buf, from);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1356 return Qt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1357 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1358
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1359
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1360 Lisp_Object
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 627
diff changeset
1361 scan_lists (struct buffer *buf, Charbpos from, int count, int depth,
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1362 int sexpflag, int noerror)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1363 {
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 627
diff changeset
1364 Charbpos stop;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
1365 Ichar c;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1366 int quoted;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1367 int mathexit = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1368 enum syntaxcode code;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1369 int syncode;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1370 int min_depth = depth; /* Err out if depth gets less than this. */
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1371 struct syntax_cache *scache;
4912
e99033b7e05c use more specific `scan-error' in scan-lists to be GNU compatible
Ben Wing <ben@xemacs.org>
parents: 4759
diff changeset
1372 Charbpos last_good = from;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1373
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1374 if (depth > 0) min_depth = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1375
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1376 scache = setup_buffer_syntax_cache (buf, from, count);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1377 while (count > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1378 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1379 QUIT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1380
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1381 stop = BUF_ZV (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1382 while (from < stop)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1383 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1384 int comstyle = 0; /* mask for finding matching comment style */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1385
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1386 UPDATE_SYNTAX_CACHE_FORWARD (scache, from);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1387 c = BUF_FETCH_CHAR (buf, from);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1388 syncode = SYNTAX_CODE_FROM_CACHE (scache, c);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1389 code = SYNTAX_FROM_CODE (syncode);
4912
e99033b7e05c use more specific `scan-error' in scan-lists to be GNU compatible
Ben Wing <ben@xemacs.org>
parents: 4759
diff changeset
1390 if (depth == min_depth)
e99033b7e05c use more specific `scan-error' in scan-lists to be GNU compatible
Ben Wing <ben@xemacs.org>
parents: 4759
diff changeset
1391 last_good = from;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1392 from++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1393
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1394 /* a 1-char comment start sequence */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1395 if (code == Scomment && parse_sexp_ignore_comments)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1396 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1397 comstyle = SYNTAX_CODE_COMMENT_1CHAR_MASK (syncode) ==
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1398 SYNTAX_COMMENT_STYLE_A ? 0 : 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1399 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1400
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1401 /* else, a 2-char comment start sequence? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1402 else if (from < stop
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1403 && SYNTAX_CODE_START_FIRST_P (syncode)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1404 && parse_sexp_ignore_comments)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1405 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1406 int next_syncode;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1407 UPDATE_SYNTAX_CACHE_FORWARD (scache, from);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1408 next_syncode =
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1409 SYNTAX_CODE_FROM_CACHE (scache, BUF_FETCH_CHAR (buf, from));
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1410
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1411 if (SYNTAX_CODES_START_P (syncode, next_syncode))
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1412 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1413 /* we have encountered a comment start sequence and we
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1414 are ignoring all text inside comments. we must record
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1415 the comment style this sequence begins so that later,
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1416 only a comment end of the same style actually ends
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1417 the comment section */
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1418 code = Scomment;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1419 comstyle = SYNTAX_CODES_COMMENT_MASK_START
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1420 (syncode, next_syncode) == SYNTAX_COMMENT_STYLE_A ? 0 : 1;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1421 from++;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1422 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1423 }
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1424 UPDATE_SYNTAX_CACHE_FORWARD (scache, from);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1425
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1426 if (SYNTAX_CODE_PREFIX (syncode))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1427 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1429 switch (code)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1430 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1431 case Sescape:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1432 case Scharquote:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1433 if (from == stop) goto lose;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1434 from++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1435 /* treat following character as a word constituent */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1436 case Sword:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1437 case Ssymbol:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1438 if (depth || !sexpflag) break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1439 /* This word counts as a sexp; return at end of it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1440 while (from < stop)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1441 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1442 UPDATE_SYNTAX_CACHE_FORWARD (scache, from);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1443 switch (SYNTAX_FROM_CACHE (scache, BUF_FETCH_CHAR (buf, from)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1444 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1445 case Scharquote:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1446 case Sescape:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1447 from++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1448 if (from == stop) goto lose;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1449 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1450 case Sword:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1451 case Ssymbol:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1452 case Squote:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1453 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1454 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1455 goto done;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1456 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1457 from++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1458 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1459 goto done;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1460
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1461 case Scomment_fence:
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1462 comstyle = ST_COMMENT_STYLE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1463 case Scomment:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1464 if (!parse_sexp_ignore_comments)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1465 break;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1466 UPDATE_SYNTAX_CACHE_FORWARD (scache, from);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1467 {
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 627
diff changeset
1468 Charbpos newfrom =
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1469 find_end_of_comment (buf, from, stop, comstyle);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1470 if (newfrom < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1471 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1472 /* we stopped because from == stop in search forward */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1473 from = stop;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1474 if (depth == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1475 goto done;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1476 goto lose;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1477 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1478 from = newfrom;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1479 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1480 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1481
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1482 case Smath:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1483 if (!sexpflag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1484 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1485 if (from != stop && c == BUF_FETCH_CHAR (buf, from))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1486 from++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1487 if (mathexit)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1488 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1489 mathexit = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1490 goto close1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1491 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1492 mathexit = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1493
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1494 case Sopen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1495 if (!++depth) goto done;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1496 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1497
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1498 case Sclose:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1499 close1:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1500 if (!--depth) goto done;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1501 if (depth < min_depth)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1502 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1503 if (noerror)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1504 return Qnil;
4912
e99033b7e05c use more specific `scan-error' in scan-lists to be GNU compatible
Ben Wing <ben@xemacs.org>
parents: 4759
diff changeset
1505 signal_error_2 (Qscan_error,
e99033b7e05c use more specific `scan-error' in scan-lists to be GNU compatible
Ben Wing <ben@xemacs.org>
parents: 4759
diff changeset
1506 "Containing expression ends prematurely",
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
1507 make_fixnum (last_good), make_fixnum (from));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1508 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1509 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1510
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1511 case Sstring_fence:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1512 case Sstring:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1513 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
1514 Ichar stringterm;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1515
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1516 if (code != Sstring_fence)
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1517 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1518 /* XEmacs change: call syntax_match on character */
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
1519 Ichar ch = BUF_FETCH_CHAR (buf, from - 1);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1520 Lisp_Object stermobj =
1296
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
1521 syntax_match (scache->syntax_table, ch);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1522
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1523 if (CHARP (stermobj))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1524 stringterm = XCHAR (stermobj);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1525 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1526 stringterm = ch;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1527 }
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1528 else
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1529 stringterm = '\0'; /* avoid compiler warnings */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1530
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1531 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1532 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1533 if (from >= stop)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1534 goto lose;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1535 UPDATE_SYNTAX_CACHE_FORWARD (scache, from);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1536 c = BUF_FETCH_CHAR (buf, from);
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1537 if (code == Sstring
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1538 ? c == stringterm
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1539 : SYNTAX_FROM_CACHE (scache, c) == Sstring_fence)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1540 break;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1541
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1542 switch (SYNTAX_FROM_CACHE (scache, c))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1543 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1544 case Scharquote:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1545 case Sescape:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1546 from++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1547 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1548 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1549 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1550 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1551 from++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1552 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1553 from++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1554 if (!depth && sexpflag) goto done;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1555 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1556 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1557
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1558 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1559 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1560 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1561 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1562
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1563 /* Reached end of buffer. Error if within object,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1564 return nil if between */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1565 if (depth) goto lose;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1566
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1567 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1568
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1569 /* End of object reached */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1570 done:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1571 count--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1572 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1573
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1574 while (count < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1575 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1576 QUIT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1577
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1578 stop = BUF_BEGV (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1579 while (from > stop)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1580 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1581 int comstyle = 0; /* mask for finding matching comment style */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1582
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1583 from--;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1584 UPDATE_SYNTAX_CACHE_BACKWARD (scache, from);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1585 quoted = char_quoted (buf, from);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1586 if (quoted)
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1587 {
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1588 from--;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1589 UPDATE_SYNTAX_CACHE_BACKWARD (scache, from);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1590 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1591
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1592 c = BUF_FETCH_CHAR (buf, from);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1593 syncode = SYNTAX_CODE_FROM_CACHE (scache, c);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1594 code = SYNTAX_FROM_CODE (syncode);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1595
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1596 if (code == Sendcomment && parse_sexp_ignore_comments)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1597 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1598 /* we have found a single char end comment. we must record
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1599 the comment style encountered so that later, we can match
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1600 only the proper comment begin sequence of the same style */
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1601 comstyle = SYNTAX_CODE_COMMENT_1CHAR_MASK (syncode)
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1602 == SYNTAX_COMMENT_STYLE_A ? 0 : 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1603 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1604
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1605 else if (from > stop
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1606 && SYNTAX_CODE_END_SECOND_P (syncode)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1607 && !char_quoted (buf, from - 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1608 && parse_sexp_ignore_comments)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1609 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1610 int prev_syncode;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1611 UPDATE_SYNTAX_CACHE_BACKWARD (scache, from - 1);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1612 prev_syncode =
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1613 SYNTAX_CODE_FROM_CACHE (scache, BUF_FETCH_CHAR (buf, from - 1));
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1614
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1615 if (SYNTAX_CODES_END_P (prev_syncode, syncode))
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1616 {
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1617 /* we must record the comment style encountered so that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1618 later, we can match only the proper comment begin
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1619 sequence of the same style */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1620 code = Sendcomment;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1621 comstyle = SYNTAX_CODES_COMMENT_MASK_END
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1622 (prev_syncode, syncode) == SYNTAX_COMMENT_STYLE_A ? 0 : 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1623 from--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1624 }
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1625 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1626
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1627 if (SYNTAX_CODE_PREFIX (syncode))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1628 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1629
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1630 switch (quoted ? Sword : code)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1631 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1632 case Sword:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1633 case Ssymbol:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1634 if (depth || !sexpflag) break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1635 /* This word counts as a sexp; count object finished after
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1636 passing it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1637 while (from > stop)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1638 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1639 UPDATE_SYNTAX_CACHE_BACKWARD (scache, from);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1640 quoted = char_quoted (buf, from - 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1641
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1642 if (quoted)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1643 from--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1644 if (! (quoted
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1645 || (syncode =
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1646 SYNTAX_FROM_CACHE (scache, BUF_FETCH_CHAR (buf,
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1647 from - 1)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1648 == Sword
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1649 || syncode == Ssymbol
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1650 || syncode == Squote))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1651 goto done2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1652 from--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1653 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1654 goto done2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1655
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1656 case Smath:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1657 if (!sexpflag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1658 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1659 if (from != stop && c == BUF_FETCH_CHAR (buf, from - 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1660 from--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1661 if (mathexit)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1662 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1663 mathexit = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1664 goto open2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1665 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1666 mathexit = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1667
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1668 case Sclose:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1669 if (!++depth) goto done2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1670 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1671
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1672 case Sopen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1673 open2:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1674 if (!--depth) goto done2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1675 if (depth < min_depth)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1676 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1677 if (noerror)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1678 return Qnil;
4912
e99033b7e05c use more specific `scan-error' in scan-lists to be GNU compatible
Ben Wing <ben@xemacs.org>
parents: 4759
diff changeset
1679 signal_error_2 (Qscan_error,
e99033b7e05c use more specific `scan-error' in scan-lists to be GNU compatible
Ben Wing <ben@xemacs.org>
parents: 4759
diff changeset
1680 "Containing expression ends prematurely",
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
1681 make_fixnum (last_good), make_fixnum (from));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1682 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1683 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1684
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1685 case Scomment_fence:
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1686 comstyle = ST_COMMENT_STYLE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1687 case Sendcomment:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1688 if (parse_sexp_ignore_comments)
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1689 from = find_start_of_comment (buf, from, stop, comstyle);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1690 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1691
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1692 case Sstring_fence:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1693 case Sstring:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1694 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
1695 Ichar stringterm;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1696
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1697 if (code != Sstring_fence)
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1698 {
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1699 /* XEmacs change: call syntax_match() on character */
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
1700 Ichar ch = BUF_FETCH_CHAR (buf, from);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1701 Lisp_Object stermobj =
1296
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
1702 syntax_match (scache->syntax_table, ch);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1703
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1704 if (CHARP (stermobj))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1705 stringterm = XCHAR (stermobj);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1706 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1707 stringterm = ch;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1708 }
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1709 else
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1710 stringterm = '\0'; /* avoid compiler warnings */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1711
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1712 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1713 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1714 if (from == stop) goto lose;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1715
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1716 UPDATE_SYNTAX_CACHE_BACKWARD (scache, from - 1);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1717 c = BUF_FETCH_CHAR (buf, from - 1);
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1718
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1719 if ((code == Sstring
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1720 ? c == stringterm
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1721 : SYNTAX_FROM_CACHE (scache, c) == Sstring_fence)
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1722 && !char_quoted (buf, from - 1))
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1723 {
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1724 break;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1725 }
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1726
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1727 from--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1728 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1729 from--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1730 if (!depth && sexpflag) goto done2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1731 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1732 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1733 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1734 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1735
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1736 /* Reached start of buffer. Error if within object,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1737 return nil if between */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1738 if (depth) goto lose;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1739
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1740 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1741
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1742 done2:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1743 count++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1744 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1745
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1746
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
1747 return (make_fixnum (from));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1748
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1749 lose:
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1750 if (!noerror)
4912
e99033b7e05c use more specific `scan-error' in scan-lists to be GNU compatible
Ben Wing <ben@xemacs.org>
parents: 4759
diff changeset
1751 signal_error_2 (Qscan_error, "Unbalanced parentheses",
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
1752 make_fixnum (last_good), make_fixnum (from));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1753 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1754 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1755
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1756 int
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 627
diff changeset
1757 char_quoted (struct buffer *buf, Charbpos pos)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1758 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1759 enum syntaxcode code;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 627
diff changeset
1760 Charbpos beg = BUF_BEGV (buf);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1761 int quoted = 0;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 627
diff changeset
1762 Charbpos startpos = pos;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1763 struct syntax_cache *scache = buf->syntax_cache;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1764
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1765 while (pos > beg)
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1766 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1767 UPDATE_SYNTAX_CACHE_BACKWARD (scache, pos - 1);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1768 code = SYNTAX_FROM_CACHE (scache, BUF_FETCH_CHAR (buf, pos - 1));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1769
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1770 if (code != Scharquote && code != Sescape)
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1771 break;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1772 pos--;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1773 quoted = !quoted;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1774 }
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1775
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1776 UPDATE_SYNTAX_CACHE (scache, startpos);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1777 return quoted;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1778 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1779
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1780 DEFUN ("scan-lists", Fscan_lists, 3, 5, 0, /*
5544
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
1781 Scan from position FROM across COUNT lists starting from nesting DEPTH.
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
1782 Returns the position thus found.
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
1783 Optional BUFFER defaults to the current buffer.
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
1784 If optional NOERROR is non-nil, scan-lists will return nil instead of
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
1785 signalling an error when attempting to cross a buffer boundary.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1786
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1787 If DEPTH is nonzero, paren depth begins counting from that value,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1788 only places where the depth in parentheses becomes zero
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1789 are candidates for stopping; COUNT such places are counted.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1790 Thus, a positive value for DEPTH means go out levels.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1791
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1792 Comments are ignored if `parse-sexp-ignore-comments' is non-nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1793
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1794 If the beginning or end of (the accessible part of) the buffer is reached
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1795 and the depth is wrong, an error is signaled.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1796 If the depth is right but the count is not used up, nil is returned.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1797
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1798 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1799 (from, count, depth, buffer, noerror))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1800 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1801 struct buffer *buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1802
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
1803 CHECK_FIXNUM (from);
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
1804 CHECK_FIXNUM (count);
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
1805 CHECK_FIXNUM (depth);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1806 buf = decode_buffer (buffer, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1807
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
1808 return scan_lists (buf, XFIXNUM (from), XFIXNUM (count), XFIXNUM (depth), 0,
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1809 !NILP (noerror));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1810 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1811
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1812 DEFUN ("scan-sexps", Fscan_sexps, 2, 4, 0, /*
5544
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
1813 Scan from position FROM by COUNT balanced expressions.
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
1814 Returns the position thus found.
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
1815
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1816 If COUNT is negative, scan backwards.
5544
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
1817 Optional BUFFER defaults to the current buffer.
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
1818 If optional NOERROR is non-nil, scan-sexps will return nil instead of
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
1819 signalling an error.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1820
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1821 Comments are ignored if `parse-sexp-ignore-comments' is non-nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1822
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1823 If the beginning or end of (the accessible part of) the buffer is reached
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1824 in the middle of a parenthetical grouping, an error is signaled.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1825 If the beginning or end is reached between groupings
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1826 but before count is used up, nil is returned.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1827 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1828 (from, count, buffer, noerror))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1829 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1830 struct buffer *buf = decode_buffer (buffer, 0);
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
1831 CHECK_FIXNUM (from);
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
1832 CHECK_FIXNUM (count);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1833
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
1834 return scan_lists (buf, XFIXNUM (from), XFIXNUM (count), 0, 1, !NILP (noerror));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1835 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1836
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1837 DEFUN ("backward-prefix-chars", Fbackward_prefix_chars, 0, 1, 0, /*
5544
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
1838 Move point backward over any number of chars with quote or prefix syntax.
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
1839 Optional BUFFER defaults to the current buffer.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1840 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1841 (buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1842 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1843 struct buffer *buf = decode_buffer (buffer, 0);
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 627
diff changeset
1844 Charbpos beg = BUF_BEGV (buf);
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 627
diff changeset
1845 Charbpos pos = BUF_PT (buf);
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
1846 Ichar c = '\0'; /* initialize to avoid compiler warnings */
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1847 struct syntax_cache *scache;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1848
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1849 scache = setup_buffer_syntax_cache (buf, pos, -1);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1850
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1851 while (pos > beg && !char_quoted (buf, pos - 1)
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1852 /* Previous statement updates syntax table. */
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1853 && (SYNTAX_FROM_CACHE (scache, c = BUF_FETCH_CHAR (buf, pos - 1)) == Squote
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1854 || SYNTAX_CODE_PREFIX (SYNTAX_CODE_FROM_CACHE (scache, c))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1855 pos--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1856
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1857 BUF_SET_PT (buf, pos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1858
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1859 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1860 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1861
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1862 /* Parse forward from FROM to END,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1863 assuming that FROM has state OLDSTATE (nil means FROM is start of function),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1864 and return a description of the state of the parse at END.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1865 If STOPBEFORE is nonzero, stop at the start of an atom.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1866 If COMMENTSTOP is nonzero, stop at the start of a comment. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1867
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1868 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1869 scan_sexps_forward (struct buffer *buf, struct lisp_parse_state *stateptr,
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 627
diff changeset
1870 Charbpos from, Charbpos end,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1871 int targetdepth, int stopbefore,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1872 Lisp_Object oldstate,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1873 int commentstop)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1874 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1875 struct lisp_parse_state state;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1876
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1877 enum syntaxcode code;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1878 struct level { int last, prev; };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1879 struct level levelstart[100];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1880 struct level *curlevel = levelstart;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1881 struct level *endlevel = levelstart + 100;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1882 int depth; /* Paren depth of current scanning location.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1883 level - levelstart equals this except
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1884 when the depth becomes negative. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1885 int mindepth; /* Lowest DEPTH value seen. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1886 int start_quoted = 0; /* Nonzero means starting after a char quote */
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1887 int boundary_stop = commentstop == -1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1888 Lisp_Object tem;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1889 struct syntax_cache *scache;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1890
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1891 scache = setup_buffer_syntax_cache (buf, from, 1);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1892 if (NILP (oldstate))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1893 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1894 depth = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1895 state.instring = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1896 state.incomment = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1897 state.comstyle = 0; /* comment style a by default */
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1898 state.comstr_start = -1; /* no comment/string seen. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1899 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1900 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1901 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1902 tem = Fcar (oldstate); /* elt 0, depth */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1903 if (!NILP (tem))
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
1904 depth = XFIXNUM (tem);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1905 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1906 depth = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1907
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1908 oldstate = Fcdr (oldstate);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1909 oldstate = Fcdr (oldstate);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1910 oldstate = Fcdr (oldstate);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1911 tem = Fcar (oldstate); /* elt 3, instring */
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1912 state.instring = ( !NILP (tem)
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
1913 ? ( FIXNUMP (tem) ? XFIXNUM (tem) : ST_STRING_STYLE)
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1914 : -1);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1915
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1916 oldstate = Fcdr (oldstate);
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1917 tem = Fcar (oldstate); /* elt 4, incomment */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1918 state.incomment = !NILP (tem);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1919
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1920 oldstate = Fcdr (oldstate);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1921 tem = Fcar (oldstate); /* elt 5, follows-quote */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1922 start_quoted = !NILP (tem);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1923
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1924 /* if the eighth element of the list is nil, we are in comment style
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2506
diff changeset
1925 a; if it is t, we are in comment style b; if it is `syntax-table',
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1926 we are in a generic comment */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1927 oldstate = Fcdr (oldstate);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1928 oldstate = Fcdr (oldstate);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1929 tem = Fcar (oldstate); /* elt 7, comment style a/b/fence */
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1930 state.comstyle = NILP (tem) ? 0 : ( EQ (tem, Qsyntax_table)
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1931 ? ST_COMMENT_STYLE : 1 );
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1932
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1933 oldstate = Fcdr (oldstate); /* elt 8, start of last comment/string */
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1934 tem = Fcar (oldstate);
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
1935 state.comstr_start = NILP (tem) ? -1 : XFIXNUM (tem);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1936
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1937 /* elt 9, char numbers of starts-of-expression of levels
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1938 (starting from outermost). */
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1939 oldstate = Fcdr (oldstate);
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1940 tem = Fcar (oldstate); /* elt 9, intermediate data for
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1941 continuation of parsing (subject
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1942 to change). */
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1943 while (!NILP (tem)) /* >= second enclosing sexps. */
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1944 {
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
1945 curlevel->last = XFIXNUM (Fcar (tem));
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1946 if (++curlevel == endlevel)
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1947 stack_overflow ("Nesting too deep for parser",
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
1948 make_fixnum (curlevel - levelstart));
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1949 curlevel->prev = -1;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1950 curlevel->last = -1;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1951 tem = Fcdr (tem);
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1952 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1953 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1954 state.quoted = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1955 mindepth = depth;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1956
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1957 curlevel->prev = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1958 curlevel->last = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1959
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1960 /* Enter the loop at a place appropriate for initial state. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1961
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1962 if (state.incomment) goto startincomment;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1963 if (state.instring >= 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1964 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1965 if (start_quoted) goto startquotedinstring;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1966 goto startinstring;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1967 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1968 if (start_quoted) goto startquoted;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1969
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1970 while (from < end)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1971 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
1972 Ichar c;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1973 int syncode;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1974
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1975 QUIT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1976
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1977 UPDATE_SYNTAX_CACHE_FORWARD (scache, from);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1978 c = BUF_FETCH_CHAR (buf, from);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1979 syncode = SYNTAX_CODE_FROM_CACHE (scache, c);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
1980 code = SYNTAX_FROM_CODE (syncode);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1981 from++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1982
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1983 /* record the comment style we have entered so that only the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1984 comment-ender sequence (or single char) of the same style
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1985 actually terminates the comment section. */
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1986 if (code == Scomment)
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1987 {
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1988 state.comstyle =
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1989 SYNTAX_CODE_COMMENT_1CHAR_MASK (syncode)
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1990 == SYNTAX_COMMENT_STYLE_A ? 0 : 1;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1991 state.comstr_start = from - 1;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1992 }
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1993
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1994 /* a generic comment delimiter? */
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1995 else if (code == Scomment_fence)
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1996 {
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1997 state.comstyle = ST_COMMENT_STYLE;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1998 state.comstr_start = from - 1;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
1999 code = Scomment;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2000 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2001
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2002 else if (from < end &&
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2003 SYNTAX_CODE_START_FIRST_P (syncode))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2004 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2005 int next_syncode;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2006 UPDATE_SYNTAX_CACHE_FORWARD (scache, from);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2007 next_syncode =
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2008 SYNTAX_CODE_FROM_CACHE (scache, BUF_FETCH_CHAR (buf, from));
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2009
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2010 if (SYNTAX_CODES_START_P (syncode, next_syncode))
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2011 {
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2012 code = Scomment;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2013 state.comstyle = SYNTAX_CODES_COMMENT_MASK_START
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2014 (syncode, next_syncode) == SYNTAX_COMMENT_STYLE_A ? 0 : 1;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2015 state.comstr_start = from - 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2016 from++;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2017 UPDATE_SYNTAX_CACHE_FORWARD (scache, from);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2018 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2019 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2020
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2021 if (SYNTAX_CODE_PREFIX (syncode))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2022 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2023 switch (code)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2024 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2025 case Sescape:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2026 case Scharquote:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2027 if (stopbefore) goto stop; /* this arg means stop at sexp start */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2028 curlevel->last = from - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2029 startquoted:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2030 if (from == end) goto endquoted;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2031 from++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2032 goto symstarted;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2033 /* treat following character as a word constituent */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2034 case Sword:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2035 case Ssymbol:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2036 if (stopbefore) goto stop; /* this arg means stop at sexp start */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2037 curlevel->last = from - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2038 symstarted:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2039 while (from < end)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2040 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2041 UPDATE_SYNTAX_CACHE_FORWARD (scache, from);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2042 switch (SYNTAX_FROM_CACHE (scache, BUF_FETCH_CHAR (buf, from)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2043 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2044 case Scharquote:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2045 case Sescape:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2046 from++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2047 if (from == end) goto endquoted;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2048 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2049 case Sword:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2050 case Ssymbol:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2051 case Squote:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2052 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2053 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2054 goto symdone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2055 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2056 from++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2057 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2058 symdone:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2059 curlevel->prev = curlevel->last;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2060 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2061
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2062 case Scomment:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2063 state.incomment = 1;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2064 if (commentstop || boundary_stop) goto done;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2065 startincomment:
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2066 if (commentstop == 1)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2067 goto done;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2068 UPDATE_SYNTAX_CACHE_FORWARD (scache, from);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2069 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2070 Charbpos newfrom = find_end_of_comment (buf, from, end,
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2071 state.comstyle);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2072 if (newfrom < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2073 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2074 /* we terminated search because from == end */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2075 from = end;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2076 goto done;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2077 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2078 from = newfrom;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2079 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2080 state.incomment = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2081 state.comstyle = 0; /* reset the comment style */
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2082 if (boundary_stop) goto done;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2083 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2084
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2085 case Sopen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2086 if (stopbefore) goto stop; /* this arg means stop at sexp start */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2087 depth++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2088 curlevel->last = from - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2089 if (++curlevel == endlevel)
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2090 stack_overflow ("Nesting too deep for parser",
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
2091 make_fixnum (curlevel - levelstart));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2092 curlevel->prev = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2093 curlevel->last = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2094 if (targetdepth == depth) goto done;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2095 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2096
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2097 case Sclose:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2098 depth--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2099 if (depth < mindepth)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2100 mindepth = depth;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2101 if (curlevel != levelstart)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2102 curlevel--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2103 curlevel->prev = curlevel->last;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2104 if (targetdepth == depth) goto done;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2105 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2106
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2107 case Sstring:
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2108 case Sstring_fence:
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2109 state.comstr_start = from - 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2110 if (stopbefore) goto stop; /* this arg means stop at sexp start */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2111 curlevel->last = from - 1;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2112 if (code == Sstring_fence)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2113 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2114 state.instring = ST_STRING_STYLE;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2115 }
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2116 else
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2117 {
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2118 /* XEmacs change: call syntax_match() on character */
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
2119 Ichar ch = BUF_FETCH_CHAR (buf, from - 1);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2120 Lisp_Object stermobj =
1296
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
2121 syntax_match (scache->syntax_table, ch);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2122
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2123 if (CHARP (stermobj))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2124 state.instring = XCHAR (stermobj);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2125 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2126 state.instring = ch;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2127 }
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2128 if (boundary_stop) goto done;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2129 startinstring:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2130 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2131 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2132 enum syntaxcode temp_code;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2133
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2134 if (from >= end) goto done;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2135
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2136 UPDATE_SYNTAX_CACHE_FORWARD (scache, from);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2137 c = BUF_FETCH_CHAR (buf, from);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2138 temp_code = SYNTAX_FROM_CACHE (scache, c);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2139
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2140 if (
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2141 state.instring != ST_STRING_STYLE &&
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2142 temp_code == Sstring &&
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2143 c == state.instring) break;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2144
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2145 switch (temp_code)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2146 {
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2147 case Sstring_fence:
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2148 if (state.instring == ST_STRING_STYLE)
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2149 goto string_end;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2150 break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2151 case Scharquote:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2152 case Sescape:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2153 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2154 from++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2155 startquotedinstring:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2156 if (from >= end) goto endquoted;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2157 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2158 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2159 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2160 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2161 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2162 from++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2163 }
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2164 string_end:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2165 state.instring = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2166 curlevel->prev = curlevel->last;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2167 from++;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2168 if (boundary_stop) goto done;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2169 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2170
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2171 case Smath:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2172 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2173
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2174 case Swhitespace:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2175 case Spunct:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2176 case Squote:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2177 case Sendcomment:
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2178 case Scomment_fence:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2179 case Sinherit:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2180 case Smax:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2181 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2182 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2183 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2184 goto done;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2185
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2186 stop: /* Here if stopping before start of sexp. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2187 from--; /* We have just fetched the char that starts it; */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2188 goto done; /* but return the position before it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2189
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2190 endquoted:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2191 state.quoted = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2192 done:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2193 state.depth = depth;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2194 state.mindepth = mindepth;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2195 state.thislevelstart = curlevel->prev;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2196 state.prevlevelstart
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2197 = (curlevel == levelstart) ? -1 : (curlevel - 1)->last;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2198 state.location = from;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2199 state.levelstarts = Qnil;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2200 while (--curlevel >= levelstart)
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
2201 state.levelstarts = Fcons (make_fixnum (curlevel->last),
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2202 state.levelstarts);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2203
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2204 *stateptr = state;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2205 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2206
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2207 DEFUN ("parse-partial-sexp", Fparse_partial_sexp, 2, 7, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2208 Parse Lisp syntax starting at FROM until TO; return status of parse at TO.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2209 Parsing stops at TO or when certain criteria are met;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2210 point is set to where parsing stops.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2211 If fifth arg OLDSTATE is omitted or nil,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2212 parsing assumes that FROM is the beginning of a function.
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2213 Value is a list of nine elements describing final state of parsing:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2214 0. depth in parens.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2215 1. character address of start of innermost containing list; nil if none.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2216 2. character address of start of last complete sexp terminated.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2217 3. non-nil if inside a string.
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2218 (It is the character that will terminate the string,
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2219 or t if the string should be terminated by an explicit
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2220 `syntax-table' property.)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2221 4. t if inside a comment.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2222 5. t if following a quote character.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2223 6. the minimum paren-depth encountered during this scan.
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2224 7. nil if in comment style a, or not in a comment; t if in comment style b;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2225 `syntax-table' if given by an explicit `syntax-table' property.
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2226 8. character address of start of last comment or string; nil if none.
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2227 9. Intermediate data for continuation of parsing (subject to change).
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2228 If third arg TARGETDEPTH is non-nil, parsing stops if the depth
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2229 in parentheses becomes equal to TARGETDEPTH.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2230 Fourth arg STOPBEFORE non-nil means stop when come to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2231 any character that starts a sexp.
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2232 Fifth arg OLDSTATE is a nine-element list like what this function returns.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2233 It is used to initialize the state of the parse. Its second and third
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2234 elements are ignored.
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2235 Sixth arg COMMENTSTOP non-nil means stop at the start of a comment. If it
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2236 is `syntax-table', stop after the start of a comment or a string, or after
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2237 the end of a comment or string.
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2238 Seventh arg BUFFER specifies the buffer to do the parsing in, and defaults
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2239 to the current buffer.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2240 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2241 (from, to, targetdepth, stopbefore, oldstate, commentstop, buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2242 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2243 struct lisp_parse_state state;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2244 int target;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 627
diff changeset
2245 Charbpos start, end;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2246 struct buffer *buf = decode_buffer (buffer, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2247 Lisp_Object val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2248
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2249 if (!NILP (targetdepth))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2250 {
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
2251 CHECK_FIXNUM (targetdepth);
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
2252 target = XFIXNUM (targetdepth);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2253 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2254 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2255 target = -100000; /* We won't reach this depth */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2256
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2257 get_buffer_range_char (buf, from, to, &start, &end, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2258 scan_sexps_forward (buf, &state, start, end,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2259 target, !NILP (stopbefore), oldstate,
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2260 (NILP (commentstop)
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2261 ? 0 : (EQ (commentstop, Qsyntax_table) ? -1 : 1)));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2262 BUF_SET_PT (buf, state.location);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2263
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2264 /* reverse order */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2265 val = Qnil;
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2266 val = Fcons (state.levelstarts, val);
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2267 val = Fcons ((state.incomment || (state.instring >= 0))
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
2268 ? make_fixnum (state.comstr_start) : Qnil, val);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2269 val = Fcons (state.comstyle ? (state.comstyle == ST_COMMENT_STYLE
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2270 ? Qsyntax_table : Qt) : Qnil, val);
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
2271 val = Fcons (make_fixnum (state.mindepth), val);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2272 val = Fcons (state.quoted ? Qt : Qnil, val);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2273 val = Fcons (state.incomment ? Qt : Qnil, val);
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2274 val = Fcons (state.instring < 0
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2275 ? Qnil
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2276 : (state.instring == ST_STRING_STYLE
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
2277 ? Qt : make_fixnum (state.instring)), val);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2278 val = Fcons (state.thislevelstart < 0 ? Qnil :
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
2279 make_fixnum (state.thislevelstart), val);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2280 val = Fcons (state.prevlevelstart < 0 ? Qnil :
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
2281 make_fixnum (state.prevlevelstart), val);
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
2282 val = Fcons (make_fixnum (state.depth), val);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2283
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2284 return val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2285 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2286
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2287
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2288 /* Updating of the mirror syntax table.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2289
1296
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
2290 Each syntax table has a corresponding mirror table in it. Whenever we
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
2291 make a change to a syntax table, we set a dirty flag. When accessing a
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
2292 value from the mirror table and the table is dirty, we call
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
2293 update_syntax_table() to clean it up.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2294
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2295 #### We really only need to map over the changed range.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2296
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2297 If we change the standard syntax table, we need to map over
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2298 all tables because any of them could be inheriting from the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2299 standard syntax table.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2300
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2301 When `set-syntax-table' is called, we set the buffer's mirror
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2302 syntax table as well.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2303 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2304
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2305 static int
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2167
diff changeset
2306 copy_to_mirrortab (struct chartab_range *range, Lisp_Object UNUSED (table),
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2307 Lisp_Object val, void *arg)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2308 {
5013
ae48681c47fa changes to VOID_TO_LISP et al.
Ben Wing <ben@xemacs.org>
parents: 4976
diff changeset
2309 Lisp_Object mirrortab = GET_LISP_FROM_VOID (arg);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2310
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2311 if (CONSP (val))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2312 val = XCAR (val);
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
2313 if (SYNTAX_FROM_CODE (XFIXNUM (val)) != Sinherit)
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2314 put_char_table (mirrortab, range, val);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2315 return 0;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2316 }
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2317
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2318 static int
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2167
diff changeset
2319 copy_if_not_already_present (struct chartab_range *range,
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2167
diff changeset
2320 Lisp_Object UNUSED (table),
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2321 Lisp_Object val, void *arg)
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2322 {
5013
ae48681c47fa changes to VOID_TO_LISP et al.
Ben Wing <ben@xemacs.org>
parents: 4976
diff changeset
2323 Lisp_Object mirrortab = GET_LISP_FROM_VOID (arg);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2324 if (CONSP (val))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2325 val = XCAR (val);
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
2326 if (SYNTAX_FROM_CODE (XFIXNUM (val)) != Sinherit)
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2327 {
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2328 Lisp_Object existing =
1296
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
2329 updating_mirror_get_range_char_table (range, mirrortab,
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
2330 Vbogus_syntax_table_value);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2331 if (NILP (existing))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2332 /* nothing at all */
1296
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
2333 put_char_table (mirrortab, range, val);
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
2334 else if (!EQ (existing, Vbogus_syntax_table_value))
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2335 /* full */
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2336 ;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2337 else
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2338 {
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2339 Freset_char_table (Vtemp_table_for_use_updating_syntax_tables);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2340 copy_char_table_range
1296
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
2341 (mirrortab, Vtemp_table_for_use_updating_syntax_tables, range);
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
2342 put_char_table (mirrortab, range, val);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2343 copy_char_table_range
1296
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
2344 (Vtemp_table_for_use_updating_syntax_tables, mirrortab, range);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2345 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2346 }
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2347
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2348 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2349 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2350
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2351 static void
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2352 update_just_this_syntax_table (Lisp_Object table)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2353 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2354 struct chartab_range range;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2355 Lisp_Object mirrortab = XCHAR_TABLE (table)->mirror_table;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2356
1296
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
2357 assert (!XCHAR_TABLE (table)->mirror_table_p);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2358 range.type = CHARTAB_RANGE_ALL;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2359 Freset_char_table (mirrortab);
1296
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
2360
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2361 /* First, copy the tables values other than inherit into the mirror
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2362 table. Then, for tables other than the standard syntax table, map
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2363 over the standard table, copying values into the mirror table only if
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2364 entries don't already exist in that table. (The copying step requires
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2365 another mapping.)
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2366 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2367
5013
ae48681c47fa changes to VOID_TO_LISP et al.
Ben Wing <ben@xemacs.org>
parents: 4976
diff changeset
2368 map_char_table (table, &range, copy_to_mirrortab, STORE_LISP_IN_VOID (mirrortab));
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2369 /* second clause catches bootstrapping problems when initializing the
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2370 standard syntax table */
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2371 if (!EQ (table, Vstandard_syntax_table) && !NILP (Vstandard_syntax_table))
1296
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
2372 map_char_table (Vstandard_syntax_table, &range,
5013
ae48681c47fa changes to VOID_TO_LISP et al.
Ben Wing <ben@xemacs.org>
parents: 4976
diff changeset
2373 copy_if_not_already_present, STORE_LISP_IN_VOID (mirrortab));
3152
b85f5d7d9d82 [xemacs-hg @ 2005-12-18 22:55:51 by aidan]
aidan
parents: 3092
diff changeset
2374 /* The resetting made the default be Qnil. Put it back to Sword. */
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
2375 set_char_table_default (mirrortab, make_fixnum (Sword));
1296
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
2376 XCHAR_TABLE (mirrortab)->dirty = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2377 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2378
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2379 /* Called from chartab.c when a change is made to a syntax table.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2380 If this is the standard syntax table, we need to recompute
5544
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
2381 *all* syntax tables. Otherwise we just recompute this one. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2382
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2383 void
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2384 update_syntax_table (Lisp_Object table)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2385 {
1296
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
2386 Lisp_Object nonmirror = XCHAR_TABLE (table)->mirror_table;
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
2387 assert (XCHAR_TABLE (table)->mirror_table_p);
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
2388 if (EQ (nonmirror, Vstandard_syntax_table))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2389 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2390 Lisp_Object syntab;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2391
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2392 for (syntab = Vall_syntax_tables; !NILP (syntab);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2393 syntab = XCHAR_TABLE (syntab)->next_table)
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2394 update_just_this_syntax_table (syntab);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2395 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2396 else
1296
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
2397 update_just_this_syntax_table (nonmirror);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2398 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2399
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2400
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2401 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2402 /* initialization */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2403 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2404
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2405 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2406 syms_of_syntax (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2407 {
3092
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3025
diff changeset
2408 #ifdef NEW_GC
5118
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 4759
diff changeset
2409 INIT_LISP_OBJECT (syntax_cache);
3092
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3025
diff changeset
2410 #endif /* NEW_GC */
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
2411 DEFSYMBOL (Qsyntax_table_p);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
2412 DEFSYMBOL (Qsyntax_table);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2413
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2414 DEFSUBR (Fsyntax_table_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2415 DEFSUBR (Fsyntax_table);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2416 #ifdef DEBUG_XEMACS
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2417 DEFSUBR (Fmirror_syntax_table);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2418 DEFSUBR (Fsyntax_cache_info);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2419 #endif /* DEBUG_XEMACS */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2420 DEFSUBR (Fstandard_syntax_table);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2421 DEFSUBR (Fcopy_syntax_table);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2422 DEFSUBR (Fset_syntax_table);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2423 DEFSUBR (Fsyntax_designator_chars);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2424 DEFSUBR (Fchar_syntax);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2425 DEFSUBR (Fmatching_paren);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2426 /* DEFSUBR (Fmodify_syntax_entry); now in Lisp. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2427 /* DEFSUBR (Fdescribe_syntax); now in Lisp. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2429 DEFSUBR (Fforward_word);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2430
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2431 DEFSUBR (Fforward_comment);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2432 DEFSUBR (Fscan_lists);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2433 DEFSUBR (Fscan_sexps);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2434 DEFSUBR (Fbackward_prefix_chars);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2435 DEFSUBR (Fparse_partial_sexp);
4912
e99033b7e05c use more specific `scan-error' in scan-lists to be GNU compatible
Ben Wing <ben@xemacs.org>
parents: 4759
diff changeset
2436
e99033b7e05c use more specific `scan-error' in scan-lists to be GNU compatible
Ben Wing <ben@xemacs.org>
parents: 4759
diff changeset
2437 DEFERROR_STANDARD (Qscan_error, Qsyntax_error);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2438 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2439
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2440 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2441 vars_of_syntax (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2442 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2443 DEFVAR_BOOL ("parse-sexp-ignore-comments", &parse_sexp_ignore_comments /*
5544
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
2444 If non-nil, `forward-sexp' etc. treat comments as whitespace.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2445 */ );
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
2446 parse_sexp_ignore_comments = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2447
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2448 DEFVAR_BOOL ("lookup-syntax-properties", &lookup_syntax_properties /*
5544
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
2449 If non-nil, `forward-sexp' etc. respect the `syntax-table' text property.
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2450 This property can be placed on buffers or strings and can be used to explicitly
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2451 specify the syntax table to be used for looking up the syntax of the chars
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2452 having this property, or to directly specify the syntax of the chars.
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2453
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2454 The value of this property should be either a syntax table, or a cons
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2455 of the form (SYNTAXCODE . MATCHCHAR), SYNTAXCODE being the numeric
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2456 syntax code, MATCHCHAR being nil or the character to match (which is
5544
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
2457 relevant only when the syntax code is of an open or close type).
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2458 */ );
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2459 lookup_syntax_properties = 1;
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 446
diff changeset
2460
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2461 DEFVAR_BOOL ("words-include-escapes", &words_include_escapes /*
5544
c2301b2c88c8 Improve documentation of syntax table internals.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5543
diff changeset
2462 If non-nil, `forward-word' etc. treat escape characters as parts of words.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2463 */ );
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
2464 words_include_escapes = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2465
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2466 no_quit_in_re_search = 0;
1296
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
2467
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
2468 Vbogus_syntax_table_value = make_float (0.0);
87084e8445a7 [xemacs-hg @ 2003-02-14 09:50:15 by ben]
ben
parents: 872
diff changeset
2469 staticpro (&Vbogus_syntax_table_value);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2470 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2471
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2472 static void
3540
efa52de8c279 [xemacs-hg @ 2006-08-04 20:01:05 by aidan]
aidan
parents: 3252
diff changeset
2473 define_standard_syntax (const UExtbyte *p, enum syntaxcode syn)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2474 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2475 for (; *p; p++)
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
2476 Fput_char_table (make_char (*p), make_fixnum (syn), Vstandard_syntax_table);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2477 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2478
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2479 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2480 complex_vars_of_syntax (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2481 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
2482 Ichar i;
3540
efa52de8c279 [xemacs-hg @ 2006-08-04 20:01:05 by aidan]
aidan
parents: 3252
diff changeset
2483 const UExtbyte *p; /* Latin-1, not internal format. */
efa52de8c279 [xemacs-hg @ 2006-08-04 20:01:05 by aidan]
aidan
parents: 3252
diff changeset
2484
efa52de8c279 [xemacs-hg @ 2006-08-04 20:01:05 by aidan]
aidan
parents: 3252
diff changeset
2485 #define SET_RANGE_SYNTAX(start, end, syntax) \
efa52de8c279 [xemacs-hg @ 2006-08-04 20:01:05 by aidan]
aidan
parents: 3252
diff changeset
2486 do { \
efa52de8c279 [xemacs-hg @ 2006-08-04 20:01:05 by aidan]
aidan
parents: 3252
diff changeset
2487 for (i = start; i <= end; i++) \
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
2488 Fput_char_table(make_char(i), make_fixnum(syntax), \
3540
efa52de8c279 [xemacs-hg @ 2006-08-04 20:01:05 by aidan]
aidan
parents: 3252
diff changeset
2489 Vstandard_syntax_table); \
efa52de8c279 [xemacs-hg @ 2006-08-04 20:01:05 by aidan]
aidan
parents: 3252
diff changeset
2490 } while (0)
efa52de8c279 [xemacs-hg @ 2006-08-04 20:01:05 by aidan]
aidan
parents: 3252
diff changeset
2491
efa52de8c279 [xemacs-hg @ 2006-08-04 20:01:05 by aidan]
aidan
parents: 3252
diff changeset
2492 /* Set this now, so first buffer creation can refer to it.
efa52de8c279 [xemacs-hg @ 2006-08-04 20:01:05 by aidan]
aidan
parents: 3252
diff changeset
2493
efa52de8c279 [xemacs-hg @ 2006-08-04 20:01:05 by aidan]
aidan
parents: 3252
diff changeset
2494 Make it nil before calling copy-syntax-table so that copy-syntax-table
efa52de8c279 [xemacs-hg @ 2006-08-04 20:01:05 by aidan]
aidan
parents: 3252
diff changeset
2495 will know not to try to copy from garbage */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2496 Vstandard_syntax_table = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2497 Vstandard_syntax_table = Fcopy_syntax_table (Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2498 staticpro (&Vstandard_syntax_table);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2499
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2500 Vtemp_table_for_use_updating_syntax_tables = Fmake_char_table (Qgeneric);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2501 staticpro (&Vtemp_table_for_use_updating_syntax_tables);
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
2502
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2503 Vsyntax_designator_chars_string = make_string_nocopy (syntax_code_spec,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2504 Smax);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2505 staticpro (&Vsyntax_designator_chars_string);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2506
3540
efa52de8c279 [xemacs-hg @ 2006-08-04 20:01:05 by aidan]
aidan
parents: 3252
diff changeset
2507 /* Default character syntax is word. */
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
2508 set_char_table_default (Vstandard_syntax_table, make_fixnum (Sword));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2509
3540
efa52de8c279 [xemacs-hg @ 2006-08-04 20:01:05 by aidan]
aidan
parents: 3252
diff changeset
2510 /* Control 0; treat as punctuation */
efa52de8c279 [xemacs-hg @ 2006-08-04 20:01:05 by aidan]
aidan
parents: 3252
diff changeset
2511 SET_RANGE_SYNTAX(0, 32, Spunct);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2512
3544
981a144e71fa [xemacs-hg @ 2006-08-05 08:30:35 by aidan]
aidan
parents: 3540
diff changeset
2513 /* The whitespace--overwriting some of the above changes.
981a144e71fa [xemacs-hg @ 2006-08-05 08:30:35 by aidan]
aidan
parents: 3540
diff changeset
2514
981a144e71fa [xemacs-hg @ 2006-08-05 08:30:35 by aidan]
aidan
parents: 3540
diff changeset
2515 String literals are const char *s, not const unsigned char *s. */
4653
25e5e5346d31 ?\012 is whitespace, as it always should have been, thank you Karl Kleinpaste.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4141
diff changeset
2516 define_standard_syntax((const UExtbyte *)" \t\015\014\012", Swhitespace);
3540
efa52de8c279 [xemacs-hg @ 2006-08-04 20:01:05 by aidan]
aidan
parents: 3252
diff changeset
2517
efa52de8c279 [xemacs-hg @ 2006-08-04 20:01:05 by aidan]
aidan
parents: 3252
diff changeset
2518 /* DEL plus Control 1 */
efa52de8c279 [xemacs-hg @ 2006-08-04 20:01:05 by aidan]
aidan
parents: 3252
diff changeset
2519 SET_RANGE_SYNTAX(127, 159, Spunct);
efa52de8c279 [xemacs-hg @ 2006-08-04 20:01:05 by aidan]
aidan
parents: 3252
diff changeset
2520
3544
981a144e71fa [xemacs-hg @ 2006-08-05 08:30:35 by aidan]
aidan
parents: 3540
diff changeset
2521 define_standard_syntax ((const UExtbyte *)"\"", Sstring);
981a144e71fa [xemacs-hg @ 2006-08-05 08:30:35 by aidan]
aidan
parents: 3540
diff changeset
2522 define_standard_syntax ((const UExtbyte *)"\\", Sescape);
981a144e71fa [xemacs-hg @ 2006-08-05 08:30:35 by aidan]
aidan
parents: 3540
diff changeset
2523 define_standard_syntax ((const UExtbyte *)"_-+*/&|<>=", Ssymbol);
981a144e71fa [xemacs-hg @ 2006-08-05 08:30:35 by aidan]
aidan
parents: 3540
diff changeset
2524 define_standard_syntax ((const UExtbyte *)".,;:?!#@~^'`", Spunct);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2525
3544
981a144e71fa [xemacs-hg @ 2006-08-05 08:30:35 by aidan]
aidan
parents: 3540
diff changeset
2526 for (p = (const UExtbyte *)"()[]{}"; *p; p+=2)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2527 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2528 Fput_char_table (make_char (p[0]),
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
2529 Fcons (make_fixnum (Sopen), make_char (p[1])),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2530 Vstandard_syntax_table);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2531 Fput_char_table (make_char (p[1]),
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5552
diff changeset
2532 Fcons (make_fixnum (Sclose), make_char (p[0])),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2533 Vstandard_syntax_table);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2534 }
3540
efa52de8c279 [xemacs-hg @ 2006-08-04 20:01:05 by aidan]
aidan
parents: 3252
diff changeset
2535
efa52de8c279 [xemacs-hg @ 2006-08-04 20:01:05 by aidan]
aidan
parents: 3252
diff changeset
2536 /* Latin 1 "symbols." This contrasts with the FSF, where they're word
efa52de8c279 [xemacs-hg @ 2006-08-04 20:01:05 by aidan]
aidan
parents: 3252
diff changeset
2537 constituents. */
efa52de8c279 [xemacs-hg @ 2006-08-04 20:01:05 by aidan]
aidan
parents: 3252
diff changeset
2538 SET_RANGE_SYNTAX(0240, 0277, Ssymbol);
efa52de8c279 [xemacs-hg @ 2006-08-04 20:01:05 by aidan]
aidan
parents: 3252
diff changeset
2539
efa52de8c279 [xemacs-hg @ 2006-08-04 20:01:05 by aidan]
aidan
parents: 3252
diff changeset
2540 /* The guillemets. These are not parentheses, in contrast to what the old
efa52de8c279 [xemacs-hg @ 2006-08-04 20:01:05 by aidan]
aidan
parents: 3252
diff changeset
2541 code did. */
3569
6486a15d7e3e [xemacs-hg @ 2006-08-23 19:57:49 by aidan]
aidan
parents: 3544
diff changeset
2542 define_standard_syntax((const UExtbyte *)"\253\273", Spunct);
3540
efa52de8c279 [xemacs-hg @ 2006-08-04 20:01:05 by aidan]
aidan
parents: 3252
diff changeset
2543
efa52de8c279 [xemacs-hg @ 2006-08-04 20:01:05 by aidan]
aidan
parents: 3252
diff changeset
2544 /* The inverted exclamation mark, and the multiplication and division
efa52de8c279 [xemacs-hg @ 2006-08-04 20:01:05 by aidan]
aidan
parents: 3252
diff changeset
2545 signs. */
3544
981a144e71fa [xemacs-hg @ 2006-08-05 08:30:35 by aidan]
aidan
parents: 3540
diff changeset
2546 define_standard_syntax((const UExtbyte *)"\241\327\367", Spunct);
3540
efa52de8c279 [xemacs-hg @ 2006-08-04 20:01:05 by aidan]
aidan
parents: 3252
diff changeset
2547
efa52de8c279 [xemacs-hg @ 2006-08-04 20:01:05 by aidan]
aidan
parents: 3252
diff changeset
2548 #undef SET_RANGE_SYNTAX
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2549 }