Package: flex
Version: 2.5.33-2
Severity: normal
Hi,
the new flex has a weird behavior when some ]] appear in comments. Here is
a small example to illustrate the problem:
%option noyywrap
%{
#include <stdio.h>
int num_lines = 0, num_chars = 0; /* Some comment: ]] */
%}
%%
\n ++num_lines; ++num_chars;
. ++num_chars;
%%
int main(int argc, char *argv[]) {
yylex();
printf( "# of lines = %d, # of chars = %d\n",
num_lines, num_chars );
return 0;
}
Apply flex to this simple C code and you'll get an uncompilable code.
surf:/tmp $ cmake A
flex -o A.c A.l
gcc -Wall -Wunused -Wpointer-arith -Wchar-subscripts -Wcomment -Wformat
-Wwrite-strings -Wno-unused-function -Werror -o A A.c
A.c:460: Error: erreur: syntax error before ']' token
In file included from A.c:469:
/usr/include/unistd.h:942: Error: erreur: syntax error before '__delta'
make: *** [A] Erreur 1
The corresponding C code looks like that:
#include <stdio.h>
int num_lines = 0, num_chars = 0; /* Some comment: */
#line 460 "A.c"
]]
#define INITIAL 0
However, if you put a space between the two ], it works perfectly.
surf:/tmp $ cmake A
flex -o A.c A.l
gcc -Wall -Wunused -Wpointer-arith -Wchar-subscripts -Wcomment -Wformat
-Wwrite-strings -Wno-unused-function -Werror -o A A.c
The corresponding C code looks like that:
#include <stdio.h>
int num_lines = 0, num_chars = 0; /* Some comment: ] ] */
#line 460 "A.c"
#define INITIAL 0
So I don't know exactly where the problem comes from in flex but this
definitely doesn't look like a normal behavior to me.
Cheers,
Arnaud
-- System Information:
Debian Release: testing/unstable
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.15-1-686
Locale: LANG=fr_FR.ISO-8859-1, LC_CTYPE=fr_FR.ISO-8859-1 (charmap=ISO-8859-1)
Versions of packages flex depends on:
ii debconf [debconf-2.0] 1.4.71 Debian configuration management sy
ii libc6 2.3.6-3 GNU C Library: Shared libraries an
ii m4 1.4.4-1 a macro processing language
Versions of packages flex recommends:
ii gcc [c-compiler] 4:4.0.2-2 The GNU C compiler
ii gcc-3.3 [c-compiler] 1:3.3.6-12 The GNU C compiler
ii gcc-3.4 [c-compiler] 3.4.5-3 The GNU C compiler
ii gcc-4.0 [c-compiler] 4.0.2-10 The GNU C compiler
-- debconf-show failed
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]