diff options
| author | Po Lu | 2023-04-13 07:32:27 +0800 |
|---|---|---|
| committer | Po Lu | 2023-04-13 07:32:27 +0800 |
| commit | 562b2fca7d824a01d759bc7ade0e54ddd8497a0b (patch) | |
| tree | e24e62b816f203a74b5b7b9d0d3d8386f23f702b /src/syntax.c | |
| parent | 91da696bbc43c39efeaeb70a86410d3652bee14d (diff) | |
| parent | 861cf3a5c9d2081d811dcfc2c5ce5357f3dc44d4 (diff) | |
| download | emacs-562b2fca7d824a01d759bc7ade0e54ddd8497a0b.tar.gz emacs-562b2fca7d824a01d759bc7ade0e54ddd8497a0b.zip | |
Merge remote-tracking branch 'origin/master' into feature/android
Diffstat (limited to 'src/syntax.c')
| -rw-r--r-- | src/syntax.c | 50 |
1 files changed, 20 insertions, 30 deletions
diff --git a/src/syntax.c b/src/syntax.c index 79e16f652f3..e9e04e2d638 100644 --- a/src/syntax.c +++ b/src/syntax.c | |||
| @@ -250,7 +250,6 @@ SETUP_SYNTAX_TABLE (ptrdiff_t from, ptrdiff_t count) | |||
| 250 | gl_state.b_property = BEGV; | 250 | gl_state.b_property = BEGV; |
| 251 | gl_state.e_property = ZV + 1; | 251 | gl_state.e_property = ZV + 1; |
| 252 | gl_state.object = Qnil; | 252 | gl_state.object = Qnil; |
| 253 | gl_state.offset = 0; | ||
| 254 | if (parse_sexp_lookup_properties) | 253 | if (parse_sexp_lookup_properties) |
| 255 | { | 254 | { |
| 256 | if (count > 0) | 255 | if (count > 0) |
| @@ -266,46 +265,38 @@ SETUP_SYNTAX_TABLE (ptrdiff_t from, ptrdiff_t count) | |||
| 266 | /* Same as above, but in OBJECT. If OBJECT is nil, use current buffer. | 265 | /* Same as above, but in OBJECT. If OBJECT is nil, use current buffer. |
| 267 | If it is t (which is only used in fast_c_string_match_ignore_case), | 266 | If it is t (which is only used in fast_c_string_match_ignore_case), |
| 268 | ignore properties altogether. | 267 | ignore properties altogether. |
| 269 | 268 | FROMBYTE is an regexp-byteoffset. */ | |
| 270 | This is meant for regex-emacs.c to use. For buffers, regex-emacs.c | ||
| 271 | passes arguments to the UPDATE_SYNTAX_TABLE functions which are | ||
| 272 | relative to BEGV. So if it is a buffer, we set the offset field to | ||
| 273 | BEGV. */ | ||
| 274 | 269 | ||
| 275 | void | 270 | void |
| 276 | SETUP_SYNTAX_TABLE_FOR_OBJECT (Lisp_Object object, | 271 | RE_SETUP_SYNTAX_TABLE_FOR_OBJECT (Lisp_Object object, |
| 277 | ptrdiff_t from, ptrdiff_t count) | 272 | ptrdiff_t frombyte) |
| 278 | { | 273 | { |
| 279 | SETUP_BUFFER_SYNTAX_TABLE (); | 274 | SETUP_BUFFER_SYNTAX_TABLE (); |
| 280 | gl_state.object = object; | 275 | gl_state.object = object; |
| 281 | if (BUFFERP (gl_state.object)) | 276 | if (BUFFERP (gl_state.object)) |
| 282 | { | 277 | { |
| 283 | struct buffer *buf = XBUFFER (gl_state.object); | 278 | struct buffer *buf = XBUFFER (gl_state.object); |
| 284 | gl_state.b_property = 1; | 279 | gl_state.b_property = BEG; |
| 285 | gl_state.e_property = BUF_ZV (buf) - BUF_BEGV (buf) + 1; | 280 | gl_state.e_property = BUF_ZV (buf); |
| 286 | gl_state.offset = BUF_BEGV (buf) - 1; | ||
| 287 | } | 281 | } |
| 288 | else if (NILP (gl_state.object)) | 282 | else if (NILP (gl_state.object)) |
| 289 | { | 283 | { |
| 290 | gl_state.b_property = 1; | 284 | gl_state.b_property = BEG; |
| 291 | gl_state.e_property = ZV - BEGV + 1; | 285 | gl_state.e_property = ZV; /* FIXME: Why not +1 like in SETUP_SYNTAX_TABLE? */ |
| 292 | gl_state.offset = BEGV - 1; | ||
| 293 | } | 286 | } |
| 294 | else if (EQ (gl_state.object, Qt)) | 287 | else if (EQ (gl_state.object, Qt)) |
| 295 | { | 288 | { |
| 296 | gl_state.b_property = 0; | 289 | gl_state.b_property = 0; |
| 297 | gl_state.e_property = PTRDIFF_MAX; | 290 | gl_state.e_property = PTRDIFF_MAX; |
| 298 | gl_state.offset = 0; | ||
| 299 | } | 291 | } |
| 300 | else | 292 | else |
| 301 | { | 293 | { |
| 302 | gl_state.b_property = 0; | 294 | gl_state.b_property = 0; |
| 303 | gl_state.e_property = 1 + SCHARS (gl_state.object); | 295 | gl_state.e_property = 1 + SCHARS (gl_state.object); |
| 304 | gl_state.offset = 0; | ||
| 305 | } | 296 | } |
| 306 | if (parse_sexp_lookup_properties) | 297 | if (parse_sexp_lookup_properties) |
| 307 | update_syntax_table (from + gl_state.offset - (count <= 0), | 298 | update_syntax_table (RE_SYNTAX_TABLE_BYTE_TO_CHAR (frombyte), |
| 308 | count, 1, gl_state.object); | 299 | 1, 1, gl_state.object); |
| 309 | } | 300 | } |
| 310 | 301 | ||
| 311 | /* Update gl_state to an appropriate interval which contains CHARPOS. The | 302 | /* Update gl_state to an appropriate interval which contains CHARPOS. The |
| @@ -341,8 +332,8 @@ update_syntax_table (ptrdiff_t charpos, EMACS_INT count, bool init, | |||
| 341 | if (!i) | 332 | if (!i) |
| 342 | return; | 333 | return; |
| 343 | i = gl_state.forward_i; | 334 | i = gl_state.forward_i; |
| 344 | gl_state.b_property = i->position - gl_state.offset; | 335 | gl_state.b_property = i->position; |
| 345 | gl_state.e_property = INTERVAL_LAST_POS (i) - gl_state.offset; | 336 | gl_state.e_property = INTERVAL_LAST_POS (i); |
| 346 | } | 337 | } |
| 347 | else | 338 | else |
| 348 | { | 339 | { |
| @@ -362,7 +353,7 @@ update_syntax_table (ptrdiff_t charpos, EMACS_INT count, bool init, | |||
| 362 | { | 353 | { |
| 363 | invalidate = false; | 354 | invalidate = false; |
| 364 | gl_state.forward_i = i; | 355 | gl_state.forward_i = i; |
| 365 | gl_state.e_property = INTERVAL_LAST_POS (i) - gl_state.offset; | 356 | gl_state.e_property = INTERVAL_LAST_POS (i); |
| 366 | } | 357 | } |
| 367 | } | 358 | } |
| 368 | else if (charpos >= INTERVAL_LAST_POS (i)) /* Move right. */ | 359 | else if (charpos >= INTERVAL_LAST_POS (i)) /* Move right. */ |
| @@ -375,7 +366,7 @@ update_syntax_table (ptrdiff_t charpos, EMACS_INT count, bool init, | |||
| 375 | { | 366 | { |
| 376 | invalidate = false; | 367 | invalidate = false; |
| 377 | gl_state.backward_i = i; | 368 | gl_state.backward_i = i; |
| 378 | gl_state.b_property = i->position - gl_state.offset; | 369 | gl_state.b_property = i->position; |
| 379 | } | 370 | } |
| 380 | } | 371 | } |
| 381 | } | 372 | } |
| @@ -391,12 +382,12 @@ update_syntax_table (ptrdiff_t charpos, EMACS_INT count, bool init, | |||
| 391 | if (count > 0) | 382 | if (count > 0) |
| 392 | { | 383 | { |
| 393 | gl_state.backward_i = i; | 384 | gl_state.backward_i = i; |
| 394 | gl_state.b_property = i->position - gl_state.offset; | 385 | gl_state.b_property = i->position; |
| 395 | } | 386 | } |
| 396 | else | 387 | else |
| 397 | { | 388 | { |
| 398 | gl_state.forward_i = i; | 389 | gl_state.forward_i = i; |
| 399 | gl_state.e_property = INTERVAL_LAST_POS (i) - gl_state.offset; | 390 | gl_state.e_property = INTERVAL_LAST_POS (i); |
| 400 | } | 391 | } |
| 401 | } | 392 | } |
| 402 | 393 | ||
| @@ -426,13 +417,13 @@ update_syntax_table (ptrdiff_t charpos, EMACS_INT count, bool init, | |||
| 426 | { | 417 | { |
| 427 | if (count > 0) | 418 | if (count > 0) |
| 428 | { | 419 | { |
| 429 | gl_state.e_property = i->position - gl_state.offset; | 420 | gl_state.e_property = i->position; |
| 430 | gl_state.forward_i = i; | 421 | gl_state.forward_i = i; |
| 431 | } | 422 | } |
| 432 | else | 423 | else |
| 433 | { | 424 | { |
| 434 | gl_state.b_property | 425 | gl_state.b_property |
| 435 | = i->position + LENGTH (i) - gl_state.offset; | 426 | = i->position + LENGTH (i); |
| 436 | gl_state.backward_i = i; | 427 | gl_state.backward_i = i; |
| 437 | } | 428 | } |
| 438 | return; | 429 | return; |
| @@ -442,7 +433,7 @@ update_syntax_table (ptrdiff_t charpos, EMACS_INT count, bool init, | |||
| 442 | if (count > 0) | 433 | if (count > 0) |
| 443 | { | 434 | { |
| 444 | gl_state.e_property | 435 | gl_state.e_property |
| 445 | = i->position + LENGTH (i) - gl_state.offset | 436 | = i->position + LENGTH (i) |
| 446 | /* e_property at EOB is not set to ZV but to ZV+1, so that | 437 | /* e_property at EOB is not set to ZV but to ZV+1, so that |
| 447 | we can do INC(from);UPDATE_SYNTAX_TABLE_FORWARD without | 438 | we can do INC(from);UPDATE_SYNTAX_TABLE_FORWARD without |
| 448 | having to check eob between the two. */ | 439 | having to check eob between the two. */ |
| @@ -451,7 +442,7 @@ update_syntax_table (ptrdiff_t charpos, EMACS_INT count, bool init, | |||
| 451 | } | 442 | } |
| 452 | else | 443 | else |
| 453 | { | 444 | { |
| 454 | gl_state.b_property = i->position - gl_state.offset; | 445 | gl_state.b_property = i->position; |
| 455 | gl_state.backward_i = i; | 446 | gl_state.backward_i = i; |
| 456 | } | 447 | } |
| 457 | return; | 448 | return; |
| @@ -2201,8 +2192,7 @@ skip_syntaxes (bool forwardp, Lisp_Object string, Lisp_Object lim) | |||
| 2201 | while (!parse_sexp_lookup_properties | 2192 | while (!parse_sexp_lookup_properties |
| 2202 | || pos < gl_state.e_property); | 2193 | || pos < gl_state.e_property); |
| 2203 | 2194 | ||
| 2204 | update_syntax_table_forward (pos + gl_state.offset, | 2195 | update_syntax_table_forward (pos, false, gl_state.object); |
| 2205 | false, gl_state.object); | ||
| 2206 | } | 2196 | } |
| 2207 | } | 2197 | } |
| 2208 | else | 2198 | else |