summaryrefslogtreecommitdiff
path: root/usr.bin/m4/misc.c
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2002-04-28 14:37:13 +0000
committerMarc Espie <espie@cvs.openbsd.org>2002-04-28 14:37:13 +0000
commit2f15e29fadc2bc35285820205ae7ff94f2d19be8 (patch)
tree77ba7576a9503cf0fede4d33937d28f1badeb600 /usr.bin/m4/misc.c
parent46b4ea21951a8b60d15104c3a547e37ce9d1ad07 (diff)
Implement -s.
Triggered by recent FreeBSD changes. - emits #line directives at every file change (like FreeBSD) - maintains a synch_lineno variable to verify when the output gets out of synch with the input, so that it can emit #line to re-synch as well (unlike FreeBSD) To do: either handle \end-of-line, or recognize when a macro expansion is in progress, so that line synch don't perturb cpp on multi-line expansions. With this, we should have a fully POSIX-compliant m4. ok miod@
Diffstat (limited to 'usr.bin/m4/misc.c')
-rw-r--r--usr.bin/m4/misc.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/usr.bin/m4/misc.c b/usr.bin/m4/misc.c
index 291c2192fde..4943518aa85 100644
--- a/usr.bin/m4/misc.c
+++ b/usr.bin/m4/misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.c,v 1.27 2002/04/26 16:15:16 espie Exp $ */
+/* $OpenBSD: misc.c,v 1.28 2002/04/28 14:37:12 espie Exp $ */
/* $NetBSD: misc.c,v 1.6 1995/09/28 05:37:41 tls Exp $ */
/*
@@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: misc.c,v 1.27 2002/04/26 16:15:16 espie Exp $";
+static char rcsid[] = "$OpenBSD: misc.c,v 1.28 2002/04/28 14:37:12 espie Exp $";
#endif
#endif /* not lint */
@@ -288,7 +288,7 @@ xstrdup(const char *s)
void
usage()
{
- fprintf(stderr, "usage: m4 [-Dname[=val]] [-Uname] [-I dirname...]\n");
+ fprintf(stderr, "usage: m4 [-gs] [-d flags] [-t macro] [-o file] [-Dname[=val]] [-Uname] [-I dirname...]\n");
exit(1);
}
@@ -311,6 +311,15 @@ set_input(struct input_file *f, FILE *real, const char *name)
f->lineno = 1;
f->c = 0;
f->name = xstrdup(name);
+ emit_synchline();
+}
+
+void
+do_emit_synchline()
+{
+ fprintf(active, "#line %lu \"%s\"\n",
+ infile[ilevel].lineno, infile[ilevel].name);
+ infile[ilevel].synch_lineno = infile[ilevel].lineno;
}
void