#67 @@else doesn't work

open
nobody
None
5
2007-05-25
2007-05-25
No

It looks like processing of @@else is not fully implemented in aide 0.13.1. There are two logical cases for how @@else should be handled:

1. When handle_endif() is called with doit = 1; e.g., "@@undef FOO ... @@ifdef FOO", the conditional test has failed. In this case, we should skip input up to the @@else and continue processing. This is implemented.

2. When handle_endif() is called with doit = 0; e.g., "@define FOO bar ... @@ifdef FOO", the conditional test has passed. In this case, we should process everything up to @@else, then skip everything from @@else to @@endif. This is not implemented. What happens instead is that we process everything on both sides of the @@else (see also bug #1461215).

I'm unfamiliar enough with lex / yacc that I don't see immediately how to fix this. Point me in the right direction and I may be able to work on it, though.

A workaround for anyone maintaining aide.conf files:

Replace:

@@ifdef FOO
...
@@else
...
@@endif

with:

@@ifdef FOO
...
@@endif
@@ifndef FOO
...
@@endif

So, in fact, direct replacement of @@else with @@endif and the opposite conditional test might turn out to be a useful trick for the parser itself to do.

Discussion

  • Robby Griffin

    Robby Griffin - 2007-05-26

    Fix @@else in aide 0.13.1

     
  • Robby Griffin

    Robby Griffin - 2007-05-26

    Logged In: YES
    user_id=83996
    Originator: YES

    I'm attaching a first draft of a patch. Please review carefully. Here are some key points:

    1. Yacc parsing continues within the unsuccessful branch of a conditional, but most actions that would normally be performed (such as including a file when we encounter @@include) are skipped with "if (!eating)" tests.

    2. Conditionals are allowed to be nested; the yacc grammar will require that text between @@ifdef and @@else be valid configuration lines (or complete @@ifdef statements, or whatever) regardless of whether that branch of the conditional is used.

    3. Some cleanup of the lex / yacc files could probably make this and future changes much simpler.
    File Added: else.patch

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks