Lines 405-411
cal_parse(FILE *in, FILE *out)
Link Here
|
405 |
{ |
405 |
{ |
406 |
char *mylocale = NULL; |
406 |
char *mylocale = NULL; |
407 |
char *line = NULL; |
407 |
char *line = NULL; |
408 |
char *buf; |
408 |
char *buf, *bufp; |
409 |
size_t linecap = 0; |
409 |
size_t linecap = 0; |
410 |
ssize_t linelen; |
410 |
ssize_t linelen; |
411 |
ssize_t l; |
411 |
ssize_t l; |
Lines 443-463
cal_parse(FILE *in, FILE *out)
Link Here
|
443 |
} |
443 |
} |
444 |
} |
444 |
} |
445 |
if (!incomment) { |
445 |
if (!incomment) { |
|
|
446 |
bufp = buf; |
446 |
do { |
447 |
do { |
447 |
c = strstr(buf, "//"); |
448 |
c = strstr(bufp, "//"); |
448 |
cc = strstr(buf, "/*"); |
449 |
cc = strstr(bufp, "/*"); |
449 |
if (c != NULL && (cc == NULL || c - cc < 0)) { |
450 |
if (c != NULL && (cc == NULL || c - cc < 0)) { |
450 |
/* single line comment */ |
451 |
bufp = c + 2; |
451 |
*c = '\0'; |
452 |
/* ignore "//" within string to allow it in an URL */ |
452 |
linelen = c - buf; |
453 |
if (c == buf || isspace(c[-1])) { |
453 |
break; |
454 |
/* single line comment */ |
|
|
455 |
*c = '\0'; |
456 |
linelen = c - buf; |
457 |
break; |
458 |
} |
454 |
} else if (cc != NULL) { |
459 |
} else if (cc != NULL) { |
455 |
c = strstr(cc + 2, "*/"); |
460 |
c = strstr(cc + 2, "*/"); |
456 |
if (c != NULL) { |
461 |
if (c != NULL) { // 'a /* b */ c' -- cc=2, c=7+2 |
457 |
/* multi-line comment ending on same line */ |
462 |
/* multi-line comment ending on same line */ |
458 |
c += 2; |
463 |
c += 2; |
459 |
memmove(cc, c, buf + linelen + 1 - c); |
464 |
memmove(cc, c, buf + linelen + 1 - c); |
460 |
linelen -= c - cc; |
465 |
linelen -= c - cc; |
|
|
466 |
bufp = cc; |
461 |
} else { |
467 |
} else { |
462 |
/* multi-line comment */ |
468 |
/* multi-line comment */ |
463 |
*cc = '\0'; |
469 |
*cc = '\0'; |