summaryrefslogtreecommitdiff
path: root/src/searchutils.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2014-05-15 18:46:51 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2014-05-15 18:47:43 -0700
commita6ae68d279b68619cd77c714fb2c5e7fb31096f5 (patch)
tree46b40c9540fa65f7da6fbc5e39f4c5f4d759af43 /src/searchutils.c
parent3b301a71d94eec362f00905be9d2fa2b044f6f83 (diff)
downloadgrep-a6ae68d279b68619cd77c714fb2c5e7fb31096f5.tar.gz
grep: port mb_next_wc to RHEL 6.5 x86-64
* src/searchutils.c (mb_next_wc): Work around glibc bug 16950; see: https://sourceware.org/bugzilla/show_bug.cgi?id=16950 This bug was masked in the other GNU/Linux tests I made. It was exposed on RHEL 6.5 x86-64, where the compiler (GCC Red Hat 4.4.7-4) happened to use temporaries in a different way. Also see recent changes to the Gnulib documentation in this area: http://lists.gnu.org/archive/html/bug-gnulib/2014-05/msg00013.html
Diffstat (limited to 'src/searchutils.c')
-rw-r--r--src/searchutils.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/searchutils.c b/src/searchutils.c
index 5eb9a12f..18dd584e 100644
--- a/src/searchutils.c
+++ b/src/searchutils.c
@@ -285,5 +285,6 @@ mb_next_wc (char const *cur, char const *end)
{
wchar_t wc;
mbstate_t mbs = { 0 };
- return mbrtowc (&wc, cur, end - cur, &mbs) < (size_t) -2 ? wc : WEOF;
+ return (end - cur != 0 && mbrtowc (&wc, cur, end - cur, &mbs) < (size_t) -2
+ ? wc : WEOF);
}