comparison src/regex.c @ 647:b39c14581166

[xemacs-hg @ 2001-08-13 04:45:47 by ben] removal of unsigned, size_t, etc.
author ben
date Mon, 13 Aug 2001 04:46:48 +0000
parents e9a3f8b4de53
children e44bbdb4e51f
comparison
equal deleted inserted replaced
646:00c54252fe4f 647:b39c14581166
178 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_"; 178 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
179 179
180 memset (re_syntax_table, 0, sizeof (re_syntax_table)); 180 memset (re_syntax_table, 0, sizeof (re_syntax_table));
181 181
182 while (*word_syntax_chars) 182 while (*word_syntax_chars)
183 re_syntax_table[(unsigned int)(*word_syntax_chars++)] = Sword; 183 re_syntax_table[(unsigned int) (*word_syntax_chars++)] = Sword;
184 184
185 done = 1; 185 done = 1;
186 } 186 }
187 } 187 }
188 188
645 /* Print the fastmap in human-readable form. */ 645 /* Print the fastmap in human-readable form. */
646 646
647 static void 647 static void
648 print_fastmap (char *fastmap) 648 print_fastmap (char *fastmap)
649 { 649 {
650 unsigned was_a_range = 0; 650 int was_a_range = 0;
651 unsigned i = 0; 651 int i = 0;
652 652
653 while (i < (1 << BYTEWIDTH)) 653 while (i < (1 << BYTEWIDTH))
654 { 654 {
655 if (fastmap[i++]) 655 if (fastmap[i++])
656 { 656 {
1004 { 1004 {
1005 if (where == NULL) 1005 if (where == NULL)
1006 printf ("(null)"); 1006 printf ("(null)");
1007 else 1007 else
1008 { 1008 {
1009 unsigned int this_char; 1009 int this_char;
1010 1010
1011 if (FIRST_STRING_P (where)) 1011 if (FIRST_STRING_P (where))
1012 { 1012 {
1013 for (this_char = where - string1; this_char < size1; this_char++) 1013 for (this_char = where - string1; this_char < size1; this_char++)
1014 putchar (string1[this_char]); 1014 putchar (string1[this_char]);
1164 typedef union fail_stack_elt fail_stack_elt_t; 1164 typedef union fail_stack_elt fail_stack_elt_t;
1165 1165
1166 typedef struct 1166 typedef struct
1167 { 1167 {
1168 fail_stack_elt_t *stack; 1168 fail_stack_elt_t *stack;
1169 size_t size; 1169 Element_Count size;
1170 size_t avail; /* Offset of next open position. */ 1170 Element_Count avail; /* Offset of next open position. */
1171 } fail_stack_type; 1171 } fail_stack_type;
1172 1172
1173 #define FAIL_STACK_EMPTY() (fail_stack.avail == 0) 1173 #define FAIL_STACK_EMPTY() (fail_stack.avail == 0)
1174 #define FAIL_STACK_PTR_EMPTY() (fail_stack_ptr->avail == 0) 1174 #define FAIL_STACK_PTR_EMPTY() (fail_stack_ptr->avail == 0)
1175 #define FAIL_STACK_FULL() (fail_stack.avail == fail_stack.size) 1175 #define FAIL_STACK_FULL() (fail_stack.avail == fail_stack.size)
1289 of 0 + -1 isn't done as unsigned. */ \ 1289 of 0 + -1 isn't done as unsigned. */ \
1290 int this_reg; \ 1290 int this_reg; \
1291 \ 1291 \
1292 DEBUG_STATEMENT (failure_id++); \ 1292 DEBUG_STATEMENT (failure_id++); \
1293 DEBUG_STATEMENT (nfailure_points_pushed++); \ 1293 DEBUG_STATEMENT (nfailure_points_pushed++); \
1294 DEBUG_PRINT2 ("\nPUSH_FAILURE_POINT #%u:\n", failure_id); \ 1294 DEBUG_PRINT2 ("\nPUSH_FAILURE_POINT #%d:\n", failure_id); \
1295 DEBUG_PRINT2 (" Before push, next avail: %lu\n", \ 1295 DEBUG_PRINT2 (" Before push, next avail: %ld\n", \
1296 (unsigned long) (fail_stack).avail); \ 1296 (long) (fail_stack).avail); \
1297 DEBUG_PRINT2 (" size: %lu\n", \ 1297 DEBUG_PRINT2 (" size: %ld\n", \
1298 (unsigned long) (fail_stack).size); \ 1298 (long) (fail_stack).size); \
1299 \ 1299 \
1300 DEBUG_PRINT2 (" slots needed: %d\n", NUM_FAILURE_ITEMS); \ 1300 DEBUG_PRINT2 (" slots needed: %d\n", NUM_FAILURE_ITEMS); \
1301 DEBUG_PRINT2 (" available: %ld\n", \ 1301 DEBUG_PRINT2 (" available: %ld\n", \
1302 (long) REMAINING_AVAIL_SLOTS); \ 1302 (long) REMAINING_AVAIL_SLOTS); \
1303 \ 1303 \
1305 while (REMAINING_AVAIL_SLOTS < NUM_FAILURE_ITEMS) \ 1305 while (REMAINING_AVAIL_SLOTS < NUM_FAILURE_ITEMS) \
1306 { \ 1306 { \
1307 if (!DOUBLE_FAIL_STACK (fail_stack)) \ 1307 if (!DOUBLE_FAIL_STACK (fail_stack)) \
1308 return failure_code; \ 1308 return failure_code; \
1309 \ 1309 \
1310 DEBUG_PRINT2 ("\n Doubled stack; size now: %lu\n", \ 1310 DEBUG_PRINT2 ("\n Doubled stack; size now: %ld\n", \
1311 (unsigned long) (fail_stack).size); \ 1311 (long) (fail_stack).size); \
1312 DEBUG_PRINT2 (" slots available: %ld\n", \ 1312 DEBUG_PRINT2 (" slots available: %ld\n", \
1313 (long) REMAINING_AVAIL_SLOTS); \ 1313 (long) REMAINING_AVAIL_SLOTS); \
1314 } \ 1314 } \
1315 \ 1315 \
1316 /* Push the info, starting with the registers. */ \ 1316 /* Push the info, starting with the registers. */ \
1408 \ 1408 \
1409 assert (!FAIL_STACK_EMPTY ()); \ 1409 assert (!FAIL_STACK_EMPTY ()); \
1410 \ 1410 \
1411 /* Remove failure points and point to how many regs pushed. */ \ 1411 /* Remove failure points and point to how many regs pushed. */ \
1412 DEBUG_PRINT1 ("POP_FAILURE_POINT:\n"); \ 1412 DEBUG_PRINT1 ("POP_FAILURE_POINT:\n"); \
1413 DEBUG_PRINT2 (" Before pop, next avail: %lu\n", \ 1413 DEBUG_PRINT2 (" Before pop, next avail: %ld\n", \
1414 (unsigned long) fail_stack.avail); \ 1414 (long) fail_stack.avail); \
1415 DEBUG_PRINT2 (" size: %lu\n", \ 1415 DEBUG_PRINT2 (" size: %ld\n", \
1416 (unsigned long) fail_stack.size); \ 1416 (long) fail_stack.size); \
1417 \ 1417 \
1418 assert (fail_stack.avail >= NUM_NONREG_ITEMS); \ 1418 assert (fail_stack.avail >= NUM_NONREG_ITEMS); \
1419 \ 1419 \
1420 DEBUG_POP (&ffailure_id.integer); \ 1420 DEBUG_POP (&ffailure_id.integer); \
1421 DEBUG_PRINT2 (" Popping failure id: %u\n", \ 1421 DEBUG_PRINT2 (" Popping failure id: %d\n", \
1422 * (unsigned int *) &ffailure_id); \ 1422 * (int *) &ffailure_id); \
1423 \ 1423 \
1424 /* If the saved string location is NULL, it came from an \ 1424 /* If the saved string location is NULL, it came from an \
1425 on_failure_keep_string_jump opcode, and we want to throw away the \ 1425 on_failure_keep_string_jump opcode, and we want to throw away the \
1426 saved NULL, thus retaining our current position in the string. */ \ 1426 saved NULL, thus retaining our current position in the string. */ \
1427 string_temp = POP_FAILURE_POINTER (); \ 1427 string_temp = POP_FAILURE_POINTER (); \
1435 pat = (unsigned char *) POP_FAILURE_POINTER (); \ 1435 pat = (unsigned char *) POP_FAILURE_POINTER (); \
1436 DEBUG_PRINT2 (" Popping pattern 0x%lx: ", (long) pat); \ 1436 DEBUG_PRINT2 (" Popping pattern 0x%lx: ", (long) pat); \
1437 DEBUG_PRINT_COMPILED_PATTERN (bufp, pat, pend); \ 1437 DEBUG_PRINT_COMPILED_PATTERN (bufp, pat, pend); \
1438 \ 1438 \
1439 /* Restore register info. */ \ 1439 /* Restore register info. */ \
1440 high_reg = (unsigned) POP_FAILURE_INT (); \ 1440 high_reg = POP_FAILURE_INT (); \
1441 DEBUG_PRINT2 (" Popping high active reg: %d\n", high_reg); \ 1441 DEBUG_PRINT2 (" Popping high active reg: %d\n", high_reg); \
1442 \ 1442 \
1443 low_reg = (unsigned) POP_FAILURE_INT (); \ 1443 low_reg = POP_FAILURE_INT (); \
1444 DEBUG_PRINT2 (" Popping low active reg: %d\n", low_reg); \ 1444 DEBUG_PRINT2 (" Popping low active reg: %d\n", low_reg); \
1445 \ 1445 \
1446 for (this_reg = high_reg; this_reg >= low_reg; this_reg--) \ 1446 for (this_reg = high_reg; this_reg >= low_reg; this_reg--) \
1447 { \ 1447 { \
1448 DEBUG_PRINT2 (" Popping reg: %d\n", this_reg); \ 1448 DEBUG_PRINT2 (" Popping reg: %d\n", this_reg); \
1481 struct 1481 struct
1482 { 1482 {
1483 /* This field is one if this group can match the empty string, 1483 /* This field is one if this group can match the empty string,
1484 zero if not. If not yet determined, `MATCH_NULL_UNSET_VALUE'. */ 1484 zero if not. If not yet determined, `MATCH_NULL_UNSET_VALUE'. */
1485 #define MATCH_NULL_UNSET_VALUE 3 1485 #define MATCH_NULL_UNSET_VALUE 3
1486 unsigned match_null_string_p : 2; 1486 unsigned int match_null_string_p : 2;
1487 unsigned is_active : 1; 1487 unsigned int is_active : 1;
1488 unsigned matched_something : 1; 1488 unsigned int matched_something : 1;
1489 unsigned ever_matched_something : 1; 1489 unsigned int ever_matched_something : 1;
1490 } bits; 1490 } bits;
1491 } register_info_type; 1491 } register_info_type;
1492 1492
1493 #define REG_MATCH_NULL_STRING_P(R) ((R).bits.match_null_string_p) 1493 #define REG_MATCH_NULL_STRING_P(R) ((R).bits.match_null_string_p)
1494 #define IS_ACTIVE(R) ((R).bits.is_active) 1494 #define IS_ACTIVE(R) ((R).bits.is_active)
1502 #define SET_REGS_MATCHED() \ 1502 #define SET_REGS_MATCHED() \
1503 do \ 1503 do \
1504 { \ 1504 { \
1505 if (!set_regs_matched_done) \ 1505 if (!set_regs_matched_done) \
1506 { \ 1506 { \
1507 unsigned r; \ 1507 int r; \
1508 set_regs_matched_done = 1; \ 1508 set_regs_matched_done = 1; \
1509 for (r = lowest_active_reg; r <= highest_active_reg; r++) \ 1509 for (r = lowest_active_reg; r <= highest_active_reg; r++) \
1510 { \ 1510 { \
1511 MATCHED_SOMETHING (reg_info[r]) \ 1511 MATCHED_SOMETHING (reg_info[r]) \
1512 = EVER_MATCHED_SOMETHING (reg_info[r]) \ 1512 = EVER_MATCHED_SOMETHING (reg_info[r]) \
1615 /* If the buffer isn't allocated when it comes in, use this. */ 1615 /* If the buffer isn't allocated when it comes in, use this. */
1616 #define INIT_BUF_SIZE 32 1616 #define INIT_BUF_SIZE 32
1617 1617
1618 /* Make sure we have at least N more bytes of space in buffer. */ 1618 /* Make sure we have at least N more bytes of space in buffer. */
1619 #define GET_BUFFER_SPACE(n) \ 1619 #define GET_BUFFER_SPACE(n) \
1620 while (buf_end - bufp->buffer + (n) > bufp->allocated) \ 1620 while (buf_end - bufp->buffer + (n) > (ptrdiff_t) bufp->allocated) \
1621 EXTEND_BUFFER () 1621 EXTEND_BUFFER ()
1622 1622
1623 /* Make sure we have one more byte of buffer space and then add C to it. */ 1623 /* Make sure we have one more byte of buffer space and then add C to it. */
1624 #define BUF_PUSH(c) \ 1624 #define BUF_PUSH(c) \
1625 do { \ 1625 do { \
1711 /* But patterns can have more than `MAX_REGNUM' registers. We just 1711 /* But patterns can have more than `MAX_REGNUM' registers. We just
1712 ignore the excess. 1712 ignore the excess.
1713 #### not true! groups past this will fail in lots of ways, if we 1713 #### not true! groups past this will fail in lots of ways, if we
1714 ever have to backtrack. 1714 ever have to backtrack.
1715 */ 1715 */
1716 typedef unsigned regnum_t; 1716 typedef int regnum_t;
1717 1717
1718 #define INIT_REG_TRANSLATE_SIZE 5 1718 #define INIT_REG_TRANSLATE_SIZE 5
1719 1719
1720 /* Macros for the compile stack. */ 1720 /* Macros for the compile stack. */
1721 1721
1734 1734
1735 1735
1736 typedef struct 1736 typedef struct
1737 { 1737 {
1738 compile_stack_elt_t *stack; 1738 compile_stack_elt_t *stack;
1739 unsigned size; 1739 int size;
1740 unsigned avail; /* Offset of next open position. */ 1740 int avail; /* Offset of next open position. */
1741 } compile_stack_type; 1741 } compile_stack_type;
1742 1742
1743 1743
1744 #define INIT_COMPILE_STACK_SIZE 32 1744 #define INIT_COMPILE_STACK_SIZE 32
1745 1745
1969 1969
1970 #ifdef DEBUG 1970 #ifdef DEBUG
1971 DEBUG_PRINT1 ("\nCompiling pattern: "); 1971 DEBUG_PRINT1 ("\nCompiling pattern: ");
1972 if (debug) 1972 if (debug)
1973 { 1973 {
1974 unsigned debug_count; 1974 int debug_count;
1975 1975
1976 for (debug_count = 0; debug_count < size; debug_count++) 1976 for (debug_count = 0; debug_count < size; debug_count++)
1977 putchar (pattern[debug_count]); 1977 putchar (pattern[debug_count]);
1978 putchar ('\n'); 1978 putchar ('\n');
1979 } 1979 }
2899 (The upper bound and `jump_n' are omitted if 2899 (The upper bound and `jump_n' are omitted if
2900 `upper_bound' is 1, though.) */ 2900 `upper_bound' is 1, though.) */
2901 else 2901 else
2902 { /* If the upper bound is > 1, we need to insert 2902 { /* If the upper bound is > 1, we need to insert
2903 more at the end of the loop. */ 2903 more at the end of the loop. */
2904 unsigned nbytes = 10 + (upper_bound > 1) * 10; 2904 int nbytes = 10 + (upper_bound > 1) * 10;
2905 2905
2906 GET_BUFFER_SPACE (nbytes); 2906 GET_BUFFER_SPACE (nbytes);
2907 2907
2908 /* Initialize lower bound of the `succeed_n', even 2908 /* Initialize lower bound of the `succeed_n', even
2909 though it will be set during matching by its 2909 though it will be set during matching by its
3393 3393
3394 static reg_errcode_t 3394 static reg_errcode_t
3395 compile_range (re_char **p_ptr, re_char *pend, RE_TRANSLATE_TYPE translate, 3395 compile_range (re_char **p_ptr, re_char *pend, RE_TRANSLATE_TYPE translate,
3396 reg_syntax_t syntax, unsigned char *buf_end) 3396 reg_syntax_t syntax, unsigned char *buf_end)
3397 { 3397 {
3398 unsigned this_char; 3398 Emchar this_char;
3399 3399
3400 re_char *p = *p_ptr; 3400 re_char *p = *p_ptr;
3401 int range_start, range_end; 3401 int range_start, range_end;
3402 3402
3403 if (p == pend) 3403 if (p == pend)
3520 DECLARE_DESTINATION; 3520 DECLARE_DESTINATION;
3521 /* We don't push any register information onto the failure stack. */ 3521 /* We don't push any register information onto the failure stack. */
3522 3522
3523 REGISTER char *fastmap = bufp->fastmap; 3523 REGISTER char *fastmap = bufp->fastmap;
3524 unsigned char *pattern = bufp->buffer; 3524 unsigned char *pattern = bufp->buffer;
3525 unsigned long size = bufp->used; 3525 long size = bufp->used;
3526 unsigned char *p = pattern; 3526 unsigned char *p = pattern;
3527 REGISTER unsigned char *pend = pattern + size; 3527 REGISTER unsigned char *pend = pattern + size;
3528 3528
3529 #ifdef REL_ALLOC 3529 #ifdef REL_ALLOC
3530 /* This holds the pointer to the failure stack, when 3530 /* This holds the pointer to the failure stack, when
3998 PATTERN_BUFFER will allocate its own register data, without 3998 PATTERN_BUFFER will allocate its own register data, without
3999 freeing the old data. */ 3999 freeing the old data. */
4000 4000
4001 void 4001 void
4002 re_set_registers (struct re_pattern_buffer *bufp, struct re_registers *regs, 4002 re_set_registers (struct re_pattern_buffer *bufp, struct re_registers *regs,
4003 unsigned num_regs, regoff_t *starts, regoff_t *ends) 4003 int num_regs, regoff_t *starts, regoff_t *ends)
4004 { 4004 {
4005 if (num_regs) 4005 if (num_regs)
4006 { 4006 {
4007 bufp->regs_allocated = REGS_REALLOCATE; 4007 bufp->regs_allocated = REGS_REALLOCATE;
4008 regs->num_regs = num_regs; 4008 regs->num_regs = num_regs;
4125 if (re_compile_fastmap (bufp) == -2) 4125 if (re_compile_fastmap (bufp) == -2)
4126 return -2; 4126 return -2;
4127 4127
4128 #ifdef REGEX_BEGLINE_CHECK 4128 #ifdef REGEX_BEGLINE_CHECK
4129 { 4129 {
4130 int i = 0; 4130 long i = 0;
4131 4131
4132 while (i < bufp->used) 4132 while (i < bufp->used)
4133 { 4133 {
4134 if (bufp->buffer[i] == start_memory || 4134 if (bufp->buffer[i] == start_memory ||
4135 bufp->buffer[i] == stop_memory) 4135 bufp->buffer[i] == stop_memory)
4476 it gets discarded and the next one is tried. */ 4476 it gets discarded and the next one is tried. */
4477 #ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global. */ 4477 #ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global. */
4478 fail_stack_type fail_stack; 4478 fail_stack_type fail_stack;
4479 #endif 4479 #endif
4480 #ifdef DEBUG 4480 #ifdef DEBUG
4481 static unsigned failure_id; 4481 static int failure_id;
4482 unsigned nfailure_points_pushed = 0, nfailure_points_popped = 0; 4482 int nfailure_points_pushed = 0, nfailure_points_popped = 0;
4483 #endif 4483 #endif
4484 4484
4485 #ifdef REL_ALLOC 4485 #ifdef REL_ALLOC
4486 /* This holds the pointer to the failure stack, when 4486 /* This holds the pointer to the failure stack, when
4487 it is allocated relocatably. */ 4487 it is allocated relocatably. */
4489 #endif 4489 #endif
4490 4490
4491 /* We fill all the registers internally, independent of what we 4491 /* We fill all the registers internally, independent of what we
4492 return, for use in backreferences. The number here includes 4492 return, for use in backreferences. The number here includes
4493 an element for register zero. */ 4493 an element for register zero. */
4494 unsigned num_regs = bufp->re_ngroups + 1; 4494 int num_regs = bufp->re_ngroups + 1;
4495 4495
4496 /* The currently active registers. */ 4496 /* The currently active registers. */
4497 unsigned lowest_active_reg = NO_LOWEST_ACTIVE_REG; 4497 int lowest_active_reg = NO_LOWEST_ACTIVE_REG;
4498 unsigned highest_active_reg = NO_HIGHEST_ACTIVE_REG; 4498 int highest_active_reg = NO_HIGHEST_ACTIVE_REG;
4499 4499
4500 /* Information on the contents of registers. These are pointers into 4500 /* Information on the contents of registers. These are pointers into
4501 the input strings; they record just what was matched (on this 4501 the input strings; they record just what was matched (on this
4502 attempt) by a subexpression part of the pattern, that is, the 4502 attempt) by a subexpression part of the pattern, that is, the
4503 regnum-th regstart pointer points to where in the pattern we began 4503 regnum-th regstart pointer points to where in the pattern we began
4529 4529
4530 /* The following record the register info as found in the above 4530 /* The following record the register info as found in the above
4531 variables when we find a match better than any we've seen before. 4531 variables when we find a match better than any we've seen before.
4532 This happens as we backtrack through the failure points, which in 4532 This happens as we backtrack through the failure points, which in
4533 turn happens only if we have not yet matched the entire string. */ 4533 turn happens only if we have not yet matched the entire string. */
4534 unsigned best_regs_set = false; 4534 int best_regs_set = false;
4535 #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ 4535 #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */
4536 re_char **best_regstart, **best_regend; 4536 re_char **best_regstart, **best_regend;
4537 #endif 4537 #endif
4538 4538
4539 /* Logically, this is `best_regend[0]'. But we don't want to have to 4539 /* Logically, this is `best_regend[0]'. But we don't want to have to
4555 register_info_type *reg_info_dummy; 4555 register_info_type *reg_info_dummy;
4556 #endif 4556 #endif
4557 4557
4558 #ifdef DEBUG 4558 #ifdef DEBUG
4559 /* Counts the total number of registers pushed. */ 4559 /* Counts the total number of registers pushed. */
4560 unsigned num_regs_pushed = 0; 4560 int num_regs_pushed = 0;
4561 #endif 4561 #endif
4562 4562
4563 /* 1 if this match ends in the same string (string1 or string2) 4563 /* 1 if this match ends in the same string (string1 or string2)
4564 as the best previous match. */ 4564 as the best previous match. */
4565 re_bool same_str_p; 4565 re_bool same_str_p;
4935 DEBUG_PRINT2 ("EXECUTING charset%s.\n", not_p ? "_not" : ""); 4935 DEBUG_PRINT2 ("EXECUTING charset%s.\n", not_p ? "_not" : "");
4936 4936
4937 REGEX_PREFETCH (); 4937 REGEX_PREFETCH ();
4938 c = TRANSLATE (*d); /* The character to match. */ 4938 c = TRANSLATE (*d); /* The character to match. */
4939 4939
4940 /* Cast to `unsigned' instead of `unsigned char' in case the 4940 /* Cast to `unsigned int' instead of `unsigned char' in case the
4941 bit list is a full 32 bytes long. */ 4941 bit list is a full 32 bytes long. */
4942 if (c < (unsigned) (*p * BYTEWIDTH) 4942 if (c < (unsigned int) (*p * BYTEWIDTH)
4943 && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) 4943 && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH)))
4944 not_p = !not_p; 4944 not_p = !not_p;
4945 4945
4946 p += 1 + *p; 4946 p += 1 + *p;
4947 4947
5144 e.g., `((a*)(b*))*' against `aba' (register 3 would 5144 e.g., `((a*)(b*))*' against `aba' (register 3 would
5145 otherwise get trashed). */ 5145 otherwise get trashed). */
5146 5146
5147 if (EVER_MATCHED_SOMETHING (reg_info[*p])) 5147 if (EVER_MATCHED_SOMETHING (reg_info[*p]))
5148 { 5148 {
5149 unsigned r; 5149 int r;
5150 5150
5151 EVER_MATCHED_SOMETHING (reg_info[*p]) = 0; 5151 EVER_MATCHED_SOMETHING (reg_info[*p]) = 0;
5152 5152
5153 /* Restore this and inner groups' (if any) registers. */ 5153 /* Restore this and inner groups' (if any) registers. */
5154 for (r = *p; r < *p + *(p + 1); r++) 5154 for (r = *p; r < *p + *(p + 1); r++)
5533 /* We need to pass separate storage for the lowest and 5533 /* We need to pass separate storage for the lowest and
5534 highest registers, even though we don't care about the 5534 highest registers, even though we don't care about the
5535 actual values. Otherwise, we will restore only one 5535 actual values. Otherwise, we will restore only one
5536 register from the stack, since lowest will == highest in 5536 register from the stack, since lowest will == highest in
5537 `pop_failure_point'. */ 5537 `pop_failure_point'. */
5538 unsigned dummy_low_reg, dummy_high_reg; 5538 int dummy_low_reg, dummy_high_reg;
5539 unsigned char *pdummy; 5539 unsigned char *pdummy;
5540 re_char *sdummy = NULL; 5540 re_char *sdummy = NULL;
5541 5541
5542 DEBUG_PRINT1 ("EXECUTING pop_failure_jump.\n"); 5542 DEBUG_PRINT1 ("EXECUTING pop_failure_jump.\n");
5543 POP_FAILURE_POINT (sdummy, pdummy, 5543 POP_FAILURE_POINT (sdummy, pdummy,
6360 6360
6361 int 6361 int
6362 regcomp (regex_t *preg, const char *pattern, int cflags) 6362 regcomp (regex_t *preg, const char *pattern, int cflags)
6363 { 6363 {
6364 reg_errcode_t ret; 6364 reg_errcode_t ret;
6365 unsigned syntax 6365 unsigned int syntax
6366 = (cflags & REG_EXTENDED) ? 6366 = (cflags & REG_EXTENDED) ?
6367 RE_SYNTAX_POSIX_EXTENDED : RE_SYNTAX_POSIX_BASIC; 6367 RE_SYNTAX_POSIX_EXTENDED : RE_SYNTAX_POSIX_BASIC;
6368 6368
6369 /* regex_compile will allocate the space for the compiled pattern. */ 6369 /* regex_compile will allocate the space for the compiled pattern. */
6370 preg->buffer = 0; 6370 preg->buffer = 0;
6377 every character. */ 6377 every character. */
6378 preg->fastmap = 0; 6378 preg->fastmap = 0;
6379 6379
6380 if (cflags & REG_ICASE) 6380 if (cflags & REG_ICASE)
6381 { 6381 {
6382 unsigned i; 6382 int i;
6383 6383
6384 preg->translate = (char *) malloc (CHAR_SET_SIZE); 6384 preg->translate = (char *) malloc (CHAR_SET_SIZE);
6385 if (preg->translate == NULL) 6385 if (preg->translate == NULL)
6386 return (int) REG_ESPACE; 6386 return (int) REG_ESPACE;
6387 6387
6451 matching routines. */ 6451 matching routines. */
6452 private_preg.regs_allocated = REGS_FIXED; 6452 private_preg.regs_allocated = REGS_FIXED;
6453 6453
6454 if (want_reg_info) 6454 if (want_reg_info)
6455 { 6455 {
6456 regs.num_regs = nmatch; 6456 regs.num_regs = (int) nmatch;
6457 regs.start = TALLOC (nmatch, regoff_t); 6457 regs.start = TALLOC ((int) nmatch, regoff_t);
6458 regs.end = TALLOC (nmatch, regoff_t); 6458 regs.end = TALLOC ((int) nmatch, regoff_t);
6459 if (regs.start == NULL || regs.end == NULL) 6459 if (regs.start == NULL || regs.end == NULL)
6460 return (int) REG_NOMATCH; 6460 return (int) REG_NOMATCH;
6461 } 6461 }
6462 6462
6463 /* Perform the searching operation. */ 6463 /* Perform the searching operation. */
6468 /* Copy the register information to the POSIX structure. */ 6468 /* Copy the register information to the POSIX structure. */
6469 if (want_reg_info) 6469 if (want_reg_info)
6470 { 6470 {
6471 if (ret >= 0) 6471 if (ret >= 0)
6472 { 6472 {
6473 unsigned r; 6473 int r;
6474 6474
6475 for (r = 0; r < nmatch; r++) 6475 for (r = 0; r < (int) nmatch; r++)
6476 { 6476 {
6477 pmatch[r].rm_so = regs.start[r]; 6477 pmatch[r].rm_so = regs.start[r];
6478 pmatch[r].rm_eo = regs.end[r]; 6478 pmatch[r].rm_eo = regs.end[r];
6479 } 6479 }
6480 } 6480 }
6491 6491
6492 /* Returns a message corresponding to an error code, ERRCODE, returned 6492 /* Returns a message corresponding to an error code, ERRCODE, returned
6493 from either regcomp or regexec. We don't use PREG here. */ 6493 from either regcomp or regexec. We don't use PREG here. */
6494 6494
6495 size_t 6495 size_t
6496 regerror (int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size) 6496 regerror (int errcode, const regex_t *preg, char *errbuf,
6497 size_t errbuf_size)
6497 { 6498 {
6498 const char *msg; 6499 const char *msg;
6499 size_t msg_size; 6500 Memory_Count msg_size;
6500 6501
6501 if (errcode < 0 6502 if (errcode < 0
6502 || errcode >= (sizeof (re_error_msgid) / sizeof (re_error_msgid[0]))) 6503 || errcode >= (int) (sizeof (re_error_msgid) /
6504 sizeof (re_error_msgid[0])))
6503 /* Only error codes returned by the rest of the code should be passed 6505 /* Only error codes returned by the rest of the code should be passed
6504 to this routine. If we are given anything else, or if other regex 6506 to this routine. If we are given anything else, or if other regex
6505 code generates an invalid error code, then the program has a bug. 6507 code generates an invalid error code, then the program has a bug.
6506 Dump core so we can fix it. */ 6508 Dump core so we can fix it. */
6507 abort (); 6509 abort ();
6510 6512
6511 msg_size = strlen (msg) + 1; /* Includes the null. */ 6513 msg_size = strlen (msg) + 1; /* Includes the null. */
6512 6514
6513 if (errbuf_size != 0) 6515 if (errbuf_size != 0)
6514 { 6516 {
6515 if (msg_size > errbuf_size) 6517 if (msg_size > (Memory_Count) errbuf_size)
6516 { 6518 {
6517 strncpy (errbuf, msg, errbuf_size - 1); 6519 strncpy (errbuf, msg, errbuf_size - 1);
6518 errbuf[errbuf_size - 1] = 0; 6520 errbuf[errbuf_size - 1] = 0;
6519 } 6521 }
6520 else 6522 else
6521 strcpy (errbuf, msg); 6523 strcpy (errbuf, msg);
6522 } 6524 }
6523 6525
6524 return msg_size; 6526 return (size_t) msg_size;
6525 } 6527 }
6526 6528
6527 6529
6528 /* Free dynamically allocated space used by PREG. */ 6530 /* Free dynamically allocated space used by PREG. */
6529 6531