Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 31 Jul 2021 00:21:14 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: ab1dedd49460 - stable/12 - awk: Make -F '' and -v FS="" behave the same
Message-ID:  <202107310021.16V0LEuo048718@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=ab1dedd4946098fe7202e825d299a2cbec81dae0

commit ab1dedd4946098fe7202e825d299a2cbec81dae0
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2021-07-20 04:47:30 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2021-07-31 00:02:51 +0000

    awk: Make -F '' and -v FS="" behave the same
    
    IEEE Std 1003.1-2008 mandates that -F str be treated the same as -v
    FS=str. For a null string, this was not the case. Since awk(1) documents
    that a null string for FS has a specific behavior, make -F '' behave
    consistently with -v FS="".
    
    PR:                     241441
    Upstream issue:         https://github.com/onetrueawk/awk/issues/127
    Upstream pull request:  https://github.com/onetrueawk/awk/pull/128
    MFC After:              2 weeks
    Sponsored by:           Netflix
    
    (cherry picked from commit a2e3e1187309f9404940b61ca49a93bd0536559d)
---
 contrib/one-true-awk/main.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/contrib/one-true-awk/main.c b/contrib/one-true-awk/main.c
index f3936341ae75..4e68bfb46d27 100644
--- a/contrib/one-true-awk/main.c
+++ b/contrib/one-true-awk/main.c
@@ -91,9 +91,7 @@ setfs(char *p)
 	/* wart: t=>\t */
 	if (p[0] == 't' && p[1] == '\0')
 		return "\t";
-	else if (p[0] != '\0')
-		return p;
-	return NULL;
+	return p;
 }
 
 static char *
@@ -169,8 +167,6 @@ int main(int argc, char *argv[])
  			break;
 		case 'F':	/* set field separator */
 			fs = setfs(getarg(&argc, &argv, "no field separator"));
-			if (fs == NULL)
-				WARNING("field separator FS is empty");
 			break;
 		case 'v':	/* -v a=1 to be done NOW.  one -v for each */
 			vn = getarg(&argc, &argv, "no variable name");



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