diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/regex.c | 40 | ||||
| -rw-r--r-- | src/regex.h | 5 | ||||
| -rw-r--r-- | src/search.c | 4 |
3 files changed, 35 insertions, 14 deletions
diff --git a/src/regex.c b/src/regex.c index c32a62f89af..8dafb118058 100644 --- a/src/regex.c +++ b/src/regex.c | |||
| @@ -1108,7 +1108,9 @@ print_compiled_pattern (struct re_pattern_buffer *bufp) | |||
| 1108 | printf ("no_sub: %d\t", bufp->no_sub); | 1108 | printf ("no_sub: %d\t", bufp->no_sub); |
| 1109 | printf ("not_bol: %d\t", bufp->not_bol); | 1109 | printf ("not_bol: %d\t", bufp->not_bol); |
| 1110 | printf ("not_eol: %d\t", bufp->not_eol); | 1110 | printf ("not_eol: %d\t", bufp->not_eol); |
| 1111 | #ifndef emacs | ||
| 1111 | printf ("syntax: %lx\n", bufp->syntax); | 1112 | printf ("syntax: %lx\n", bufp->syntax); |
| 1113 | #endif | ||
| 1112 | fflush (stdout); | 1114 | fflush (stdout); |
| 1113 | /* Perhaps we should print the translate table? */ | 1115 | /* Perhaps we should print the translate table? */ |
| 1114 | } | 1116 | } |
| @@ -1558,9 +1560,11 @@ do { \ | |||
| 1558 | /* Subroutine declarations and macros for regex_compile. */ | 1560 | /* Subroutine declarations and macros for regex_compile. */ |
| 1559 | 1561 | ||
| 1560 | static reg_errcode_t regex_compile (re_char *pattern, size_t size, | 1562 | static reg_errcode_t regex_compile (re_char *pattern, size_t size, |
| 1561 | reg_syntax_t syntax, | ||
| 1562 | #ifdef emacs | 1563 | #ifdef emacs |
| 1564 | bool posix_backtracking, | ||
| 1563 | const char *whitespace_regexp, | 1565 | const char *whitespace_regexp, |
| 1566 | #else | ||
| 1567 | reg_syntax_t syntax, | ||
| 1564 | #endif | 1568 | #endif |
| 1565 | struct re_pattern_buffer *bufp); | 1569 | struct re_pattern_buffer *bufp); |
| 1566 | static void store_op1 (re_opcode_t op, unsigned char *loc, int arg); | 1570 | static void store_op1 (re_opcode_t op, unsigned char *loc, int arg); |
| @@ -2426,9 +2430,14 @@ do { \ | |||
| 2426 | } while (0) | 2430 | } while (0) |
| 2427 | 2431 | ||
| 2428 | static reg_errcode_t | 2432 | static reg_errcode_t |
| 2429 | regex_compile (const_re_char *pattern, size_t size, reg_syntax_t syntax, | 2433 | regex_compile (const_re_char *pattern, size_t size, |
| 2430 | #ifdef emacs | 2434 | #ifdef emacs |
| 2435 | # define syntax RE_SYNTAX_EMACS | ||
| 2436 | bool posix_backtracking, | ||
| 2431 | const char *whitespace_regexp, | 2437 | const char *whitespace_regexp, |
| 2438 | #else | ||
| 2439 | reg_syntax_t syntax, | ||
| 2440 | # define posix_backtracking (!(syntax & RE_NO_POSIX_BACKTRACKING)) | ||
| 2432 | #endif | 2441 | #endif |
| 2433 | struct re_pattern_buffer *bufp) | 2442 | struct re_pattern_buffer *bufp) |
| 2434 | { | 2443 | { |
| @@ -2518,7 +2527,9 @@ regex_compile (const_re_char *pattern, size_t size, reg_syntax_t syntax, | |||
| 2518 | range_table_work.allocated = 0; | 2527 | range_table_work.allocated = 0; |
| 2519 | 2528 | ||
| 2520 | /* Initialize the pattern buffer. */ | 2529 | /* Initialize the pattern buffer. */ |
| 2530 | #ifndef emacs | ||
| 2521 | bufp->syntax = syntax; | 2531 | bufp->syntax = syntax; |
| 2532 | #endif | ||
| 2522 | bufp->fastmap_accurate = 0; | 2533 | bufp->fastmap_accurate = 0; |
| 2523 | bufp->not_bol = bufp->not_eol = 0; | 2534 | bufp->not_bol = bufp->not_eol = 0; |
| 2524 | bufp->used_syntax = 0; | 2535 | bufp->used_syntax = 0; |
| @@ -3645,7 +3656,7 @@ regex_compile (const_re_char *pattern, size_t size, reg_syntax_t syntax, | |||
| 3645 | 3656 | ||
| 3646 | /* If we don't want backtracking, force success | 3657 | /* If we don't want backtracking, force success |
| 3647 | the first time we reach the end of the compiled pattern. */ | 3658 | the first time we reach the end of the compiled pattern. */ |
| 3648 | if (syntax & RE_NO_POSIX_BACKTRACKING) | 3659 | if (!posix_backtracking) |
| 3649 | BUF_PUSH (succeed); | 3660 | BUF_PUSH (succeed); |
| 3650 | 3661 | ||
| 3651 | /* We have succeeded; set the length of the buffer. */ | 3662 | /* We have succeeded; set the length of the buffer. */ |
| @@ -3680,6 +3691,12 @@ regex_compile (const_re_char *pattern, size_t size, reg_syntax_t syntax, | |||
| 3680 | #endif /* not MATCH_MAY_ALLOCATE */ | 3691 | #endif /* not MATCH_MAY_ALLOCATE */ |
| 3681 | 3692 | ||
| 3682 | FREE_STACK_RETURN (REG_NOERROR); | 3693 | FREE_STACK_RETURN (REG_NOERROR); |
| 3694 | |||
| 3695 | #ifdef emacs | ||
| 3696 | # undef syntax | ||
| 3697 | #else | ||
| 3698 | # undef posix_backtracking | ||
| 3699 | #endif | ||
| 3683 | } /* regex_compile */ | 3700 | } /* regex_compile */ |
| 3684 | 3701 | ||
| 3685 | /* Subroutines for `regex_compile'. */ | 3702 | /* Subroutines for `regex_compile'. */ |
| @@ -5442,6 +5459,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, const_re_char *string1, | |||
| 5442 | { | 5459 | { |
| 5443 | int buf_charlen; | 5460 | int buf_charlen; |
| 5444 | re_wchar_t buf_ch; | 5461 | re_wchar_t buf_ch; |
| 5462 | reg_syntax_t syntax; | ||
| 5445 | 5463 | ||
| 5446 | DEBUG_PRINT ("EXECUTING anychar.\n"); | 5464 | DEBUG_PRINT ("EXECUTING anychar.\n"); |
| 5447 | 5465 | ||
| @@ -5450,10 +5468,14 @@ re_match_2_internal (struct re_pattern_buffer *bufp, const_re_char *string1, | |||
| 5450 | target_multibyte); | 5468 | target_multibyte); |
| 5451 | buf_ch = TRANSLATE (buf_ch); | 5469 | buf_ch = TRANSLATE (buf_ch); |
| 5452 | 5470 | ||
| 5453 | if ((!(bufp->syntax & RE_DOT_NEWLINE) | 5471 | #ifdef emacs |
| 5454 | && buf_ch == '\n') | 5472 | syntax = RE_SYNTAX_EMACS; |
| 5455 | || ((bufp->syntax & RE_DOT_NOT_NULL) | 5473 | #else |
| 5456 | && buf_ch == '\000')) | 5474 | syntax = bufp->syntax; |
| 5475 | #endif | ||
| 5476 | |||
| 5477 | if ((!(syntax & RE_DOT_NEWLINE) && buf_ch == '\n') | ||
| 5478 | || ((syntax & RE_DOT_NOT_NULL) && buf_ch == '\000')) | ||
| 5457 | goto fail; | 5479 | goto fail; |
| 5458 | 5480 | ||
| 5459 | DEBUG_PRINT (" Matched \"%d\".\n", *d); | 5481 | DEBUG_PRINT (" Matched \"%d\".\n", *d); |
| @@ -6281,7 +6303,7 @@ bcmp_translate (const_re_char *s1, const_re_char *s2, register ssize_t len, | |||
| 6281 | const char * | 6303 | const char * |
| 6282 | re_compile_pattern (const char *pattern, size_t length, | 6304 | re_compile_pattern (const char *pattern, size_t length, |
| 6283 | #ifdef emacs | 6305 | #ifdef emacs |
| 6284 | reg_syntax_t syntax, const char *whitespace_regexp, | 6306 | bool posix_backtracking, const char *whitespace_regexp, |
| 6285 | #endif | 6307 | #endif |
| 6286 | struct re_pattern_buffer *bufp) | 6308 | struct re_pattern_buffer *bufp) |
| 6287 | { | 6309 | { |
| @@ -6298,7 +6320,7 @@ re_compile_pattern (const char *pattern, size_t length, | |||
| 6298 | 6320 | ||
| 6299 | ret = regex_compile ((re_char*) pattern, length, | 6321 | ret = regex_compile ((re_char*) pattern, length, |
| 6300 | #ifdef emacs | 6322 | #ifdef emacs |
| 6301 | syntax, | 6323 | posix_backtracking, |
| 6302 | whitespace_regexp, | 6324 | whitespace_regexp, |
| 6303 | #else | 6325 | #else |
| 6304 | re_syntax_options, | 6326 | re_syntax_options, |
diff --git a/src/regex.h b/src/regex.h index af9480d583c..b672d3fdef7 100644 --- a/src/regex.h +++ b/src/regex.h | |||
| @@ -354,9 +354,10 @@ struct re_pattern_buffer | |||
| 354 | /* Number of bytes actually used in `buffer'. */ | 354 | /* Number of bytes actually used in `buffer'. */ |
| 355 | size_t used; | 355 | size_t used; |
| 356 | 356 | ||
| 357 | #ifndef emacs | ||
| 357 | /* Syntax setting with which the pattern was compiled. */ | 358 | /* Syntax setting with which the pattern was compiled. */ |
| 358 | reg_syntax_t syntax; | 359 | reg_syntax_t syntax; |
| 359 | 360 | #endif | |
| 360 | /* Pointer to a fastmap, if any, otherwise zero. re_search uses | 361 | /* Pointer to a fastmap, if any, otherwise zero. re_search uses |
| 361 | the fastmap, if there is one, to skip over impossible | 362 | the fastmap, if there is one, to skip over impossible |
| 362 | starting points for matches. */ | 363 | starting points for matches. */ |
| @@ -473,7 +474,7 @@ extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax); | |||
| 473 | BUFFER. Return NULL if successful, and an error string if not. */ | 474 | BUFFER. Return NULL if successful, and an error string if not. */ |
| 474 | extern const char *re_compile_pattern (const char *__pattern, size_t __length, | 475 | extern const char *re_compile_pattern (const char *__pattern, size_t __length, |
| 475 | #ifdef emacs | 476 | #ifdef emacs |
| 476 | reg_syntax_t syntax, | 477 | bool posix_backtracking, |
| 477 | const char *whitespace_regexp, | 478 | const char *whitespace_regexp, |
| 478 | #endif | 479 | #endif |
| 479 | struct re_pattern_buffer *__buffer); | 480 | struct re_pattern_buffer *__buffer); |
diff --git a/src/search.c b/src/search.c index c7556a90cb4..7f2b4f9840c 100644 --- a/src/search.c +++ b/src/search.c | |||
| @@ -114,7 +114,6 @@ compile_pattern_1 (struct regexp_cache *cp, Lisp_Object pattern, | |||
| 114 | Lisp_Object translate, bool posix) | 114 | Lisp_Object translate, bool posix) |
| 115 | { | 115 | { |
| 116 | const char *whitespace_regexp; | 116 | const char *whitespace_regexp; |
| 117 | reg_syntax_t syntax; | ||
| 118 | char *val; | 117 | char *val; |
| 119 | 118 | ||
| 120 | cp->regexp = Qnil; | 119 | cp->regexp = Qnil; |
| @@ -133,12 +132,11 @@ compile_pattern_1 (struct regexp_cache *cp, Lisp_Object pattern, | |||
| 133 | So let's turn it off. */ | 132 | So let's turn it off. */ |
| 134 | /* BLOCK_INPUT; */ | 133 | /* BLOCK_INPUT; */ |
| 135 | 134 | ||
| 136 | syntax = RE_SYNTAX_EMACS | (posix ? 0 : RE_NO_POSIX_BACKTRACKING); | ||
| 137 | whitespace_regexp = STRINGP (Vsearch_spaces_regexp) ? | 135 | whitespace_regexp = STRINGP (Vsearch_spaces_regexp) ? |
| 138 | SSDATA (Vsearch_spaces_regexp) : NULL; | 136 | SSDATA (Vsearch_spaces_regexp) : NULL; |
| 139 | 137 | ||
| 140 | val = (char *) re_compile_pattern (SSDATA (pattern), SBYTES (pattern), | 138 | val = (char *) re_compile_pattern (SSDATA (pattern), SBYTES (pattern), |
| 141 | syntax, whitespace_regexp, &cp->buf); | 139 | posix, whitespace_regexp, &cp->buf); |
| 142 | 140 | ||
| 143 | /* If the compiled pattern hard codes some of the contents of the | 141 | /* If the compiled pattern hard codes some of the contents of the |
| 144 | syntax-table, it can only be reused with *this* syntax table. */ | 142 | syntax-table, it can only be reused with *this* syntax table. */ |