summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorChad Loder <cloder@cvs.openbsd.org>2005-11-30 19:42:59 +0000
committerChad Loder <cloder@cvs.openbsd.org>2005-11-30 19:42:59 +0000
commit7b845fa9a1c2b5f5a669196485c523f77e90ff43 (patch)
tree28fad489283215a9520bf0043c150d396db1e0a7 /usr.bin
parent8420b3f21b37fc129626b64cd313cb7f6e942946 (diff)
Add support for // comments. From NetBSD
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/xlint/lint1/scan.l17
1 files changed, 15 insertions, 2 deletions
diff --git a/usr.bin/xlint/lint1/scan.l b/usr.bin/xlint/lint1/scan.l
index dc675199efb..f12e5829ad3 100644
--- a/usr.bin/xlint/lint1/scan.l
+++ b/usr.bin/xlint/lint1/scan.l
@@ -1,5 +1,5 @@
%{
-/* $OpenBSD: scan.l,v 1.15 2005/11/30 06:32:00 cloder Exp $ */
+/* $OpenBSD: scan.l,v 1.16 2005/11/30 19:42:58 cloder Exp $ */
/* $NetBSD: scan.l,v 1.8 1995/10/23 13:38:51 jpo Exp $ */
/*
@@ -34,7 +34,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: scan.l,v 1.15 2005/11/30 06:32:00 cloder Exp $";
+static char rcsid[] = "$OpenBSD: scan.l,v 1.16 2005/11/30 19:42:58 cloder Exp $";
#endif
#include <stdlib.h>
@@ -77,6 +77,7 @@ static int wccon(void);
static int getescc(int);
static void directive(void);
static void comment(void);
+static void slashslashcomment(void);
static int string(void);
static int wcstrg(void);
@@ -152,6 +153,7 @@ EX ([eE][+-]?[0-9]+)
\n incline();
\t|" "|\f|\v ;
"/*" comment();
+"//" slashslashcomment();
. badchar(yytext[0]);
%%
@@ -1076,6 +1078,17 @@ comment(void)
}
/*
+ * Handle // style comments, which are valid in C99.
+ */
+static void
+slashslashcomment(void)
+{
+ int c;
+
+ while ((c = inpc()) != EOF && c != '\n');
+}
+
+/*
* Clear flags for lint comments LINTED, LONGLONG and CONSTCOND.
* clrwflgs() is called after function definitions and global and
* local declarations and definitions. It is also called between