svn commit: r343988 - stable/12/gnu/usr.bin/grep

Pedro F. Giffuni pfg at FreeBSD.org
Sun Feb 10 23:45:15 UTC 2019


Author: pfg
Date: Sun Feb 10 23:45:14 2019
New Revision: 343988
URL: https://svnweb.freebsd.org/changeset/base/343988

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

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

Modified: stable/12/gnu/usr.bin/grep/search.c
==============================================================================
--- stable/12/gnu/usr.bin/grep/search.c	Sun Feb 10 23:30:54 2019	(r343987)
+++ stable/12/gnu/usr.bin/grep/search.c	Sun Feb 10 23:45:14 2019	(r343988)
@@ -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;
 			    }
 


More information about the svn-src-all mailing list