Date: Sun, 10 Feb 2019 23:45:15 +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-12@freebsd.org Subject: svn commit: r343988 - stable/12/gnu/usr.bin/grep Message-ID: <201902102345.x1ANjFVZ032589@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201902102345.x1ANjFVZ032589>