diff options
Diffstat (limited to 'src/regex.c')
| -rw-r--r-- | src/regex.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/src/regex.c b/src/regex.c index 79fb28ba12a..39adb080efd 100644 --- a/src/regex.c +++ b/src/regex.c | |||
| @@ -531,8 +531,10 @@ init_syntax_once (void) | |||
| 531 | /* Type of source-pattern and string chars. */ | 531 | /* Type of source-pattern and string chars. */ |
| 532 | #ifdef _MSC_VER | 532 | #ifdef _MSC_VER |
| 533 | typedef unsigned char re_char; | 533 | typedef unsigned char re_char; |
| 534 | typedef const re_char const_re_char; | ||
| 534 | #else | 535 | #else |
| 535 | typedef const unsigned char re_char; | 536 | typedef const unsigned char re_char; |
| 537 | typedef re_char const_re_char; | ||
| 536 | #endif | 538 | #endif |
| 537 | 539 | ||
| 538 | typedef char boolean; | 540 | typedef char boolean; |
| @@ -2015,7 +2017,7 @@ struct range_table_work_area | |||
| 2015 | 2017 | ||
| 2016 | /* Map a string to the char class it names (if any). */ | 2018 | /* Map a string to the char class it names (if any). */ |
| 2017 | re_wctype_t | 2019 | re_wctype_t |
| 2018 | re_wctype (const re_char *str) | 2020 | re_wctype (const_re_char *str) |
| 2019 | { | 2021 | { |
| 2020 | const char *string = (const char *) str; | 2022 | const char *string = (const char *) str; |
| 2021 | if (STREQ (string, "alnum")) return RECC_ALNUM; | 2023 | if (STREQ (string, "alnum")) return RECC_ALNUM; |
| @@ -2409,7 +2411,8 @@ do { \ | |||
| 2409 | } while (0) | 2411 | } while (0) |
| 2410 | 2412 | ||
| 2411 | static reg_errcode_t | 2413 | static reg_errcode_t |
| 2412 | regex_compile (const re_char *pattern, size_t size, reg_syntax_t syntax, struct re_pattern_buffer *bufp) | 2414 | regex_compile (const_re_char *pattern, size_t size, reg_syntax_t syntax, |
| 2415 | struct re_pattern_buffer *bufp) | ||
| 2413 | { | 2416 | { |
| 2414 | /* We fetch characters from PATTERN here. */ | 2417 | /* We fetch characters from PATTERN here. */ |
| 2415 | register re_wchar_t c, c1; | 2418 | register re_wchar_t c, c1; |
| @@ -3765,7 +3768,7 @@ insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, unsigned cha | |||
| 3765 | least one character before the ^. */ | 3768 | least one character before the ^. */ |
| 3766 | 3769 | ||
| 3767 | static boolean | 3770 | static boolean |
| 3768 | at_begline_loc_p (const re_char *pattern, const re_char *p, reg_syntax_t syntax) | 3771 | at_begline_loc_p (const_re_char *pattern, const_re_char *p, reg_syntax_t syntax) |
| 3769 | { | 3772 | { |
| 3770 | re_char *prev = p - 2; | 3773 | re_char *prev = p - 2; |
| 3771 | boolean odd_backslashes; | 3774 | boolean odd_backslashes; |
| @@ -3806,7 +3809,7 @@ at_begline_loc_p (const re_char *pattern, const re_char *p, reg_syntax_t syntax) | |||
| 3806 | at least one character after the $, i.e., `P < PEND'. */ | 3809 | at least one character after the $, i.e., `P < PEND'. */ |
| 3807 | 3810 | ||
| 3808 | static boolean | 3811 | static boolean |
| 3809 | at_endline_loc_p (const re_char *p, const re_char *pend, reg_syntax_t syntax) | 3812 | at_endline_loc_p (const_re_char *p, const_re_char *pend, reg_syntax_t syntax) |
| 3810 | { | 3813 | { |
| 3811 | re_char *next = p; | 3814 | re_char *next = p; |
| 3812 | boolean next_backslash = *next == '\\'; | 3815 | boolean next_backslash = *next == '\\'; |
| @@ -3850,7 +3853,8 @@ group_in_compile_stack (compile_stack_type compile_stack, regnum_t regnum) | |||
| 3850 | Return -1 if fastmap was not updated accurately. */ | 3853 | Return -1 if fastmap was not updated accurately. */ |
| 3851 | 3854 | ||
| 3852 | static int | 3855 | static int |
| 3853 | analyse_first (const re_char *p, const re_char *pend, char *fastmap, const int multibyte) | 3856 | analyse_first (const_re_char *p, const_re_char *pend, char *fastmap, |
| 3857 | const int multibyte) | ||
| 3854 | { | 3858 | { |
| 3855 | int j, k; | 3859 | int j, k; |
| 3856 | boolean not; | 3860 | boolean not; |
| @@ -4594,7 +4598,7 @@ static int bcmp_translate (re_char *s1, re_char *s2, | |||
| 4594 | /* If the operation is a match against one or more chars, | 4598 | /* If the operation is a match against one or more chars, |
| 4595 | return a pointer to the next operation, else return NULL. */ | 4599 | return a pointer to the next operation, else return NULL. */ |
| 4596 | static re_char * | 4600 | static re_char * |
| 4597 | skip_one_char (const re_char *p) | 4601 | skip_one_char (const_re_char *p) |
| 4598 | { | 4602 | { |
| 4599 | switch (*p++) | 4603 | switch (*p++) |
| 4600 | { | 4604 | { |
| @@ -4636,7 +4640,7 @@ skip_one_char (const re_char *p) | |||
| 4636 | 4640 | ||
| 4637 | /* Jump over non-matching operations. */ | 4641 | /* Jump over non-matching operations. */ |
| 4638 | static re_char * | 4642 | static re_char * |
| 4639 | skip_noops (const re_char *p, const re_char *pend) | 4643 | skip_noops (const_re_char *p, const_re_char *pend) |
| 4640 | { | 4644 | { |
| 4641 | int mcnt; | 4645 | int mcnt; |
| 4642 | while (p < pend) | 4646 | while (p < pend) |
| @@ -4663,7 +4667,8 @@ skip_noops (const re_char *p, const re_char *pend) | |||
| 4663 | 4667 | ||
| 4664 | /* Non-zero if "p1 matches something" implies "p2 fails". */ | 4668 | /* Non-zero if "p1 matches something" implies "p2 fails". */ |
| 4665 | static int | 4669 | static int |
| 4666 | mutually_exclusive_p (struct re_pattern_buffer *bufp, const re_char *p1, const re_char *p2) | 4670 | mutually_exclusive_p (struct re_pattern_buffer *bufp, const_re_char *p1, |
| 4671 | const_re_char *p2) | ||
| 4667 | { | 4672 | { |
| 4668 | re_opcode_t op2; | 4673 | re_opcode_t op2; |
| 4669 | const boolean multibyte = RE_MULTIBYTE_P (bufp); | 4674 | const boolean multibyte = RE_MULTIBYTE_P (bufp); |
| @@ -4922,8 +4927,8 @@ WEAK_ALIAS (__re_match_2, re_match_2) | |||
| 4922 | /* This is a separate function so that we can force an alloca cleanup | 4927 | /* This is a separate function so that we can force an alloca cleanup |
| 4923 | afterwards. */ | 4928 | afterwards. */ |
| 4924 | static regoff_t | 4929 | static regoff_t |
| 4925 | re_match_2_internal (struct re_pattern_buffer *bufp, const re_char *string1, | 4930 | re_match_2_internal (struct re_pattern_buffer *bufp, const_re_char *string1, |
| 4926 | size_t size1, const re_char *string2, size_t size2, | 4931 | size_t size1, const_re_char *string2, size_t size2, |
| 4927 | ssize_t pos, struct re_registers *regs, ssize_t stop) | 4932 | ssize_t pos, struct re_registers *regs, ssize_t stop) |
| 4928 | { | 4933 | { |
| 4929 | /* General temporaries. */ | 4934 | /* General temporaries. */ |
| @@ -6265,7 +6270,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, const re_char *string1, | |||
| 6265 | bytes; nonzero otherwise. */ | 6270 | bytes; nonzero otherwise. */ |
| 6266 | 6271 | ||
| 6267 | static int | 6272 | static int |
| 6268 | bcmp_translate (const re_char *s1, const re_char *s2, register ssize_t len, | 6273 | bcmp_translate (const_re_char *s1, const_re_char *s2, register ssize_t len, |
| 6269 | RE_TRANSLATE_TYPE translate, const int target_multibyte) | 6274 | RE_TRANSLATE_TYPE translate, const int target_multibyte) |
| 6270 | { | 6275 | { |
| 6271 | register re_char *p1 = s1, *p2 = s2; | 6276 | register re_char *p1 = s1, *p2 = s2; |
| @@ -6434,7 +6439,7 @@ re_exec (const char *s) | |||
| 6434 | the return codes and their meanings.) */ | 6439 | the return codes and their meanings.) */ |
| 6435 | 6440 | ||
| 6436 | reg_errcode_t | 6441 | reg_errcode_t |
| 6437 | regcomp (regex_t *__restrict preg, const char *__restrict pattern, | 6442 | regcomp (regex_t *_Restrict_ preg, const char *_Restrict_ pattern, |
| 6438 | int cflags) | 6443 | int cflags) |
| 6439 | { | 6444 | { |
| 6440 | reg_errcode_t ret; | 6445 | reg_errcode_t ret; |
| @@ -6515,8 +6520,8 @@ WEAK_ALIAS (__regcomp, regcomp) | |||
| 6515 | We return 0 if we find a match and REG_NOMATCH if not. */ | 6520 | We return 0 if we find a match and REG_NOMATCH if not. */ |
| 6516 | 6521 | ||
| 6517 | reg_errcode_t | 6522 | reg_errcode_t |
| 6518 | regexec (const regex_t *__restrict preg, const char *__restrict string, | 6523 | regexec (const regex_t *_Restrict_ preg, const char *_Restrict_ string, |
| 6519 | size_t nmatch, regmatch_t pmatch[__restrict_arr], int eflags) | 6524 | size_t nmatch, regmatch_t pmatch[_Restrict_arr_], int eflags) |
| 6520 | { | 6525 | { |
| 6521 | regoff_t ret; | 6526 | regoff_t ret; |
| 6522 | struct re_registers regs; | 6527 | struct re_registers regs; |