diff options
| author | Eli Zaretskii | 2011-04-16 21:26:30 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2011-04-16 21:26:30 +0300 |
| commit | d1dfb56cc84a6d70262d979face230a71e98d479 (patch) | |
| tree | 8204edb64962a875b368dd248c00e127f9584b73 /src/regex.c | |
| parent | 10472dd0d62d986e048c01a3d37627b843a321d2 (diff) | |
| download | emacs-d1dfb56cc84a6d70262d979face230a71e98d479.tar.gz emacs-d1dfb56cc84a6d70262d979face230a71e98d479.zip | |
Fix regex.c, syntax.c and friends for buffers > 2GB.
src/syntax.h (struct gl_state_s): Declare character position members
EMACS_INT.
src/syntax.c (update_syntax_table): Declare 2nd argument EMACS_INT.
src/textprop.c (verify_interval_modification, interval_of): Declare
arguments EMACS_INT.
src/intervals.c (adjust_intervals_for_insertion): Declare arguments
EMACS_INT.
src/intervals.h (CHECK_TOTAL_LENGTH): Cast to EMACS_INT, not `int'.
src/indent.c (Fvertical_motion): Local variable it_start is now
EMACS_INT.
src/regex.c (re_match, re_match_2, re_match_2_internal)
(bcmp_translate, regcomp, regexec, print_double_string)
(group_in_compile_stack, re_search, re_search_2, regex_compile)
(re_compile_pattern, re_exec): Declare arguments and local
variables `size_t' and `ssize_t' and return values `regoff_t', as
appropriate.
(POP_FAILURE_REG_OR_COUNT) <pfreg>: Declare `long'.
(CHECK_INFINITE_LOOP) <failure>: Declare `ssize_t'.
<compile_stack_type>: `size' and `avail' are now `size_t'.
src/regex.h <regoff_t>: Use ssize_t, not int.
(re_search, re_search_2, re_match, re_match_2): Arguments that
specify buffer/string position and length are now ssize_t and
size_t. Return type is regoff_t.
Diffstat (limited to 'src/regex.c')
| -rw-r--r-- | src/regex.c | 141 |
1 files changed, 74 insertions, 67 deletions
diff --git a/src/regex.c b/src/regex.c index a60ff0ce35c..479239897bc 100644 --- a/src/regex.c +++ b/src/regex.c | |||
| @@ -569,12 +569,12 @@ typedef char boolean; | |||
| 569 | #define false 0 | 569 | #define false 0 |
| 570 | #define true 1 | 570 | #define true 1 |
| 571 | 571 | ||
| 572 | static int re_match_2_internal _RE_ARGS ((struct re_pattern_buffer *bufp, | 572 | static regoff_t re_match_2_internal _RE_ARGS ((struct re_pattern_buffer *bufp, |
| 573 | re_char *string1, int size1, | 573 | re_char *string1, size_t size1, |
| 574 | re_char *string2, int size2, | 574 | re_char *string2, size_t size2, |
| 575 | int pos, | 575 | ssize_t pos, |
| 576 | struct re_registers *regs, | 576 | struct re_registers *regs, |
| 577 | int stop)); | 577 | ssize_t stop)); |
| 578 | 578 | ||
| 579 | /* These are the command codes that appear in compiled regular | 579 | /* These are the command codes that appear in compiled regular |
| 580 | expressions. Some opcodes are followed by argument bytes. A | 580 | expressions. Some opcodes are followed by argument bytes. A |
| @@ -1230,10 +1230,10 @@ print_double_string (where, string1, size1, string2, size2) | |||
| 1230 | re_char *where; | 1230 | re_char *where; |
| 1231 | re_char *string1; | 1231 | re_char *string1; |
| 1232 | re_char *string2; | 1232 | re_char *string2; |
| 1233 | int size1; | 1233 | ssize_t size1; |
| 1234 | int size2; | 1234 | ssize_t size2; |
| 1235 | { | 1235 | { |
| 1236 | int this_char; | 1236 | ssize_t this_char; |
| 1237 | 1237 | ||
| 1238 | if (where == NULL) | 1238 | if (where == NULL) |
| 1239 | printf ("(null)"); | 1239 | printf ("(null)"); |
| @@ -1546,7 +1546,7 @@ do { \ | |||
| 1546 | /* Pop a saved register off the stack. */ | 1546 | /* Pop a saved register off the stack. */ |
| 1547 | #define POP_FAILURE_REG_OR_COUNT() \ | 1547 | #define POP_FAILURE_REG_OR_COUNT() \ |
| 1548 | do { \ | 1548 | do { \ |
| 1549 | int pfreg = POP_FAILURE_INT (); \ | 1549 | long pfreg = POP_FAILURE_INT (); \ |
| 1550 | if (pfreg == -1) \ | 1550 | if (pfreg == -1) \ |
| 1551 | { \ | 1551 | { \ |
| 1552 | /* It's a counter. */ \ | 1552 | /* It's a counter. */ \ |
| @@ -1568,7 +1568,7 @@ do { \ | |||
| 1568 | /* Check that we are not stuck in an infinite loop. */ | 1568 | /* Check that we are not stuck in an infinite loop. */ |
| 1569 | #define CHECK_INFINITE_LOOP(pat_cur, string_place) \ | 1569 | #define CHECK_INFINITE_LOOP(pat_cur, string_place) \ |
| 1570 | do { \ | 1570 | do { \ |
| 1571 | int failure = TOP_FAILURE_HANDLE (); \ | 1571 | ssize_t failure = TOP_FAILURE_HANDLE (); \ |
| 1572 | /* Check for infinite matching loops */ \ | 1572 | /* Check for infinite matching loops */ \ |
| 1573 | while (failure > 0 \ | 1573 | while (failure > 0 \ |
| 1574 | && (FAILURE_STR (failure) == string_place \ | 1574 | && (FAILURE_STR (failure) == string_place \ |
| @@ -1876,8 +1876,8 @@ typedef struct | |||
| 1876 | typedef struct | 1876 | typedef struct |
| 1877 | { | 1877 | { |
| 1878 | compile_stack_elt_t *stack; | 1878 | compile_stack_elt_t *stack; |
| 1879 | unsigned size; | 1879 | size_t size; |
| 1880 | unsigned avail; /* Offset of next open position. */ | 1880 | size_t avail; /* Offset of next open position. */ |
| 1881 | } compile_stack_type; | 1881 | } compile_stack_type; |
| 1882 | 1882 | ||
| 1883 | 1883 | ||
| @@ -2779,7 +2779,7 @@ regex_compile (const re_char *pattern, size_t size, reg_syntax_t syntax, struct | |||
| 2779 | if (many_times_ok) | 2779 | if (many_times_ok) |
| 2780 | { | 2780 | { |
| 2781 | boolean simple = skip_one_char (laststart) == b; | 2781 | boolean simple = skip_one_char (laststart) == b; |
| 2782 | unsigned int startoffset = 0; | 2782 | size_t startoffset = 0; |
| 2783 | re_opcode_t ofj = | 2783 | re_opcode_t ofj = |
| 2784 | /* Check if the loop can match the empty string. */ | 2784 | /* Check if the loop can match the empty string. */ |
| 2785 | (simple || !analyse_first (laststart, b, NULL, 0)) | 2785 | (simple || !analyse_first (laststart, b, NULL, 0)) |
| @@ -3361,7 +3361,7 @@ regex_compile (const re_char *pattern, size_t size, reg_syntax_t syntax, struct | |||
| 3361 | _____ _____ | 3361 | _____ _____ |
| 3362 | | | | | | 3362 | | | | | |
| 3363 | | v | v | 3363 | | v | v |
| 3364 | a | b | c | 3364 | a | b | c |
| 3365 | 3365 | ||
| 3366 | If we are at `b', then fixup_alt_jump right now points to a | 3366 | If we are at `b', then fixup_alt_jump right now points to a |
| 3367 | three-byte space after `a'. We'll put in the jump, set | 3367 | three-byte space after `a'. We'll put in the jump, set |
| @@ -3905,7 +3905,7 @@ at_endline_loc_p (const re_char *p, const re_char *pend, reg_syntax_t syntax) | |||
| 3905 | static boolean | 3905 | static boolean |
| 3906 | group_in_compile_stack (compile_stack_type compile_stack, regnum_t regnum) | 3906 | group_in_compile_stack (compile_stack_type compile_stack, regnum_t regnum) |
| 3907 | { | 3907 | { |
| 3908 | int this_element; | 3908 | ssize_t this_element; |
| 3909 | 3909 | ||
| 3910 | for (this_element = compile_stack.avail - 1; | 3910 | for (this_element = compile_stack.avail - 1; |
| 3911 | this_element >= 0; | 3911 | this_element >= 0; |
| @@ -4291,8 +4291,9 @@ WEAK_ALIAS (__re_set_registers, re_set_registers) | |||
| 4291 | /* Like re_search_2, below, but only one string is specified, and | 4291 | /* Like re_search_2, below, but only one string is specified, and |
| 4292 | doesn't let you say where to stop matching. */ | 4292 | doesn't let you say where to stop matching. */ |
| 4293 | 4293 | ||
| 4294 | int | 4294 | regoff_t |
| 4295 | re_search (struct re_pattern_buffer *bufp, const char *string, int size, int startpos, int range, struct re_registers *regs) | 4295 | re_search (struct re_pattern_buffer *bufp, const char *string, size_t size, |
| 4296 | ssize_t startpos, ssize_t range, struct re_registers *regs) | ||
| 4296 | { | 4297 | { |
| 4297 | return re_search_2 (bufp, NULL, 0, string, size, startpos, range, | 4298 | return re_search_2 (bufp, NULL, 0, string, size, startpos, range, |
| 4298 | regs, size); | 4299 | regs, size); |
| @@ -4328,16 +4329,18 @@ WEAK_ALIAS (__re_search, re_search) | |||
| 4328 | found, -1 if no match, or -2 if error (such as failure | 4329 | found, -1 if no match, or -2 if error (such as failure |
| 4329 | stack overflow). */ | 4330 | stack overflow). */ |
| 4330 | 4331 | ||
| 4331 | int | 4332 | regoff_t |
| 4332 | re_search_2 (struct re_pattern_buffer *bufp, const char *str1, int size1, const char *str2, int size2, int startpos, int range, struct re_registers *regs, int stop) | 4333 | re_search_2 (struct re_pattern_buffer *bufp, const char *str1, size_t size1, |
| 4334 | const char *str2, size_t size2, ssize_t startpos, ssize_t range, | ||
| 4335 | struct re_registers *regs, ssize_t stop) | ||
| 4333 | { | 4336 | { |
| 4334 | int val; | 4337 | regoff_t val; |
| 4335 | re_char *string1 = (re_char*) str1; | 4338 | re_char *string1 = (re_char*) str1; |
| 4336 | re_char *string2 = (re_char*) str2; | 4339 | re_char *string2 = (re_char*) str2; |
| 4337 | register char *fastmap = bufp->fastmap; | 4340 | register char *fastmap = bufp->fastmap; |
| 4338 | register RE_TRANSLATE_TYPE translate = bufp->translate; | 4341 | register RE_TRANSLATE_TYPE translate = bufp->translate; |
| 4339 | int total_size = size1 + size2; | 4342 | size_t total_size = size1 + size2; |
| 4340 | int endpos = startpos + range; | 4343 | ssize_t endpos = startpos + range; |
| 4341 | boolean anchored_start; | 4344 | boolean anchored_start; |
| 4342 | /* Nonzero if we are searching multibyte string. */ | 4345 | /* Nonzero if we are searching multibyte string. */ |
| 4343 | const boolean multibyte = RE_TARGET_MULTIBYTE_P (bufp); | 4346 | const boolean multibyte = RE_TARGET_MULTIBYTE_P (bufp); |
| @@ -4385,7 +4388,7 @@ re_search_2 (struct re_pattern_buffer *bufp, const char *str1, int size1, const | |||
| 4385 | #ifdef emacs | 4388 | #ifdef emacs |
| 4386 | gl_state.object = re_match_object; /* Used by SYNTAX_TABLE_BYTE_TO_CHAR. */ | 4389 | gl_state.object = re_match_object; /* Used by SYNTAX_TABLE_BYTE_TO_CHAR. */ |
| 4387 | { | 4390 | { |
| 4388 | int charpos = SYNTAX_TABLE_BYTE_TO_CHAR (POS_AS_IN_BUFFER (startpos)); | 4391 | ssize_t charpos = SYNTAX_TABLE_BYTE_TO_CHAR (POS_AS_IN_BUFFER (startpos)); |
| 4389 | 4392 | ||
| 4390 | SETUP_SYNTAX_TABLE_FOR_OBJECT (re_match_object, charpos, 1); | 4393 | SETUP_SYNTAX_TABLE_FOR_OBJECT (re_match_object, charpos, 1); |
| 4391 | } | 4394 | } |
| @@ -4420,7 +4423,7 @@ re_search_2 (struct re_pattern_buffer *bufp, const char *str1, int size1, const | |||
| 4420 | if (range > 0) /* Searching forwards. */ | 4423 | if (range > 0) /* Searching forwards. */ |
| 4421 | { | 4424 | { |
| 4422 | register int lim = 0; | 4425 | register int lim = 0; |
| 4423 | int irange = range; | 4426 | ssize_t irange = range; |
| 4424 | 4427 | ||
| 4425 | if (startpos < size1 && startpos + range >= size1) | 4428 | if (startpos < size1 && startpos + range >= size1) |
| 4426 | lim = range - (size1 - startpos); | 4429 | lim = range - (size1 - startpos); |
| @@ -4571,7 +4574,7 @@ WEAK_ALIAS (__re_search_2, re_search_2) | |||
| 4571 | /* Declarations and macros for re_match_2. */ | 4574 | /* Declarations and macros for re_match_2. */ |
| 4572 | 4575 | ||
| 4573 | static int bcmp_translate _RE_ARGS((re_char *s1, re_char *s2, | 4576 | static int bcmp_translate _RE_ARGS((re_char *s1, re_char *s2, |
| 4574 | register int len, | 4577 | register ssize_t len, |
| 4575 | RE_TRANSLATE_TYPE translate, | 4578 | RE_TRANSLATE_TYPE translate, |
| 4576 | const int multibyte)); | 4579 | const int multibyte)); |
| 4577 | 4580 | ||
| @@ -4873,11 +4876,11 @@ mutually_exclusive_p (struct re_pattern_buffer *bufp, const re_char *p1, const r | |||
| 4873 | && ((p2[2 + idx] & ~ p1[2 + idx]) == 0)))) | 4876 | && ((p2[2 + idx] & ~ p1[2 + idx]) == 0)))) |
| 4874 | break; | 4877 | break; |
| 4875 | 4878 | ||
| 4876 | if (idx == p2[1]) | 4879 | if (idx == p2[1]) |
| 4877 | { | 4880 | { |
| 4878 | DEBUG_PRINT1 (" No match => fast loop.\n"); | 4881 | DEBUG_PRINT1 (" No match => fast loop.\n"); |
| 4879 | return 1; | 4882 | return 1; |
| 4880 | } | 4883 | } |
| 4881 | } | 4884 | } |
| 4882 | } | 4885 | } |
| 4883 | } | 4886 | } |
| @@ -4941,12 +4944,12 @@ mutually_exclusive_p (struct re_pattern_buffer *bufp, const re_char *p1, const r | |||
| 4941 | #ifndef emacs /* Emacs never uses this. */ | 4944 | #ifndef emacs /* Emacs never uses this. */ |
| 4942 | /* re_match is like re_match_2 except it takes only a single string. */ | 4945 | /* re_match is like re_match_2 except it takes only a single string. */ |
| 4943 | 4946 | ||
| 4944 | int | 4947 | regoff_t |
| 4945 | re_match (struct re_pattern_buffer *bufp, const char *string, | 4948 | re_match (struct re_pattern_buffer *bufp, const char *string, |
| 4946 | int size, int pos, struct re_registers *regs) | 4949 | size_t size, ssize_t pos, struct re_registers *regs) |
| 4947 | { | 4950 | { |
| 4948 | int result = re_match_2_internal (bufp, NULL, 0, (re_char*) string, size, | 4951 | regoff_t result = re_match_2_internal (bufp, NULL, 0, (re_char*) string, |
| 4949 | pos, regs, size); | 4952 | size, pos, regs, size); |
| 4950 | return result; | 4953 | return result; |
| 4951 | } | 4954 | } |
| 4952 | WEAK_ALIAS (__re_match, re_match) | 4955 | WEAK_ALIAS (__re_match, re_match) |
| @@ -4971,13 +4974,15 @@ Lisp_Object re_match_object; | |||
| 4971 | failure stack overflowing). Otherwise, we return the length of the | 4974 | failure stack overflowing). Otherwise, we return the length of the |
| 4972 | matched substring. */ | 4975 | matched substring. */ |
| 4973 | 4976 | ||
| 4974 | int | 4977 | regoff_t |
| 4975 | re_match_2 (struct re_pattern_buffer *bufp, const char *string1, int size1, const char *string2, int size2, int pos, struct re_registers *regs, int stop) | 4978 | re_match_2 (struct re_pattern_buffer *bufp, const char *string1, |
| 4979 | size_t size1, const char *string2, size_t size2, ssize_t pos, | ||
| 4980 | struct re_registers *regs, ssize_t stop) | ||
| 4976 | { | 4981 | { |
| 4977 | int result; | 4982 | regoff_t result; |
| 4978 | 4983 | ||
| 4979 | #ifdef emacs | 4984 | #ifdef emacs |
| 4980 | int charpos; | 4985 | ssize_t charpos; |
| 4981 | gl_state.object = re_match_object; /* Used by SYNTAX_TABLE_BYTE_TO_CHAR. */ | 4986 | gl_state.object = re_match_object; /* Used by SYNTAX_TABLE_BYTE_TO_CHAR. */ |
| 4982 | charpos = SYNTAX_TABLE_BYTE_TO_CHAR (POS_AS_IN_BUFFER (pos)); | 4987 | charpos = SYNTAX_TABLE_BYTE_TO_CHAR (POS_AS_IN_BUFFER (pos)); |
| 4983 | SETUP_SYNTAX_TABLE_FOR_OBJECT (re_match_object, charpos, 1); | 4988 | SETUP_SYNTAX_TABLE_FOR_OBJECT (re_match_object, charpos, 1); |
| @@ -4993,11 +4998,13 @@ WEAK_ALIAS (__re_match_2, re_match_2) | |||
| 4993 | 4998 | ||
| 4994 | /* This is a separate function so that we can force an alloca cleanup | 4999 | /* This is a separate function so that we can force an alloca cleanup |
| 4995 | afterwards. */ | 5000 | afterwards. */ |
| 4996 | static int | 5001 | static regoff_t |
| 4997 | re_match_2_internal (struct re_pattern_buffer *bufp, const re_char *string1, int size1, const re_char *string2, int size2, int pos, struct re_registers *regs, int stop) | 5002 | re_match_2_internal (struct re_pattern_buffer *bufp, const re_char *string1, |
| 5003 | size_t size1, const re_char *string2, size_t size2, | ||
| 5004 | ssize_t pos, struct re_registers *regs, ssize_t stop) | ||
| 4998 | { | 5005 | { |
| 4999 | /* General temporaries. */ | 5006 | /* General temporaries. */ |
| 5000 | int mcnt; | 5007 | ssize_t mcnt; |
| 5001 | size_t reg; | 5008 | size_t reg; |
| 5002 | 5009 | ||
| 5003 | /* Just past the end of the corresponding string. */ | 5010 | /* Just past the end of the corresponding string. */ |
| @@ -5996,8 +6003,8 @@ re_match_2_internal (struct re_pattern_buffer *bufp, const re_char *string1, int | |||
| 5996 | int s1, s2; | 6003 | int s1, s2; |
| 5997 | int dummy; | 6004 | int dummy; |
| 5998 | #ifdef emacs | 6005 | #ifdef emacs |
| 5999 | int offset = PTR_TO_OFFSET (d - 1); | 6006 | ssize_t offset = PTR_TO_OFFSET (d - 1); |
| 6000 | int charpos = SYNTAX_TABLE_BYTE_TO_CHAR (offset); | 6007 | ssize_t charpos = SYNTAX_TABLE_BYTE_TO_CHAR (offset); |
| 6001 | UPDATE_SYNTAX_TABLE (charpos); | 6008 | UPDATE_SYNTAX_TABLE (charpos); |
| 6002 | #endif | 6009 | #endif |
| 6003 | GET_CHAR_BEFORE_2 (c1, d, string1, end1, string2, end2); | 6010 | GET_CHAR_BEFORE_2 (c1, d, string1, end1, string2, end2); |
| @@ -6038,8 +6045,8 @@ re_match_2_internal (struct re_pattern_buffer *bufp, const re_char *string1, int | |||
| 6038 | int s1, s2; | 6045 | int s1, s2; |
| 6039 | int dummy; | 6046 | int dummy; |
| 6040 | #ifdef emacs | 6047 | #ifdef emacs |
| 6041 | int offset = PTR_TO_OFFSET (d); | 6048 | ssize_t offset = PTR_TO_OFFSET (d); |
| 6042 | int charpos = SYNTAX_TABLE_BYTE_TO_CHAR (offset); | 6049 | ssize_t charpos = SYNTAX_TABLE_BYTE_TO_CHAR (offset); |
| 6043 | UPDATE_SYNTAX_TABLE (charpos); | 6050 | UPDATE_SYNTAX_TABLE (charpos); |
| 6044 | #endif | 6051 | #endif |
| 6045 | PREFETCH (); | 6052 | PREFETCH (); |
| @@ -6083,8 +6090,8 @@ re_match_2_internal (struct re_pattern_buffer *bufp, const re_char *string1, int | |||
| 6083 | int s1, s2; | 6090 | int s1, s2; |
| 6084 | int dummy; | 6091 | int dummy; |
| 6085 | #ifdef emacs | 6092 | #ifdef emacs |
| 6086 | int offset = PTR_TO_OFFSET (d) - 1; | 6093 | ssize_t offset = PTR_TO_OFFSET (d) - 1; |
| 6087 | int charpos = SYNTAX_TABLE_BYTE_TO_CHAR (offset); | 6094 | ssize_t charpos = SYNTAX_TABLE_BYTE_TO_CHAR (offset); |
| 6088 | UPDATE_SYNTAX_TABLE (charpos); | 6095 | UPDATE_SYNTAX_TABLE (charpos); |
| 6089 | #endif | 6096 | #endif |
| 6090 | GET_CHAR_BEFORE_2 (c1, d, string1, end1, string2, end2); | 6097 | GET_CHAR_BEFORE_2 (c1, d, string1, end1, string2, end2); |
| @@ -6127,8 +6134,8 @@ re_match_2_internal (struct re_pattern_buffer *bufp, const re_char *string1, int | |||
| 6127 | re_wchar_t c1, c2; | 6134 | re_wchar_t c1, c2; |
| 6128 | int s1, s2; | 6135 | int s1, s2; |
| 6129 | #ifdef emacs | 6136 | #ifdef emacs |
| 6130 | int offset = PTR_TO_OFFSET (d); | 6137 | ssize_t offset = PTR_TO_OFFSET (d); |
| 6131 | int charpos = SYNTAX_TABLE_BYTE_TO_CHAR (offset); | 6138 | ssize_t charpos = SYNTAX_TABLE_BYTE_TO_CHAR (offset); |
| 6132 | UPDATE_SYNTAX_TABLE (charpos); | 6139 | UPDATE_SYNTAX_TABLE (charpos); |
| 6133 | #endif | 6140 | #endif |
| 6134 | PREFETCH (); | 6141 | PREFETCH (); |
| @@ -6170,8 +6177,8 @@ re_match_2_internal (struct re_pattern_buffer *bufp, const re_char *string1, int | |||
| 6170 | re_wchar_t c1, c2; | 6177 | re_wchar_t c1, c2; |
| 6171 | int s1, s2; | 6178 | int s1, s2; |
| 6172 | #ifdef emacs | 6179 | #ifdef emacs |
| 6173 | int offset = PTR_TO_OFFSET (d) - 1; | 6180 | ssize_t offset = PTR_TO_OFFSET (d) - 1; |
| 6174 | int charpos = SYNTAX_TABLE_BYTE_TO_CHAR (offset); | 6181 | ssize_t charpos = SYNTAX_TABLE_BYTE_TO_CHAR (offset); |
| 6175 | UPDATE_SYNTAX_TABLE (charpos); | 6182 | UPDATE_SYNTAX_TABLE (charpos); |
| 6176 | #endif | 6183 | #endif |
| 6177 | GET_CHAR_BEFORE_2 (c1, d, string1, end1, string2, end2); | 6184 | GET_CHAR_BEFORE_2 (c1, d, string1, end1, string2, end2); |
| @@ -6207,8 +6214,8 @@ re_match_2_internal (struct re_pattern_buffer *bufp, const re_char *string1, int | |||
| 6207 | PREFETCH (); | 6214 | PREFETCH (); |
| 6208 | #ifdef emacs | 6215 | #ifdef emacs |
| 6209 | { | 6216 | { |
| 6210 | int offset = PTR_TO_OFFSET (d); | 6217 | ssize_t offset = PTR_TO_OFFSET (d); |
| 6211 | int pos1 = SYNTAX_TABLE_BYTE_TO_CHAR (offset); | 6218 | ssize_t pos1 = SYNTAX_TABLE_BYTE_TO_CHAR (offset); |
| 6212 | UPDATE_SYNTAX_TABLE (pos1); | 6219 | UPDATE_SYNTAX_TABLE (pos1); |
| 6213 | } | 6220 | } |
| 6214 | #endif | 6221 | #endif |
| @@ -6331,7 +6338,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, const re_char *string1, int | |||
| 6331 | bytes; nonzero otherwise. */ | 6338 | bytes; nonzero otherwise. */ |
| 6332 | 6339 | ||
| 6333 | static int | 6340 | static int |
| 6334 | bcmp_translate (const re_char *s1, const re_char *s2, register int len, | 6341 | bcmp_translate (const re_char *s1, const re_char *s2, register ssize_t len, |
| 6335 | RE_TRANSLATE_TYPE translate, const int target_multibyte) | 6342 | RE_TRANSLATE_TYPE translate, const int target_multibyte) |
| 6336 | { | 6343 | { |
| 6337 | register re_char *p1 = s1, *p2 = s2; | 6344 | register re_char *p1 = s1, *p2 = s2; |
| @@ -6373,7 +6380,8 @@ bcmp_translate (const re_char *s1, const re_char *s2, register int len, | |||
| 6373 | We call regex_compile to do the actual compilation. */ | 6380 | We call regex_compile to do the actual compilation. */ |
| 6374 | 6381 | ||
| 6375 | const char * | 6382 | const char * |
| 6376 | re_compile_pattern (const char *pattern, size_t length, struct re_pattern_buffer *bufp) | 6383 | re_compile_pattern (const char *pattern, size_t length, |
| 6384 | struct re_pattern_buffer *bufp) | ||
| 6377 | { | 6385 | { |
| 6378 | reg_errcode_t ret; | 6386 | reg_errcode_t ret; |
| 6379 | 6387 | ||
| @@ -6449,14 +6457,13 @@ re_comp (s) | |||
| 6449 | } | 6457 | } |
| 6450 | 6458 | ||
| 6451 | 6459 | ||
| 6452 | int | 6460 | regoff_t |
| 6453 | # ifdef _LIBC | 6461 | # ifdef _LIBC |
| 6454 | weak_function | 6462 | weak_function |
| 6455 | # endif | 6463 | # endif |
| 6456 | re_exec (s) | 6464 | re_exec (const char *s) |
| 6457 | const char *s; | ||
| 6458 | { | 6465 | { |
| 6459 | const int len = strlen (s); | 6466 | const size_t len = strlen (s); |
| 6460 | return | 6467 | return |
| 6461 | 0 <= re_search (&re_comp_buf, s, len, 0, len, (struct re_registers *) 0); | 6468 | 0 <= re_search (&re_comp_buf, s, len, 0, len, (struct re_registers *) 0); |
| 6462 | } | 6469 | } |
| @@ -6500,7 +6507,7 @@ re_exec (s) | |||
| 6500 | It returns 0 if it succeeds, nonzero if it doesn't. (See regex.h for | 6507 | It returns 0 if it succeeds, nonzero if it doesn't. (See regex.h for |
| 6501 | the return codes and their meanings.) */ | 6508 | the return codes and their meanings.) */ |
| 6502 | 6509 | ||
| 6503 | int | 6510 | reg_errcode_t |
| 6504 | regcomp (regex_t *__restrict preg, const char *__restrict pattern, | 6511 | regcomp (regex_t *__restrict preg, const char *__restrict pattern, |
| 6505 | int cflags) | 6512 | int cflags) |
| 6506 | { | 6513 | { |
| @@ -6564,7 +6571,7 @@ regcomp (regex_t *__restrict preg, const char *__restrict pattern, | |||
| 6564 | preg->fastmap = NULL; | 6571 | preg->fastmap = NULL; |
| 6565 | } | 6572 | } |
| 6566 | } | 6573 | } |
| 6567 | return (int) ret; | 6574 | return ret; |
| 6568 | } | 6575 | } |
| 6569 | WEAK_ALIAS (__regcomp, regcomp) | 6576 | WEAK_ALIAS (__regcomp, regcomp) |
| 6570 | 6577 | ||
| @@ -6583,14 +6590,14 @@ WEAK_ALIAS (__regcomp, regcomp) | |||
| 6583 | 6590 | ||
| 6584 | We return 0 if we find a match and REG_NOMATCH if not. */ | 6591 | We return 0 if we find a match and REG_NOMATCH if not. */ |
| 6585 | 6592 | ||
| 6586 | int | 6593 | reg_errcode_t |
| 6587 | regexec (const regex_t *__restrict preg, const char *__restrict string, | 6594 | regexec (const regex_t *__restrict preg, const char *__restrict string, |
| 6588 | size_t nmatch, regmatch_t pmatch[__restrict_arr], int eflags) | 6595 | size_t nmatch, regmatch_t pmatch[__restrict_arr], int eflags) |
| 6589 | { | 6596 | { |
| 6590 | int ret; | 6597 | reg_errcode_t ret; |
| 6591 | struct re_registers regs; | 6598 | struct re_registers regs; |
| 6592 | regex_t private_preg; | 6599 | regex_t private_preg; |
| 6593 | int len = strlen (string); | 6600 | size_t len = strlen (string); |
| 6594 | boolean want_reg_info = !preg->no_sub && nmatch > 0 && pmatch; | 6601 | boolean want_reg_info = !preg->no_sub && nmatch > 0 && pmatch; |
| 6595 | 6602 | ||
| 6596 | private_preg = *preg; | 6603 | private_preg = *preg; |
| @@ -6608,7 +6615,7 @@ regexec (const regex_t *__restrict preg, const char *__restrict string, | |||
| 6608 | regs.num_regs = nmatch; | 6615 | regs.num_regs = nmatch; |
| 6609 | regs.start = TALLOC (nmatch * 2, regoff_t); | 6616 | regs.start = TALLOC (nmatch * 2, regoff_t); |
| 6610 | if (regs.start == NULL) | 6617 | if (regs.start == NULL) |
| 6611 | return (int) REG_NOMATCH; | 6618 | return REG_NOMATCH; |
| 6612 | regs.end = regs.start + nmatch; | 6619 | regs.end = regs.start + nmatch; |
| 6613 | } | 6620 | } |
| 6614 | 6621 | ||
| @@ -6645,7 +6652,7 @@ regexec (const regex_t *__restrict preg, const char *__restrict string, | |||
| 6645 | } | 6652 | } |
| 6646 | 6653 | ||
| 6647 | /* We want zero return to mean success, unlike `re_search'. */ | 6654 | /* We want zero return to mean success, unlike `re_search'. */ |
| 6648 | return ret >= 0 ? (int) REG_NOERROR : (int) REG_NOMATCH; | 6655 | return ret >= 0 ? REG_NOERROR : REG_NOMATCH; |
| 6649 | } | 6656 | } |
| 6650 | WEAK_ALIAS (__regexec, regexec) | 6657 | WEAK_ALIAS (__regexec, regexec) |
| 6651 | 6658 | ||