GNU bug report logs - #17506
[PATCH] grep: port mb_next_wc to RHEL 6.5 x86-64

Previous Next

Package: grep;

Reported by: Paul Eggert <eggert <at> CS.UCLA.EDU>

Date: Fri, 16 May 2014 01:49:01 UTC

Severity: normal

Tags: easy, fixed, patch

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Paul Eggert <eggert <at> CS.UCLA.EDU>
To: 17506 <at> debbugs.gnu.org
Subject: bug#17506: [PATCH] grep: port mb_next_wc to RHEL 6.5 x86-64
Date: Thu, 15 May 2014 18:46:51 -0700
* 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
---
 src/searchutils.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/searchutils.c b/src/searchutils.c
index 5eb9a12..18dd584 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);
 }
-- 
1.9.0





This bug report was last modified 11 years and 28 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.