version 1.66, 2010/05/15 05:11:50 |
version 1.67, 2010/05/15 05:50:19 |
Line 376 fdesc(struct curparse *curp) |
|
Line 376 fdesc(struct curparse *curp) |
|
/* Fill buf with file blocksize. */ |
/* Fill buf with file blocksize. */ |
|
|
for (i = lnn = pos = comment = 0; i < (int)blk.sz; ++i) { |
for (i = lnn = pos = comment = 0; i < (int)blk.sz; ++i) { |
if (pos >= (int)ln.sz) { |
if (pos >= (int)ln.sz) { |
ln.sz += 256; /* Step-size. */ |
ln.sz += 256; /* Step-size. */ |
ln.buf = realloc(ln.buf, ln.sz); |
ln.buf = realloc(ln.buf, ln.sz); |
if (NULL == ln.buf) { |
if (NULL == ln.buf) { |
perror(NULL); |
perror(NULL); |
goto bailout; |
goto bailout; |
} |
|
} |
} |
|
} |
|
|
if ('\n' != blk.buf[i]) { |
if ('\n' != blk.buf[i]) { |
if (comment) |
if (comment) |
continue; |
continue; |
ln.buf[pos++] = blk.buf[i]; |
ln.buf[pos++] = blk.buf[i]; |
|
|
/* Handle in-line `\"' comments. */ |
/* Handle in-line `\"' comments. */ |
|
|
if (1 == pos || '\"' != ln.buf[pos - 1]) |
if (1 == pos || '\"' != ln.buf[pos - 1]) |
continue; |
continue; |
|
|
for (j = pos - 2; j >= 0; j--) |
for (j = pos - 2; j >= 0; j--) |
if ('\\' != ln.buf[j]) |
if ('\\' != ln.buf[j]) |
break; |
break; |
|
|
if ( ! ((pos - 2 - j) % 2)) |
if ( ! ((pos - 2 - j) % 2)) |
continue; |
|
|
|
comment = 1; |
|
pos -= 2; |
|
for (; pos > 0; --pos) { |
|
if (ln.buf[pos - 1] != ' ') |
|
break; |
|
if (pos > 2 && ln.buf[pos - 2] == '\\') |
|
break; |
|
} |
|
continue; |
continue; |
} |
|
|
|
/* Handle escaped `\\n' newlines. */ |
comment = 1; |
|
pos -= 2; |
|
for (; pos > 0; --pos) { |
|
if (ln.buf[pos - 1] != ' ') |
|
break; |
|
if (pos > 2 && ln.buf[pos - 2] == '\\') |
|
break; |
|
} |
|
continue; |
|
} |
|
|
if (pos > 0 && 0 == comment && |
/* Handle escaped `\\n' newlines. */ |
'\\' == ln.buf[pos - 1]) { |
|
for (j = pos - 1; j >= 0; j--) |
if (pos > 0 && 0 == comment && '\\' == ln.buf[pos - 1]) { |
if ('\\' != ln.buf[j]) |
for (j = pos - 1; j >= 0; j--) |
break; |
if ('\\' != ln.buf[j]) |
if ( ! ((pos - j) % 2)) { |
break; |
pos--; |
if ( ! ((pos - j) % 2)) { |
lnn++; |
pos--; |
continue; |
lnn++; |
} |
continue; |
} |
} |
|
} |
|
|
ln.buf[pos] = 0; |
ln.buf[pos] = 0; |
lnn++; |
lnn++; |
|
|
/* If unset, assign parser in pset(). */ |
/* If unset, assign parser in pset(). */ |
|
|
if ( ! (man || mdoc) && ! pset(ln.buf, |
if ( ! (man || mdoc) && ! pset(ln.buf, pos, curp, &man, &mdoc)) |
pos, curp, &man, &mdoc)) |
goto bailout; |
goto bailout; |
|
|
|
pos = comment = 0; |
pos = comment = 0; |
|
|
/* Pass down into parsers. */ |
/* Pass down into parsers. */ |
|
|
if (man && ! man_parseln(man, lnn, ln.buf)) |
if (man && ! man_parseln(man, lnn, ln.buf)) |
goto bailout; |
goto bailout; |
if (mdoc && ! mdoc_parseln(mdoc, lnn, ln.buf)) |
if (mdoc && ! mdoc_parseln(mdoc, lnn, ln.buf)) |
goto bailout; |
goto bailout; |
} |
} |
|
|
/* NOTE a parser may not have been assigned, yet. */ |
/* NOTE a parser may not have been assigned, yet. */ |