diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2012-03-16 15:25:40 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2012-03-16 15:25:40 +0200 |
commit | a19298ed002eb20d91c37fd5067de18466211f83 (patch) | |
tree | 054a08cd961bff2b6a5e01973f194e1e6b6a236f /regexec.c | |
parent | 58b5aa30bc83d715b1d0708e686eed50ccf11f15 (diff) | |
download | egawk-a19298ed002eb20d91c37fd5067de18466211f83.tar.gz egawk-a19298ed002eb20d91c37fd5067de18466211f83.tar.bz2 egawk-a19298ed002eb20d91c37fd5067de18466211f83.zip |
Sync from GLIBC.
Diffstat (limited to 'regexec.c')
-rw-r--r-- | regexec.c | 27 |
1 files changed, 19 insertions, 8 deletions
@@ -1,5 +1,5 @@ /* Extended regular expression matching and search library. - Copyright (C) 2002-2005, 2007, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2002-2005,2007,2009,2010,2011 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. @@ -14,9 +14,8 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301 USA. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ static reg_errcode_t match_ctx_init (re_match_context_t *cache, int eflags, int n) internal_function; @@ -200,6 +199,15 @@ static int check_node_accept (const re_match_context_t *mctx, internal_function; static reg_errcode_t extend_buffers (re_match_context_t *mctx) internal_function; + +#ifdef GAWK +#undef MIN /* safety */ +static int +MIN(size_t a, size_t b) +{ + return (a < b ? a : b); +} +#endif /* Entry point for POSIX code. */ @@ -1156,7 +1164,8 @@ check_matching (re_match_context_t *mctx, int fl_longest_match, re_dfastate_t *old_state = cur_state; int next_char_idx = re_string_cur_idx (&mctx->input) + 1; - if (BE (next_char_idx >= mctx->input.bufs_len, 0) + if ((BE (next_char_idx >= mctx->input.bufs_len, 0) + && mctx->input.bufs_len < mctx->input.len) || (BE (next_char_idx >= mctx->input.valid_len, 0) && mctx->input.valid_len < mctx->input.len)) { @@ -1734,7 +1743,8 @@ clean_state_log_if_needed (re_match_context_t *mctx, int next_state_log_idx) { int top = mctx->state_log_top; - if (next_state_log_idx >= mctx->input.bufs_len + if ((next_state_log_idx >= mctx->input.bufs_len + && mctx->input.bufs_len < mctx->input.len) || (next_state_log_idx >= mctx->input.valid_len && mctx->input.valid_len < mctx->input.len)) { @@ -3924,6 +3934,7 @@ check_node_accept_bytes (const re_dfa_t *dfa, int node_idx, if (cset->nequiv_classes) { const unsigned char *cp = pin; + int32_t idx; table = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB); weights = (const unsigned char *) @@ -3932,7 +3943,7 @@ check_node_accept_bytes (const re_dfa_t *dfa, int node_idx, _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB); indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB); - int32_t idx = findidx (&cp); + idx = findidx (&cp, elem_len); if (idx > 0) for (i = 0; i < cset->nequiv_classes; ++i) { @@ -4113,7 +4124,7 @@ extend_buffers (re_match_context_t *mctx) return REG_ESPACE; /* Double the lengthes of the buffers. */ - ret = re_string_realloc_buffers (pstr, pstr->bufs_len * 2); + ret = re_string_realloc_buffers (pstr, MIN (pstr->len, pstr->bufs_len * 2)); if (BE (ret != REG_NOERROR, 0)) return ret; |