grep-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

grep branch, master, updated. v2.12-20-g074842d


From: Paul Eggert
Subject: grep branch, master, updated. v2.12-20-g074842d
Date: Tue, 12 Jun 2012 16:46:31 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  074842d3e3054714a495252e582886f0e4ace4e4 (commit)
      from  02f1daa1e7dc80a544b7904d1d9d9841e02e3d8b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=074842d3e3054714a495252e582886f0e4ace4e4


commit 074842d3e3054714a495252e582886f0e4ace4e4
Author: Paul Eggert <address@hidden>
Date:   Tue Jun 12 08:46:18 2012 -0700

    grep: handle -i when chars differ in length but line does not
    
    * src/searchutils.c (mbtolower): Return the map back to the caller
    if any input character's length differs from the corresponding output
    character's, not merely if the total string length differs.
    Problem reported by Johannes Mercer in
    <http://lists.gnu.org/archive/html/bug-grep/2012-06/msg00029.html>.

diff --git a/src/searchutils.c b/src/searchutils.c
index 4942c51..c1fb656 100644
--- a/src/searchutils.c
+++ b/src/searchutils.c
@@ -55,7 +55,8 @@ kwsinit (kwset_t *kwset)
    to the buffer and reuses it on any subsequent call.  As a consequence,
    this function is not thread-safe.
 
-   When the lowercase result string has the same length as the input string,
+   When all the characters in the lowercase result string have the
+   same length as corresponding characters in the input string,
    set *LEN_MAP_P to NULL.  Otherwise, set it to a malloc'd buffer (like the
    returned buffer, this must not be freed by caller) of the same length as
    the result string.  (*LEN_MAP_P)[J] is one less than the length-in-bytes
@@ -74,6 +75,7 @@ mbtolower (const char *beg, size_t *n, unsigned char 
**len_map_p)
   const char *end;
   char *p;
   unsigned char *m;
+  bool lengths_differ = false;
 
   if (*n > outalloc || outalloc == 0)
     {
@@ -99,7 +101,7 @@ mbtolower (const char *beg, size_t *n, unsigned char 
**len_map_p)
   while (beg < end)
     {
       wchar_t wc;
-      size_t mbclen = mbrtowc(&wc, beg, end - beg, &is);
+      size_t mbclen = mbrtowc (&wc, beg, end - beg, &is);
       if (outlen + mb_cur_max >= outalloc)
         {
           size_t dm = m - len_map;
@@ -123,14 +125,14 @@ mbtolower (const char *beg, size_t *n, unsigned char 
**len_map_p)
         {
           *m++ = mbclen - 1;
           beg += mbclen;
-          mbclen = wcrtomb (p, towlower ((wint_t) wc), &os);
-          p += mbclen;
-          outlen += mbclen;
+          size_t ombclen = wcrtomb (p, towlower ((wint_t) wc), &os);
+          p += ombclen;
+          outlen += ombclen;
+          lengths_differ |= (mbclen != ombclen);
         }
     }
 
-  /* If the new length differs from the original, give caller the map.  */
-  *len_map_p = p - out == *n ? NULL : len_map;
+  *len_map_p = lengths_differ ? len_map : NULL;
   *n = p - out;
   *p = 0;
   return out;

-----------------------------------------------------------------------

Summary of changes:
 src/searchutils.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)


hooks/post-receive
-- 
grep



reply via email to

[Prev in Thread] Current Thread [Next in Thread]