summaryrefslogtreecommitdiff
path: root/usr.bin/m4/eval.c
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2005-03-02 10:12:16 +0000
committerMarc Espie <espie@cvs.openbsd.org>2005-03-02 10:12:16 +0000
commit0881d45f2f57f4fe554eaf02317176e510800e2d (patch)
tree332bf8c544401d4cec97025f523e2814ea21cd3e /usr.bin/m4/eval.c
parent3abe8debbffa05857cb7deaa65dd547295859d50 (diff)
let m4wrap handle multiple wraps, both in normal and gnu-mode.
based on Noah Misch's bug report. okay otto, jmc.
Diffstat (limited to 'usr.bin/m4/eval.c')
-rw-r--r--usr.bin/m4/eval.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/usr.bin/m4/eval.c b/usr.bin/m4/eval.c
index e2484d42729..87e036ab27a 100644
--- a/usr.bin/m4/eval.c
+++ b/usr.bin/m4/eval.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: eval.c,v 1.54 2005/01/31 16:06:54 robert Exp $ */
+/* $OpenBSD: eval.c,v 1.55 2005/03/02 10:12:15 espie Exp $ */
/* $NetBSD: eval.c,v 1.7 1996/11/10 21:21:29 pk Exp $ */
/*
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)eval.c 8.2 (Berkeley) 4/27/95";
#else
-static char rcsid[] = "$OpenBSD: eval.c,v 1.54 2005/01/31 16:06:54 robert Exp $";
+static char rcsid[] = "$OpenBSD: eval.c,v 1.55 2005/03/02 10:12:15 espie Exp $";
#endif
#endif /* not lint */
@@ -72,6 +72,7 @@ static void gnu_dochq(const char *[], int);
static void dochq(const char *[], int);
static void gnu_dochc(const char *[], int);
static void dochc(const char *[], int);
+static void dom4wrap(const char *);
static void dodiv(int);
static void doundiv(const char *[], int);
static void dosub(const char *[], int);
@@ -434,7 +435,8 @@ expand_builtin(const char *argv[], int argc, int td)
* dom4wrap - set up for
* wrap-up/wind-down activity
*/
- m4wraps = (argc > 2) ? xstrdup(argv[2]) : null;
+ if (argc > 2)
+ dom4wrap(argv[2]);
break;
case EXITTYPE:
@@ -806,6 +808,23 @@ dochc(const char *argv[], int argc)
}
/*
+ * dom4wrap - expand text at EOF
+ */
+static void
+dom4wrap(const char *text)
+{
+ if (wrapindex >= maxwraps) {
+ if (maxwraps == 0)
+ maxwraps = 16;
+ else
+ maxwraps *= 2;
+ m4wraps = xrealloc(m4wraps, maxwraps * sizeof(*m4wraps),
+ "too many m4wraps");
+ }
+ m4wraps[wrapindex++] = xstrdup(text);
+}
+
+/*
* dodivert - divert the output to a temporary file
*/
static void