Archive: C-style comment problem


C-style comment problem
Not sure if this has been reported before.
I found that putting a complete C-style comment in a line skips everything preceding the comment in the line.
This doesn't seem to be intuitively correct.
See the attached script for an example.


Do you want to take a shot at it?


I can try.
IMHO what should be done is that any tokens after the comment should be added to tokens before the comment.
e.g.,


MessageBox MB_OK /* comment */ "Hello"


should effectively become


MessageBox MB_OK "Hello"


Let me see if I can put together a patch.

I have submitted a patch for this.
I have tested it on a few scripts and it seems to be working OK. Give it a whirl and see if it is acceptable.


What about C++'s //? :)


Not part of the NSIS spec, sorry. :D


Are you going to commit the first patch?


Sure, if you want me to.
I thought you might want to test it before I commit it.


Take a look at the bug tracker, I've replied there.


I have a question for you in the bug tracker- please take a look.


You should get an e-mail for each change to the item in the tracker. If you don't, hit the monitor button again and make sure the e-mail address you gave SourceForge is working.


I usually do get emails. Your first reply to the patch wasn't emailed to me. Since then all replies have been emailed to me.


I was also wondering if you could put in // to comment a line.
It gets a little annoying when you swap from a C\C++ IDE to nsis script and forget that nsis dosen't support //.


I suppose you could always create a feature request. But I don't think it will be a very high priority.


I was just playing around and I think I found a bug (unless I did someting stupid)

The compiler is executing the code inside my /**/ comment
It only seems to happen with include files


This is not related to this patch. The preprocessor comes before the comment handling, so !ifdef will always be handled. That's why your code is invalid. !ifdef doesn't have enough parameters.


yeah, i know its missing a parameter, but it seems wrong to me that a comment only comments out real commands, IMHO the comments must be parsed out first


Ignore my last comment. Multiple line comments should be treated inside ifdef'ed blocks, just like normal comments. I've fixed this and add a test case to make sure it doesn't come back.

Here's a stripped down version of the script showing the problem:

!ifdef some_define_that_doesnt_exist
/*
!ifdef
*/
!endif

Yeah, I always wondered why !ifdef processing worked the way it did.
I did run into the same problem as Anders but I assumed that preprocessor commands trumped comments.