diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2001-06-13 12:20:44 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2001-06-13 12:20:44 +0000 |
commit | c820ed342cb9529e7d1fc1dbf40cb6907f990a47 (patch) | |
tree | b68d834161bdf90894d87f6eef541ad3c57743cf | |
parent | 1da1739beba437ba513e83781dd96e65931e89ed (diff) |
Fix PR 1868. MAXSTR has no place there.
MAXSTR is still a hard limit, but only for token length, where 512
characters seems reasonable.
Ok millert@
-rw-r--r-- | usr.bin/m4/eval.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/usr.bin/m4/eval.c b/usr.bin/m4/eval.c index 3708d4caf91..964058f7fdc 100644 --- a/usr.bin/m4/eval.c +++ b/usr.bin/m4/eval.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eval.c,v 1.28 2000/07/27 17:44:32 espie Exp $ */ +/* $OpenBSD: eval.c,v 1.29 2001/06/13 12:20:43 espie Exp $ */ /* $NetBSD: eval.c,v 1.7 1996/11/10 21:21:29 pk Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)eval.c 8.2 (Berkeley) 4/27/95"; #else -static char rcsid[] = "$OpenBSD: eval.c,v 1.28 2000/07/27 17:44:32 espie Exp $"; +static char rcsid[] = "$OpenBSD: eval.c,v 1.29 2001/06/13 12:20:43 espie Exp $"; #endif #endif /* not lint */ @@ -801,22 +801,21 @@ dosub(argv, argc) const char *ap, *fc, *k; int nc; - if (argc < 5) - nc = MAXTOK; - else -#ifdef EXPR - nc = expr(argv[4]); -#else - nc = atoi(argv[4]); -#endif ap = argv[2]; /* target string */ #ifdef EXPR fc = ap + expr(argv[3]); /* first char */ #else fc = ap + atoi(argv[3]); /* first char */ #endif + nc = strlen(fc); + if (argc >= 5) +#ifdef EXPR + nc = min(nc, expr(argv[4])); +#else + nc = min(nc, atoi(argv[4])); +#endif if (fc >= ap && fc < ap + strlen(ap)) - for (k = fc + min(nc, strlen(fc)) - 1; k >= fc; k--) + for (k = fc + nc - 1; k >= fc; k--) putback(*k); } |