From 7b845fa9a1c2b5f5a669196485c523f77e90ff43 Mon Sep 17 00:00:00 2001 From: Chad Loder Date: Wed, 30 Nov 2005 19:42:59 +0000 Subject: Add support for // comments. From NetBSD --- usr.bin/xlint/lint1/scan.l | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'usr.bin') 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 @@ -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]); %% @@ -1075,6 +1077,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 -- cgit v1.2.3