diff options
Diffstat (limited to 'lib/regcomp.c')
| -rw-r--r-- | lib/regcomp.c | 305 |
1 files changed, 158 insertions, 147 deletions
diff --git a/lib/regcomp.c b/lib/regcomp.c index 0e4816c89c2..0b05a63b632 100644 --- a/lib/regcomp.c +++ b/lib/regcomp.c | |||
| @@ -476,7 +476,7 @@ regcomp (regex_t *_Restrict_ preg, const char *_Restrict_ pattern, int cflags) | |||
| 476 | 476 | ||
| 477 | /* Try to allocate space for the fastmap. */ | 477 | /* Try to allocate space for the fastmap. */ |
| 478 | preg->fastmap = re_malloc (char, SBC_MAX); | 478 | preg->fastmap = re_malloc (char, SBC_MAX); |
| 479 | if (BE (preg->fastmap == NULL, 0)) | 479 | if (__glibc_unlikely (preg->fastmap == NULL)) |
| 480 | return REG_ESPACE; | 480 | return REG_ESPACE; |
| 481 | 481 | ||
| 482 | syntax |= (cflags & REG_ICASE) ? RE_ICASE : 0; | 482 | syntax |= (cflags & REG_ICASE) ? RE_ICASE : 0; |
| @@ -502,7 +502,7 @@ regcomp (regex_t *_Restrict_ preg, const char *_Restrict_ pattern, int cflags) | |||
| 502 | ret = REG_EPAREN; | 502 | ret = REG_EPAREN; |
| 503 | 503 | ||
| 504 | /* We have already checked preg->fastmap != NULL. */ | 504 | /* We have already checked preg->fastmap != NULL. */ |
| 505 | if (BE (ret == REG_NOERROR, 1)) | 505 | if (__glibc_likely (ret == REG_NOERROR)) |
| 506 | /* Compute the fastmap now, since regexec cannot modify the pattern | 506 | /* Compute the fastmap now, since regexec cannot modify the pattern |
| 507 | buffer. This function never fails in this implementation. */ | 507 | buffer. This function never fails in this implementation. */ |
| 508 | (void) re_compile_fastmap (preg); | 508 | (void) re_compile_fastmap (preg); |
| @@ -529,10 +529,9 @@ regerror (int errcode, const regex_t *_Restrict_ preg, char *_Restrict_ errbuf, | |||
| 529 | { | 529 | { |
| 530 | const char *msg; | 530 | const char *msg; |
| 531 | size_t msg_size; | 531 | size_t msg_size; |
| 532 | int nerrcodes = sizeof __re_error_msgid_idx / sizeof __re_error_msgid_idx[0]; | ||
| 532 | 533 | ||
| 533 | if (BE (errcode < 0 | 534 | if (__glibc_unlikely (errcode < 0 || errcode >= nerrcodes)) |
| 534 | || errcode >= (int) (sizeof (__re_error_msgid_idx) | ||
| 535 | / sizeof (__re_error_msgid_idx[0])), 0)) | ||
| 536 | /* Only error codes returned by the rest of the code should be passed | 535 | /* Only error codes returned by the rest of the code should be passed |
| 537 | to this routine. If we are given anything else, or if other regex | 536 | to this routine. If we are given anything else, or if other regex |
| 538 | code generates an invalid error code, then the program has a bug. | 537 | code generates an invalid error code, then the program has a bug. |
| @@ -543,10 +542,10 @@ regerror (int errcode, const regex_t *_Restrict_ preg, char *_Restrict_ errbuf, | |||
| 543 | 542 | ||
| 544 | msg_size = strlen (msg) + 1; /* Includes the null. */ | 543 | msg_size = strlen (msg) + 1; /* Includes the null. */ |
| 545 | 544 | ||
| 546 | if (BE (errbuf_size != 0, 1)) | 545 | if (__glibc_likely (errbuf_size != 0)) |
| 547 | { | 546 | { |
| 548 | size_t cpy_size = msg_size; | 547 | size_t cpy_size = msg_size; |
| 549 | if (BE (msg_size > errbuf_size, 0)) | 548 | if (__glibc_unlikely (msg_size > errbuf_size)) |
| 550 | { | 549 | { |
| 551 | cpy_size = errbuf_size - 1; | 550 | cpy_size = errbuf_size - 1; |
| 552 | errbuf[cpy_size] = '\0'; | 551 | errbuf[cpy_size] = '\0'; |
| @@ -644,7 +643,7 @@ void | |||
| 644 | regfree (regex_t *preg) | 643 | regfree (regex_t *preg) |
| 645 | { | 644 | { |
| 646 | re_dfa_t *dfa = preg->buffer; | 645 | re_dfa_t *dfa = preg->buffer; |
| 647 | if (BE (dfa != NULL, 1)) | 646 | if (__glibc_likely (dfa != NULL)) |
| 648 | { | 647 | { |
| 649 | lock_fini (dfa->lock); | 648 | lock_fini (dfa->lock); |
| 650 | free_dfa_content (dfa); | 649 | free_dfa_content (dfa); |
| @@ -754,7 +753,7 @@ re_compile_internal (regex_t *preg, const char * pattern, size_t length, | |||
| 754 | 753 | ||
| 755 | /* Initialize the dfa. */ | 754 | /* Initialize the dfa. */ |
| 756 | dfa = preg->buffer; | 755 | dfa = preg->buffer; |
| 757 | if (BE (preg->allocated < sizeof (re_dfa_t), 0)) | 756 | if (__glibc_unlikely (preg->allocated < sizeof (re_dfa_t))) |
| 758 | { | 757 | { |
| 759 | /* If zero allocated, but buffer is non-null, try to realloc | 758 | /* If zero allocated, but buffer is non-null, try to realloc |
| 760 | enough space. This loses if buffer's address is bogus, but | 759 | enough space. This loses if buffer's address is bogus, but |
| @@ -769,9 +768,9 @@ re_compile_internal (regex_t *preg, const char * pattern, size_t length, | |||
| 769 | preg->used = sizeof (re_dfa_t); | 768 | preg->used = sizeof (re_dfa_t); |
| 770 | 769 | ||
| 771 | err = init_dfa (dfa, length); | 770 | err = init_dfa (dfa, length); |
| 772 | if (BE (err == REG_NOERROR && lock_init (dfa->lock) != 0, 0)) | 771 | if (__glibc_unlikely (err == REG_NOERROR && lock_init (dfa->lock) != 0)) |
| 773 | err = REG_ESPACE; | 772 | err = REG_ESPACE; |
| 774 | if (BE (err != REG_NOERROR, 0)) | 773 | if (__glibc_unlikely (err != REG_NOERROR)) |
| 775 | { | 774 | { |
| 776 | free_dfa_content (dfa); | 775 | free_dfa_content (dfa); |
| 777 | preg->buffer = NULL; | 776 | preg->buffer = NULL; |
| @@ -786,7 +785,7 @@ re_compile_internal (regex_t *preg, const char * pattern, size_t length, | |||
| 786 | 785 | ||
| 787 | err = re_string_construct (®exp, pattern, length, preg->translate, | 786 | err = re_string_construct (®exp, pattern, length, preg->translate, |
| 788 | (syntax & RE_ICASE) != 0, dfa); | 787 | (syntax & RE_ICASE) != 0, dfa); |
| 789 | if (BE (err != REG_NOERROR, 0)) | 788 | if (__glibc_unlikely (err != REG_NOERROR)) |
| 790 | { | 789 | { |
| 791 | re_compile_internal_free_return: | 790 | re_compile_internal_free_return: |
| 792 | free_workarea_compile (preg); | 791 | free_workarea_compile (preg); |
| @@ -801,12 +800,12 @@ re_compile_internal (regex_t *preg, const char * pattern, size_t length, | |||
| 801 | /* Parse the regular expression, and build a structure tree. */ | 800 | /* Parse the regular expression, and build a structure tree. */ |
| 802 | preg->re_nsub = 0; | 801 | preg->re_nsub = 0; |
| 803 | dfa->str_tree = parse (®exp, preg, syntax, &err); | 802 | dfa->str_tree = parse (®exp, preg, syntax, &err); |
| 804 | if (BE (dfa->str_tree == NULL, 0)) | 803 | if (__glibc_unlikely (dfa->str_tree == NULL)) |
| 805 | goto re_compile_internal_free_return; | 804 | goto re_compile_internal_free_return; |
| 806 | 805 | ||
| 807 | /* Analyze the tree and create the nfa. */ | 806 | /* Analyze the tree and create the nfa. */ |
| 808 | err = analyze (preg); | 807 | err = analyze (preg); |
| 809 | if (BE (err != REG_NOERROR, 0)) | 808 | if (__glibc_unlikely (err != REG_NOERROR)) |
| 810 | goto re_compile_internal_free_return; | 809 | goto re_compile_internal_free_return; |
| 811 | 810 | ||
| 812 | #ifdef RE_ENABLE_I18N | 811 | #ifdef RE_ENABLE_I18N |
| @@ -822,7 +821,7 @@ re_compile_internal (regex_t *preg, const char * pattern, size_t length, | |||
| 822 | free_workarea_compile (preg); | 821 | free_workarea_compile (preg); |
| 823 | re_string_destruct (®exp); | 822 | re_string_destruct (®exp); |
| 824 | 823 | ||
| 825 | if (BE (err != REG_NOERROR, 0)) | 824 | if (__glibc_unlikely (err != REG_NOERROR)) |
| 826 | { | 825 | { |
| 827 | lock_fini (dfa->lock); | 826 | lock_fini (dfa->lock); |
| 828 | free_dfa_content (dfa); | 827 | free_dfa_content (dfa); |
| @@ -864,7 +863,8 @@ init_dfa (re_dfa_t *dfa, size_t pat_len) | |||
| 864 | calculation below, and for similar doubling calculations | 863 | calculation below, and for similar doubling calculations |
| 865 | elsewhere. And it's <= rather than <, because some of the | 864 | elsewhere. And it's <= rather than <, because some of the |
| 866 | doubling calculations add 1 afterwards. */ | 865 | doubling calculations add 1 afterwards. */ |
| 867 | if (BE (MIN (IDX_MAX, SIZE_MAX / max_object_size) / 2 <= pat_len, 0)) | 866 | if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / max_object_size) / 2 |
| 867 | <= pat_len)) | ||
| 868 | return REG_ESPACE; | 868 | return REG_ESPACE; |
| 869 | 869 | ||
| 870 | dfa->nodes_alloc = pat_len + 1; | 870 | dfa->nodes_alloc = pat_len + 1; |
| @@ -908,7 +908,7 @@ init_dfa (re_dfa_t *dfa, size_t pat_len) | |||
| 908 | int i, j, ch; | 908 | int i, j, ch; |
| 909 | 909 | ||
| 910 | dfa->sb_char = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); | 910 | dfa->sb_char = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); |
| 911 | if (BE (dfa->sb_char == NULL, 0)) | 911 | if (__glibc_unlikely (dfa->sb_char == NULL)) |
| 912 | return REG_ESPACE; | 912 | return REG_ESPACE; |
| 913 | 913 | ||
| 914 | /* Set the bits corresponding to single byte chars. */ | 914 | /* Set the bits corresponding to single byte chars. */ |
| @@ -927,7 +927,7 @@ init_dfa (re_dfa_t *dfa, size_t pat_len) | |||
| 927 | } | 927 | } |
| 928 | #endif | 928 | #endif |
| 929 | 929 | ||
| 930 | if (BE (dfa->nodes == NULL || dfa->state_table == NULL, 0)) | 930 | if (__glibc_unlikely (dfa->nodes == NULL || dfa->state_table == NULL)) |
| 931 | return REG_ESPACE; | 931 | return REG_ESPACE; |
| 932 | return REG_NOERROR; | 932 | return REG_NOERROR; |
| 933 | } | 933 | } |
| @@ -943,7 +943,7 @@ init_word_char (re_dfa_t *dfa) | |||
| 943 | int j; | 943 | int j; |
| 944 | int ch = 0; | 944 | int ch = 0; |
| 945 | dfa->word_ops_used = 1; | 945 | dfa->word_ops_used = 1; |
| 946 | if (BE (dfa->map_notascii == 0, 1)) | 946 | if (__glibc_likely (dfa->map_notascii == 0)) |
| 947 | { | 947 | { |
| 948 | /* Avoid uint32_t and uint64_t as some non-GCC platforms lack | 948 | /* Avoid uint32_t and uint64_t as some non-GCC platforms lack |
| 949 | them, an issue when this code is used in Gnulib. */ | 949 | them, an issue when this code is used in Gnulib. */ |
| @@ -970,7 +970,7 @@ init_word_char (re_dfa_t *dfa) | |||
| 970 | goto general_case; | 970 | goto general_case; |
| 971 | ch = 128; | 971 | ch = 128; |
| 972 | 972 | ||
| 973 | if (BE (dfa->is_utf8, 1)) | 973 | if (__glibc_likely (dfa->is_utf8)) |
| 974 | { | 974 | { |
| 975 | memset (&dfa->word_char[i], '\0', (SBC_MAX - ch) / 8); | 975 | memset (&dfa->word_char[i], '\0', (SBC_MAX - ch) / 8); |
| 976 | return; | 976 | return; |
| @@ -1017,7 +1017,7 @@ create_initial_state (re_dfa_t *dfa) | |||
| 1017 | first = dfa->str_tree->first->node_idx; | 1017 | first = dfa->str_tree->first->node_idx; |
| 1018 | dfa->init_node = first; | 1018 | dfa->init_node = first; |
| 1019 | err = re_node_set_init_copy (&init_nodes, dfa->eclosures + first); | 1019 | err = re_node_set_init_copy (&init_nodes, dfa->eclosures + first); |
| 1020 | if (BE (err != REG_NOERROR, 0)) | 1020 | if (__glibc_unlikely (err != REG_NOERROR)) |
| 1021 | return err; | 1021 | return err; |
| 1022 | 1022 | ||
| 1023 | /* The back-references which are in initial states can epsilon transit, | 1023 | /* The back-references which are in initial states can epsilon transit, |
| @@ -1061,7 +1061,7 @@ create_initial_state (re_dfa_t *dfa) | |||
| 1061 | /* It must be the first time to invoke acquire_state. */ | 1061 | /* It must be the first time to invoke acquire_state. */ |
| 1062 | dfa->init_state = re_acquire_state_context (&err, dfa, &init_nodes, 0); | 1062 | dfa->init_state = re_acquire_state_context (&err, dfa, &init_nodes, 0); |
| 1063 | /* We don't check ERR here, since the initial state must not be NULL. */ | 1063 | /* We don't check ERR here, since the initial state must not be NULL. */ |
| 1064 | if (BE (dfa->init_state == NULL, 0)) | 1064 | if (__glibc_unlikely (dfa->init_state == NULL)) |
| 1065 | return err; | 1065 | return err; |
| 1066 | if (dfa->init_state->has_constraint) | 1066 | if (dfa->init_state->has_constraint) |
| 1067 | { | 1067 | { |
| @@ -1073,8 +1073,9 @@ create_initial_state (re_dfa_t *dfa) | |||
| 1073 | &init_nodes, | 1073 | &init_nodes, |
| 1074 | CONTEXT_NEWLINE | 1074 | CONTEXT_NEWLINE |
| 1075 | | CONTEXT_BEGBUF); | 1075 | | CONTEXT_BEGBUF); |
| 1076 | if (BE (dfa->init_state_word == NULL || dfa->init_state_nl == NULL | 1076 | if (__glibc_unlikely (dfa->init_state_word == NULL |
| 1077 | || dfa->init_state_begbuf == NULL, 0)) | 1077 | || dfa->init_state_nl == NULL |
| 1078 | || dfa->init_state_begbuf == NULL)) | ||
| 1078 | return err; | 1079 | return err; |
| 1079 | } | 1080 | } |
| 1080 | else | 1081 | else |
| @@ -1181,8 +1182,8 @@ analyze (regex_t *preg) | |||
| 1181 | dfa->org_indices = re_malloc (Idx, dfa->nodes_alloc); | 1182 | dfa->org_indices = re_malloc (Idx, dfa->nodes_alloc); |
| 1182 | dfa->edests = re_malloc (re_node_set, dfa->nodes_alloc); | 1183 | dfa->edests = re_malloc (re_node_set, dfa->nodes_alloc); |
| 1183 | dfa->eclosures = re_malloc (re_node_set, dfa->nodes_alloc); | 1184 | dfa->eclosures = re_malloc (re_node_set, dfa->nodes_alloc); |
| 1184 | if (BE (dfa->nexts == NULL || dfa->org_indices == NULL || dfa->edests == NULL | 1185 | if (__glibc_unlikely (dfa->nexts == NULL || dfa->org_indices == NULL |
| 1185 | || dfa->eclosures == NULL, 0)) | 1186 | || dfa->edests == NULL || dfa->eclosures == NULL)) |
| 1186 | return REG_ESPACE; | 1187 | return REG_ESPACE; |
| 1187 | 1188 | ||
| 1188 | dfa->subexp_map = re_malloc (Idx, preg->re_nsub); | 1189 | dfa->subexp_map = re_malloc (Idx, preg->re_nsub); |
| @@ -1203,17 +1204,17 @@ analyze (regex_t *preg) | |||
| 1203 | } | 1204 | } |
| 1204 | 1205 | ||
| 1205 | ret = postorder (dfa->str_tree, lower_subexps, preg); | 1206 | ret = postorder (dfa->str_tree, lower_subexps, preg); |
| 1206 | if (BE (ret != REG_NOERROR, 0)) | 1207 | if (__glibc_unlikely (ret != REG_NOERROR)) |
| 1207 | return ret; | 1208 | return ret; |
| 1208 | ret = postorder (dfa->str_tree, calc_first, dfa); | 1209 | ret = postorder (dfa->str_tree, calc_first, dfa); |
| 1209 | if (BE (ret != REG_NOERROR, 0)) | 1210 | if (__glibc_unlikely (ret != REG_NOERROR)) |
| 1210 | return ret; | 1211 | return ret; |
| 1211 | preorder (dfa->str_tree, calc_next, dfa); | 1212 | preorder (dfa->str_tree, calc_next, dfa); |
| 1212 | ret = preorder (dfa->str_tree, link_nfa_nodes, dfa); | 1213 | ret = preorder (dfa->str_tree, link_nfa_nodes, dfa); |
| 1213 | if (BE (ret != REG_NOERROR, 0)) | 1214 | if (__glibc_unlikely (ret != REG_NOERROR)) |
| 1214 | return ret; | 1215 | return ret; |
| 1215 | ret = calc_eclosure (dfa); | 1216 | ret = calc_eclosure (dfa); |
| 1216 | if (BE (ret != REG_NOERROR, 0)) | 1217 | if (__glibc_unlikely (ret != REG_NOERROR)) |
| 1217 | return ret; | 1218 | return ret; |
| 1218 | 1219 | ||
| 1219 | /* We only need this during the prune_impossible_nodes pass in regexec.c; | 1220 | /* We only need this during the prune_impossible_nodes pass in regexec.c; |
| @@ -1222,7 +1223,7 @@ analyze (regex_t *preg) | |||
| 1222 | || dfa->nbackref) | 1223 | || dfa->nbackref) |
| 1223 | { | 1224 | { |
| 1224 | dfa->inveclosures = re_malloc (re_node_set, dfa->nodes_len); | 1225 | dfa->inveclosures = re_malloc (re_node_set, dfa->nodes_len); |
| 1225 | if (BE (dfa->inveclosures == NULL, 0)) | 1226 | if (__glibc_unlikely (dfa->inveclosures == NULL)) |
| 1226 | return REG_ESPACE; | 1227 | return REG_ESPACE; |
| 1227 | ret = calc_inveclosure (dfa); | 1228 | ret = calc_inveclosure (dfa); |
| 1228 | } | 1229 | } |
| @@ -1252,7 +1253,7 @@ postorder (bin_tree_t *root, reg_errcode_t (fn (void *, bin_tree_t *)), | |||
| 1252 | do | 1253 | do |
| 1253 | { | 1254 | { |
| 1254 | reg_errcode_t err = fn (extra, node); | 1255 | reg_errcode_t err = fn (extra, node); |
| 1255 | if (BE (err != REG_NOERROR, 0)) | 1256 | if (__glibc_unlikely (err != REG_NOERROR)) |
| 1256 | return err; | 1257 | return err; |
| 1257 | if (node->parent == NULL) | 1258 | if (node->parent == NULL) |
| 1258 | return REG_NOERROR; | 1259 | return REG_NOERROR; |
| @@ -1274,7 +1275,7 @@ preorder (bin_tree_t *root, reg_errcode_t (fn (void *, bin_tree_t *)), | |||
| 1274 | for (node = root; ; ) | 1275 | for (node = root; ; ) |
| 1275 | { | 1276 | { |
| 1276 | reg_errcode_t err = fn (extra, node); | 1277 | reg_errcode_t err = fn (extra, node); |
| 1277 | if (BE (err != REG_NOERROR, 0)) | 1278 | if (__glibc_unlikely (err != REG_NOERROR)) |
| 1278 | return err; | 1279 | return err; |
| 1279 | 1280 | ||
| 1280 | /* Go to the left node, or up and to the right. */ | 1281 | /* Go to the left node, or up and to the right. */ |
| @@ -1375,7 +1376,8 @@ lower_subexp (reg_errcode_t *err, regex_t *preg, bin_tree_t *node) | |||
| 1375 | cls = create_tree (dfa, NULL, NULL, OP_CLOSE_SUBEXP); | 1376 | cls = create_tree (dfa, NULL, NULL, OP_CLOSE_SUBEXP); |
| 1376 | tree1 = body ? create_tree (dfa, body, cls, CONCAT) : cls; | 1377 | tree1 = body ? create_tree (dfa, body, cls, CONCAT) : cls; |
| 1377 | tree = create_tree (dfa, op, tree1, CONCAT); | 1378 | tree = create_tree (dfa, op, tree1, CONCAT); |
| 1378 | if (BE (tree == NULL || tree1 == NULL || op == NULL || cls == NULL, 0)) | 1379 | if (__glibc_unlikely (tree == NULL || tree1 == NULL |
| 1380 | || op == NULL || cls == NULL)) | ||
| 1379 | { | 1381 | { |
| 1380 | *err = REG_ESPACE; | 1382 | *err = REG_ESPACE; |
| 1381 | return NULL; | 1383 | return NULL; |
| @@ -1401,7 +1403,7 @@ calc_first (void *extra, bin_tree_t *node) | |||
| 1401 | { | 1403 | { |
| 1402 | node->first = node; | 1404 | node->first = node; |
| 1403 | node->node_idx = re_dfa_add_node (dfa, node->token); | 1405 | node->node_idx = re_dfa_add_node (dfa, node->token); |
| 1404 | if (BE (node->node_idx == -1, 0)) | 1406 | if (__glibc_unlikely (node->node_idx == -1)) |
| 1405 | return REG_ESPACE; | 1407 | return REG_ESPACE; |
| 1406 | if (node->token.type == ANCHOR) | 1408 | if (node->token.type == ANCHOR) |
| 1407 | dfa->nodes[node->node_idx].constraint = node->token.opr.ctx_type; | 1409 | dfa->nodes[node->node_idx].constraint = node->token.opr.ctx_type; |
| @@ -1512,11 +1514,11 @@ duplicate_node_closure (re_dfa_t *dfa, Idx top_org_node, Idx top_clone_node, | |||
| 1512 | org_dest = dfa->nexts[org_node]; | 1514 | org_dest = dfa->nexts[org_node]; |
| 1513 | re_node_set_empty (dfa->edests + clone_node); | 1515 | re_node_set_empty (dfa->edests + clone_node); |
| 1514 | clone_dest = duplicate_node (dfa, org_dest, constraint); | 1516 | clone_dest = duplicate_node (dfa, org_dest, constraint); |
| 1515 | if (BE (clone_dest == -1, 0)) | 1517 | if (__glibc_unlikely (clone_dest == -1)) |
| 1516 | return REG_ESPACE; | 1518 | return REG_ESPACE; |
| 1517 | dfa->nexts[clone_node] = dfa->nexts[org_node]; | 1519 | dfa->nexts[clone_node] = dfa->nexts[org_node]; |
| 1518 | ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); | 1520 | ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); |
| 1519 | if (BE (! ok, 0)) | 1521 | if (__glibc_unlikely (! ok)) |
| 1520 | return REG_ESPACE; | 1522 | return REG_ESPACE; |
| 1521 | } | 1523 | } |
| 1522 | else if (dfa->edests[org_node].nelem == 0) | 1524 | else if (dfa->edests[org_node].nelem == 0) |
| @@ -1538,17 +1540,17 @@ duplicate_node_closure (re_dfa_t *dfa, Idx top_org_node, Idx top_clone_node, | |||
| 1538 | if (org_node == root_node && clone_node != org_node) | 1540 | if (org_node == root_node && clone_node != org_node) |
| 1539 | { | 1541 | { |
| 1540 | ok = re_node_set_insert (dfa->edests + clone_node, org_dest); | 1542 | ok = re_node_set_insert (dfa->edests + clone_node, org_dest); |
| 1541 | if (BE (! ok, 0)) | 1543 | if (__glibc_unlikely (! ok)) |
| 1542 | return REG_ESPACE; | 1544 | return REG_ESPACE; |
| 1543 | break; | 1545 | break; |
| 1544 | } | 1546 | } |
| 1545 | /* In case the node has another constraint, append it. */ | 1547 | /* In case the node has another constraint, append it. */ |
| 1546 | constraint |= dfa->nodes[org_node].constraint; | 1548 | constraint |= dfa->nodes[org_node].constraint; |
| 1547 | clone_dest = duplicate_node (dfa, org_dest, constraint); | 1549 | clone_dest = duplicate_node (dfa, org_dest, constraint); |
| 1548 | if (BE (clone_dest == -1, 0)) | 1550 | if (__glibc_unlikely (clone_dest == -1)) |
| 1549 | return REG_ESPACE; | 1551 | return REG_ESPACE; |
| 1550 | ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); | 1552 | ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); |
| 1551 | if (BE (! ok, 0)) | 1553 | if (__glibc_unlikely (! ok)) |
| 1552 | return REG_ESPACE; | 1554 | return REG_ESPACE; |
| 1553 | } | 1555 | } |
| 1554 | else /* dfa->edests[org_node].nelem == 2 */ | 1556 | else /* dfa->edests[org_node].nelem == 2 */ |
| @@ -1564,14 +1566,14 @@ duplicate_node_closure (re_dfa_t *dfa, Idx top_org_node, Idx top_clone_node, | |||
| 1564 | /* There is no such duplicated node, create a new one. */ | 1566 | /* There is no such duplicated node, create a new one. */ |
| 1565 | reg_errcode_t err; | 1567 | reg_errcode_t err; |
| 1566 | clone_dest = duplicate_node (dfa, org_dest, constraint); | 1568 | clone_dest = duplicate_node (dfa, org_dest, constraint); |
| 1567 | if (BE (clone_dest == -1, 0)) | 1569 | if (__glibc_unlikely (clone_dest == -1)) |
| 1568 | return REG_ESPACE; | 1570 | return REG_ESPACE; |
| 1569 | ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); | 1571 | ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); |
| 1570 | if (BE (! ok, 0)) | 1572 | if (__glibc_unlikely (! ok)) |
| 1571 | return REG_ESPACE; | 1573 | return REG_ESPACE; |
| 1572 | err = duplicate_node_closure (dfa, org_dest, clone_dest, | 1574 | err = duplicate_node_closure (dfa, org_dest, clone_dest, |
| 1573 | root_node, constraint); | 1575 | root_node, constraint); |
| 1574 | if (BE (err != REG_NOERROR, 0)) | 1576 | if (__glibc_unlikely (err != REG_NOERROR)) |
| 1575 | return err; | 1577 | return err; |
| 1576 | } | 1578 | } |
| 1577 | else | 1579 | else |
| @@ -1579,16 +1581,16 @@ duplicate_node_closure (re_dfa_t *dfa, Idx top_org_node, Idx top_clone_node, | |||
| 1579 | /* There is a duplicated node which satisfies the constraint, | 1581 | /* There is a duplicated node which satisfies the constraint, |
| 1580 | use it to avoid infinite loop. */ | 1582 | use it to avoid infinite loop. */ |
| 1581 | ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); | 1583 | ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); |
| 1582 | if (BE (! ok, 0)) | 1584 | if (__glibc_unlikely (! ok)) |
| 1583 | return REG_ESPACE; | 1585 | return REG_ESPACE; |
| 1584 | } | 1586 | } |
| 1585 | 1587 | ||
| 1586 | org_dest = dfa->edests[org_node].elems[1]; | 1588 | org_dest = dfa->edests[org_node].elems[1]; |
| 1587 | clone_dest = duplicate_node (dfa, org_dest, constraint); | 1589 | clone_dest = duplicate_node (dfa, org_dest, constraint); |
| 1588 | if (BE (clone_dest == -1, 0)) | 1590 | if (__glibc_unlikely (clone_dest == -1)) |
| 1589 | return REG_ESPACE; | 1591 | return REG_ESPACE; |
| 1590 | ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); | 1592 | ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); |
| 1591 | if (BE (! ok, 0)) | 1593 | if (__glibc_unlikely (! ok)) |
| 1592 | return REG_ESPACE; | 1594 | return REG_ESPACE; |
| 1593 | } | 1595 | } |
| 1594 | org_node = org_dest; | 1596 | org_node = org_dest; |
| @@ -1622,7 +1624,7 @@ static Idx | |||
| 1622 | duplicate_node (re_dfa_t *dfa, Idx org_idx, unsigned int constraint) | 1624 | duplicate_node (re_dfa_t *dfa, Idx org_idx, unsigned int constraint) |
| 1623 | { | 1625 | { |
| 1624 | Idx dup_idx = re_dfa_add_node (dfa, dfa->nodes[org_idx]); | 1626 | Idx dup_idx = re_dfa_add_node (dfa, dfa->nodes[org_idx]); |
| 1625 | if (BE (dup_idx != -1, 1)) | 1627 | if (__glibc_likely (dup_idx != -1)) |
| 1626 | { | 1628 | { |
| 1627 | dfa->nodes[dup_idx].constraint = constraint; | 1629 | dfa->nodes[dup_idx].constraint = constraint; |
| 1628 | dfa->nodes[dup_idx].constraint |= dfa->nodes[org_idx].constraint; | 1630 | dfa->nodes[dup_idx].constraint |= dfa->nodes[org_idx].constraint; |
| @@ -1648,7 +1650,7 @@ calc_inveclosure (re_dfa_t *dfa) | |||
| 1648 | for (idx = 0; idx < dfa->eclosures[src].nelem; ++idx) | 1650 | for (idx = 0; idx < dfa->eclosures[src].nelem; ++idx) |
| 1649 | { | 1651 | { |
| 1650 | ok = re_node_set_insert_last (dfa->inveclosures + elems[idx], src); | 1652 | ok = re_node_set_insert_last (dfa->inveclosures + elems[idx], src); |
| 1651 | if (BE (! ok, 0)) | 1653 | if (__glibc_unlikely (! ok)) |
| 1652 | return REG_ESPACE; | 1654 | return REG_ESPACE; |
| 1653 | } | 1655 | } |
| 1654 | } | 1656 | } |
| @@ -1689,7 +1691,7 @@ calc_eclosure (re_dfa_t *dfa) | |||
| 1689 | continue; | 1691 | continue; |
| 1690 | /* Calculate epsilon closure of 'node_idx'. */ | 1692 | /* Calculate epsilon closure of 'node_idx'. */ |
| 1691 | err = calc_eclosure_iter (&eclosure_elem, dfa, node_idx, true); | 1693 | err = calc_eclosure_iter (&eclosure_elem, dfa, node_idx, true); |
| 1692 | if (BE (err != REG_NOERROR, 0)) | 1694 | if (__glibc_unlikely (err != REG_NOERROR)) |
| 1693 | return err; | 1695 | return err; |
| 1694 | 1696 | ||
| 1695 | if (dfa->eclosures[node_idx].nelem == 0) | 1697 | if (dfa->eclosures[node_idx].nelem == 0) |
| @@ -1712,7 +1714,7 @@ calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root) | |||
| 1712 | bool ok; | 1714 | bool ok; |
| 1713 | bool incomplete = false; | 1715 | bool incomplete = false; |
| 1714 | err = re_node_set_alloc (&eclosure, dfa->edests[node].nelem + 1); | 1716 | err = re_node_set_alloc (&eclosure, dfa->edests[node].nelem + 1); |
| 1715 | if (BE (err != REG_NOERROR, 0)) | 1717 | if (__glibc_unlikely (err != REG_NOERROR)) |
| 1716 | return err; | 1718 | return err; |
| 1717 | 1719 | ||
| 1718 | /* This indicates that we are calculating this node now. | 1720 | /* This indicates that we are calculating this node now. |
| @@ -1727,7 +1729,7 @@ calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root) | |||
| 1727 | { | 1729 | { |
| 1728 | err = duplicate_node_closure (dfa, node, node, node, | 1730 | err = duplicate_node_closure (dfa, node, node, node, |
| 1729 | dfa->nodes[node].constraint); | 1731 | dfa->nodes[node].constraint); |
| 1730 | if (BE (err != REG_NOERROR, 0)) | 1732 | if (__glibc_unlikely (err != REG_NOERROR)) |
| 1731 | return err; | 1733 | return err; |
| 1732 | } | 1734 | } |
| 1733 | 1735 | ||
| @@ -1749,14 +1751,14 @@ calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root) | |||
| 1749 | if (dfa->eclosures[edest].nelem == 0) | 1751 | if (dfa->eclosures[edest].nelem == 0) |
| 1750 | { | 1752 | { |
| 1751 | err = calc_eclosure_iter (&eclosure_elem, dfa, edest, false); | 1753 | err = calc_eclosure_iter (&eclosure_elem, dfa, edest, false); |
| 1752 | if (BE (err != REG_NOERROR, 0)) | 1754 | if (__glibc_unlikely (err != REG_NOERROR)) |
| 1753 | return err; | 1755 | return err; |
| 1754 | } | 1756 | } |
| 1755 | else | 1757 | else |
| 1756 | eclosure_elem = dfa->eclosures[edest]; | 1758 | eclosure_elem = dfa->eclosures[edest]; |
| 1757 | /* Merge the epsilon closure of 'edest'. */ | 1759 | /* Merge the epsilon closure of 'edest'. */ |
| 1758 | err = re_node_set_merge (&eclosure, &eclosure_elem); | 1760 | err = re_node_set_merge (&eclosure, &eclosure_elem); |
| 1759 | if (BE (err != REG_NOERROR, 0)) | 1761 | if (__glibc_unlikely (err != REG_NOERROR)) |
| 1760 | return err; | 1762 | return err; |
| 1761 | /* If the epsilon closure of 'edest' is incomplete, | 1763 | /* If the epsilon closure of 'edest' is incomplete, |
| 1762 | the epsilon closure of this node is also incomplete. */ | 1764 | the epsilon closure of this node is also incomplete. */ |
| @@ -1769,7 +1771,7 @@ calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root) | |||
| 1769 | 1771 | ||
| 1770 | /* An epsilon closure includes itself. */ | 1772 | /* An epsilon closure includes itself. */ |
| 1771 | ok = re_node_set_insert (&eclosure, node); | 1773 | ok = re_node_set_insert (&eclosure, node); |
| 1772 | if (BE (! ok, 0)) | 1774 | if (__glibc_unlikely (! ok)) |
| 1773 | return REG_ESPACE; | 1775 | return REG_ESPACE; |
| 1774 | if (incomplete && !root) | 1776 | if (incomplete && !root) |
| 1775 | dfa->eclosures[node].nelem = 0; | 1777 | dfa->eclosures[node].nelem = 0; |
| @@ -2139,14 +2141,14 @@ parse (re_string_t *regexp, regex_t *preg, reg_syntax_t syntax, | |||
| 2139 | dfa->syntax = syntax; | 2141 | dfa->syntax = syntax; |
| 2140 | fetch_token (¤t_token, regexp, syntax | RE_CARET_ANCHORS_HERE); | 2142 | fetch_token (¤t_token, regexp, syntax | RE_CARET_ANCHORS_HERE); |
| 2141 | tree = parse_reg_exp (regexp, preg, ¤t_token, syntax, 0, err); | 2143 | tree = parse_reg_exp (regexp, preg, ¤t_token, syntax, 0, err); |
| 2142 | if (BE (*err != REG_NOERROR && tree == NULL, 0)) | 2144 | if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL)) |
| 2143 | return NULL; | 2145 | return NULL; |
| 2144 | eor = create_tree (dfa, NULL, NULL, END_OF_RE); | 2146 | eor = create_tree (dfa, NULL, NULL, END_OF_RE); |
| 2145 | if (tree != NULL) | 2147 | if (tree != NULL) |
| 2146 | root = create_tree (dfa, tree, eor, CONCAT); | 2148 | root = create_tree (dfa, tree, eor, CONCAT); |
| 2147 | else | 2149 | else |
| 2148 | root = eor; | 2150 | root = eor; |
| 2149 | if (BE (eor == NULL || root == NULL, 0)) | 2151 | if (__glibc_unlikely (eor == NULL || root == NULL)) |
| 2150 | { | 2152 | { |
| 2151 | *err = REG_ESPACE; | 2153 | *err = REG_ESPACE; |
| 2152 | return NULL; | 2154 | return NULL; |
| @@ -2171,7 +2173,7 @@ parse_reg_exp (re_string_t *regexp, regex_t *preg, re_token_t *token, | |||
| 2171 | bin_tree_t *tree, *branch = NULL; | 2173 | bin_tree_t *tree, *branch = NULL; |
| 2172 | bitset_word_t initial_bkref_map = dfa->completed_bkref_map; | 2174 | bitset_word_t initial_bkref_map = dfa->completed_bkref_map; |
| 2173 | tree = parse_branch (regexp, preg, token, syntax, nest, err); | 2175 | tree = parse_branch (regexp, preg, token, syntax, nest, err); |
| 2174 | if (BE (*err != REG_NOERROR && tree == NULL, 0)) | 2176 | if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL)) |
| 2175 | return NULL; | 2177 | return NULL; |
| 2176 | 2178 | ||
| 2177 | while (token->type == OP_ALT) | 2179 | while (token->type == OP_ALT) |
| @@ -2183,7 +2185,7 @@ parse_reg_exp (re_string_t *regexp, regex_t *preg, re_token_t *token, | |||
| 2183 | bitset_word_t accumulated_bkref_map = dfa->completed_bkref_map; | 2185 | bitset_word_t accumulated_bkref_map = dfa->completed_bkref_map; |
| 2184 | dfa->completed_bkref_map = initial_bkref_map; | 2186 | dfa->completed_bkref_map = initial_bkref_map; |
| 2185 | branch = parse_branch (regexp, preg, token, syntax, nest, err); | 2187 | branch = parse_branch (regexp, preg, token, syntax, nest, err); |
| 2186 | if (BE (*err != REG_NOERROR && branch == NULL, 0)) | 2188 | if (__glibc_unlikely (*err != REG_NOERROR && branch == NULL)) |
| 2187 | { | 2189 | { |
| 2188 | if (tree != NULL) | 2190 | if (tree != NULL) |
| 2189 | postorder (tree, free_tree, NULL); | 2191 | postorder (tree, free_tree, NULL); |
| @@ -2194,7 +2196,7 @@ parse_reg_exp (re_string_t *regexp, regex_t *preg, re_token_t *token, | |||
| 2194 | else | 2196 | else |
| 2195 | branch = NULL; | 2197 | branch = NULL; |
| 2196 | tree = create_tree (dfa, tree, branch, OP_ALT); | 2198 | tree = create_tree (dfa, tree, branch, OP_ALT); |
| 2197 | if (BE (tree == NULL, 0)) | 2199 | if (__glibc_unlikely (tree == NULL)) |
| 2198 | { | 2200 | { |
| 2199 | *err = REG_ESPACE; | 2201 | *err = REG_ESPACE; |
| 2200 | return NULL; | 2202 | return NULL; |
| @@ -2219,14 +2221,14 @@ parse_branch (re_string_t *regexp, regex_t *preg, re_token_t *token, | |||
| 2219 | bin_tree_t *tree, *expr; | 2221 | bin_tree_t *tree, *expr; |
| 2220 | re_dfa_t *dfa = preg->buffer; | 2222 | re_dfa_t *dfa = preg->buffer; |
| 2221 | tree = parse_expression (regexp, preg, token, syntax, nest, err); | 2223 | tree = parse_expression (regexp, preg, token, syntax, nest, err); |
| 2222 | if (BE (*err != REG_NOERROR && tree == NULL, 0)) | 2224 | if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL)) |
| 2223 | return NULL; | 2225 | return NULL; |
| 2224 | 2226 | ||
| 2225 | while (token->type != OP_ALT && token->type != END_OF_RE | 2227 | while (token->type != OP_ALT && token->type != END_OF_RE |
| 2226 | && (nest == 0 || token->type != OP_CLOSE_SUBEXP)) | 2228 | && (nest == 0 || token->type != OP_CLOSE_SUBEXP)) |
| 2227 | { | 2229 | { |
| 2228 | expr = parse_expression (regexp, preg, token, syntax, nest, err); | 2230 | expr = parse_expression (regexp, preg, token, syntax, nest, err); |
| 2229 | if (BE (*err != REG_NOERROR && expr == NULL, 0)) | 2231 | if (__glibc_unlikely (*err != REG_NOERROR && expr == NULL)) |
| 2230 | { | 2232 | { |
| 2231 | if (tree != NULL) | 2233 | if (tree != NULL) |
| 2232 | postorder (tree, free_tree, NULL); | 2234 | postorder (tree, free_tree, NULL); |
| @@ -2267,7 +2269,7 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token, | |||
| 2267 | { | 2269 | { |
| 2268 | case CHARACTER: | 2270 | case CHARACTER: |
| 2269 | tree = create_token_tree (dfa, NULL, NULL, token); | 2271 | tree = create_token_tree (dfa, NULL, NULL, token); |
| 2270 | if (BE (tree == NULL, 0)) | 2272 | if (__glibc_unlikely (tree == NULL)) |
| 2271 | { | 2273 | { |
| 2272 | *err = REG_ESPACE; | 2274 | *err = REG_ESPACE; |
| 2273 | return NULL; | 2275 | return NULL; |
| @@ -2282,7 +2284,7 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token, | |||
| 2282 | fetch_token (token, regexp, syntax); | 2284 | fetch_token (token, regexp, syntax); |
| 2283 | mbc_remain = create_token_tree (dfa, NULL, NULL, token); | 2285 | mbc_remain = create_token_tree (dfa, NULL, NULL, token); |
| 2284 | tree = create_tree (dfa, tree, mbc_remain, CONCAT); | 2286 | tree = create_tree (dfa, tree, mbc_remain, CONCAT); |
| 2285 | if (BE (mbc_remain == NULL || tree == NULL, 0)) | 2287 | if (__glibc_unlikely (mbc_remain == NULL || tree == NULL)) |
| 2286 | { | 2288 | { |
| 2287 | *err = REG_ESPACE; | 2289 | *err = REG_ESPACE; |
| 2288 | return NULL; | 2290 | return NULL; |
| @@ -2294,25 +2296,25 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token, | |||
| 2294 | 2296 | ||
| 2295 | case OP_OPEN_SUBEXP: | 2297 | case OP_OPEN_SUBEXP: |
| 2296 | tree = parse_sub_exp (regexp, preg, token, syntax, nest + 1, err); | 2298 | tree = parse_sub_exp (regexp, preg, token, syntax, nest + 1, err); |
| 2297 | if (BE (*err != REG_NOERROR && tree == NULL, 0)) | 2299 | if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL)) |
| 2298 | return NULL; | 2300 | return NULL; |
| 2299 | break; | 2301 | break; |
| 2300 | 2302 | ||
| 2301 | case OP_OPEN_BRACKET: | 2303 | case OP_OPEN_BRACKET: |
| 2302 | tree = parse_bracket_exp (regexp, dfa, token, syntax, err); | 2304 | tree = parse_bracket_exp (regexp, dfa, token, syntax, err); |
| 2303 | if (BE (*err != REG_NOERROR && tree == NULL, 0)) | 2305 | if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL)) |
| 2304 | return NULL; | 2306 | return NULL; |
| 2305 | break; | 2307 | break; |
| 2306 | 2308 | ||
| 2307 | case OP_BACK_REF: | 2309 | case OP_BACK_REF: |
| 2308 | if (!BE (dfa->completed_bkref_map & (1 << token->opr.idx), 1)) | 2310 | if (!__glibc_likely (dfa->completed_bkref_map & (1 << token->opr.idx))) |
| 2309 | { | 2311 | { |
| 2310 | *err = REG_ESUBREG; | 2312 | *err = REG_ESUBREG; |
| 2311 | return NULL; | 2313 | return NULL; |
| 2312 | } | 2314 | } |
| 2313 | dfa->used_bkref_map |= 1 << token->opr.idx; | 2315 | dfa->used_bkref_map |= 1 << token->opr.idx; |
| 2314 | tree = create_token_tree (dfa, NULL, NULL, token); | 2316 | tree = create_token_tree (dfa, NULL, NULL, token); |
| 2315 | if (BE (tree == NULL, 0)) | 2317 | if (__glibc_unlikely (tree == NULL)) |
| 2316 | { | 2318 | { |
| 2317 | *err = REG_ESPACE; | 2319 | *err = REG_ESPACE; |
| 2318 | return NULL; | 2320 | return NULL; |
| @@ -2358,7 +2360,7 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token, | |||
| 2358 | /* mb_partial and word_char bits should be initialized already | 2360 | /* mb_partial and word_char bits should be initialized already |
| 2359 | by peek_token. */ | 2361 | by peek_token. */ |
| 2360 | tree = create_token_tree (dfa, NULL, NULL, token); | 2362 | tree = create_token_tree (dfa, NULL, NULL, token); |
| 2361 | if (BE (tree == NULL, 0)) | 2363 | if (__glibc_unlikely (tree == NULL)) |
| 2362 | { | 2364 | { |
| 2363 | *err = REG_ESPACE; | 2365 | *err = REG_ESPACE; |
| 2364 | return NULL; | 2366 | return NULL; |
| @@ -2388,7 +2390,8 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token, | |||
| 2388 | } | 2390 | } |
| 2389 | tree_last = create_token_tree (dfa, NULL, NULL, token); | 2391 | tree_last = create_token_tree (dfa, NULL, NULL, token); |
| 2390 | tree = create_tree (dfa, tree_first, tree_last, OP_ALT); | 2392 | tree = create_tree (dfa, tree_first, tree_last, OP_ALT); |
| 2391 | if (BE (tree_first == NULL || tree_last == NULL || tree == NULL, 0)) | 2393 | if (__glibc_unlikely (tree_first == NULL || tree_last == NULL |
| 2394 | || tree == NULL)) | ||
| 2392 | { | 2395 | { |
| 2393 | *err = REG_ESPACE; | 2396 | *err = REG_ESPACE; |
| 2394 | return NULL; | 2397 | return NULL; |
| @@ -2397,7 +2400,7 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token, | |||
| 2397 | else | 2400 | else |
| 2398 | { | 2401 | { |
| 2399 | tree = create_token_tree (dfa, NULL, NULL, token); | 2402 | tree = create_token_tree (dfa, NULL, NULL, token); |
| 2400 | if (BE (tree == NULL, 0)) | 2403 | if (__glibc_unlikely (tree == NULL)) |
| 2401 | { | 2404 | { |
| 2402 | *err = REG_ESPACE; | 2405 | *err = REG_ESPACE; |
| 2403 | return NULL; | 2406 | return NULL; |
| @@ -2412,7 +2415,7 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token, | |||
| 2412 | 2415 | ||
| 2413 | case OP_PERIOD: | 2416 | case OP_PERIOD: |
| 2414 | tree = create_token_tree (dfa, NULL, NULL, token); | 2417 | tree = create_token_tree (dfa, NULL, NULL, token); |
| 2415 | if (BE (tree == NULL, 0)) | 2418 | if (__glibc_unlikely (tree == NULL)) |
| 2416 | { | 2419 | { |
| 2417 | *err = REG_ESPACE; | 2420 | *err = REG_ESPACE; |
| 2418 | return NULL; | 2421 | return NULL; |
| @@ -2427,7 +2430,7 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token, | |||
| 2427 | "alnum", | 2430 | "alnum", |
| 2428 | "_", | 2431 | "_", |
| 2429 | token->type == OP_NOTWORD, err); | 2432 | token->type == OP_NOTWORD, err); |
| 2430 | if (BE (*err != REG_NOERROR && tree == NULL, 0)) | 2433 | if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL)) |
| 2431 | return NULL; | 2434 | return NULL; |
| 2432 | break; | 2435 | break; |
| 2433 | 2436 | ||
| @@ -2437,7 +2440,7 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token, | |||
| 2437 | "space", | 2440 | "space", |
| 2438 | "", | 2441 | "", |
| 2439 | token->type == OP_NOTSPACE, err); | 2442 | token->type == OP_NOTSPACE, err); |
| 2440 | if (BE (*err != REG_NOERROR && tree == NULL, 0)) | 2443 | if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL)) |
| 2441 | return NULL; | 2444 | return NULL; |
| 2442 | break; | 2445 | break; |
| 2443 | 2446 | ||
| @@ -2463,7 +2466,7 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token, | |||
| 2463 | { | 2466 | { |
| 2464 | bin_tree_t *dup_tree = parse_dup_op (tree, regexp, dfa, token, | 2467 | bin_tree_t *dup_tree = parse_dup_op (tree, regexp, dfa, token, |
| 2465 | syntax, err); | 2468 | syntax, err); |
| 2466 | if (BE (*err != REG_NOERROR && dup_tree == NULL, 0)) | 2469 | if (__glibc_unlikely (*err != REG_NOERROR && dup_tree == NULL)) |
| 2467 | { | 2470 | { |
| 2468 | if (tree != NULL) | 2471 | if (tree != NULL) |
| 2469 | postorder (tree, free_tree, NULL); | 2472 | postorder (tree, free_tree, NULL); |
| @@ -2509,13 +2512,14 @@ parse_sub_exp (re_string_t *regexp, regex_t *preg, re_token_t *token, | |||
| 2509 | else | 2512 | else |
| 2510 | { | 2513 | { |
| 2511 | tree = parse_reg_exp (regexp, preg, token, syntax, nest, err); | 2514 | tree = parse_reg_exp (regexp, preg, token, syntax, nest, err); |
| 2512 | if (BE (*err == REG_NOERROR && token->type != OP_CLOSE_SUBEXP, 0)) | 2515 | if (__glibc_unlikely (*err == REG_NOERROR |
| 2516 | && token->type != OP_CLOSE_SUBEXP)) | ||
| 2513 | { | 2517 | { |
| 2514 | if (tree != NULL) | 2518 | if (tree != NULL) |
| 2515 | postorder (tree, free_tree, NULL); | 2519 | postorder (tree, free_tree, NULL); |
| 2516 | *err = REG_EPAREN; | 2520 | *err = REG_EPAREN; |
| 2517 | } | 2521 | } |
| 2518 | if (BE (*err != REG_NOERROR, 0)) | 2522 | if (__glibc_unlikely (*err != REG_NOERROR)) |
| 2519 | return NULL; | 2523 | return NULL; |
| 2520 | } | 2524 | } |
| 2521 | 2525 | ||
| @@ -2523,7 +2527,7 @@ parse_sub_exp (re_string_t *regexp, regex_t *preg, re_token_t *token, | |||
| 2523 | dfa->completed_bkref_map |= 1 << cur_nsub; | 2527 | dfa->completed_bkref_map |= 1 << cur_nsub; |
| 2524 | 2528 | ||
| 2525 | tree = create_tree (dfa, tree, NULL, SUBEXP); | 2529 | tree = create_tree (dfa, tree, NULL, SUBEXP); |
| 2526 | if (BE (tree == NULL, 0)) | 2530 | if (__glibc_unlikely (tree == NULL)) |
| 2527 | { | 2531 | { |
| 2528 | *err = REG_ESPACE; | 2532 | *err = REG_ESPACE; |
| 2529 | return NULL; | 2533 | return NULL; |
| @@ -2556,17 +2560,17 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa, | |||
| 2556 | return NULL; | 2560 | return NULL; |
| 2557 | } | 2561 | } |
| 2558 | } | 2562 | } |
| 2559 | if (BE (start != -2, 1)) | 2563 | if (__glibc_likely (start != -2)) |
| 2560 | { | 2564 | { |
| 2561 | /* We treat "{n}" as "{n,n}". */ | 2565 | /* We treat "{n}" as "{n,n}". */ |
| 2562 | end = ((token->type == OP_CLOSE_DUP_NUM) ? start | 2566 | end = ((token->type == OP_CLOSE_DUP_NUM) ? start |
| 2563 | : ((token->type == CHARACTER && token->opr.c == ',') | 2567 | : ((token->type == CHARACTER && token->opr.c == ',') |
| 2564 | ? fetch_number (regexp, token, syntax) : -2)); | 2568 | ? fetch_number (regexp, token, syntax) : -2)); |
| 2565 | } | 2569 | } |
| 2566 | if (BE (start == -2 || end == -2, 0)) | 2570 | if (__glibc_unlikely (start == -2 || end == -2)) |
| 2567 | { | 2571 | { |
| 2568 | /* Invalid sequence. */ | 2572 | /* Invalid sequence. */ |
| 2569 | if (BE (!(syntax & RE_INVALID_INTERVAL_ORD), 0)) | 2573 | if (__glibc_unlikely (!(syntax & RE_INVALID_INTERVAL_ORD))) |
| 2570 | { | 2574 | { |
| 2571 | if (token->type == END_OF_RE) | 2575 | if (token->type == END_OF_RE) |
| 2572 | *err = REG_EBRACE; | 2576 | *err = REG_EBRACE; |
| @@ -2585,15 +2589,15 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa, | |||
| 2585 | return elem; | 2589 | return elem; |
| 2586 | } | 2590 | } |
| 2587 | 2591 | ||
| 2588 | if (BE ((end != -1 && start > end) | 2592 | if (__glibc_unlikely ((end != -1 && start > end) |
| 2589 | || token->type != OP_CLOSE_DUP_NUM, 0)) | 2593 | || token->type != OP_CLOSE_DUP_NUM)) |
| 2590 | { | 2594 | { |
| 2591 | /* First number greater than second. */ | 2595 | /* First number greater than second. */ |
| 2592 | *err = REG_BADBR; | 2596 | *err = REG_BADBR; |
| 2593 | return NULL; | 2597 | return NULL; |
| 2594 | } | 2598 | } |
| 2595 | 2599 | ||
| 2596 | if (BE (RE_DUP_MAX < (end == -1 ? start : end), 0)) | 2600 | if (__glibc_unlikely (RE_DUP_MAX < (end == -1 ? start : end))) |
| 2597 | { | 2601 | { |
| 2598 | *err = REG_ESIZE; | 2602 | *err = REG_ESIZE; |
| 2599 | return NULL; | 2603 | return NULL; |
| @@ -2607,23 +2611,23 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa, | |||
| 2607 | 2611 | ||
| 2608 | fetch_token (token, regexp, syntax); | 2612 | fetch_token (token, regexp, syntax); |
| 2609 | 2613 | ||
| 2610 | if (BE (elem == NULL, 0)) | 2614 | if (__glibc_unlikely (elem == NULL)) |
| 2611 | return NULL; | 2615 | return NULL; |
| 2612 | if (BE (start == 0 && end == 0, 0)) | 2616 | if (__glibc_unlikely (start == 0 && end == 0)) |
| 2613 | { | 2617 | { |
| 2614 | postorder (elem, free_tree, NULL); | 2618 | postorder (elem, free_tree, NULL); |
| 2615 | return NULL; | 2619 | return NULL; |
| 2616 | } | 2620 | } |
| 2617 | 2621 | ||
| 2618 | /* Extract "<re>{n,m}" to "<re><re>...<re><re>{0,<m-n>}". */ | 2622 | /* Extract "<re>{n,m}" to "<re><re>...<re><re>{0,<m-n>}". */ |
| 2619 | if (BE (start > 0, 0)) | 2623 | if (__glibc_unlikely (start > 0)) |
| 2620 | { | 2624 | { |
| 2621 | tree = elem; | 2625 | tree = elem; |
| 2622 | for (i = 2; i <= start; ++i) | 2626 | for (i = 2; i <= start; ++i) |
| 2623 | { | 2627 | { |
| 2624 | elem = duplicate_tree (elem, dfa); | 2628 | elem = duplicate_tree (elem, dfa); |
| 2625 | tree = create_tree (dfa, tree, elem, CONCAT); | 2629 | tree = create_tree (dfa, tree, elem, CONCAT); |
| 2626 | if (BE (elem == NULL || tree == NULL, 0)) | 2630 | if (__glibc_unlikely (elem == NULL || tree == NULL)) |
| 2627 | goto parse_dup_op_espace; | 2631 | goto parse_dup_op_espace; |
| 2628 | } | 2632 | } |
| 2629 | 2633 | ||
| @@ -2632,7 +2636,7 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa, | |||
| 2632 | 2636 | ||
| 2633 | /* Duplicate ELEM before it is marked optional. */ | 2637 | /* Duplicate ELEM before it is marked optional. */ |
| 2634 | elem = duplicate_tree (elem, dfa); | 2638 | elem = duplicate_tree (elem, dfa); |
| 2635 | if (BE (elem == NULL, 0)) | 2639 | if (__glibc_unlikely (elem == NULL)) |
| 2636 | goto parse_dup_op_espace; | 2640 | goto parse_dup_op_espace; |
| 2637 | old_tree = tree; | 2641 | old_tree = tree; |
| 2638 | } | 2642 | } |
| @@ -2647,7 +2651,7 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa, | |||
| 2647 | 2651 | ||
| 2648 | tree = create_tree (dfa, elem, NULL, | 2652 | tree = create_tree (dfa, elem, NULL, |
| 2649 | (end == -1 ? OP_DUP_ASTERISK : OP_ALT)); | 2653 | (end == -1 ? OP_DUP_ASTERISK : OP_ALT)); |
| 2650 | if (BE (tree == NULL, 0)) | 2654 | if (__glibc_unlikely (tree == NULL)) |
| 2651 | goto parse_dup_op_espace; | 2655 | goto parse_dup_op_espace; |
| 2652 | 2656 | ||
| 2653 | /* This loop is actually executed only when end != -1, | 2657 | /* This loop is actually executed only when end != -1, |
| @@ -2658,11 +2662,11 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa, | |||
| 2658 | { | 2662 | { |
| 2659 | elem = duplicate_tree (elem, dfa); | 2663 | elem = duplicate_tree (elem, dfa); |
| 2660 | tree = create_tree (dfa, tree, elem, CONCAT); | 2664 | tree = create_tree (dfa, tree, elem, CONCAT); |
| 2661 | if (BE (elem == NULL || tree == NULL, 0)) | 2665 | if (__glibc_unlikely (elem == NULL || tree == NULL)) |
| 2662 | goto parse_dup_op_espace; | 2666 | goto parse_dup_op_espace; |
| 2663 | 2667 | ||
| 2664 | tree = create_tree (dfa, tree, NULL, OP_ALT); | 2668 | tree = create_tree (dfa, tree, NULL, OP_ALT); |
| 2665 | if (BE (tree == NULL, 0)) | 2669 | if (__glibc_unlikely (tree == NULL)) |
| 2666 | goto parse_dup_op_espace; | 2670 | goto parse_dup_op_espace; |
| 2667 | } | 2671 | } |
| 2668 | 2672 | ||
| @@ -2717,17 +2721,18 @@ build_range_exp (const reg_syntax_t syntax, | |||
| 2717 | { | 2721 | { |
| 2718 | unsigned int start_ch, end_ch; | 2722 | unsigned int start_ch, end_ch; |
| 2719 | /* Equivalence Classes and Character Classes can't be a range start/end. */ | 2723 | /* Equivalence Classes and Character Classes can't be a range start/end. */ |
| 2720 | if (BE (start_elem->type == EQUIV_CLASS || start_elem->type == CHAR_CLASS | 2724 | if (__glibc_unlikely (start_elem->type == EQUIV_CLASS |
| 2721 | || end_elem->type == EQUIV_CLASS || end_elem->type == CHAR_CLASS, | 2725 | || start_elem->type == CHAR_CLASS |
| 2722 | 0)) | 2726 | || end_elem->type == EQUIV_CLASS |
| 2727 | || end_elem->type == CHAR_CLASS)) | ||
| 2723 | return REG_ERANGE; | 2728 | return REG_ERANGE; |
| 2724 | 2729 | ||
| 2725 | /* We can handle no multi character collating elements without libc | 2730 | /* We can handle no multi character collating elements without libc |
| 2726 | support. */ | 2731 | support. */ |
| 2727 | if (BE ((start_elem->type == COLL_SYM | 2732 | if (__glibc_unlikely ((start_elem->type == COLL_SYM |
| 2728 | && strlen ((char *) start_elem->opr.name) > 1) | 2733 | && strlen ((char *) start_elem->opr.name) > 1) |
| 2729 | || (end_elem->type == COLL_SYM | 2734 | || (end_elem->type == COLL_SYM |
| 2730 | && strlen ((char *) end_elem->opr.name) > 1), 0)) | 2735 | && strlen ((char *) end_elem->opr.name) > 1))) |
| 2731 | return REG_ECOLLATE; | 2736 | return REG_ECOLLATE; |
| 2732 | 2737 | ||
| 2733 | # ifdef RE_ENABLE_I18N | 2738 | # ifdef RE_ENABLE_I18N |
| @@ -2748,7 +2753,8 @@ build_range_exp (const reg_syntax_t syntax, | |||
| 2748 | ? parse_byte (end_ch, mbcset) : end_elem->opr.wch); | 2753 | ? parse_byte (end_ch, mbcset) : end_elem->opr.wch); |
| 2749 | if (start_wc == WEOF || end_wc == WEOF) | 2754 | if (start_wc == WEOF || end_wc == WEOF) |
| 2750 | return REG_ECOLLATE; | 2755 | return REG_ECOLLATE; |
| 2751 | else if (BE ((syntax & RE_NO_EMPTY_RANGES) && start_wc > end_wc, 0)) | 2756 | else if (__glibc_unlikely ((syntax & RE_NO_EMPTY_RANGES) |
| 2757 | && start_wc > end_wc)) | ||
| 2752 | return REG_ERANGE; | 2758 | return REG_ERANGE; |
| 2753 | 2759 | ||
| 2754 | /* Got valid collation sequence values, add them as a new entry. | 2760 | /* Got valid collation sequence values, add them as a new entry. |
| @@ -2759,7 +2765,7 @@ build_range_exp (const reg_syntax_t syntax, | |||
| 2759 | if (mbcset) | 2765 | if (mbcset) |
| 2760 | { | 2766 | { |
| 2761 | /* Check the space of the arrays. */ | 2767 | /* Check the space of the arrays. */ |
| 2762 | if (BE (*range_alloc == mbcset->nranges, 0)) | 2768 | if (__glibc_unlikely (*range_alloc == mbcset->nranges)) |
| 2763 | { | 2769 | { |
| 2764 | /* There is not enough space, need realloc. */ | 2770 | /* There is not enough space, need realloc. */ |
| 2765 | wchar_t *new_array_start, *new_array_end; | 2771 | wchar_t *new_array_start, *new_array_end; |
| @@ -2774,7 +2780,8 @@ build_range_exp (const reg_syntax_t syntax, | |||
| 2774 | new_array_end = re_realloc (mbcset->range_ends, wchar_t, | 2780 | new_array_end = re_realloc (mbcset->range_ends, wchar_t, |
| 2775 | new_nranges); | 2781 | new_nranges); |
| 2776 | 2782 | ||
| 2777 | if (BE (new_array_start == NULL || new_array_end == NULL, 0)) | 2783 | if (__glibc_unlikely (new_array_start == NULL |
| 2784 | || new_array_end == NULL)) | ||
| 2778 | { | 2785 | { |
| 2779 | re_free (new_array_start); | 2786 | re_free (new_array_start); |
| 2780 | re_free (new_array_end); | 2787 | re_free (new_array_end); |
| @@ -2834,7 +2841,7 @@ build_collating_symbol (bitset_t sbcset, const unsigned char *name) | |||
| 2834 | # endif /* not RE_ENABLE_I18N */ | 2841 | # endif /* not RE_ENABLE_I18N */ |
| 2835 | { | 2842 | { |
| 2836 | size_t name_len = strlen ((const char *) name); | 2843 | size_t name_len = strlen ((const char *) name); |
| 2837 | if (BE (name_len != 1, 0)) | 2844 | if (__glibc_unlikely (name_len != 1)) |
| 2838 | return REG_ECOLLATE; | 2845 | return REG_ECOLLATE; |
| 2839 | else | 2846 | else |
| 2840 | { | 2847 | { |
| @@ -2969,18 +2976,21 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, | |||
| 2969 | 2976 | ||
| 2970 | /* Equivalence Classes and Character Classes can't be a range | 2977 | /* Equivalence Classes and Character Classes can't be a range |
| 2971 | start/end. */ | 2978 | start/end. */ |
| 2972 | if (BE (start_elem->type == EQUIV_CLASS || start_elem->type == CHAR_CLASS | 2979 | if (__glibc_unlikely (start_elem->type == EQUIV_CLASS |
| 2973 | || end_elem->type == EQUIV_CLASS || end_elem->type == CHAR_CLASS, | 2980 | || start_elem->type == CHAR_CLASS |
| 2974 | 0)) | 2981 | || end_elem->type == EQUIV_CLASS |
| 2982 | || end_elem->type == CHAR_CLASS)) | ||
| 2975 | return REG_ERANGE; | 2983 | return REG_ERANGE; |
| 2976 | 2984 | ||
| 2977 | /* FIXME: Implement rational ranges here, too. */ | 2985 | /* FIXME: Implement rational ranges here, too. */ |
| 2978 | start_collseq = lookup_collation_sequence_value (start_elem); | 2986 | start_collseq = lookup_collation_sequence_value (start_elem); |
| 2979 | end_collseq = lookup_collation_sequence_value (end_elem); | 2987 | end_collseq = lookup_collation_sequence_value (end_elem); |
| 2980 | /* Check start/end collation sequence values. */ | 2988 | /* Check start/end collation sequence values. */ |
| 2981 | if (BE (start_collseq == UINT_MAX || end_collseq == UINT_MAX, 0)) | 2989 | if (__glibc_unlikely (start_collseq == UINT_MAX |
| 2990 | || end_collseq == UINT_MAX)) | ||
| 2982 | return REG_ECOLLATE; | 2991 | return REG_ECOLLATE; |
| 2983 | if (BE ((syntax & RE_NO_EMPTY_RANGES) && start_collseq > end_collseq, 0)) | 2992 | if (__glibc_unlikely ((syntax & RE_NO_EMPTY_RANGES) |
| 2993 | && start_collseq > end_collseq)) | ||
| 2984 | return REG_ERANGE; | 2994 | return REG_ERANGE; |
| 2985 | 2995 | ||
| 2986 | /* Got valid collation sequence values, add them as a new entry. | 2996 | /* Got valid collation sequence values, add them as a new entry. |
| @@ -2990,7 +3000,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, | |||
| 2990 | if (nrules > 0 || dfa->mb_cur_max > 1) | 3000 | if (nrules > 0 || dfa->mb_cur_max > 1) |
| 2991 | { | 3001 | { |
| 2992 | /* Check the space of the arrays. */ | 3002 | /* Check the space of the arrays. */ |
| 2993 | if (BE (*range_alloc == mbcset->nranges, 0)) | 3003 | if (__glibc_unlikely (*range_alloc == mbcset->nranges)) |
| 2994 | { | 3004 | { |
| 2995 | /* There is not enough space, need realloc. */ | 3005 | /* There is not enough space, need realloc. */ |
| 2996 | uint32_t *new_array_start; | 3006 | uint32_t *new_array_start; |
| @@ -3004,7 +3014,8 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, | |||
| 3004 | new_array_end = re_realloc (mbcset->range_ends, uint32_t, | 3014 | new_array_end = re_realloc (mbcset->range_ends, uint32_t, |
| 3005 | new_nranges); | 3015 | new_nranges); |
| 3006 | 3016 | ||
| 3007 | if (BE (new_array_start == NULL || new_array_end == NULL, 0)) | 3017 | if (__glibc_unlikely (new_array_start == NULL |
| 3018 | || new_array_end == NULL)) | ||
| 3008 | return REG_ESPACE; | 3019 | return REG_ESPACE; |
| 3009 | 3020 | ||
| 3010 | mbcset->range_starts = new_array_start; | 3021 | mbcset->range_starts = new_array_start; |
| @@ -3068,7 +3079,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, | |||
| 3068 | 3079 | ||
| 3069 | /* Got valid collation sequence, add it as a new entry. */ | 3080 | /* Got valid collation sequence, add it as a new entry. */ |
| 3070 | /* Check the space of the arrays. */ | 3081 | /* Check the space of the arrays. */ |
| 3071 | if (BE (*coll_sym_alloc == mbcset->ncoll_syms, 0)) | 3082 | if (__glibc_unlikely (*coll_sym_alloc == mbcset->ncoll_syms)) |
| 3072 | { | 3083 | { |
| 3073 | /* Not enough, realloc it. */ | 3084 | /* Not enough, realloc it. */ |
| 3074 | /* +1 in case of mbcset->ncoll_syms is 0. */ | 3085 | /* +1 in case of mbcset->ncoll_syms is 0. */ |
| @@ -3077,7 +3088,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, | |||
| 3077 | if *alloc == 0. */ | 3088 | if *alloc == 0. */ |
| 3078 | int32_t *new_coll_syms = re_realloc (mbcset->coll_syms, int32_t, | 3089 | int32_t *new_coll_syms = re_realloc (mbcset->coll_syms, int32_t, |
| 3079 | new_coll_sym_alloc); | 3090 | new_coll_sym_alloc); |
| 3080 | if (BE (new_coll_syms == NULL, 0)) | 3091 | if (__glibc_unlikely (new_coll_syms == NULL)) |
| 3081 | return REG_ESPACE; | 3092 | return REG_ESPACE; |
| 3082 | mbcset->coll_syms = new_coll_syms; | 3093 | mbcset->coll_syms = new_coll_syms; |
| 3083 | *coll_sym_alloc = new_coll_sym_alloc; | 3094 | *coll_sym_alloc = new_coll_sym_alloc; |
| @@ -3087,7 +3098,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, | |||
| 3087 | } | 3098 | } |
| 3088 | else | 3099 | else |
| 3089 | { | 3100 | { |
| 3090 | if (BE (name_len != 1, 0)) | 3101 | if (__glibc_unlikely (name_len != 1)) |
| 3091 | return REG_ECOLLATE; | 3102 | return REG_ECOLLATE; |
| 3092 | else | 3103 | else |
| 3093 | { | 3104 | { |
| @@ -3131,9 +3142,9 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, | |||
| 3131 | mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1); | 3142 | mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1); |
| 3132 | #endif /* RE_ENABLE_I18N */ | 3143 | #endif /* RE_ENABLE_I18N */ |
| 3133 | #ifdef RE_ENABLE_I18N | 3144 | #ifdef RE_ENABLE_I18N |
| 3134 | if (BE (sbcset == NULL || mbcset == NULL, 0)) | 3145 | if (__glibc_unlikely (sbcset == NULL || mbcset == NULL)) |
| 3135 | #else | 3146 | #else |
| 3136 | if (BE (sbcset == NULL, 0)) | 3147 | if (__glibc_unlikely (sbcset == NULL)) |
| 3137 | #endif /* RE_ENABLE_I18N */ | 3148 | #endif /* RE_ENABLE_I18N */ |
| 3138 | { | 3149 | { |
| 3139 | re_free (sbcset); | 3150 | re_free (sbcset); |
| @@ -3145,7 +3156,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, | |||
| 3145 | } | 3156 | } |
| 3146 | 3157 | ||
| 3147 | token_len = peek_token_bracket (token, regexp, syntax); | 3158 | token_len = peek_token_bracket (token, regexp, syntax); |
| 3148 | if (BE (token->type == END_OF_RE, 0)) | 3159 | if (__glibc_unlikely (token->type == END_OF_RE)) |
| 3149 | { | 3160 | { |
| 3150 | *err = REG_BADPAT; | 3161 | *err = REG_BADPAT; |
| 3151 | goto parse_bracket_exp_free_return; | 3162 | goto parse_bracket_exp_free_return; |
| @@ -3160,7 +3171,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, | |||
| 3160 | bitset_set (sbcset, '\n'); | 3171 | bitset_set (sbcset, '\n'); |
| 3161 | re_string_skip_bytes (regexp, token_len); /* Skip a token. */ | 3172 | re_string_skip_bytes (regexp, token_len); /* Skip a token. */ |
| 3162 | token_len = peek_token_bracket (token, regexp, syntax); | 3173 | token_len = peek_token_bracket (token, regexp, syntax); |
| 3163 | if (BE (token->type == END_OF_RE, 0)) | 3174 | if (__glibc_unlikely (token->type == END_OF_RE)) |
| 3164 | { | 3175 | { |
| 3165 | *err = REG_BADPAT; | 3176 | *err = REG_BADPAT; |
| 3166 | goto parse_bracket_exp_free_return; | 3177 | goto parse_bracket_exp_free_return; |
| @@ -3185,7 +3196,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, | |||
| 3185 | start_elem.type = COLL_SYM; | 3196 | start_elem.type = COLL_SYM; |
| 3186 | ret = parse_bracket_element (&start_elem, regexp, token, token_len, dfa, | 3197 | ret = parse_bracket_element (&start_elem, regexp, token, token_len, dfa, |
| 3187 | syntax, first_round); | 3198 | syntax, first_round); |
| 3188 | if (BE (ret != REG_NOERROR, 0)) | 3199 | if (__glibc_unlikely (ret != REG_NOERROR)) |
| 3189 | { | 3200 | { |
| 3190 | *err = ret; | 3201 | *err = ret; |
| 3191 | goto parse_bracket_exp_free_return; | 3202 | goto parse_bracket_exp_free_return; |
| @@ -3198,7 +3209,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, | |||
| 3198 | /* Do not check for ranges if we know they are not allowed. */ | 3209 | /* Do not check for ranges if we know they are not allowed. */ |
| 3199 | if (start_elem.type != CHAR_CLASS && start_elem.type != EQUIV_CLASS) | 3210 | if (start_elem.type != CHAR_CLASS && start_elem.type != EQUIV_CLASS) |
| 3200 | { | 3211 | { |
| 3201 | if (BE (token->type == END_OF_RE, 0)) | 3212 | if (__glibc_unlikely (token->type == END_OF_RE)) |
| 3202 | { | 3213 | { |
| 3203 | *err = REG_EBRACK; | 3214 | *err = REG_EBRACK; |
| 3204 | goto parse_bracket_exp_free_return; | 3215 | goto parse_bracket_exp_free_return; |
| @@ -3207,7 +3218,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, | |||
| 3207 | { | 3218 | { |
| 3208 | re_string_skip_bytes (regexp, token_len); /* Skip '-'. */ | 3219 | re_string_skip_bytes (regexp, token_len); /* Skip '-'. */ |
| 3209 | token_len2 = peek_token_bracket (&token2, regexp, syntax); | 3220 | token_len2 = peek_token_bracket (&token2, regexp, syntax); |
| 3210 | if (BE (token2.type == END_OF_RE, 0)) | 3221 | if (__glibc_unlikely (token2.type == END_OF_RE)) |
| 3211 | { | 3222 | { |
| 3212 | *err = REG_EBRACK; | 3223 | *err = REG_EBRACK; |
| 3213 | goto parse_bracket_exp_free_return; | 3224 | goto parse_bracket_exp_free_return; |
| @@ -3229,7 +3240,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, | |||
| 3229 | end_elem.type = COLL_SYM; | 3240 | end_elem.type = COLL_SYM; |
| 3230 | ret = parse_bracket_element (&end_elem, regexp, &token2, token_len2, | 3241 | ret = parse_bracket_element (&end_elem, regexp, &token2, token_len2, |
| 3231 | dfa, syntax, true); | 3242 | dfa, syntax, true); |
| 3232 | if (BE (ret != REG_NOERROR, 0)) | 3243 | if (__glibc_unlikely (ret != REG_NOERROR)) |
| 3233 | { | 3244 | { |
| 3234 | *err = ret; | 3245 | *err = ret; |
| 3235 | goto parse_bracket_exp_free_return; | 3246 | goto parse_bracket_exp_free_return; |
| @@ -3249,7 +3260,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, | |||
| 3249 | *err = build_range_exp (syntax, sbcset, &start_elem, &end_elem); | 3260 | *err = build_range_exp (syntax, sbcset, &start_elem, &end_elem); |
| 3250 | # endif | 3261 | # endif |
| 3251 | #endif /* RE_ENABLE_I18N */ | 3262 | #endif /* RE_ENABLE_I18N */ |
| 3252 | if (BE (*err != REG_NOERROR, 0)) | 3263 | if (__glibc_unlikely (*err != REG_NOERROR)) |
| 3253 | goto parse_bracket_exp_free_return; | 3264 | goto parse_bracket_exp_free_return; |
| 3254 | } | 3265 | } |
| 3255 | else | 3266 | else |
| @@ -3262,7 +3273,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, | |||
| 3262 | #ifdef RE_ENABLE_I18N | 3273 | #ifdef RE_ENABLE_I18N |
| 3263 | case MB_CHAR: | 3274 | case MB_CHAR: |
| 3264 | /* Check whether the array has enough space. */ | 3275 | /* Check whether the array has enough space. */ |
| 3265 | if (BE (mbchar_alloc == mbcset->nmbchars, 0)) | 3276 | if (__glibc_unlikely (mbchar_alloc == mbcset->nmbchars)) |
| 3266 | { | 3277 | { |
| 3267 | wchar_t *new_mbchars; | 3278 | wchar_t *new_mbchars; |
| 3268 | /* Not enough, realloc it. */ | 3279 | /* Not enough, realloc it. */ |
| @@ -3271,7 +3282,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, | |||
| 3271 | /* Use realloc since array is NULL if *alloc == 0. */ | 3282 | /* Use realloc since array is NULL if *alloc == 0. */ |
| 3272 | new_mbchars = re_realloc (mbcset->mbchars, wchar_t, | 3283 | new_mbchars = re_realloc (mbcset->mbchars, wchar_t, |
| 3273 | mbchar_alloc); | 3284 | mbchar_alloc); |
| 3274 | if (BE (new_mbchars == NULL, 0)) | 3285 | if (__glibc_unlikely (new_mbchars == NULL)) |
| 3275 | goto parse_bracket_exp_espace; | 3286 | goto parse_bracket_exp_espace; |
| 3276 | mbcset->mbchars = new_mbchars; | 3287 | mbcset->mbchars = new_mbchars; |
| 3277 | } | 3288 | } |
| @@ -3284,7 +3295,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, | |||
| 3284 | mbcset, &equiv_class_alloc, | 3295 | mbcset, &equiv_class_alloc, |
| 3285 | #endif /* RE_ENABLE_I18N */ | 3296 | #endif /* RE_ENABLE_I18N */ |
| 3286 | start_elem.opr.name); | 3297 | start_elem.opr.name); |
| 3287 | if (BE (*err != REG_NOERROR, 0)) | 3298 | if (__glibc_unlikely (*err != REG_NOERROR)) |
| 3288 | goto parse_bracket_exp_free_return; | 3299 | goto parse_bracket_exp_free_return; |
| 3289 | break; | 3300 | break; |
| 3290 | case COLL_SYM: | 3301 | case COLL_SYM: |
| @@ -3293,7 +3304,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, | |||
| 3293 | mbcset, &coll_sym_alloc, | 3304 | mbcset, &coll_sym_alloc, |
| 3294 | #endif /* RE_ENABLE_I18N */ | 3305 | #endif /* RE_ENABLE_I18N */ |
| 3295 | start_elem.opr.name); | 3306 | start_elem.opr.name); |
| 3296 | if (BE (*err != REG_NOERROR, 0)) | 3307 | if (__glibc_unlikely (*err != REG_NOERROR)) |
| 3297 | goto parse_bracket_exp_free_return; | 3308 | goto parse_bracket_exp_free_return; |
| 3298 | break; | 3309 | break; |
| 3299 | case CHAR_CLASS: | 3310 | case CHAR_CLASS: |
| @@ -3303,7 +3314,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, | |||
| 3303 | #endif /* RE_ENABLE_I18N */ | 3314 | #endif /* RE_ENABLE_I18N */ |
| 3304 | (const char *) start_elem.opr.name, | 3315 | (const char *) start_elem.opr.name, |
| 3305 | syntax); | 3316 | syntax); |
| 3306 | if (BE (*err != REG_NOERROR, 0)) | 3317 | if (__glibc_unlikely (*err != REG_NOERROR)) |
| 3307 | goto parse_bracket_exp_free_return; | 3318 | goto parse_bracket_exp_free_return; |
| 3308 | break; | 3319 | break; |
| 3309 | default: | 3320 | default: |
| @@ -3311,7 +3322,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, | |||
| 3311 | break; | 3322 | break; |
| 3312 | } | 3323 | } |
| 3313 | } | 3324 | } |
| 3314 | if (BE (token->type == END_OF_RE, 0)) | 3325 | if (__glibc_unlikely (token->type == END_OF_RE)) |
| 3315 | { | 3326 | { |
| 3316 | *err = REG_EBRACK; | 3327 | *err = REG_EBRACK; |
| 3317 | goto parse_bracket_exp_free_return; | 3328 | goto parse_bracket_exp_free_return; |
| @@ -3342,7 +3353,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, | |||
| 3342 | br_token.type = COMPLEX_BRACKET; | 3353 | br_token.type = COMPLEX_BRACKET; |
| 3343 | br_token.opr.mbcset = mbcset; | 3354 | br_token.opr.mbcset = mbcset; |
| 3344 | mbc_tree = create_token_tree (dfa, NULL, NULL, &br_token); | 3355 | mbc_tree = create_token_tree (dfa, NULL, NULL, &br_token); |
| 3345 | if (BE (mbc_tree == NULL, 0)) | 3356 | if (__glibc_unlikely (mbc_tree == NULL)) |
| 3346 | goto parse_bracket_exp_espace; | 3357 | goto parse_bracket_exp_espace; |
| 3347 | for (sbc_idx = 0; sbc_idx < BITSET_WORDS; ++sbc_idx) | 3358 | for (sbc_idx = 0; sbc_idx < BITSET_WORDS; ++sbc_idx) |
| 3348 | if (sbcset[sbc_idx]) | 3359 | if (sbcset[sbc_idx]) |
| @@ -3355,12 +3366,12 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, | |||
| 3355 | br_token.type = SIMPLE_BRACKET; | 3366 | br_token.type = SIMPLE_BRACKET; |
| 3356 | br_token.opr.sbcset = sbcset; | 3367 | br_token.opr.sbcset = sbcset; |
| 3357 | work_tree = create_token_tree (dfa, NULL, NULL, &br_token); | 3368 | work_tree = create_token_tree (dfa, NULL, NULL, &br_token); |
| 3358 | if (BE (work_tree == NULL, 0)) | 3369 | if (__glibc_unlikely (work_tree == NULL)) |
| 3359 | goto parse_bracket_exp_espace; | 3370 | goto parse_bracket_exp_espace; |
| 3360 | 3371 | ||
| 3361 | /* Then join them by ALT node. */ | 3372 | /* Then join them by ALT node. */ |
| 3362 | work_tree = create_tree (dfa, work_tree, mbc_tree, OP_ALT); | 3373 | work_tree = create_tree (dfa, work_tree, mbc_tree, OP_ALT); |
| 3363 | if (BE (work_tree == NULL, 0)) | 3374 | if (__glibc_unlikely (work_tree == NULL)) |
| 3364 | goto parse_bracket_exp_espace; | 3375 | goto parse_bracket_exp_espace; |
| 3365 | } | 3376 | } |
| 3366 | else | 3377 | else |
| @@ -3379,7 +3390,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, | |||
| 3379 | br_token.type = SIMPLE_BRACKET; | 3390 | br_token.type = SIMPLE_BRACKET; |
| 3380 | br_token.opr.sbcset = sbcset; | 3391 | br_token.opr.sbcset = sbcset; |
| 3381 | work_tree = create_token_tree (dfa, NULL, NULL, &br_token); | 3392 | work_tree = create_token_tree (dfa, NULL, NULL, &br_token); |
| 3382 | if (BE (work_tree == NULL, 0)) | 3393 | if (__glibc_unlikely (work_tree == NULL)) |
| 3383 | goto parse_bracket_exp_espace; | 3394 | goto parse_bracket_exp_espace; |
| 3384 | } | 3395 | } |
| 3385 | return work_tree; | 3396 | return work_tree; |
| @@ -3416,7 +3427,7 @@ parse_bracket_element (bracket_elem_t *elem, re_string_t *regexp, | |||
| 3416 | if (token->type == OP_OPEN_COLL_ELEM || token->type == OP_OPEN_CHAR_CLASS | 3427 | if (token->type == OP_OPEN_COLL_ELEM || token->type == OP_OPEN_CHAR_CLASS |
| 3417 | || token->type == OP_OPEN_EQUIV_CLASS) | 3428 | || token->type == OP_OPEN_EQUIV_CLASS) |
| 3418 | return parse_bracket_symbol (elem, regexp, token); | 3429 | return parse_bracket_symbol (elem, regexp, token); |
| 3419 | if (BE (token->type == OP_CHARSET_RANGE, 0) && !accept_hyphen) | 3430 | if (__glibc_unlikely (token->type == OP_CHARSET_RANGE) && !accept_hyphen) |
| 3420 | { | 3431 | { |
| 3421 | /* A '-' must only appear as anything but a range indicator before | 3432 | /* A '-' must only appear as anything but a range indicator before |
| 3422 | the closing bracket. Everything else is an error. */ | 3433 | the closing bracket. Everything else is an error. */ |
| @@ -3511,7 +3522,7 @@ build_equiv_class (bitset_t sbcset, const unsigned char *name) | |||
| 3511 | indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE, | 3522 | indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE, |
| 3512 | _NL_COLLATE_INDIRECTMB); | 3523 | _NL_COLLATE_INDIRECTMB); |
| 3513 | idx1 = findidx (table, indirect, extra, &cp, -1); | 3524 | idx1 = findidx (table, indirect, extra, &cp, -1); |
| 3514 | if (BE (idx1 == 0 || *cp != '\0', 0)) | 3525 | if (__glibc_unlikely (idx1 == 0 || *cp != '\0')) |
| 3515 | /* This isn't a valid character. */ | 3526 | /* This isn't a valid character. */ |
| 3516 | return REG_ECOLLATE; | 3527 | return REG_ECOLLATE; |
| 3517 | 3528 | ||
| @@ -3536,7 +3547,7 @@ build_equiv_class (bitset_t sbcset, const unsigned char *name) | |||
| 3536 | bitset_set (sbcset, ch); | 3547 | bitset_set (sbcset, ch); |
| 3537 | } | 3548 | } |
| 3538 | /* Check whether the array has enough space. */ | 3549 | /* Check whether the array has enough space. */ |
| 3539 | if (BE (*equiv_class_alloc == mbcset->nequiv_classes, 0)) | 3550 | if (__glibc_unlikely (*equiv_class_alloc == mbcset->nequiv_classes)) |
| 3540 | { | 3551 | { |
| 3541 | /* Not enough, realloc it. */ | 3552 | /* Not enough, realloc it. */ |
| 3542 | /* +1 in case of mbcset->nequiv_classes is 0. */ | 3553 | /* +1 in case of mbcset->nequiv_classes is 0. */ |
| @@ -3545,7 +3556,7 @@ build_equiv_class (bitset_t sbcset, const unsigned char *name) | |||
| 3545 | int32_t *new_equiv_classes = re_realloc (mbcset->equiv_classes, | 3556 | int32_t *new_equiv_classes = re_realloc (mbcset->equiv_classes, |
| 3546 | int32_t, | 3557 | int32_t, |
| 3547 | new_equiv_class_alloc); | 3558 | new_equiv_class_alloc); |
| 3548 | if (BE (new_equiv_classes == NULL, 0)) | 3559 | if (__glibc_unlikely (new_equiv_classes == NULL)) |
| 3549 | return REG_ESPACE; | 3560 | return REG_ESPACE; |
| 3550 | mbcset->equiv_classes = new_equiv_classes; | 3561 | mbcset->equiv_classes = new_equiv_classes; |
| 3551 | *equiv_class_alloc = new_equiv_class_alloc; | 3562 | *equiv_class_alloc = new_equiv_class_alloc; |
| @@ -3555,7 +3566,7 @@ build_equiv_class (bitset_t sbcset, const unsigned char *name) | |||
| 3555 | else | 3566 | else |
| 3556 | #endif /* _LIBC */ | 3567 | #endif /* _LIBC */ |
| 3557 | { | 3568 | { |
| 3558 | if (BE (strlen ((const char *) name) != 1, 0)) | 3569 | if (__glibc_unlikely (strlen ((const char *) name) != 1)) |
| 3559 | return REG_ECOLLATE; | 3570 | return REG_ECOLLATE; |
| 3560 | bitset_set (sbcset, *name); | 3571 | bitset_set (sbcset, *name); |
| 3561 | } | 3572 | } |
| @@ -3589,7 +3600,7 @@ build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset, | |||
| 3589 | 3600 | ||
| 3590 | #ifdef RE_ENABLE_I18N | 3601 | #ifdef RE_ENABLE_I18N |
| 3591 | /* Check the space of the arrays. */ | 3602 | /* Check the space of the arrays. */ |
| 3592 | if (BE (*char_class_alloc == mbcset->nchar_classes, 0)) | 3603 | if (__glibc_unlikely (*char_class_alloc == mbcset->nchar_classes)) |
| 3593 | { | 3604 | { |
| 3594 | /* Not enough, realloc it. */ | 3605 | /* Not enough, realloc it. */ |
| 3595 | /* +1 in case of mbcset->nchar_classes is 0. */ | 3606 | /* +1 in case of mbcset->nchar_classes is 0. */ |
| @@ -3597,7 +3608,7 @@ build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset, | |||
| 3597 | /* Use realloc since array is NULL if *alloc == 0. */ | 3608 | /* Use realloc since array is NULL if *alloc == 0. */ |
| 3598 | wctype_t *new_char_classes = re_realloc (mbcset->char_classes, wctype_t, | 3609 | wctype_t *new_char_classes = re_realloc (mbcset->char_classes, wctype_t, |
| 3599 | new_char_class_alloc); | 3610 | new_char_class_alloc); |
| 3600 | if (BE (new_char_classes == NULL, 0)) | 3611 | if (__glibc_unlikely (new_char_classes == NULL)) |
| 3601 | return REG_ESPACE; | 3612 | return REG_ESPACE; |
| 3602 | mbcset->char_classes = new_char_classes; | 3613 | mbcset->char_classes = new_char_classes; |
| 3603 | *char_class_alloc = new_char_class_alloc; | 3614 | *char_class_alloc = new_char_class_alloc; |
| @@ -3607,7 +3618,7 @@ build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset, | |||
| 3607 | 3618 | ||
| 3608 | #define BUILD_CHARCLASS_LOOP(ctype_func) \ | 3619 | #define BUILD_CHARCLASS_LOOP(ctype_func) \ |
| 3609 | do { \ | 3620 | do { \ |
| 3610 | if (BE (trans != NULL, 0)) \ | 3621 | if (__glibc_unlikely (trans != NULL)) \ |
| 3611 | { \ | 3622 | { \ |
| 3612 | for (i = 0; i < SBC_MAX; ++i) \ | 3623 | for (i = 0; i < SBC_MAX; ++i) \ |
| 3613 | if (ctype_func (i)) \ | 3624 | if (ctype_func (i)) \ |
| @@ -3667,14 +3678,14 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans, | |||
| 3667 | bin_tree_t *tree; | 3678 | bin_tree_t *tree; |
| 3668 | 3679 | ||
| 3669 | sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); | 3680 | sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); |
| 3670 | if (BE (sbcset == NULL, 0)) | 3681 | if (__glibc_unlikely (sbcset == NULL)) |
| 3671 | { | 3682 | { |
| 3672 | *err = REG_ESPACE; | 3683 | *err = REG_ESPACE; |
| 3673 | return NULL; | 3684 | return NULL; |
| 3674 | } | 3685 | } |
| 3675 | #ifdef RE_ENABLE_I18N | 3686 | #ifdef RE_ENABLE_I18N |
| 3676 | mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1); | 3687 | mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1); |
| 3677 | if (BE (mbcset == NULL, 0)) | 3688 | if (__glibc_unlikely (mbcset == NULL)) |
| 3678 | { | 3689 | { |
| 3679 | re_free (sbcset); | 3690 | re_free (sbcset); |
| 3680 | *err = REG_ESPACE; | 3691 | *err = REG_ESPACE; |
| @@ -3690,7 +3701,7 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans, | |||
| 3690 | #endif /* RE_ENABLE_I18N */ | 3701 | #endif /* RE_ENABLE_I18N */ |
| 3691 | class_name, 0); | 3702 | class_name, 0); |
| 3692 | 3703 | ||
| 3693 | if (BE (ret != REG_NOERROR, 0)) | 3704 | if (__glibc_unlikely (ret != REG_NOERROR)) |
| 3694 | { | 3705 | { |
| 3695 | re_free (sbcset); | 3706 | re_free (sbcset); |
| 3696 | #ifdef RE_ENABLE_I18N | 3707 | #ifdef RE_ENABLE_I18N |
| @@ -3720,7 +3731,7 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans, | |||
| 3720 | br_token.type = SIMPLE_BRACKET; | 3731 | br_token.type = SIMPLE_BRACKET; |
| 3721 | br_token.opr.sbcset = sbcset; | 3732 | br_token.opr.sbcset = sbcset; |
| 3722 | tree = create_token_tree (dfa, NULL, NULL, &br_token); | 3733 | tree = create_token_tree (dfa, NULL, NULL, &br_token); |
| 3723 | if (BE (tree == NULL, 0)) | 3734 | if (__glibc_unlikely (tree == NULL)) |
| 3724 | goto build_word_op_espace; | 3735 | goto build_word_op_espace; |
| 3725 | 3736 | ||
| 3726 | #ifdef RE_ENABLE_I18N | 3737 | #ifdef RE_ENABLE_I18N |
| @@ -3732,11 +3743,11 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans, | |||
| 3732 | br_token.opr.mbcset = mbcset; | 3743 | br_token.opr.mbcset = mbcset; |
| 3733 | dfa->has_mb_node = 1; | 3744 | dfa->has_mb_node = 1; |
| 3734 | mbc_tree = create_token_tree (dfa, NULL, NULL, &br_token); | 3745 | mbc_tree = create_token_tree (dfa, NULL, NULL, &br_token); |
| 3735 | if (BE (mbc_tree == NULL, 0)) | 3746 | if (__glibc_unlikely (mbc_tree == NULL)) |
| 3736 | goto build_word_op_espace; | 3747 | goto build_word_op_espace; |
| 3737 | /* Then join them by ALT node. */ | 3748 | /* Then join them by ALT node. */ |
| 3738 | tree = create_tree (dfa, tree, mbc_tree, OP_ALT); | 3749 | tree = create_tree (dfa, tree, mbc_tree, OP_ALT); |
| 3739 | if (BE (mbc_tree != NULL, 1)) | 3750 | if (__glibc_likely (mbc_tree != NULL)) |
| 3740 | return tree; | 3751 | return tree; |
| 3741 | } | 3752 | } |
| 3742 | else | 3753 | else |
| @@ -3772,7 +3783,7 @@ fetch_number (re_string_t *input, re_token_t *token, reg_syntax_t syntax) | |||
| 3772 | { | 3783 | { |
| 3773 | fetch_token (token, input, syntax); | 3784 | fetch_token (token, input, syntax); |
| 3774 | c = token->opr.c; | 3785 | c = token->opr.c; |
| 3775 | if (BE (token->type == END_OF_RE, 0)) | 3786 | if (__glibc_unlikely (token->type == END_OF_RE)) |
| 3776 | return -2; | 3787 | return -2; |
| 3777 | if (token->type == OP_CLOSE_DUP_NUM || c == ',') | 3788 | if (token->type == OP_CLOSE_DUP_NUM || c == ',') |
| 3778 | break; | 3789 | break; |
| @@ -3822,7 +3833,7 @@ create_token_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right, | |||
| 3822 | const re_token_t *token) | 3833 | const re_token_t *token) |
| 3823 | { | 3834 | { |
| 3824 | bin_tree_t *tree; | 3835 | bin_tree_t *tree; |
| 3825 | if (BE (dfa->str_tree_storage_idx == BIN_TREE_STORAGE_SIZE, 0)) | 3836 | if (__glibc_unlikely (dfa->str_tree_storage_idx == BIN_TREE_STORAGE_SIZE)) |
| 3826 | { | 3837 | { |
| 3827 | bin_tree_storage_t *storage = re_malloc (bin_tree_storage_t, 1); | 3838 | bin_tree_storage_t *storage = re_malloc (bin_tree_storage_t, 1); |
| 3828 | 3839 | ||