mirror of
https://github.com/fachat/xa65.git
synced 2024-06-26 08:29:29 +00:00
simplify // comment handling
This commit is contained in:
parent
7e20fd26d5
commit
c5d94b4981
48
xa/src/xap.c
48
xa/src/xap.c
|
@ -925,39 +925,6 @@ int pgetline(char *t)
|
||||||
errout(E_OPENPP);
|
errout(E_OPENPP);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* handle the double-slash comment (like in C++) */
|
|
||||||
/* get p past any quoted strings */
|
|
||||||
p = strchr(in_line, '/');
|
|
||||||
if (p != NULL) {
|
|
||||||
q = strchr(in_line, '"');
|
|
||||||
for(;;) {
|
|
||||||
/* no more quotes to skip, or slashes before quotes */
|
|
||||||
if (q == NULL || (p < q)) {
|
|
||||||
if (p[1] == '/') {
|
|
||||||
/* truncate line, done with loop */
|
|
||||||
*p = 0;
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
/* wasn't //, but could be later */
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/* quote before slash, so skip string */
|
|
||||||
q++;
|
|
||||||
while (*q != 0 && *q != '"') {
|
|
||||||
if (*q == '\\') q++;
|
|
||||||
if (*q != 0) q++;
|
|
||||||
}
|
|
||||||
if (*q == 0) break; /* oops */
|
|
||||||
q++;
|
|
||||||
p = q;
|
|
||||||
}
|
|
||||||
|
|
||||||
p = strchr(p, '/');
|
|
||||||
if (p == NULL) break; /* never mind */
|
|
||||||
if (q != NULL) q = strchr(q, '"');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!er || loopfl) {
|
if(!er || loopfl) {
|
||||||
in_line[0]='\0';
|
in_line[0]='\0';
|
||||||
|
@ -1046,12 +1013,21 @@ int rgetc(FILE *fp)
|
||||||
/* check for start of comment */
|
/* check for start of comment */
|
||||||
if(!inquote && c=='/')
|
if(!inquote && c=='/')
|
||||||
{
|
{
|
||||||
if((d=egetc(fp))!='*') {
|
d = egetc(fp);
|
||||||
ungetc(d,fp);
|
|
||||||
} else {
|
// C++ double slash comment
|
||||||
|
if (d == '/') {
|
||||||
|
do {
|
||||||
|
c = egetc(fp);
|
||||||
|
} while (c != '\n' && c != EOF);
|
||||||
|
} else
|
||||||
|
if (d == '*') {
|
||||||
|
/* start block comment */
|
||||||
incomment++;
|
incomment++;
|
||||||
/* convene normal processing */
|
/* convene normal processing */
|
||||||
goto restart;
|
goto restart;
|
||||||
|
} else {
|
||||||
|
ungetc(d,fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user