From owner-freebsd-bugs Thu May 25 20:10:12 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 4216D37BE37 for ; Thu, 25 May 2000 20:10:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id UAA63419; Thu, 25 May 2000 20:10:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from mail.ptd.net (mail1.ha-net.ptd.net [207.44.96.65]) by hub.freebsd.org (Postfix) with SMTP id C6A8F37B820 for ; Thu, 25 May 2000 20:08:02 -0700 (PDT) (envelope-from tms@mail.ptd.net) Received: (qmail 25787 invoked from network); 26 May 2000 03:07:58 -0000 Received: from du146.cli.ptd.net (HELO beowulf.bsd.home) (204.186.33.146) by mail.ptd.net with SMTP; 26 May 2000 03:07:58 -0000 Received: (from tms@localhost) by beowulf.bsd.home (8.9.3/8.9.3) id WAA01736; Thu, 25 May 2000 22:52:41 -0400 (EDT) (envelope-from tms) Message-Id: <200005260252.WAA01736@beowulf.bsd.home> Date: Thu, 25 May 2000 22:52:41 -0400 (EDT) From: tms2@mail.ptd.net Reply-To: tms2@mail.ptd.net To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: misc/18821: lint does not understand C++-style comments Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >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