Browse Source

Ignore end-of-line comments in quoted strings.

pre-master-46
Giles Atkinson 2 years ago
parent
commit
4228ba6e8a
  1. 20
      src/frontend/inpcom.c

20
src/frontend/inpcom.c

@ -3184,8 +3184,6 @@ static void inp_stripcomments_deck(struct card *c, bool cf)
If there is only white space before the end-of-line comment the If there is only white space before the end-of-line comment the
the whole line is converted to a normal comment line (i.e. one that the whole line is converted to a normal comment line (i.e. one that
begins with a '*'). begins with a '*').
BUG: comment characters in side of string literals are not ignored
('$' outside of .control section is o.k. however).
If the comaptibility mode is PS, LTPS or LTPSA, '$' is treated as a valid If the comaptibility mode is PS, LTPS or LTPSA, '$' is treated as a valid
character, not as end-of-line comment delimiter, except for that it is character, not as end-of-line comment delimiter, except for that it is
@ -3202,6 +3200,24 @@ static void inp_stripcomments_line(char *s, bool cs)
/* look for comments */ /* look for comments */
while ((c = *d) != '\0') { while ((c = *d) != '\0') {
d++; d++;
/* Skip over single or double-quoted strings. */
if (c == '"') {
while ((c = *d) && (c != '"' || d[-1] == '\\'))
++d;
if (c)
++d;
continue;
}
if (c == '\'') {
while ((c = *d) && (c != '\'' || d[-1] == '\\'))
++d;
if (c)
++d;
continue;
}
if (*d == ';') { if (*d == ';') {
break; break;
} }

Loading…
Cancel
Save