Mercurial > emacs
comparison src/syntax.c @ 21207:390b39d69836
(Fbackward_prefix_chars): Set point properly while scanning.
(scan_sexps_forward): Make INC_FROM do UPDATE_SYNTAX_TABLE_FORWARD.
Delete the explicit calls to UPDATE_SYNTAX_TABLE_FORWARD.
Also set prev_from_syntax (new local var). Test that in the loop,
instead of fetching syntax of the previous char.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 18 Mar 1998 00:11:33 +0000 |
parents | ceb05db73a63 |
children | fa9ff387d260 |
comparison
equal
deleted
inserted
replaced
21206:dac44ee5f772 | 21207:390b39d69836 |
---|---|
2172 SETUP_SYNTAX_TABLE (pos, -1); | 2172 SETUP_SYNTAX_TABLE (pos, -1); |
2173 } | 2173 } |
2174 | 2174 |
2175 DEC_BOTH (pos, pos_byte); | 2175 DEC_BOTH (pos, pos_byte); |
2176 | 2176 |
2177 while (pos + 1 > beg && !char_quoted (pos, pos_byte) | 2177 while (!char_quoted (pos, pos_byte) |
2178 /* Previous statement updates syntax table. */ | 2178 /* Previous statement updates syntax table. */ |
2179 && ((c = FETCH_CHAR (pos_byte), SYNTAX (c) == Squote) | 2179 && ((c = FETCH_CHAR (pos_byte), SYNTAX (c) == Squote) |
2180 || SYNTAX_PREFIX (c))) | 2180 || SYNTAX_PREFIX (c))) |
2181 { | 2181 { |
2182 DEC_BOTH (pos, pos_byte); | 2182 opoint = pos; |
2183 opoint_byte = pos_byte; | |
2184 | |
2185 if (pos + 1 > beg) | |
2186 DEC_BOTH (pos, pos_byte); | |
2183 } | 2187 } |
2184 | 2188 |
2185 SET_PT_BOTH (opoint, opoint_byte); | 2189 SET_PT_BOTH (opoint, opoint_byte); |
2186 | 2190 |
2187 return Qnil; | 2191 return Qnil; |
2218 int mindepth; /* Lowest DEPTH value seen. */ | 2222 int mindepth; /* Lowest DEPTH value seen. */ |
2219 int start_quoted = 0; /* Nonzero means starting after a char quote */ | 2223 int start_quoted = 0; /* Nonzero means starting after a char quote */ |
2220 Lisp_Object tem; | 2224 Lisp_Object tem; |
2221 int prev_from; /* Keep one character before FROM. */ | 2225 int prev_from; /* Keep one character before FROM. */ |
2222 int prev_from_byte; | 2226 int prev_from_byte; |
2227 int prev_from_syntax; | |
2223 int boundary_stop = commentstop == -1; | 2228 int boundary_stop = commentstop == -1; |
2224 int nofence; | 2229 int nofence; |
2225 | 2230 |
2226 prev_from = from; | 2231 prev_from = from; |
2227 prev_from_byte = from_byte; | 2232 prev_from_byte = from_byte; |
2230 | 2235 |
2231 /* Use this macro instead of `from++'. */ | 2236 /* Use this macro instead of `from++'. */ |
2232 #define INC_FROM \ | 2237 #define INC_FROM \ |
2233 do { prev_from = from; \ | 2238 do { prev_from = from; \ |
2234 prev_from_byte = from_byte; \ | 2239 prev_from_byte = from_byte; \ |
2240 prev_from_syntax \ | |
2241 = SYNTAX_WITH_FLAGS (FETCH_CHAR (prev_from_byte)); \ | |
2235 INC_BOTH (from, from_byte); \ | 2242 INC_BOTH (from, from_byte); \ |
2243 UPDATE_SYNTAX_TABLE_FORWARD (from); \ | |
2236 } while (0) | 2244 } while (0) |
2237 | 2245 |
2238 immediate_quit = 1; | 2246 immediate_quit = 1; |
2239 QUIT; | 2247 QUIT; |
2240 | |
2241 SETUP_SYNTAX_TABLE (from, 1); | |
2242 | 2248 |
2243 if (NILP (oldstate)) | 2249 if (NILP (oldstate)) |
2244 { | 2250 { |
2245 depth = 0; | 2251 depth = 0; |
2246 state.instring = -1; | 2252 state.instring = -1; |
2300 if (start_quoted) goto startquotedinstring; | 2306 if (start_quoted) goto startquotedinstring; |
2301 goto startinstring; | 2307 goto startinstring; |
2302 } | 2308 } |
2303 if (start_quoted) goto startquoted; | 2309 if (start_quoted) goto startquoted; |
2304 | 2310 |
2311 | |
2312 SETUP_SYNTAX_TABLE (prev_from, 1); | |
2313 prev_from_syntax = SYNTAX_WITH_FLAGS (FETCH_CHAR (prev_from_byte)); | |
2314 UPDATE_SYNTAX_TABLE_FORWARD (from); | |
2315 | |
2305 while (from < end) | 2316 while (from < end) |
2306 { | 2317 { |
2307 UPDATE_SYNTAX_TABLE_FORWARD (from); | |
2308 code = SYNTAX (FETCH_CHAR (from_byte)); | |
2309 INC_FROM; | 2318 INC_FROM; |
2319 code = prev_from_syntax & 0xff; | |
2310 | 2320 |
2311 if (code == Scomment) | 2321 if (code == Scomment) |
2312 state.comstr_start = prev_from; | 2322 state.comstr_start = prev_from; |
2313 else if (code == Scomment_fence) | 2323 else if (code == Scomment_fence) |
2314 { | 2324 { |
2317 terminates the comment section. */ | 2327 terminates the comment section. */ |
2318 state.comstyle = ( code == Scomment_fence | 2328 state.comstyle = ( code == Scomment_fence |
2319 ? ST_COMMENT_STYLE | 2329 ? ST_COMMENT_STYLE |
2320 : SYNTAX_COMMENT_STYLE (FETCH_CHAR (from_byte))); | 2330 : SYNTAX_COMMENT_STYLE (FETCH_CHAR (from_byte))); |
2321 state.comstr_start = prev_from; | 2331 state.comstr_start = prev_from; |
2322 if (code != Scomment_fence) INC_FROM; | 2332 if (code != Scomment_fence) |
2333 INC_FROM; | |
2323 code = Scomment; | 2334 code = Scomment; |
2324 } | 2335 } |
2325 else if (from < end) | 2336 else if (from < end) |
2326 if (SYNTAX_COMSTART_FIRST (FETCH_CHAR (prev_from_byte))) | 2337 if (SYNTAX_FLAGS_COMSTART_FIRST (prev_from_syntax)) |
2327 if (SYNTAX_COMSTART_SECOND (FETCH_CHAR (from_byte))) | 2338 if (SYNTAX_COMSTART_SECOND (FETCH_CHAR (from_byte))) |
2328 /* Duplicate code to avoid a very complex if-expression | 2339 /* Duplicate code to avoid a complex if-expression |
2329 which causes trouble for the SGI compiler. */ | 2340 which causes trouble for the SGI compiler. */ |
2330 { | 2341 { |
2331 /* Record the comment style we have entered so that only | 2342 /* Record the comment style we have entered so that only |
2332 the comment-end sequence of the same style actually | 2343 the comment-end sequence of the same style actually |
2333 terminates the comment section. */ | 2344 terminates the comment section. */ |
2334 state.comstyle = ( code == Scomment_fence | 2345 state.comstyle = ( code == Scomment_fence |
2335 ? ST_COMMENT_STYLE | 2346 ? ST_COMMENT_STYLE |
2336 : SYNTAX_COMMENT_STYLE (FETCH_CHAR (from_byte))); | 2347 : SYNTAX_COMMENT_STYLE (FETCH_CHAR (from_byte))); |
2337 state.comstr_start = prev_from; | 2348 state.comstr_start = prev_from; |
2338 if (code != Scomment_fence) INC_FROM; | 2349 if (code != Scomment_fence) |
2350 INC_FROM; | |
2339 code = Scomment; | 2351 code = Scomment; |
2340 } | 2352 } |
2341 | 2353 |
2342 if (SYNTAX_PREFIX (FETCH_CHAR (prev_from_byte))) | 2354 if (SYNTAX_FLAGS_PREFIX (prev_from_syntax)) |
2343 continue; | 2355 continue; |
2344 switch (SWITCH_ENUM_CAST (code)) | 2356 switch (SWITCH_ENUM_CAST (code)) |
2345 { | 2357 { |
2346 case Sescape: | 2358 case Sescape: |
2347 case Scharquote: | 2359 case Scharquote: |
2357 if (stopbefore) goto stop; /* this arg means stop at sexp start */ | 2369 if (stopbefore) goto stop; /* this arg means stop at sexp start */ |
2358 curlevel->last = prev_from; | 2370 curlevel->last = prev_from; |
2359 symstarted: | 2371 symstarted: |
2360 while (from < end) | 2372 while (from < end) |
2361 { | 2373 { |
2362 UPDATE_SYNTAX_TABLE_FORWARD (from); | |
2363 switch (SWITCH_ENUM_CAST (SYNTAX (FETCH_CHAR (from_byte)))) | 2374 switch (SWITCH_ENUM_CAST (SYNTAX (FETCH_CHAR (from_byte)))) |
2364 { | 2375 { |
2365 case Scharquote: | 2376 case Scharquote: |
2366 case Sescape: | 2377 case Sescape: |
2367 INC_FROM; | 2378 INC_FROM; |
2385 goto done; | 2396 goto done; |
2386 if (from != BEGV) | 2397 if (from != BEGV) |
2387 { | 2398 { |
2388 /* Enter the loop in the middle so that we find | 2399 /* Enter the loop in the middle so that we find |
2389 a 2-char comment ender if we start in the middle of it. */ | 2400 a 2-char comment ender if we start in the middle of it. */ |
2390 prev = FETCH_CHAR (prev_from_byte); | |
2391 goto startincomment_1; | 2401 goto startincomment_1; |
2392 } | 2402 } |
2393 /* At beginning of buffer, enter the loop the ordinary way. */ | 2403 /* At beginning of buffer, enter the loop the ordinary way. */ |
2394 state.incomment = 1; | 2404 state.incomment = 1; |
2395 goto commentloop; | 2405 goto commentloop; |
2399 if (commentstop || boundary_stop) goto done; | 2409 if (commentstop || boundary_stop) goto done; |
2400 commentloop: | 2410 commentloop: |
2401 while (1) | 2411 while (1) |
2402 { | 2412 { |
2403 if (from == end) goto done; | 2413 if (from == end) goto done; |
2404 UPDATE_SYNTAX_TABLE_FORWARD (from); | |
2405 prev = FETCH_CHAR (from_byte); | 2414 prev = FETCH_CHAR (from_byte); |
2406 if (SYNTAX (prev) == Sendcomment | 2415 if (SYNTAX (prev) == Sendcomment |
2407 && SYNTAX_COMMENT_STYLE (prev) == state.comstyle) | 2416 && SYNTAX_COMMENT_STYLE (prev) == state.comstyle) |
2408 /* Only terminate the comment section if the endcomment | 2417 /* Only terminate the comment section if the endcomment |
2409 of the same style as the start sequence has been | 2418 of the same style as the start sequence has been |
2412 if (state.comstyle == ST_COMMENT_STYLE | 2421 if (state.comstyle == ST_COMMENT_STYLE |
2413 && SYNTAX (prev) == Scomment_fence) | 2422 && SYNTAX (prev) == Scomment_fence) |
2414 break; | 2423 break; |
2415 INC_FROM; | 2424 INC_FROM; |
2416 startincomment_1: | 2425 startincomment_1: |
2417 if (from < end && SYNTAX_COMEND_FIRST (prev) | 2426 if (from < end && SYNTAX_FLAGS_COMEND_FIRST (prev_from_syntax) |
2418 && SYNTAX_COMEND_SECOND (FETCH_CHAR (from_byte)) | 2427 && SYNTAX_COMEND_SECOND (FETCH_CHAR (from_byte)) |
2419 && SYNTAX_COMMENT_STYLE (prev) == state.comstyle) | 2428 && (SYNTAX_FLAGS_COMMENT_STYLE (prev_from_syntax) |
2429 == state.comstyle)) | |
2420 /* Only terminate the comment section if the end-comment | 2430 /* Only terminate the comment section if the end-comment |
2421 sequence of the same style as the start sequence has | 2431 sequence of the same style as the start sequence has |
2422 been encountered. */ | 2432 been encountered. */ |
2423 break; | 2433 break; |
2424 } | 2434 } |
2468 int c; | 2478 int c; |
2469 | 2479 |
2470 if (from >= end) goto done; | 2480 if (from >= end) goto done; |
2471 c = FETCH_CHAR (from_byte); | 2481 c = FETCH_CHAR (from_byte); |
2472 if (nofence && c == state.instring) break; | 2482 if (nofence && c == state.instring) break; |
2473 UPDATE_SYNTAX_TABLE_FORWARD (from); | |
2474 switch (SWITCH_ENUM_CAST (SYNTAX (c))) | 2483 switch (SWITCH_ENUM_CAST (SYNTAX (c))) |
2475 { | 2484 { |
2476 case Sstring_fence: | 2485 case Sstring_fence: |
2477 if (!nofence) goto string_end; | 2486 if (!nofence) goto string_end; |
2478 break; | 2487 break; |