CVS commit: src/gnu/dist/grep/src

2015-09-12 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Sat Sep 12 19:05:11 UTC 2015

Modified Files:
src/gnu/dist/grep/src: grep.c

Log Message:
Avoid TYPE_MAXIMUM, it depends on undefined behavior.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/gnu/dist/grep/src/grep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/gnu/dist/grep/src/grep.c
diff -u src/gnu/dist/grep/src/grep.c:1.15 src/gnu/dist/grep/src/grep.c:1.16
--- src/gnu/dist/grep/src/grep.c:1.15	Thu Jun 12 07:42:46 2014
+++ src/gnu/dist/grep/src/grep.c	Sat Sep 12 19:05:11 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: grep.c,v 1.15 2014/06/12 07:42:46 dholland Exp $	*/
+/*	$NetBSD: grep.c,v 1.16 2015/09/12 19:05:11 joerg Exp $	*/
 
 /* grep.c - main driver file for grep.
Copyright 1992, 1997-1999, 2000 Free Software Foundation, Inc.
@@ -53,6 +53,13 @@ struct stats
   struct stat stat;
 };
 
+#include 
+#define MAX_OFF_T (sizeof(off_t) == sizeof(char) ? INT_MAX : \
+   (sizeof(off_t) == sizeof(short) ? SHRT_MAX : \
+(sizeof(off_t) == sizeof(int) ? INT_MAX : \
+ (sizeof(off_t) == sizeof(long) ? LONG_MAX : \
+  (sizeof(off_t) == sizeof(long long) ? LLONG_MAX : INTMAX_MAX)
+
 /* base of chain of stat buffers, used to detect directory loops */
 static struct stats stats_base;
 
@@ -1341,7 +1348,7 @@ main (int argc, char **argv)
   eolbyte = '\n';
   filename_mask = ~0;
 
-  max_count = TYPE_MAXIMUM (off_t);
+  max_count = MAX_OFF_T;
 
   /* The value -1 means to use DEFAULT_CONTEXT. */
   out_after = out_before = -1;
@@ -1516,7 +1523,7 @@ main (int argc, char **argv)
 		break;
 	  /* Fall through.  */
 	case LONGINT_OVERFLOW:
-	  max_count = TYPE_MAXIMUM (off_t);
+	  max_count = MAX_OFF_T;
 	  break;
 
 	default:



CVS commit: src/gnu/dist/grep/src

2014-06-12 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Thu Jun 12 07:42:46 UTC 2014

Modified Files:
src/gnu/dist/grep/src: grep.c

Log Message:
Hide the -P option in the usage message unless HAVE_LIBPCRE (which we
don't have in base) as per PR 39122.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/gnu/dist/grep/src/grep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/gnu/dist/grep/src/grep.c
diff -u src/gnu/dist/grep/src/grep.c:1.14 src/gnu/dist/grep/src/grep.c:1.15
--- src/gnu/dist/grep/src/grep.c:1.14	Sat Jan  5 09:40:16 2013
+++ src/gnu/dist/grep/src/grep.c	Thu Jun 12 07:42:46 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: grep.c,v 1.14 2013/01/05 09:40:16 apb Exp $	*/
+/*	$NetBSD: grep.c,v 1.15 2014/06/12 07:42:46 dholland Exp $	*/
 
 /* grep.c - main driver file for grep.
Copyright 1992, 1997-1999, 2000 Free Software Foundation, Inc.
@@ -1066,8 +1066,11 @@ Regexp selection and interpretation:\n)
   printf (_(\
   -E, --extended-regexp PATTERN is an extended regular expression\n\
   -F, --fixed-strings   PATTERN is a set of newline-separated strings\n\
-  -G, --basic-regexpPATTERN is a basic regular expression\n\
+  -G, --basic-regexpPATTERN is a basic regular expression\n));
+#if HAVE_LIBPCRE
+  printf (_(\
   -P, --perl-regexp PATTERN is a Perl regular expression\n));
+#endif
   printf (_(\
   -e, --regexp=PATTERN  use PATTERN as a regular expression\n\
   -f, --file=FILE   obtain PATTERN from FILE\n\



CVS commit: src/gnu/dist/grep/src

2010-09-27 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Tue Sep 28 00:54:04 UTC 2010

Modified Files:
src/gnu/dist/grep/src: grep.c

Log Message:
Fix -o behavior with patterns that match the empty string, as per PR 43896.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/gnu/dist/grep/src/grep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/gnu/dist/grep/src/grep.c
diff -u src/gnu/dist/grep/src/grep.c:1.12 src/gnu/dist/grep/src/grep.c:1.13
--- src/gnu/dist/grep/src/grep.c:1.12	Thu Aug 28 03:59:06 2008
+++ src/gnu/dist/grep/src/grep.c	Tue Sep 28 00:54:04 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: grep.c,v 1.12 2008/08/28 03:59:06 lukem Exp $	*/
+/*	$NetBSD: grep.c,v 1.13 2010/09/28 00:54:04 dholland Exp $	*/
 
 /* grep.c - main driver file for grep.
Copyright 1992, 1997-1999, 2000 Free Software Foundation, Inc.
@@ -542,7 +542,10 @@
 	  if (b == lim)
 	break;
 	  if (match_size == 0)
-	break;
+	{
+	  beg++;
+	  continue;
+	}
 	  if(color_option)
 	printf(\33[%sm, grep_color);
 	  fwrite(b, sizeof (char), match_size, stdout);