Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/gnu/dist/grep/src Avoid TYPE_MAXIMUM, it depends on undefine...
details: https://anonhg.NetBSD.org/src/rev/fbe396691486
branches: trunk
changeset: 340552:fbe396691486
user: joerg <joerg%NetBSD.org@localhost>
date: Sat Sep 12 19:05:11 2015 +0000
description:
Avoid TYPE_MAXIMUM, it depends on undefined behavior.
diffstat:
gnu/dist/grep/src/grep.c | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
diffs (41 lines):
diff -r b7cdfa15621b -r fbe396691486 gnu/dist/grep/src/grep.c
--- a/gnu/dist/grep/src/grep.c Sat Sep 12 19:04:21 2015 +0000
+++ b/gnu/dist/grep/src/grep.c Sat Sep 12 19:05:11 2015 +0000
@@ -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 stat stat;
};
+#include <limits.h>
+#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 @@
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 @@
break;
/* Fall through. */
case LONGINT_OVERFLOW:
- max_count = TYPE_MAXIMUM (off_t);
+ max_count = MAX_OFF_T;
break;
default:
Home |
Main Index |
Thread Index |
Old Index