summaryrefslogtreecommitdiff
path: root/usr.bin/m4/main.c
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>1999-11-30 22:19:51 +0000
committerMarc Espie <espie@cvs.openbsd.org>1999-11-30 22:19:51 +0000
commit7aad3d32d1df2773dc37f5b2763f3b9e206f8b5c (patch)
tree3118b3a171b9610ea9d0d6af9bf8571c7c24a158 /usr.bin/m4/main.c
parent3d479ce926caeb7bc8a2e899655dfc6c09b17da4 (diff)
Clean up comment/quote recognition a little bit:
- use strlcpy to make clear that the strings are line terminated, - remove the number of magic constants, - use assert() for preconditions, - use puts instead of looping over array of chars...
Diffstat (limited to 'usr.bin/m4/main.c')
-rw-r--r--usr.bin/m4/main.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/usr.bin/m4/main.c b/usr.bin/m4/main.c
index cbd2ec4fd29..6bc389a9bd2 100644
--- a/usr.bin/m4/main.c
+++ b/usr.bin/m4/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.20 1999/11/25 00:54:22 millert Exp $ */
+/* $OpenBSD: main.c,v 1.21 1999/11/30 22:19:50 espie Exp $ */
/* $NetBSD: main.c,v 1.12 1997/02/08 23:54:49 cgd Exp $ */
/*-
@@ -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.20 1999/11/25 00:54:22 millert Exp $";
+static char rcsid[] = "$OpenBSD: main.c,v 1.21 1999/11/30 22:19:50 espie Exp $";
#endif
#endif /* not lint */
@@ -58,6 +58,7 @@ static char rcsid[] = "$OpenBSD: main.c,v 1.20 1999/11/25 00:54:22 millert Exp $
*/
#include <sys/types.h>
+#include <assert.h>
#include <signal.h>
#include <errno.h>
#include <unistd.h>
@@ -230,7 +231,7 @@ main(argc,argv)
}
/*
- * Look ahead (at most MAXCCHARS characters) for `token'.
+ * Look ahead for `token'.
* (on input `t == token[0]')
* Used for comment and quoting delimiters.
* Returns 1 if `token' present; copied to output.
@@ -243,8 +244,7 @@ do_look_ahead(t, token)
{
int i;
- if (t != token[0])
- errx(1, "internal error");
+ assert(t == token[0]);
for (i = 1; *++token; i++) {
t = gpbc();
@@ -356,16 +356,12 @@ macro()
}
else if (sp < 0 && LOOK_AHEAD(t, scommt)) {
- int i;
- for (i = 0; i < MAXCCHARS && scommt[i]; i++)
- putc(scommt[i], active);
+ fputs(scommt, active);
for(;;) {
t = gpbc();
if (LOOK_AHEAD(t, ecommt)) {
- for (i = 0; i < MAXCCHARS && ecommt[i];
- i++)
- putc(ecommt[i], active);
+ fputs(ecommt, active);
break;
}
if (t == EOF)