Date: Thu, 25 May 2000 22:52:41 -0400 (EDT) From: tms2@mail.ptd.net To: FreeBSD-gnats-submit@freebsd.org Subject: misc/18821: lint does not understand C++-style comments Message-ID: <200005260252.WAA01736@beowulf.bsd.home>
next in thread | raw e-mail | index | archive | help
>Number: 18821
>Category: misc
>Synopsis: lint does not understand C++-style comments
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Thu May 25 20:10:01 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator: Thomas M. Sommers
>Release: FreeBSD 3.2-RELEASE i386
>Organization:
>Environment:
>Description:
lint does not understand C++-style comments. gcc does understand them,
and they are part of the new C99 standard.
>How-To-Repeat:
>Fix:
*** scan.l.orig Thu May 25 21:00:46 2000
--- scan.l Thu May 25 21:49:15 2000
***************
*** 50,55 ****
--- 50,58 ----
#define CHAR_MASK (~(~0 << CHAR_BIT))
+ #define C_STYLE 1
+ #define CPP_STYLE 2
+
/* XXX declaration of strtouq() is missing in stdlib.h ? */
extern u_quad_t strtouq __P((const char *, char **, int));
***************
*** 78,84 ****
static int wccon __P((void));
static int getescc __P((int));
static void directive __P((void));
! static void comment __P((void));
static int string __P((void));
static int wcstrg __P((void));
--- 81,87 ----
static int wccon __P((void));
static int getescc __P((int));
static void directive __P((void));
! static void comment __P((int));
static int string __P((void));
static int wcstrg __P((void));
***************
*** 153,159 ****
^#.*$ directive();
\n incline();
\t|" "|\f|\v ;
! "/*" comment();
. badchar(yytext[0]);
%%
--- 156,163 ----
^#.*$ directive();
\n incline();
\t|" "|\f|\v ;
! "/*" comment(C_STYLE);
! "//" comment(CPP_STYLE);
. badchar(yytext[0]);
%%
***************
*** 1003,1009 ****
* parsed and a function which handles this comment is called.
*/
static void
! comment()
{
int c, lc;
static struct {
--- 1007,1013 ----
* parsed and a function which handles this comment is called.
*/
static void
! comment(int style)
{
int c, lc;
static struct {
***************
*** 1035,1041 ****
eoc = 0;
/* Skip white spaces after the start of the comment */
! while ((c = inpc()) != EOF && isspace(c)) ;
/* Read the potential keyword to keywd */
l = 0;
--- 1039,1054 ----
eoc = 0;
/* Skip white spaces after the start of the comment */
! if ( style == C_STYLE ) {
! while ((c = inpc()) != EOF && isspace(c)) ;
! }
! else {
! while ((c = inpc()) != EOF && c != '\n' && isspace(c)) ;
! if ( c == '\n' ) {
! eoc = 1;
! goto skip_rest;
! }
! }
/* Read the potential keyword to keywd */
l = 0;
***************
*** 1054,1062 ****
goto skip_rest;
/* skip white spaces after the keyword */
! while (c != EOF && isspace(c))
! c = inpc();
!
/* read the argument, if the keyword accepts one and there is one */
l = 0;
if (keywtab[i].arg) {
--- 1067,1081 ----
goto skip_rest;
/* skip white spaces after the keyword */
! if ( style == C_STYLE ) {
! while (c != EOF && isspace(c))
! c = inpc();
! }
! else {
! while (c != EOF && c != '\n' && isspace(c))
! c = inpc();
! }
!
/* read the argument, if the keyword accepts one and there is one */
l = 0;
if (keywtab[i].arg) {
***************
*** 1069,1078 ****
a = l != 0 ? atoi(arg) : -1;
/* skip white spaces after the argument */
! while (c != EOF && isspace(c))
! c = inpc();
! if (c != '*' || (c = inpc()) != '/') {
if (keywtab[i].func != linted)
/* extra characters in lint comment */
warning(257);
--- 1088,1104 ----
a = l != 0 ? atoi(arg) : -1;
/* skip white spaces after the argument */
! if ( style == C_STYLE ) {
! while (c != EOF && isspace(c))
! c = inpc();
! }
! else {
! while (c != EOF && c != '\n' && isspace(c))
! c = inpc();
! }
! if ( (style == C_STYLE && (c != '*' || (c = inpc()) != '/'))
! || (style == CPP_STYLE && c != '\n') ) {
if (keywtab[i].func != linted)
/* extra characters in lint comment */
warning(257);
***************
*** 1088,1102 ****
(*keywtab[i].func)(a);
skip_rest:
! while (!eoc) {
! lc = c;
! if ((c = inpc()) == EOF) {
! /* unterminated comment */
! error(256);
! break;
}
! if (lc == '*' && c == '/')
! eoc = 1;
}
}
--- 1114,1133 ----
(*keywtab[i].func)(a);
skip_rest:
! if ( style == C_STYLE ) {
! while (!eoc) {
! lc = c;
! if ((c = inpc()) == EOF) {
! /* unterminated comment */
! error(256);
! break;
! }
! if (lc == '*' && c == '/')
! eoc = 1;
}
! }
! else {
! while ( (c = inpc()) != '\n' ) ;
}
}
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200005260252.WAA01736>
