summaryrefslogtreecommitdiff
path: root/usr.bin/m4/main.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1997-12-20 15:39:15 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1997-12-20 15:39:15 +0000
commit653ace9d3ec27cdd8e4aa1baa633902ecab5c0c0 (patch)
tree27692c4bcc0d95028b54782c586053a9cf1432c3 /usr.bin/m4/main.c
parentd1e240e9a356c75fe1356e44b8ee69e787ba8412 (diff)
Simplify some push-back code (e.g. for left and right quotes) so that
it uses pbstr() instead of doing the characters individually (in reverse order) with putback(); cgd
Diffstat (limited to 'usr.bin/m4/main.c')
-rw-r--r--usr.bin/m4/main.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/usr.bin/m4/main.c b/usr.bin/m4/main.c
index d1f3b08ce9e..28ba8f8724c 100644
--- a/usr.bin/m4/main.c
+++ b/usr.bin/m4/main.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: main.c,v 1.6 1997/12/10 20:24:15 deraadt Exp $ */
-/* $NetBSD: main.c,v 1.11 1996/01/13 23:25:26 pk Exp $ */
+/* $OpenBSD: main.c,v 1.7 1997/12/20 15:39:14 deraadt Exp $ */
+/* $NetBSD: main.c,v 1.12 1997/02/08 23:54:49 cgd Exp $ */
/*-
* Copyright (c) 1989, 1993
@@ -47,7 +47,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: main.c,v 1.6 1997/12/10 20:24:15 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: main.c,v 1.7 1997/12/20 15:39:14 deraadt Exp $";
#endif
#endif /* not lint */
@@ -280,7 +280,7 @@ do_look_ahead(t, token)
*/
void
macro() {
- char token[MAXTOK];
+ char token[MAXTOK], chars[2];
register char *s;
register int t, l;
register ndptr p;
@@ -331,24 +331,34 @@ macro() {
continue;
}
/*
- * non-alpha single-char token seen..
+ * non-alpha token possibly seen..
* [the order of else if .. stmts is important.]
*/
else if (LOOK_AHEAD(t,lquote)) { /* strip quotes */
nlpar = 1;
do {
+
l = gpbc();
- if (LOOK_AHEAD(l,rquote))
+ if (LOOK_AHEAD(l,rquote)) {
nlpar--;
- else if (LOOK_AHEAD(l,lquote))
+ s = rquote;
+ } else if (LOOK_AHEAD(l,lquote)) {
nlpar++;
- else if (l == EOF)
+ s = lquote;
+ } else if (l == EOF)
oops("missing right quote", "");
+ else {
+ chars[0] = l;
+ chars[1] = '\0';
+ s = chars;
+ }
if (nlpar > 0) {
if (sp < 0)
- putc(l, active);
+ while (*s)
+ putc(*s++, active);
else
- chrsave(l);
+ while (*s)
+ chrsave(*s++);
}
}
while (nlpar != 0);