I suspect someone's already put this change in since it's pretty 
straightforward, but just in case...

PilRC current processes // type comments only in certain states. With a 
simple change, it can be made to properly process (i.e. ignore) // 
comments anywhere.

To fix this in FGetTok (pilrc.c), change:

    if (ptok->lex.lt == ltCComment)
      fInComment = fTrue;
    else if (ptok->lex.lt != ltEndCComment)
      break;
    else
      fInComment = fFalse;

to:

    if (ptok->lex.lt == ltCComment)
      fInComment = fTrue;
    else if (ptok->lex.lt == ltEndCComment)
      fInComment = fFalse;
    else if (ptok->lex.lt == ltDoubleSlash)
      NextLine();
    else
      break;

Notes:

1. To test this change, I took a fairly complex PilRC script and made 
used search replace to make every line end with a // comment. The result 
was perfect.

2. I've made all the conditions positive instead of negative. It reads 
easier, at least IMHO. It also implies that switch/case might be more 
appropriate. I've left it as a series of if statements since that is 
what it was originally.

3. This change will cause FGetTok to *never* return when lex.lt == 
ltDoubleSlash. There are a couple places in the code that check for this 
condition (and the response is always to call NextLine()). These can be 
removed.

4. I don't know how to make a patch, so I hope this is adequate. :)

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to