summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2003-06-08 22:42:28 +0000
committerMarc Espie <espie@cvs.openbsd.org>2003-06-08 22:42:28 +0000
commitd873e811f8644f9438c150c53eb50d985e3edeeb (patch)
tree4bff2e169e8d691a23bab74f1d518f05d889709e
parente2ce8857349b11b2e572b12d671395d8f16e4f57 (diff)
Better argv tests, enough to fix autoconf 2.57, apparently.
okay millert@
-rw-r--r--usr.bin/m4/gnum4.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/usr.bin/m4/gnum4.c b/usr.bin/m4/gnum4.c
index 553ef38da1a..3f6c41ee891 100644
--- a/usr.bin/m4/gnum4.c
+++ b/usr.bin/m4/gnum4.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: gnum4.c,v 1.20 2003/06/08 20:11:45 espie Exp $ */
+/* $OpenBSD: gnum4.c,v 1.21 2003/06/08 22:42:27 espie Exp $ */
/*
* Copyright (c) 1999 Marc Espie
@@ -436,7 +436,11 @@ dopatsubst(const char *argv[], int argc)
/* special case: empty regexp */
if (argv[3][0] == '\0') {
const char *s;
- size_t len = strlen(argv[4]);
+ size_t len;
+ if (argv[4] && argc > 4)
+ len = strlen(argv[4]);
+ else
+ len = 0;
for (s = argv[2]; *s != '\0'; s++) {
addchars(argv[4], len);
addchar(*s);
@@ -453,7 +457,7 @@ dopatsubst(const char *argv[], int argc)
pmatch = xalloc(sizeof(regmatch_t) * (re.re_nsub+1));
do_subst(argv[2], &re,
- argc != 4 && argv[4] != NULL ? argv[4] : "", pmatch);
+ argc > 4 && argv[4] != NULL ? argv[4] : "", pmatch);
free(pmatch);
regfree(&re);
}