diff options
| author | Paul Eggert | 2019-10-11 18:23:47 -0700 |
|---|---|---|
| committer | Paul Eggert | 2019-10-11 18:24:19 -0700 |
| commit | 4b60e0722d0a79751f345bd470d07db0d635aa28 (patch) | |
| tree | 9ebcaa21ec5f08c0caafc7190daf34ed047f8e1f /lib/regcomp.c | |
| parent | f9d8babe6a28b19c781778c361e45b93f7a01f17 (diff) | |
| download | emacs-4b60e0722d0a79751f345bd470d07db0d635aa28.tar.gz emacs-4b60e0722d0a79751f345bd470d07db0d635aa28.zip | |
Update from Gnulib
This incorporates:
2019-10-11 Simplify and regularize regex use of ‘assert’
2019-10-09 regex: omit debug assignment when not debugging
2019-10-09 regex: tell compiler there’s at most 256 arcs out
2019-10-09 regex: simplify by assuming C99
2019-10-09 regex: avoid copying of uninitialized storage
2019-09-29 fbufmode: Fix compilation error on glibc >= 2.28 systems
2019-09-28 Update comments that refer to POSIX
2019-09-23 Update URLs and associated text
* doc/misc/texinfo.tex, lib/open.c, lib/regcomp.c:
* lib/regex_internal.c, lib/regex_internal.h, lib/regexec.c:
* lib/stdio-impl.h:
Copy from Gnulib.
Diffstat (limited to 'lib/regcomp.c')
| -rw-r--r-- | lib/regcomp.c | 35 |
1 files changed, 10 insertions, 25 deletions
diff --git a/lib/regcomp.c b/lib/regcomp.c index 892139a02af..ad6f931a5c3 100644 --- a/lib/regcomp.c +++ b/lib/regcomp.c | |||
| @@ -1436,7 +1436,7 @@ link_nfa_nodes (void *extra, bin_tree_t *node) | |||
| 1436 | break; | 1436 | break; |
| 1437 | 1437 | ||
| 1438 | case END_OF_RE: | 1438 | case END_OF_RE: |
| 1439 | assert (node->next == NULL); | 1439 | DEBUG_ASSERT (node->next == NULL); |
| 1440 | break; | 1440 | break; |
| 1441 | 1441 | ||
| 1442 | case OP_DUP_ASTERISK: | 1442 | case OP_DUP_ASTERISK: |
| @@ -1452,8 +1452,8 @@ link_nfa_nodes (void *extra, bin_tree_t *node) | |||
| 1452 | right = node->right->first->node_idx; | 1452 | right = node->right->first->node_idx; |
| 1453 | else | 1453 | else |
| 1454 | right = node->next->node_idx; | 1454 | right = node->next->node_idx; |
| 1455 | assert (left > -1); | 1455 | DEBUG_ASSERT (left > -1); |
| 1456 | assert (right > -1); | 1456 | DEBUG_ASSERT (right > -1); |
| 1457 | err = re_node_set_init_2 (dfa->edests + idx, left, right); | 1457 | err = re_node_set_init_2 (dfa->edests + idx, left, right); |
| 1458 | } | 1458 | } |
| 1459 | break; | 1459 | break; |
| @@ -1471,7 +1471,7 @@ link_nfa_nodes (void *extra, bin_tree_t *node) | |||
| 1471 | break; | 1471 | break; |
| 1472 | 1472 | ||
| 1473 | default: | 1473 | default: |
| 1474 | assert (!IS_EPSILON_NODE (node->token.type)); | 1474 | DEBUG_ASSERT (!IS_EPSILON_NODE (node->token.type)); |
| 1475 | dfa->nexts[idx] = node->next->node_idx; | 1475 | dfa->nexts[idx] = node->next->node_idx; |
| 1476 | break; | 1476 | break; |
| 1477 | } | 1477 | } |
| @@ -1653,9 +1653,7 @@ calc_eclosure (re_dfa_t *dfa) | |||
| 1653 | { | 1653 | { |
| 1654 | Idx node_idx; | 1654 | Idx node_idx; |
| 1655 | bool incomplete; | 1655 | bool incomplete; |
| 1656 | #ifdef DEBUG | 1656 | DEBUG_ASSERT (dfa->nodes_len > 0); |
| 1657 | assert (dfa->nodes_len > 0); | ||
| 1658 | #endif | ||
| 1659 | incomplete = false; | 1657 | incomplete = false; |
| 1660 | /* For each nodes, calculate epsilon closure. */ | 1658 | /* For each nodes, calculate epsilon closure. */ |
| 1661 | for (node_idx = 0; ; ++node_idx) | 1659 | for (node_idx = 0; ; ++node_idx) |
| @@ -1670,9 +1668,7 @@ calc_eclosure (re_dfa_t *dfa) | |||
| 1670 | node_idx = 0; | 1668 | node_idx = 0; |
| 1671 | } | 1669 | } |
| 1672 | 1670 | ||
| 1673 | #ifdef DEBUG | 1671 | DEBUG_ASSERT (dfa->eclosures[node_idx].nelem != -1); |
| 1674 | assert (dfa->eclosures[node_idx].nelem != -1); | ||
| 1675 | #endif | ||
| 1676 | 1672 | ||
| 1677 | /* If we have already calculated, skip it. */ | 1673 | /* If we have already calculated, skip it. */ |
| 1678 | if (dfa->eclosures[node_idx].nelem != 0) | 1674 | if (dfa->eclosures[node_idx].nelem != 0) |
| @@ -2442,9 +2438,7 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token, | |||
| 2442 | 2438 | ||
| 2443 | default: | 2439 | default: |
| 2444 | /* Must not happen? */ | 2440 | /* Must not happen? */ |
| 2445 | #ifdef DEBUG | 2441 | DEBUG_ASSERT (false); |
| 2446 | assert (0); | ||
| 2447 | #endif | ||
| 2448 | return NULL; | 2442 | return NULL; |
| 2449 | } | 2443 | } |
| 2450 | fetch_token (token, regexp, syntax); | 2444 | fetch_token (token, regexp, syntax); |
| @@ -3306,7 +3300,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, | |||
| 3306 | goto parse_bracket_exp_free_return; | 3300 | goto parse_bracket_exp_free_return; |
| 3307 | break; | 3301 | break; |
| 3308 | default: | 3302 | default: |
| 3309 | assert (0); | 3303 | DEBUG_ASSERT (false); |
| 3310 | break; | 3304 | break; |
| 3311 | } | 3305 | } |
| 3312 | } | 3306 | } |
| @@ -3662,7 +3656,6 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans, | |||
| 3662 | Idx alloc = 0; | 3656 | Idx alloc = 0; |
| 3663 | #endif /* not RE_ENABLE_I18N */ | 3657 | #endif /* not RE_ENABLE_I18N */ |
| 3664 | reg_errcode_t ret; | 3658 | reg_errcode_t ret; |
| 3665 | re_token_t br_token; | ||
| 3666 | bin_tree_t *tree; | 3659 | bin_tree_t *tree; |
| 3667 | 3660 | ||
| 3668 | sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); | 3661 | sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); |
| @@ -3713,11 +3706,7 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans, | |||
| 3713 | #endif | 3706 | #endif |
| 3714 | 3707 | ||
| 3715 | /* Build a tree for simple bracket. */ | 3708 | /* Build a tree for simple bracket. */ |
| 3716 | #if defined GCC_LINT || defined lint | 3709 | re_token_t br_token = { .type = SIMPLE_BRACKET, .opr.sbcset = sbcset }; |
| 3717 | memset (&br_token, 0, sizeof br_token); | ||
| 3718 | #endif | ||
| 3719 | br_token.type = SIMPLE_BRACKET; | ||
| 3720 | br_token.opr.sbcset = sbcset; | ||
| 3721 | tree = create_token_tree (dfa, NULL, NULL, &br_token); | 3710 | tree = create_token_tree (dfa, NULL, NULL, &br_token); |
| 3722 | if (__glibc_unlikely (tree == NULL)) | 3711 | if (__glibc_unlikely (tree == NULL)) |
| 3723 | goto build_word_op_espace; | 3712 | goto build_word_op_espace; |
| @@ -3808,11 +3797,7 @@ static bin_tree_t * | |||
| 3808 | create_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right, | 3797 | create_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right, |
| 3809 | re_token_type_t type) | 3798 | re_token_type_t type) |
| 3810 | { | 3799 | { |
| 3811 | re_token_t t; | 3800 | re_token_t t = { .type = type }; |
| 3812 | #if defined GCC_LINT || defined lint | ||
| 3813 | memset (&t, 0, sizeof t); | ||
| 3814 | #endif | ||
| 3815 | t.type = type; | ||
| 3816 | return create_token_tree (dfa, left, right, &t); | 3801 | return create_token_tree (dfa, left, right, &t); |
| 3817 | } | 3802 | } |
| 3818 | 3803 | ||