summaryrefslogtreecommitdiff
path: root/src/searchutils.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2014-05-04 18:59:51 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2014-05-04 19:35:49 -0700
commit3ba30d3ecc809fca6148d09b30edcb7d59636e9a (patch)
treeb071860bb4261955c248ea52e26abdd60959f98e /src/searchutils.c
parent87a84a103685be58b1cc218410156df7eff15662 (diff)
downloadgrep-3ba30d3ecc809fca6148d09b30edcb7d59636e9a.tar.gz
grep: simplify and fix problems with KWset-DFA agreement patch
* src/dfa.c (dfambcache, parse_bracket_exp): Simplify. (mbs_to_wchar, wctok, FETCH_WC, match_anychar, match_mb_charset) (check_matching_with_multibyte_ops, transit_state_consume_1char) (transit_state, dfaexec): Use wint_t, not wchar_t, so that WEOF is treated correctly on platforms where WEOF is not a valid wchar_t value. (ctok, lex): Use int, not unsigned int, for characters, so that EOF is treated more naturally. (parse_bracket_exp): Use NOTCHAR to mark uninitialized char, since FETCH_WC can now set the char to EOF. (lex): Remove unnecessary test for EOF. (parse_bracket_exp, atom): Swap then and else parts, to put the small one first; this is more readable here. * src/searchutils.c (is_mb_middle): Simplify.
Diffstat (limited to 'src/searchutils.c')
-rw-r--r--src/searchutils.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/searchutils.c b/src/searchutils.c
index 3c78f31c..76005bfc 100644
--- a/src/searchutils.c
+++ b/src/searchutils.c
@@ -249,10 +249,10 @@ is_mb_middle (const char **good, const char *buf, const char *end,
if (mbclen == (size_t) -2)
mbclen = mbrlen (p, end - p, &cur_state);
- if (mbclen == (size_t) -1 || mbclen == (size_t) -2 || mbclen == 0)
+ if (! (0 < mbclen && mbclen < (size_t) -2))
{
- /* An invalid sequence, or a truncated multibyte character.
- We treat it as a single byte character. */
+ /* An invalid sequence, or a truncated multibyte character, or
+ a null wide character. Treat it as a single byte character. */
mbclen = 1;
memset (&cur_state, 0, sizeof cur_state);
}
@@ -261,9 +261,5 @@ is_mb_middle (const char **good, const char *buf, const char *end,
*good = p;
- if (p > buf)
- return true;
-
- /* P == BUF here. */
- return false;
+ return buf < p;
}