version 1.25, 2019/04/14 14:59:37 |
version 1.26, 2019/04/14 16:26:34 |
Line 211 parse_file(int fd, char *fname) |
|
Line 211 parse_file(int fd, char *fname) |
|
size_t rlen; /* Number of bytes in b[]. */ |
size_t rlen; /* Number of bytes in b[]. */ |
size_t poff; /* Parse offset in b[]. */ |
size_t poff; /* Parse offset in b[]. */ |
size_t pend; /* Offset of the end of the current word. */ |
size_t pend; /* Offset of the end of the current word. */ |
int in_tag, in_arg, in_quotes, elem_end; |
int in_tag, in_arg, in_quotes, in_doctype, elem_end; |
|
|
rlen = 0; |
rlen = 0; |
in_tag = in_arg = in_quotes = 0; |
in_tag = in_arg = in_quotes = in_doctype = 0; |
while ((rsz = read(fd, b + rlen, sizeof(b) - rlen - 1)) >= 0) { |
while ((rsz = read(fd, b + rlen, sizeof(b) - rlen - 1)) >= 0) { |
if ((rlen += rsz) == 0) |
if ((rlen += rsz) == 0) |
break; |
break; |
Line 251 parse_file(int fd, char *fname) |
|
Line 251 parse_file(int fd, char *fname) |
|
if (elem_end) |
if (elem_end) |
stack_pop(NULL); |
stack_pop(NULL); |
} else if (in_tag) { |
} else if (in_tag) { |
|
if (in_doctype && b[pend] == '[') { |
|
in_tag = in_doctype = 0; |
|
pend++; |
|
continue; |
|
} |
if (advance(b, rlen, &pend, " =>") && rsz > 0) |
if (advance(b, rlen, &pend, " =>") && rsz > 0) |
break; |
break; |
elem_end = 0; |
elem_end = 0; |
Line 301 parse_file(int fd, char *fname) |
|
Line 306 parse_file(int fd, char *fname) |
|
if (b[++poff] == '/') { |
if (b[++poff] == '/') { |
elem_end = 1; |
elem_end = 1; |
poff++; |
poff++; |
|
} else if (strcasecmp(b + poff, |
|
"!DOCTYPE") == 0) { |
|
in_doctype = 1; |
} else if (b[poff] != '!' && b[poff] != '?') { |
} else if (b[poff] != '!' && b[poff] != '?') { |
table_add(stacki > 0 ? |
table_add(stacki > 0 ? |
stack[stacki - 1] : "ROOT", |
stack[stacki - 1] : "ROOT", |