Package: rats
Version: 2.1-4
Severity: minor
Tags: patch

Hello

I've noticed that the fix applied for bug #191197 leads to a nested
function declaration in the lex.yyc.c file produces by flex (around
line 5300) :

/** The main scanner function which does all the work.
 */
YY_DECL
{
        register yy_state_type yy_current_state;
        register char *yy_cp, *yy_bp;
        register int yy_act;
    
#line 64 "c-lex.l"


int preprocessor(void)
{
    signed char    c;

...

The problem (and bug #191197 problem) comes from the fact that unput()
function should only be used in action with newer version of flex.

So instead of moving the preprocessor function declaration in the
definition section of c-lex.l, it's better (IMHO) to extract the
function's code and place it directly in the only action that uses the
preprocessor function (for pattern "#").

This patch is compatible with flex-old and newer flex and does not
produce nested functions declaration.

This bug is tagged minor since gcc accepts to compile nested function
declaration.

Cheers

PS: In case you're wondering why I bothered to read generated code: I
noticed this problem because I tried to port debian's version of rats
on HP-UX.  And HP-UX aCC compiler does not like nested function
declaration.


--- rats-2.1.orig/c-lex.l       2005-05-10 14:42:20.000000000 +0200
+++ rats-2.1/c-lex.l    2005-05-10 14:58:51.000000000 +0200
@@ -31,7 +31,6 @@
 
 static int  identifier(void);
 static int  string_const(void);
-int  preprocessor(void);
 static void reset_comment(void);
 static int  cstyle_comment(void);
 static void no_match(void);
@@ -62,10 +61,10 @@
 %}
 
 %%
-%{
-int preprocessor(void)
-{
+
+"#" { 
     signed char    c;
+    count(); 
 
     while ((c = input()) && c != -1)
     {
@@ -106,9 +105,7 @@
 
     return TOKEN_JUNK;
 }
-%}
 
-"#"                     { count(); return preprocessor(); }
 "/*"                    { count(); return cstyle_comment(); }
 "//".*                  { count(); reset_comment();  
                           accumulate_comment(yytext+2,strlen(yytext+2)); 



-- System Information:
Debian Release: 3.1
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing')
Architecture: i386 (i686)
Kernel: Linux 2.4.27-2-686-smp
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages rats depends on:
ii  libc6                       2.3.2.ds1-21 GNU C Library: Shared libraries an
ii  libexpat1                   1.95.8-3     XML parsing C library - runtime li

-- no debconf information


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to