diff options
author | Anil Madhavapeddy <avsm@cvs.openbsd.org> | 2003-06-30 18:37:49 +0000 |
---|---|---|
committer | Anil Madhavapeddy <avsm@cvs.openbsd.org> | 2003-06-30 18:37:49 +0000 |
commit | a14f21e139247c2f4a4b25d2f709b55822684663 (patch) | |
tree | 05957cff747cba8c8fc3c9444d7f7b0abfa6127e /usr.bin/unifdef | |
parent | ec46948c955ded5dcd149fc79465c26e0913c945 (diff) |
sync with freebsd:
- avoid a coredump in 'line mode' and correct a comment
- stub for -I option (our manpage already mentions this)
- add author's copyright (tony finch)
millert@ ok
Diffstat (limited to 'usr.bin/unifdef')
-rw-r--r-- | usr.bin/unifdef/unifdef.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/usr.bin/unifdef/unifdef.c b/usr.bin/unifdef/unifdef.c index 44e6589706a..68a62ac3a3c 100644 --- a/usr.bin/unifdef/unifdef.c +++ b/usr.bin/unifdef/unifdef.c @@ -1,5 +1,6 @@ -/* $OpenBSD: unifdef.c,v 1.10 2003/06/03 02:56:21 millert Exp $ */ +/* $OpenBSD: unifdef.c,v 1.11 2003/06/30 18:37:48 avsm Exp $ */ /* + * Copyright (c) 2002, 2003 Tony Finch <dot@dotat.at> * Copyright (c) 1985, 1993 * The Regents of the University of California. All rights reserved. * @@ -39,7 +40,7 @@ static const char copyright[] = #if 0 static char sccsid[] = "@(#)unifdef.c 8.1 (Berkeley) 6/6/93"; #endif -static const char rcsid[] = "$OpenBSD: unifdef.c,v 1.10 2003/06/03 02:56:21 millert Exp $"; +static const char rcsid[] = "$OpenBSD: unifdef.c,v 1.11 2003/06/30 18:37:48 avsm Exp $"; #endif /* @@ -216,7 +217,7 @@ main(int argc, char *argv[]) { int opt; - while ((opt = getopt(argc, argv, "i:D:U:cdeklst")) != -1) + while ((opt = getopt(argc, argv, "i:D:U:I:cdeklst")) != -1) switch (opt) { case 'i': /* treat stuff controlled by these symbols as text */ /* @@ -238,6 +239,9 @@ main(int argc, char *argv[]) case 'U': /* undef a symbol */ addsym(false, false, optarg); break; + case 'I': + /* no-op for compatibility with cpp */ + break; case 'c': /* treat -D as -U and vice versa */ complement = true; break; @@ -981,16 +985,18 @@ ifeval(const char **cpp) /* * Skip over comments and stop at the next character position that is - * not whitespace. Between calls we keep the comment state in a global - * variable, and we also make a note when we get a proper end-of-line. + * not whitespace. Between calls we keep the comment state in the + * global variable incomment, and we also adjust the global variable + * linestate when we see a newline. * XXX: doesn't cope with the buffer splitting inside a state transition. */ static const char * skipcomment(const char *cp) { if (text || ignoring[depth]) { - while (isspace((unsigned char)*cp)) - cp += 1; + for (; isspace((unsigned char)*cp); cp++) + if (*cp == '\n') + linestate = LS_START; return (cp); } while (*cp != '\0') |