aboutsummaryrefslogtreecommitdiffstats
path: root/src/syntax.c
diff options
context:
space:
mode:
authorStephen Berman2013-06-14 22:07:55 +0200
committerStephen Berman2013-06-14 22:07:55 +0200
commitbd358779861f265a7acff31ead40172735af693e (patch)
tree345217a9889dbd29b09bdc80a94265c17719d41f /src/syntax.c
parent2a97b47f0878cbda86cb6ba0e7e744924810b70e (diff)
parentf7394b12358ae453a0c8b85fc307afc1b740010d (diff)
downloademacs-bd358779861f265a7acff31ead40172735af693e.tar.gz
emacs-bd358779861f265a7acff31ead40172735af693e.zip
Merge from trunk.
Diffstat (limited to 'src/syntax.c')
-rw-r--r--src/syntax.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/syntax.c b/src/syntax.c
index fdd9353bb87..390d732944d 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -1,6 +1,6 @@
1/* GNU Emacs routines to deal with syntax tables; also word and list parsing. 1/* GNU Emacs routines to deal with syntax tables; also word and list parsing.
2 Copyright (C) 1985, 1987, 1993-1995, 1997-1999, 2001-2012 2 Copyright (C) 1985, 1987, 1993-1995, 1997-1999, 2001-2013 Free
3 Free Software Foundation, Inc. 3 Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
@@ -21,7 +21,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21#include <config.h> 21#include <config.h>
22 22
23#include <sys/types.h> 23#include <sys/types.h>
24#include <setjmp.h> 24
25#include "lisp.h" 25#include "lisp.h"
26#include "commands.h" 26#include "commands.h"
27#include "character.h" 27#include "character.h"
@@ -121,6 +121,7 @@ struct lisp_parse_state
121 /* Char number of start of containing expression */ 121 /* Char number of start of containing expression */
122 ptrdiff_t prevlevelstart; 122 ptrdiff_t prevlevelstart;
123 ptrdiff_t location; /* Char number at which parsing stopped. */ 123 ptrdiff_t location; /* Char number at which parsing stopped. */
124 ptrdiff_t location_byte; /* Corresponding byte position. */
124 ptrdiff_t comstr_start; /* Position of last comment/string starter. */ 125 ptrdiff_t comstr_start; /* Position of last comment/string starter. */
125 Lisp_Object levelstarts; /* Char numbers of starts-of-expression 126 Lisp_Object levelstarts; /* Char numbers of starts-of-expression
126 of levels (starting from outermost). */ 127 of levels (starting from outermost). */
@@ -151,7 +152,7 @@ static void scan_sexps_forward (struct lisp_parse_state *,
151static int in_classes (int, Lisp_Object); 152static int in_classes (int, Lisp_Object);
152 153
153/* This setter is used only in this file, so it can be private. */ 154/* This setter is used only in this file, so it can be private. */
154static inline void 155static void
155bset_syntax_table (struct buffer *b, Lisp_Object val) 156bset_syntax_table (struct buffer *b, Lisp_Object val)
156{ 157{
157 b->INTERNAL_FIELD (syntax_table) = val; 158 b->INTERNAL_FIELD (syntax_table) = val;
@@ -372,7 +373,7 @@ char_quoted (ptrdiff_t charpos, ptrdiff_t bytepos)
372/* Return the bytepos one character before BYTEPOS. 373/* Return the bytepos one character before BYTEPOS.
373 We assume that BYTEPOS is not at the start of the buffer. */ 374 We assume that BYTEPOS is not at the start of the buffer. */
374 375
375static inline ptrdiff_t 376static ptrdiff_t
376dec_bytepos (ptrdiff_t bytepos) 377dec_bytepos (ptrdiff_t bytepos)
377{ 378{
378 if (NILP (BVAR (current_buffer, enable_multibyte_characters))) 379 if (NILP (BVAR (current_buffer, enable_multibyte_characters)))
@@ -3277,6 +3278,7 @@ do { prev_from = from; \
3277 3278
3278 stop: /* Here if stopping before start of sexp. */ 3279 stop: /* Here if stopping before start of sexp. */
3279 from = prev_from; /* We have just fetched the char that starts it; */ 3280 from = prev_from; /* We have just fetched the char that starts it; */
3281 from_byte = prev_from_byte;
3280 goto done; /* but return the position before it. */ 3282 goto done; /* but return the position before it. */
3281 3283
3282 endquoted: 3284 endquoted:
@@ -3288,6 +3290,7 @@ do { prev_from = from; \
3288 state.prevlevelstart 3290 state.prevlevelstart
3289 = (curlevel == levelstart) ? -1 : (curlevel - 1)->last; 3291 = (curlevel == levelstart) ? -1 : (curlevel - 1)->last;
3290 state.location = from; 3292 state.location = from;
3293 state.location_byte = from_byte;
3291 state.levelstarts = Qnil; 3294 state.levelstarts = Qnil;
3292 while (curlevel > levelstart) 3295 while (curlevel > levelstart)
3293 state.levelstarts = Fcons (make_number ((--curlevel)->last), 3296 state.levelstarts = Fcons (make_number ((--curlevel)->last),
@@ -3327,7 +3330,8 @@ Fifth arg OLDSTATE is a list like what this function returns.
3327Sixth arg COMMENTSTOP non-nil means stop at the start of a comment. 3330Sixth arg COMMENTSTOP non-nil means stop at the start of a comment.
3328 If it is symbol `syntax-table', stop after the start of a comment or a 3331 If it is symbol `syntax-table', stop after the start of a comment or a
3329 string, or after end of a comment or a string. */) 3332 string, or after end of a comment or a string. */)
3330 (Lisp_Object from, Lisp_Object to, Lisp_Object targetdepth, Lisp_Object stopbefore, Lisp_Object oldstate, Lisp_Object commentstop) 3333 (Lisp_Object from, Lisp_Object to, Lisp_Object targetdepth,
3334 Lisp_Object stopbefore, Lisp_Object oldstate, Lisp_Object commentstop)
3331{ 3335{
3332 struct lisp_parse_state state; 3336 struct lisp_parse_state state;
3333 EMACS_INT target; 3337 EMACS_INT target;
@@ -3347,7 +3351,7 @@ Sixth arg COMMENTSTOP non-nil means stop at the start of a comment.
3347 (NILP (commentstop) 3351 (NILP (commentstop)
3348 ? 0 : (EQ (commentstop, Qsyntax_table) ? -1 : 1))); 3352 ? 0 : (EQ (commentstop, Qsyntax_table) ? -1 : 1)));
3349 3353
3350 SET_PT (state.location); 3354 SET_PT_BOTH (state.location, state.location_byte);
3351 3355
3352 return Fcons (make_number (state.depth), 3356 return Fcons (make_number (state.depth),
3353 Fcons (state.prevlevelstart < 0 3357 Fcons (state.prevlevelstart < 0
@@ -3389,8 +3393,8 @@ init_syntax_once (void)
3389 Qchar_table_extra_slots = intern_c_string ("char-table-extra-slots"); 3393 Qchar_table_extra_slots = intern_c_string ("char-table-extra-slots");
3390 3394
3391 /* Create objects which can be shared among syntax tables. */ 3395 /* Create objects which can be shared among syntax tables. */
3392 Vsyntax_code_object = Fmake_vector (make_number (Smax), Qnil); 3396 Vsyntax_code_object = make_uninit_vector (Smax);
3393 for (i = 0; i < ASIZE (Vsyntax_code_object); i++) 3397 for (i = 0; i < Smax; i++)
3394 ASET (Vsyntax_code_object, i, Fcons (make_number (i), Qnil)); 3398 ASET (Vsyntax_code_object, i, Fcons (make_number (i), Qnil));
3395 3399
3396 /* Now we are ready to set up this property, so we can 3400 /* Now we are ready to set up this property, so we can