diff options
author | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2010-04-08 01:11:46 (GMT) |
---|---|---|
committer | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2010-04-13 01:26:35 (GMT) |
commit | 74da141e618ef99959d509cb2e7be35a348a39db (patch) | |
tree | 88ebc38b381a1021fc2d74864a71e230ae591c3d /gl/regex_internal.c | |
parent | c63a4f726a0b6ad8cf6040f947754a81fd4683bb (diff) | |
download | monitoring-plugins-74da141e618ef99959d509cb2e7be35a348a39db.tar.gz |
Sync with the latest Gnulib code (177f525)
Signed-off-by: Thomas Guyot-Sionnest <dermoth@aei.ca>
Diffstat (limited to 'gl/regex_internal.c')
-rw-r--r-- | gl/regex_internal.c | 101 |
1 files changed, 52 insertions, 49 deletions
diff --git a/gl/regex_internal.c b/gl/regex_internal.c index 7acec79..17eafaa 100644 --- a/gl/regex_internal.c +++ b/gl/regex_internal.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* Extended regular expression matching and search library. | 1 | /* Extended regular expression matching and search library. |
2 | Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 | 2 | Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free |
3 | Free Software Foundation, Inc. | 3 | Software Foundation, Inc. |
4 | This file is part of the GNU C Library. | 4 | This file is part of the GNU C Library. |
5 | Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. | 5 | Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. |
6 | 6 | ||
@@ -36,7 +36,7 @@ static re_dfastate_t *create_cd_newstate (const re_dfa_t *dfa, | |||
36 | re_string_reconstruct before using the object. */ | 36 | re_string_reconstruct before using the object. */ |
37 | 37 | ||
38 | static reg_errcode_t | 38 | static reg_errcode_t |
39 | internal_function | 39 | internal_function __attribute_warn_unused_result__ |
40 | re_string_allocate (re_string_t *pstr, const char *str, Idx len, Idx init_len, | 40 | re_string_allocate (re_string_t *pstr, const char *str, Idx len, Idx init_len, |
41 | RE_TRANSLATE_TYPE trans, bool icase, const re_dfa_t *dfa) | 41 | RE_TRANSLATE_TYPE trans, bool icase, const re_dfa_t *dfa) |
42 | { | 42 | { |
@@ -64,7 +64,7 @@ re_string_allocate (re_string_t *pstr, const char *str, Idx len, Idx init_len, | |||
64 | /* This function allocate the buffers, and initialize them. */ | 64 | /* This function allocate the buffers, and initialize them. */ |
65 | 65 | ||
66 | static reg_errcode_t | 66 | static reg_errcode_t |
67 | internal_function | 67 | internal_function __attribute_warn_unused_result__ |
68 | re_string_construct (re_string_t *pstr, const char *str, Idx len, | 68 | re_string_construct (re_string_t *pstr, const char *str, Idx len, |
69 | RE_TRANSLATE_TYPE trans, bool icase, const re_dfa_t *dfa) | 69 | RE_TRANSLATE_TYPE trans, bool icase, const re_dfa_t *dfa) |
70 | { | 70 | { |
@@ -127,7 +127,7 @@ re_string_construct (re_string_t *pstr, const char *str, Idx len, | |||
127 | /* Helper functions for re_string_allocate, and re_string_construct. */ | 127 | /* Helper functions for re_string_allocate, and re_string_construct. */ |
128 | 128 | ||
129 | static reg_errcode_t | 129 | static reg_errcode_t |
130 | internal_function | 130 | internal_function __attribute_warn_unused_result__ |
131 | re_string_realloc_buffers (re_string_t *pstr, Idx new_buf_len) | 131 | re_string_realloc_buffers (re_string_t *pstr, Idx new_buf_len) |
132 | { | 132 | { |
133 | #ifdef RE_ENABLE_I18N | 133 | #ifdef RE_ENABLE_I18N |
@@ -267,7 +267,7 @@ build_wcs_buffer (re_string_t *pstr) | |||
267 | but for REG_ICASE. */ | 267 | but for REG_ICASE. */ |
268 | 268 | ||
269 | static reg_errcode_t | 269 | static reg_errcode_t |
270 | internal_function | 270 | internal_function __attribute_warn_unused_result__ |
271 | build_wcs_upper_buffer (re_string_t *pstr) | 271 | build_wcs_upper_buffer (re_string_t *pstr) |
272 | { | 272 | { |
273 | mbstate_t prev_st; | 273 | mbstate_t prev_st; |
@@ -430,8 +430,8 @@ build_wcs_upper_buffer (re_string_t *pstr) | |||
430 | src_idx += mbclen; | 430 | src_idx += mbclen; |
431 | continue; | 431 | continue; |
432 | } | 432 | } |
433 | else | 433 | else |
434 | memcpy (pstr->mbs + byte_idx, p, mbclen); | 434 | memcpy (pstr->mbs + byte_idx, p, mbclen); |
435 | } | 435 | } |
436 | else | 436 | else |
437 | memcpy (pstr->mbs + byte_idx, p, mbclen); | 437 | memcpy (pstr->mbs + byte_idx, p, mbclen); |
@@ -569,7 +569,7 @@ re_string_translate_buffer (re_string_t *pstr) | |||
569 | convert to upper case in case of REG_ICASE, apply translation. */ | 569 | convert to upper case in case of REG_ICASE, apply translation. */ |
570 | 570 | ||
571 | static reg_errcode_t | 571 | static reg_errcode_t |
572 | internal_function | 572 | internal_function __attribute_warn_unused_result__ |
573 | re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags) | 573 | re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags) |
574 | { | 574 | { |
575 | Idx offset; | 575 | Idx offset; |
@@ -964,7 +964,7 @@ re_string_context_at (const re_string_t *input, Idx idx, int eflags) | |||
964 | /* Functions for set operation. */ | 964 | /* Functions for set operation. */ |
965 | 965 | ||
966 | static reg_errcode_t | 966 | static reg_errcode_t |
967 | internal_function | 967 | internal_function __attribute_warn_unused_result__ |
968 | re_node_set_alloc (re_node_set *set, Idx size) | 968 | re_node_set_alloc (re_node_set *set, Idx size) |
969 | { | 969 | { |
970 | set->alloc = size; | 970 | set->alloc = size; |
@@ -976,7 +976,7 @@ re_node_set_alloc (re_node_set *set, Idx size) | |||
976 | } | 976 | } |
977 | 977 | ||
978 | static reg_errcode_t | 978 | static reg_errcode_t |
979 | internal_function | 979 | internal_function __attribute_warn_unused_result__ |
980 | re_node_set_init_1 (re_node_set *set, Idx elem) | 980 | re_node_set_init_1 (re_node_set *set, Idx elem) |
981 | { | 981 | { |
982 | set->alloc = 1; | 982 | set->alloc = 1; |
@@ -992,7 +992,7 @@ re_node_set_init_1 (re_node_set *set, Idx elem) | |||
992 | } | 992 | } |
993 | 993 | ||
994 | static reg_errcode_t | 994 | static reg_errcode_t |
995 | internal_function | 995 | internal_function __attribute_warn_unused_result__ |
996 | re_node_set_init_2 (re_node_set *set, Idx elem1, Idx elem2) | 996 | re_node_set_init_2 (re_node_set *set, Idx elem1, Idx elem2) |
997 | { | 997 | { |
998 | set->alloc = 2; | 998 | set->alloc = 2; |
@@ -1022,7 +1022,7 @@ re_node_set_init_2 (re_node_set *set, Idx elem1, Idx elem2) | |||
1022 | } | 1022 | } |
1023 | 1023 | ||
1024 | static reg_errcode_t | 1024 | static reg_errcode_t |
1025 | internal_function | 1025 | internal_function __attribute_warn_unused_result__ |
1026 | re_node_set_init_copy (re_node_set *dest, const re_node_set *src) | 1026 | re_node_set_init_copy (re_node_set *dest, const re_node_set *src) |
1027 | { | 1027 | { |
1028 | dest->nelem = src->nelem; | 1028 | dest->nelem = src->nelem; |
@@ -1047,7 +1047,7 @@ re_node_set_init_copy (re_node_set *dest, const re_node_set *src) | |||
1047 | Note: We assume dest->elems is NULL, when dest->alloc is 0. */ | 1047 | Note: We assume dest->elems is NULL, when dest->alloc is 0. */ |
1048 | 1048 | ||
1049 | static reg_errcode_t | 1049 | static reg_errcode_t |
1050 | internal_function | 1050 | internal_function __attribute_warn_unused_result__ |
1051 | re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1, | 1051 | re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1, |
1052 | const re_node_set *src2) | 1052 | const re_node_set *src2) |
1053 | { | 1053 | { |
@@ -1062,7 +1062,7 @@ re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1, | |||
1062 | Idx new_alloc = src1->nelem + src2->nelem + dest->alloc; | 1062 | Idx new_alloc = src1->nelem + src2->nelem + dest->alloc; |
1063 | Idx *new_elems = re_realloc (dest->elems, Idx, new_alloc); | 1063 | Idx *new_elems = re_realloc (dest->elems, Idx, new_alloc); |
1064 | if (BE (new_elems == NULL, 0)) | 1064 | if (BE (new_elems == NULL, 0)) |
1065 | return REG_ESPACE; | 1065 | return REG_ESPACE; |
1066 | dest->elems = new_elems; | 1066 | dest->elems = new_elems; |
1067 | dest->alloc = new_alloc; | 1067 | dest->alloc = new_alloc; |
1068 | } | 1068 | } |
@@ -1112,20 +1112,20 @@ re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1, | |||
1112 | if (delta > 0 && REG_VALID_INDEX (id)) | 1112 | if (delta > 0 && REG_VALID_INDEX (id)) |
1113 | for (;;) | 1113 | for (;;) |
1114 | { | 1114 | { |
1115 | if (dest->elems[is] > dest->elems[id]) | 1115 | if (dest->elems[is] > dest->elems[id]) |
1116 | { | 1116 | { |
1117 | /* Copy from the top. */ | 1117 | /* Copy from the top. */ |
1118 | dest->elems[id + delta--] = dest->elems[is--]; | 1118 | dest->elems[id + delta--] = dest->elems[is--]; |
1119 | if (delta == 0) | 1119 | if (delta == 0) |
1120 | break; | 1120 | break; |
1121 | } | 1121 | } |
1122 | else | 1122 | else |
1123 | { | 1123 | { |
1124 | /* Slide from the bottom. */ | 1124 | /* Slide from the bottom. */ |
1125 | dest->elems[id + delta] = dest->elems[id]; | 1125 | dest->elems[id + delta] = dest->elems[id]; |
1126 | if (! REG_VALID_INDEX (--id)) | 1126 | if (! REG_VALID_INDEX (--id)) |
1127 | break; | 1127 | break; |
1128 | } | 1128 | } |
1129 | } | 1129 | } |
1130 | 1130 | ||
1131 | /* Copy remaining SRC elements. */ | 1131 | /* Copy remaining SRC elements. */ |
@@ -1138,7 +1138,7 @@ re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1, | |||
1138 | DEST. Return value indicate the error code or REG_NOERROR if succeeded. */ | 1138 | DEST. Return value indicate the error code or REG_NOERROR if succeeded. */ |
1139 | 1139 | ||
1140 | static reg_errcode_t | 1140 | static reg_errcode_t |
1141 | internal_function | 1141 | internal_function __attribute_warn_unused_result__ |
1142 | re_node_set_init_union (re_node_set *dest, const re_node_set *src1, | 1142 | re_node_set_init_union (re_node_set *dest, const re_node_set *src1, |
1143 | const re_node_set *src2) | 1143 | const re_node_set *src2) |
1144 | { | 1144 | { |
@@ -1191,7 +1191,7 @@ re_node_set_init_union (re_node_set *dest, const re_node_set *src1, | |||
1191 | DEST. Return value indicate the error code or REG_NOERROR if succeeded. */ | 1191 | DEST. Return value indicate the error code or REG_NOERROR if succeeded. */ |
1192 | 1192 | ||
1193 | static reg_errcode_t | 1193 | static reg_errcode_t |
1194 | internal_function | 1194 | internal_function __attribute_warn_unused_result__ |
1195 | re_node_set_merge (re_node_set *dest, const re_node_set *src) | 1195 | re_node_set_merge (re_node_set *dest, const re_node_set *src) |
1196 | { | 1196 | { |
1197 | Idx is, id, sbase, delta; | 1197 | Idx is, id, sbase, delta; |
@@ -1221,11 +1221,11 @@ re_node_set_merge (re_node_set *dest, const re_node_set *src) | |||
1221 | REG_VALID_INDEX (is) && REG_VALID_INDEX (id); ) | 1221 | REG_VALID_INDEX (is) && REG_VALID_INDEX (id); ) |
1222 | { | 1222 | { |
1223 | if (dest->elems[id] == src->elems[is]) | 1223 | if (dest->elems[id] == src->elems[is]) |
1224 | is--, id--; | 1224 | is--, id--; |
1225 | else if (dest->elems[id] < src->elems[is]) | 1225 | else if (dest->elems[id] < src->elems[is]) |
1226 | dest->elems[--sbase] = src->elems[is--]; | 1226 | dest->elems[--sbase] = src->elems[is--]; |
1227 | else /* if (dest->elems[id] > src->elems[is]) */ | 1227 | else /* if (dest->elems[id] > src->elems[is]) */ |
1228 | --id; | 1228 | --id; |
1229 | } | 1229 | } |
1230 | 1230 | ||
1231 | if (REG_VALID_INDEX (is)) | 1231 | if (REG_VALID_INDEX (is)) |
@@ -1247,21 +1247,21 @@ re_node_set_merge (re_node_set *dest, const re_node_set *src) | |||
1247 | for (;;) | 1247 | for (;;) |
1248 | { | 1248 | { |
1249 | if (dest->elems[is] > dest->elems[id]) | 1249 | if (dest->elems[is] > dest->elems[id]) |
1250 | { | 1250 | { |
1251 | /* Copy from the top. */ | 1251 | /* Copy from the top. */ |
1252 | dest->elems[id + delta--] = dest->elems[is--]; | 1252 | dest->elems[id + delta--] = dest->elems[is--]; |
1253 | if (delta == 0) | 1253 | if (delta == 0) |
1254 | break; | 1254 | break; |
1255 | } | 1255 | } |
1256 | else | 1256 | else |
1257 | { | 1257 | { |
1258 | /* Slide from the bottom. */ | 1258 | /* Slide from the bottom. */ |
1259 | dest->elems[id + delta] = dest->elems[id]; | 1259 | dest->elems[id + delta] = dest->elems[id]; |
1260 | if (! REG_VALID_INDEX (--id)) | 1260 | if (! REG_VALID_INDEX (--id)) |
1261 | { | 1261 | { |
1262 | /* Copy remaining SRC elements. */ | 1262 | /* Copy remaining SRC elements. */ |
1263 | memcpy (dest->elems, dest->elems + sbase, | 1263 | memcpy (dest->elems, dest->elems + sbase, |
1264 | delta * sizeof (Idx)); | 1264 | delta * sizeof (Idx)); |
1265 | break; | 1265 | break; |
1266 | } | 1266 | } |
1267 | } | 1267 | } |
@@ -1275,7 +1275,7 @@ re_node_set_merge (re_node_set *dest, const re_node_set *src) | |||
1275 | Return true if successful. */ | 1275 | Return true if successful. */ |
1276 | 1276 | ||
1277 | static bool | 1277 | static bool |
1278 | internal_function | 1278 | internal_function __attribute_warn_unused_result__ |
1279 | re_node_set_insert (re_node_set *set, Idx elem) | 1279 | re_node_set_insert (re_node_set *set, Idx elem) |
1280 | { | 1280 | { |
1281 | Idx idx; | 1281 | Idx idx; |
@@ -1308,12 +1308,12 @@ re_node_set_insert (re_node_set *set, Idx elem) | |||
1308 | { | 1308 | { |
1309 | idx = 0; | 1309 | idx = 0; |
1310 | for (idx = set->nelem; idx > 0; idx--) | 1310 | for (idx = set->nelem; idx > 0; idx--) |
1311 | set->elems[idx] = set->elems[idx - 1]; | 1311 | set->elems[idx] = set->elems[idx - 1]; |
1312 | } | 1312 | } |
1313 | else | 1313 | else |
1314 | { | 1314 | { |
1315 | for (idx = set->nelem; set->elems[idx - 1] > elem; idx--) | 1315 | for (idx = set->nelem; set->elems[idx - 1] > elem; idx--) |
1316 | set->elems[idx] = set->elems[idx - 1]; | 1316 | set->elems[idx] = set->elems[idx - 1]; |
1317 | } | 1317 | } |
1318 | 1318 | ||
1319 | /* Insert the new element. */ | 1319 | /* Insert the new element. */ |
@@ -1327,7 +1327,7 @@ re_node_set_insert (re_node_set *set, Idx elem) | |||
1327 | Return true if successful. */ | 1327 | Return true if successful. */ |
1328 | 1328 | ||
1329 | static bool | 1329 | static bool |
1330 | internal_function | 1330 | internal_function __attribute_warn_unused_result__ |
1331 | re_node_set_insert_last (re_node_set *set, Idx elem) | 1331 | re_node_set_insert_last (re_node_set *set, Idx elem) |
1332 | { | 1332 | { |
1333 | /* Realloc if we need. */ | 1333 | /* Realloc if we need. */ |
@@ -1473,7 +1473,7 @@ calc_state_hash (const re_node_set *nodes, unsigned int context) | |||
1473 | optimization. */ | 1473 | optimization. */ |
1474 | 1474 | ||
1475 | static re_dfastate_t * | 1475 | static re_dfastate_t * |
1476 | internal_function | 1476 | internal_function __attribute_warn_unused_result__ |
1477 | re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa, | 1477 | re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa, |
1478 | const re_node_set *nodes) | 1478 | const re_node_set *nodes) |
1479 | { | 1479 | { |
@@ -1521,7 +1521,7 @@ re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa, | |||
1521 | optimization. */ | 1521 | optimization. */ |
1522 | 1522 | ||
1523 | static re_dfastate_t * | 1523 | static re_dfastate_t * |
1524 | internal_function | 1524 | internal_function __attribute_warn_unused_result__ |
1525 | re_acquire_state_context (reg_errcode_t *err, const re_dfa_t *dfa, | 1525 | re_acquire_state_context (reg_errcode_t *err, const re_dfa_t *dfa, |
1526 | const re_node_set *nodes, unsigned int context) | 1526 | const re_node_set *nodes, unsigned int context) |
1527 | { | 1527 | { |
@@ -1562,6 +1562,7 @@ re_acquire_state_context (reg_errcode_t *err, const re_dfa_t *dfa, | |||
1562 | indicates the error code if failed. */ | 1562 | indicates the error code if failed. */ |
1563 | 1563 | ||
1564 | static reg_errcode_t | 1564 | static reg_errcode_t |
1565 | __attribute_warn_unused_result__ | ||
1565 | register_state (const re_dfa_t *dfa, re_dfastate_t *newstate, | 1566 | register_state (const re_dfa_t *dfa, re_dfastate_t *newstate, |
1566 | re_hashval_t hash) | 1567 | re_hashval_t hash) |
1567 | { | 1568 | { |
@@ -1616,7 +1617,7 @@ free_state (re_dfastate_t *state) | |||
1616 | Return the new state if succeeded, otherwise return NULL. */ | 1617 | Return the new state if succeeded, otherwise return NULL. */ |
1617 | 1618 | ||
1618 | static re_dfastate_t * | 1619 | static re_dfastate_t * |
1619 | internal_function | 1620 | internal_function __attribute_warn_unused_result__ |
1620 | create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes, | 1621 | create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes, |
1621 | re_hashval_t hash) | 1622 | re_hashval_t hash) |
1622 | { | 1623 | { |
@@ -1666,7 +1667,7 @@ create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes, | |||
1666 | Return the new state if succeeded, otherwise return NULL. */ | 1667 | Return the new state if succeeded, otherwise return NULL. */ |
1667 | 1668 | ||
1668 | static re_dfastate_t * | 1669 | static re_dfastate_t * |
1669 | internal_function | 1670 | internal_function __attribute_warn_unused_result__ |
1670 | create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes, | 1671 | create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes, |
1671 | unsigned int context, re_hashval_t hash) | 1672 | unsigned int context, re_hashval_t hash) |
1672 | { | 1673 | { |
@@ -1715,7 +1716,9 @@ create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes, | |||
1715 | free_state (newstate); | 1716 | free_state (newstate); |
1716 | return NULL; | 1717 | return NULL; |
1717 | } | 1718 | } |
1718 | re_node_set_init_copy (newstate->entrance_nodes, nodes); | 1719 | if (re_node_set_init_copy (newstate->entrance_nodes, nodes) |
1720 | != REG_NOERROR) | ||
1721 | return NULL; | ||
1719 | nctx_nodes = 0; | 1722 | nctx_nodes = 0; |
1720 | newstate->has_constraint = 1; | 1723 | newstate->has_constraint = 1; |
1721 | } | 1724 | } |