summaryrefslogtreecommitdiff
path: root/usr.bin/m4
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2000-06-28 10:01:28 +0000
committerMarc Espie <espie@cvs.openbsd.org>2000-06-28 10:01:28 +0000
commitd71b01cab6af2cd105f4cceca0cdebc019a46f37 (patch)
tree935b989d2b53706f448d620feb33da7eb33a534e /usr.bin/m4
parent13219342e717a77706f81b444a4b8e7ece7cc83b (diff)
Fix stupid bug in argument handling. Problem found by fries@
Jason, that's a candidate for stable...
Diffstat (limited to 'usr.bin/m4')
-rw-r--r--usr.bin/m4/gnum4.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/usr.bin/m4/gnum4.c b/usr.bin/m4/gnum4.c
index eebb7d593d6..9fd15a7dc2b 100644
--- a/usr.bin/m4/gnum4.c
+++ b/usr.bin/m4/gnum4.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: gnum4.c,v 1.6 2000/04/10 17:16:30 espie Exp $ */
+/* $OpenBSD: gnum4.c,v 1.7 2000/06/28 10:01:27 espie Exp $ */
/*
* Copyright (c) 1999 Marc Espie
@@ -445,7 +445,8 @@ dopatsubst(argv, argc)
exit_regerror(error, &re);
pmatch = xalloc(sizeof(regmatch_t) * (re.re_nsub+1));
- do_subst(argv[2], &re, argv[4] != NULL ? argv[4] : "", pmatch);
+ do_subst(argv[2], &re,
+ argc != 4 && argv[4] != NULL ? argv[4] : "", pmatch);
pbstr(getstring());
free(pmatch);
regfree(&re);
@@ -461,7 +462,7 @@ doregexp(argv, argc)
regmatch_t *pmatch;
if (argc <= 3) {
- warnx("Too few arguments to patsubst");
+ warnx("Too few arguments to regexp");
return;
}
error = regcomp(&re, mimic_gnu ? twiddle(argv[3]) : argv[3],
@@ -470,7 +471,7 @@ doregexp(argv, argc)
exit_regerror(error, &re);
pmatch = xalloc(sizeof(regmatch_t) * (re.re_nsub+1));
- if (argv[4] == NULL)
+ if (argv[4] == NULL || argc == 4)
do_regexpindex(argv[2], &re, pmatch);
else
do_regexp(argv[2], &re, argv[4], pmatch);