Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 10 Feb 2019 23:47:37 +0000 (UTC)
From:      "Pedro F. Giffuni" <pfg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r343989 - stable/11/gnu/usr.bin/grep
Message-ID:  <201902102347.x1ANlbbM032745@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pfg
Date: Sun Feb 10 23:47:37 2019
New Revision: 343989
URL: https://svnweb.freebsd.org/changeset/base/343989

Log:
  MFC r342910:
  grep(1) outputs NOT-matched lines with multi-byte characters
  
  PR:	113343

Modified:
  stable/11/gnu/usr.bin/grep/search.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/gnu/usr.bin/grep/search.c
==============================================================================
--- stable/11/gnu/usr.bin/grep/search.c	Sun Feb 10 23:45:14 2019	(r343988)
+++ stable/11/gnu/usr.bin/grep/search.c	Sun Feb 10 23:47:37 2019	(r343989)
@@ -401,9 +401,12 @@ EGexecute (char const *buf, size_t size, size_t *match
 			}
 
 		      if (mlen == (size_t) -2)
-			/* Offset points inside multibyte character:
-			 * no good. */
-			break;
+			{
+			  /* Offset points inside multibyte character:
+			   * no good. */
+			  memset (&mbs, '\0', sizeof (mbstate_t));
+			  break;
+			}
 
 		      beg += mlen;
 		      bytes_left -= mlen;
@@ -463,9 +466,12 @@ EGexecute (char const *buf, size_t size, size_t *match
 			}
 
 		      if (mlen == (size_t) -2)
-			/* Offset points inside multibyte character:
-			 * no good. */
-			break;
+			{
+			  /* Offset points inside multibyte character:
+			   * no good. */
+			  memset (&mbs, '\0', sizeof (mbstate_t));
+			  break;
+			}
 
 		      beg += mlen;
 		      bytes_left -= mlen;
@@ -926,15 +932,21 @@ Fexecute (char const *buf, size_t size, size_t *match_
 		}
 
 	      if (mlen == (size_t) -2)
-		/* Offset points inside multibyte character: no good. */
-		break;
+		{
+		  /* Offset points inside multibyte character: no good. */
+		  memset (&mbs, '\0', sizeof (mbstate_t));
+		  break;
+		}
 
 	      beg += mlen;
 	      bytes_left -= mlen;
 	    }
 
 	  if (bytes_left)
-	    continue;
+	    {
+	      beg += bytes_left;
+	      continue;
+	    }
 	}
       else
 #endif /* MBS_SUPPORT */
@@ -1052,6 +1064,7 @@ Fexecute (char const *buf, size_t size, size_t *match_
 			    {
 			      /* Offset points inside multibyte character:
 			       * no good. */
+			      memset (&mbs, '\0', sizeof (mbstate_t));
 			      break;
 			    }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201902102347.x1ANlbbM032745>