diff options
| author | Paul Eggert | 2011-03-15 11:53:29 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-03-15 11:53:29 -0700 |
| commit | b313f9d86378db4dd4619923572b07513c53ceac (patch) | |
| tree | 3e6564454a56d36d1f2922267f319830f2ee7603 /src | |
| parent | da053e48b16db6fa8dedd72d9d7f80c392259193 (diff) | |
| download | emacs-b313f9d86378db4dd4619923572b07513c53ceac.tar.gz emacs-b313f9d86378db4dd4619923572b07513c53ceac.zip | |
* regex.c (RETALLOC_IF): Define only if needed.
(WORDCHAR_P): Likewise. This one is never needed, but is used
only in a comment talking about a compiler bug, so put inside
the #if 0 of that comment.
(CHARSET_LOOKUP_BITMAP, FAIL_STACK_FULL, RESET_FAIL_STACK):
(PUSH_FAILURE_ELT, BUF_PUSH_3, STOP_ADDR_VSTRING):
Remove; unused.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 7 | ||||
| -rw-r--r-- | src/regex.c | 55 |
2 files changed, 19 insertions, 43 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 2ebe327e326..706612da945 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -8,6 +8,13 @@ | |||
| 8 | (FREE_VAR): Rewrite so as not to use empty "else", | 8 | (FREE_VAR): Rewrite so as not to use empty "else", |
| 9 | which gcc can warn about. | 9 | which gcc can warn about. |
| 10 | (regex_compile, re_match_2_internal): Mark locals as initialized. | 10 | (regex_compile, re_match_2_internal): Mark locals as initialized. |
| 11 | (RETALLOC_IF): Define only if needed. | ||
| 12 | (WORDCHAR_P): Likewise. This one is never needed, but is used | ||
| 13 | only in a comment talking about a compiler bug, so put inside | ||
| 14 | the #if 0 of that comment. | ||
| 15 | (CHARSET_LOOKUP_BITMAP, FAIL_STACK_FULL, RESET_FAIL_STACK): | ||
| 16 | (PUSH_FAILURE_ELT, BUF_PUSH_3, STOP_ADDR_VSTRING): | ||
| 17 | Remove; unused. | ||
| 11 | 18 | ||
| 12 | * search.c (boyer_moore): Rename locals to avoid shadowing. | 19 | * search.c (boyer_moore): Rename locals to avoid shadowing. |
| 13 | * character.h (FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE): Likewise. | 20 | * character.h (FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE): Likewise. |
diff --git a/src/regex.c b/src/regex.c index 6c6aa03e437..4194ccc7c00 100644 --- a/src/regex.c +++ b/src/regex.c | |||
| @@ -551,8 +551,6 @@ init_syntax_once (void) | |||
| 551 | /* (Re)Allocate N items of type T using malloc, or fail. */ | 551 | /* (Re)Allocate N items of type T using malloc, or fail. */ |
| 552 | #define TALLOC(n, t) ((t *) malloc ((n) * sizeof (t))) | 552 | #define TALLOC(n, t) ((t *) malloc ((n) * sizeof (t))) |
| 553 | #define RETALLOC(addr, n, t) ((addr) = (t *) realloc (addr, (n) * sizeof (t))) | 553 | #define RETALLOC(addr, n, t) ((addr) = (t *) realloc (addr, (n) * sizeof (t))) |
| 554 | #define RETALLOC_IF(addr, n, t) \ | ||
| 555 | if (addr) RETALLOC((addr), (n), t); else (addr) = TALLOC ((n), t) | ||
| 556 | #define REGEX_TALLOC(n, t) ((t *) REGEX_ALLOCATE ((n) * sizeof (t))) | 554 | #define REGEX_TALLOC(n, t) ((t *) REGEX_ALLOCATE ((n) * sizeof (t))) |
| 557 | 555 | ||
| 558 | #define BYTEWIDTH 8 /* In bits. */ | 556 | #define BYTEWIDTH 8 /* In bits. */ |
| @@ -843,11 +841,6 @@ extract_number_and_incr (destination, source) | |||
| 843 | ((p)[2 + CHARSET_BITMAP_SIZE (p)] \ | 841 | ((p)[2 + CHARSET_BITMAP_SIZE (p)] \ |
| 844 | + (p)[3 + CHARSET_BITMAP_SIZE (p)] * 0x100) | 842 | + (p)[3 + CHARSET_BITMAP_SIZE (p)] * 0x100) |
| 845 | 843 | ||
| 846 | /* Test if C is listed in the bitmap of charset P. */ | ||
| 847 | #define CHARSET_LOOKUP_BITMAP(p, c) \ | ||
| 848 | ((c) < CHARSET_BITMAP_SIZE (p) * BYTEWIDTH \ | ||
| 849 | && (p)[2 + (c) / BYTEWIDTH] & (1 << ((c) % BYTEWIDTH))) | ||
| 850 | |||
| 851 | /* Return the address of end of RANGE_TABLE. COUNT is number of | 844 | /* Return the address of end of RANGE_TABLE. COUNT is number of |
| 852 | ranges (which is a pair of (start, end)) in the RANGE_TABLE. `* 2' | 845 | ranges (which is a pair of (start, end)) in the RANGE_TABLE. `* 2' |
| 853 | is start of range and end of range. `* 3' is size of each start | 846 | is start of range and end of range. `* 3' is size of each start |
| @@ -1413,7 +1406,6 @@ typedef struct | |||
| 1413 | } fail_stack_type; | 1406 | } fail_stack_type; |
| 1414 | 1407 | ||
| 1415 | #define FAIL_STACK_EMPTY() (fail_stack.frame == 0) | 1408 | #define FAIL_STACK_EMPTY() (fail_stack.frame == 0) |
| 1416 | #define FAIL_STACK_FULL() (fail_stack.avail == fail_stack.size) | ||
| 1417 | 1409 | ||
| 1418 | 1410 | ||
| 1419 | /* Define macros to initialize and free the failure stack. | 1411 | /* Define macros to initialize and free the failure stack. |
| @@ -1433,8 +1425,6 @@ typedef struct | |||
| 1433 | fail_stack.avail = 0; \ | 1425 | fail_stack.avail = 0; \ |
| 1434 | fail_stack.frame = 0; \ | 1426 | fail_stack.frame = 0; \ |
| 1435 | } while (0) | 1427 | } while (0) |
| 1436 | |||
| 1437 | # define RESET_FAIL_STACK() REGEX_FREE_STACK (fail_stack.stack) | ||
| 1438 | #else | 1428 | #else |
| 1439 | # define INIT_FAIL_STACK() \ | 1429 | # define INIT_FAIL_STACK() \ |
| 1440 | do { \ | 1430 | do { \ |
| @@ -1442,7 +1432,8 @@ typedef struct | |||
| 1442 | fail_stack.frame = 0; \ | 1432 | fail_stack.frame = 0; \ |
| 1443 | } while (0) | 1433 | } while (0) |
| 1444 | 1434 | ||
| 1445 | # define RESET_FAIL_STACK() ((void)0) | 1435 | # define RETALLOC_IF(addr, n, t) \ |
| 1436 | if (addr) RETALLOC((addr), (n), t); else (addr) = TALLOC ((n), t) | ||
| 1446 | #endif | 1437 | #endif |
| 1447 | 1438 | ||
| 1448 | 1439 | ||
| @@ -1495,17 +1486,10 @@ typedef struct | |||
| 1495 | #define PUSH_FAILURE_INT(item) \ | 1486 | #define PUSH_FAILURE_INT(item) \ |
| 1496 | fail_stack.stack[fail_stack.avail++].integer = (item) | 1487 | fail_stack.stack[fail_stack.avail++].integer = (item) |
| 1497 | 1488 | ||
| 1498 | /* Push a fail_stack_elt_t value onto the failure stack. | 1489 | /* These POP... operations complement the PUSH... operations. |
| 1499 | Assumes the variable `fail_stack'. Probably should only | ||
| 1500 | be called from within `PUSH_FAILURE_POINT'. */ | ||
| 1501 | #define PUSH_FAILURE_ELT(item) \ | ||
| 1502 | fail_stack.stack[fail_stack.avail++] = (item) | ||
| 1503 | |||
| 1504 | /* These three POP... operations complement the three PUSH... operations. | ||
| 1505 | All assume that `fail_stack' is nonempty. */ | 1490 | All assume that `fail_stack' is nonempty. */ |
| 1506 | #define POP_FAILURE_POINTER() fail_stack.stack[--fail_stack.avail].pointer | 1491 | #define POP_FAILURE_POINTER() fail_stack.stack[--fail_stack.avail].pointer |
| 1507 | #define POP_FAILURE_INT() fail_stack.stack[--fail_stack.avail].integer | 1492 | #define POP_FAILURE_INT() fail_stack.stack[--fail_stack.avail].integer |
| 1508 | #define POP_FAILURE_ELT() fail_stack.stack[--fail_stack.avail] | ||
| 1509 | 1493 | ||
| 1510 | /* Individual items aside from the registers. */ | 1494 | /* Individual items aside from the registers. */ |
| 1511 | #define NUM_NONREG_ITEMS 3 | 1495 | #define NUM_NONREG_ITEMS 3 |
| @@ -1765,16 +1749,6 @@ static int analyse_first _RE_ARGS ((re_char *p, re_char *pend, | |||
| 1765 | } while (0) | 1749 | } while (0) |
| 1766 | 1750 | ||
| 1767 | 1751 | ||
| 1768 | /* As with BUF_PUSH_2, except for three bytes. */ | ||
| 1769 | #define BUF_PUSH_3(c1, c2, c3) \ | ||
| 1770 | do { \ | ||
| 1771 | GET_BUFFER_SPACE (3); \ | ||
| 1772 | *b++ = (unsigned char) (c1); \ | ||
| 1773 | *b++ = (unsigned char) (c2); \ | ||
| 1774 | *b++ = (unsigned char) (c3); \ | ||
| 1775 | } while (0) | ||
| 1776 | |||
| 1777 | |||
| 1778 | /* Store a jump with opcode OP at LOC to location TO. We store a | 1752 | /* Store a jump with opcode OP at LOC to location TO. We store a |
| 1779 | relative address offset by the three bytes the jump itself occupies. */ | 1753 | relative address offset by the three bytes the jump itself occupies. */ |
| 1780 | #define STORE_JUMP(op, loc, to) \ | 1754 | #define STORE_JUMP(op, loc, to) \ |
| @@ -4322,10 +4296,6 @@ WEAK_ALIAS (__re_search, re_search) | |||
| 4322 | #define HEAD_ADDR_VSTRING(P) \ | 4296 | #define HEAD_ADDR_VSTRING(P) \ |
| 4323 | (((P) >= size1 ? string2 : string1)) | 4297 | (((P) >= size1 ? string2 : string1)) |
| 4324 | 4298 | ||
| 4325 | /* End address of virtual concatenation of string. */ | ||
| 4326 | #define STOP_ADDR_VSTRING(P) \ | ||
| 4327 | (((P) >= size1 ? string2 + size2 : string1 + size1)) | ||
| 4328 | |||
| 4329 | /* Address of POS in the concatenation of virtual string. */ | 4299 | /* Address of POS in the concatenation of virtual string. */ |
| 4330 | #define POS_ADDR_VSTRING(POS) \ | 4300 | #define POS_ADDR_VSTRING(POS) \ |
| 4331 | (((POS) >= size1 ? string2 - size1 : string1) + (POS)) | 4301 | (((POS) >= size1 ? string2 - size1 : string1) + (POS)) |
| @@ -4636,16 +4606,6 @@ static int bcmp_translate _RE_ARGS((re_char *s1, re_char *s2, | |||
| 4636 | #define AT_STRINGS_BEG(d) ((d) == (size1 ? string1 : string2) || !size2) | 4606 | #define AT_STRINGS_BEG(d) ((d) == (size1 ? string1 : string2) || !size2) |
| 4637 | #define AT_STRINGS_END(d) ((d) == end2) | 4607 | #define AT_STRINGS_END(d) ((d) == end2) |
| 4638 | 4608 | ||
| 4639 | |||
| 4640 | /* Test if D points to a character which is word-constituent. We have | ||
| 4641 | two special cases to check for: if past the end of string1, look at | ||
| 4642 | the first character in string2; and if before the beginning of | ||
| 4643 | string2, look at the last character in string1. */ | ||
| 4644 | #define WORDCHAR_P(d) \ | ||
| 4645 | (SYNTAX ((d) == end1 ? *string2 \ | ||
| 4646 | : (d) == string2 - 1 ? *(end1 - 1) : *(d)) \ | ||
| 4647 | == Sword) | ||
| 4648 | |||
| 4649 | /* Disabled due to a compiler bug -- see comment at case wordbound */ | 4609 | /* Disabled due to a compiler bug -- see comment at case wordbound */ |
| 4650 | 4610 | ||
| 4651 | /* The comment at case wordbound is following one, but we don't use | 4611 | /* The comment at case wordbound is following one, but we don't use |
| @@ -4657,6 +4617,15 @@ static int bcmp_translate _RE_ARGS((re_char *s1, re_char *s2, | |||
| 4657 | macro and introducing temporary variables works around the bug. */ | 4617 | macro and introducing temporary variables works around the bug. */ |
| 4658 | 4618 | ||
| 4659 | #if 0 | 4619 | #if 0 |
| 4620 | /* Test if D points to a character which is word-constituent. We have | ||
| 4621 | two special cases to check for: if past the end of string1, look at | ||
| 4622 | the first character in string2; and if before the beginning of | ||
| 4623 | string2, look at the last character in string1. */ | ||
| 4624 | #define WORDCHAR_P(d) \ | ||
| 4625 | (SYNTAX ((d) == end1 ? *string2 \ | ||
| 4626 | : (d) == string2 - 1 ? *(end1 - 1) : *(d)) \ | ||
| 4627 | == Sword) | ||
| 4628 | |||
| 4660 | /* Test if the character before D and the one at D differ with respect | 4629 | /* Test if the character before D and the one at D differ with respect |
| 4661 | to being word-constituent. */ | 4630 | to being word-constituent. */ |
| 4662 | #define AT_WORD_BOUNDARY(d) \ | 4631 | #define AT_WORD_BOUNDARY(d) \ |