Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 6 Oct 2019 04:12:09 +0000 (UTC)
From:      Kyle Evans <kevans@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: r353139 - in stable/12/usr.bin/grep: . tests
Message-ID:  <201910060412.x964C9iq044293@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Sun Oct  6 04:12:08 2019
New Revision: 353139
URL: https://svnweb.freebsd.org/changeset/base/353139

Log:
  MFC r348503, r351769: bsdgrep nits
  
  r348503:
  grep: Move lone 'r'grep case into the adjacent switch
  
  This 'r' case should have belonged to the switch in the first place, but
  I had somehow missed the switch when initially adding the rgrep link. The
  zgrep script later came along and faithfully left this case standing alone,
  so we will now go ahead and join it.
  
  Nearby comment also adjusted a tad bit for wording and style.
  
  r351769:
  bsdgrep(1): add some basic tests for some GNU Extension support
  
  These will be expanded later as I come up with good test cases; for now,
  these seem to be enough to trigger bugs in base gnugrep and expose missing
  features in bsdgrep.

Modified:
  stable/12/usr.bin/grep/grep.c
  stable/12/usr.bin/grep/tests/grep_freebsd_test.sh
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/usr.bin/grep/grep.c
==============================================================================
--- stable/12/usr.bin/grep/grep.c	Sun Oct  6 04:10:28 2019	(r353138)
+++ stable/12/usr.bin/grep/grep.c	Sun Oct  6 04:12:08 2019	(r353139)
@@ -332,20 +332,22 @@ main(int argc, char *argv[])
 
 	setlocale(LC_ALL, "");
 
-	/* Check what is the program name of the binary.  In this
-	   way we can have all the funcionalities in one binary
-	   without the need of scripting and using ugly hacks. */
+	/*
+	 * Check how we've bene invoked to determine the behavior we should
+	 * exhibit. In this way we can have all the functionalities in one
+	 * binary without the need of scripting and using ugly hacks.
+	 */
 	pn = getprogname();
-	if (pn[0] == 'r') {
-		dirbehave = DIR_RECURSE;
-		Hflag = true;
-	}
 	switch (pn[0]) {
 	case 'e':
 		grepbehave = GREP_EXTENDED;
 		break;
 	case 'f':
 		grepbehave = GREP_FIXED;
+		break;
+	case 'r':
+		dirbehave = DIR_RECURSE;
+		Hflag = true;
 		break;
 	}
 

Modified: stable/12/usr.bin/grep/tests/grep_freebsd_test.sh
==============================================================================
--- stable/12/usr.bin/grep/tests/grep_freebsd_test.sh	Sun Oct  6 04:10:28 2019	(r353138)
+++ stable/12/usr.bin/grep/tests/grep_freebsd_test.sh	Sun Oct  6 04:12:08 2019	(r353139)
@@ -82,8 +82,34 @@ rgrep_body()
 	atf_check -o file:d_grep_r_implied.out rgrep --exclude="*.out" -e "test" "$(atf_get_srcdir)"
 }
 
+atf_test_case gnuext
+gnuext_body()
+{
+	grep_type
+	_type=$?
+	if [ $_type -eq $GREP_TYPE_BSD ]; then
+		atf_expect_fail "this test requires GNU extensions in regex(3)"
+	elif [ $_type -eq $GREP_TYPE_GNU_FREEBSD ]; then
+		atf_expect_fail "\\s and \\S are known to be buggy in base gnugrep"
+	fi
+
+	atf_check -o save:grep_alnum.out grep -o '[[:alnum:]]' /COPYRIGHT
+	atf_check -o file:grep_alnum.out grep -o '\w' /COPYRIGHT
+
+	atf_check -o save:grep_nalnum.out grep -o '[^[:alnum:]]' /COPYRIGHT
+	atf_check -o file:grep_nalnum.out grep -o '\W' /COPYRIGHT
+
+	atf_check -o save:grep_space.out grep -o '[[:space:]]' /COPYRIGHT
+	atf_check -o file:grep_space.out grep -o '\s' /COPYRIGHT
+
+	atf_check -o save:grep_nspace.out grep -o '[^[:space:]]' /COPYRIGHT
+	atf_check -o file:grep_nspace.out grep -o '\S' /COPYRIGHT
+
+}
+
 atf_init_test_cases()
 {
 	atf_add_test_case grep_r_implied
 	atf_add_test_case rgrep
+	atf_add_test_case gnuext
 }



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