Last line comment produces an error (without a newline at the end)

Issue #34 new
spqr created an issue

I noticed that if the last line of an analysed file includes a double-slash comment (e.g: "#endif // FOO") without a newline at the end, vera++ quits the entire analysis with a single error message, such as:

#!
error: test.h:11: illegal token in column 8, giving up (hint: fix the file or remove it from the working set)
    while executing
"getAllLines $f"
    ("foreach" body line 4)
    invoked from within
"foreach f [getSourceFileNames] {
    set lineNumber 1
    set previousIndent ""
    foreach line [getAllLines $f] {

        if [regexp {^.*[[:space:]..."
    (file "C:/vera++-1.2.1.win/lib/vera++/scripts/rules/L001.tcl" line 6)

A comment should be allowed in a case like this. The used vera++ version is 1.2.1 on a Windows Server 2008 platform.

Comments (17)

  1. ThArGos

    Sorry for the very late answer. We were quite busy the last months.

    Thank you for reporting the issue. I will have a look at this.

    It is totally a valid use case.

  2. Steven R

    I also encountered this bug in 1.2.1. The problem is in Tokens::parse() which affects multiple rules making it difficult to work around.

  3. ThArGos

    Hi,

    We are still brainstorming about this issue. We have a patch but we are not satisfied with it. This bug has pointed out a little design issue which we are working on at the moment.

    Besides it seems that a comment without a carriage return is not a valid c++ sequence.

    Thanks for your concern. We will provide more feedback once we have decided how to fix this correctly.

  4. Harald-René Flasch

    Still same behavior here. Last line:

    Produces error:

    #endif // __FILE_H
    

    OK:

    #endif /* __FILE_H */
    
  5. Gaëtan Lehmann

    Sorry for the long delay to reply and the lack of description of the expected behavior.

    The token is actually invalid, so an error must be produced. However the error is now non blocking and does not prevent to parse the tokens before it or the other files.

  6. Y J

    I have also encountered this issue, but I see there hasn't been an install uploaded since the fix. Are there any plans to upload a new install file any time soon ?

  7. Gaëtan Lehmann

    Yes, there are such plans, but I've said that once already and we didn't had time to make the release, so I prefer to not announce any date

  8. Emilio González Montaña

    Any progress on this?, or at least, any workaround without modifying analyzed source files? Thanks!

  9. Vincent Hobeïka

    Sorry, nothing new regarding this issue. As said earlier by Gaëtan this is an invalid token. Vera++ is able to provide an error and go on without crashing. So far we could only provide this.

    Best regards

  10. Log in to comment