{
char *mylocale = NULL;
char *line = NULL;
- char *buf;
+ char *buf, *bufp;
size_t linecap = 0;
ssize_t linelen;
ssize_t l;
}
}
if (!incomment) {
+ bufp = buf;
do {
- c = strstr(buf, "//");
- cc = strstr(buf, "/*");
+ c = strstr(bufp, "//");
+ cc = strstr(bufp, "/*");
if (c != NULL && (cc == NULL || c - cc < 0)) {
- /* single line comment */
- *c = '\0';
- linelen = c - buf;
- break;
+ bufp = c + 2;
+ /* ignore "//" within string to allow it in an URL */
+ if (c == buf || isspace(c[-1])) {
+ /* single line comment */
+ *c = '\0';
+ linelen = c - buf;
+ break;
+ }
} else if (cc != NULL) {
c = strstr(cc + 2, "*/");
- if (c != NULL) {
+ if (c != NULL) { // 'a /* b */ c' -- cc=2, c=7+2
/* multi-line comment ending on same line */
c += 2;
memmove(cc, c, buf + linelen + 1 - c);
linelen -= c - cc;
+ bufp = cc;
} else {
/* multi-line comment */
*cc = '\0';
1/* comment */ 6 jan 6
1 7 jan 7 // /* comment */ comment
1 1/* comment */1 jan /* comment */11 // comment
-
+1 12 http://localhost.local/
+1 13 http://localhost.local/ // URL with additional comment