- if (!read_whole_file(curp, &blk, &with_mmap))
- return;
-
- /* Fill buf with file blocksize. */
-
- for (i = lnn = pos = comment = 0; i < (int)blk.sz; ++i) {
- if (pos >= (int)ln.sz) {
- if (! resize_buf(&ln, 256))
- goto bailout;
- }
-
- if ('\n' != blk.buf[i]) {
- if (comment)
- continue;
- ln.buf[pos++] = blk.buf[i];
-
- /* Handle in-line `\"' comments. */
-
- if (1 == pos || '\"' != ln.buf[pos - 1])
- continue;
-
- for (j = pos - 2; j >= 0; j--)
- if ('\\' != ln.buf[j])
- break;
-
- 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;
- }
-
- /* Handle escaped `\\n' newlines. */
-
- if (pos > 0 && 0 == comment && '\\' == ln.buf[pos - 1]) {
- for (j = pos - 1; j >= 0; j--)
- if ('\\' != ln.buf[j])
- break;
- if ( ! ((pos - j) % 2)) {
- pos--;
- lnn++;
- continue;
- }
- }
-
- ln.buf[pos] = 0;
- lnn++;
-
- /* If unset, assign parser in pset(). */
-
- if ( ! (man || mdoc) && ! pset(ln.buf, pos, curp, &man, &mdoc))
- goto bailout;
-
- pos = comment = 0;
-
- /* Pass down into parsers. */
-
- if (man && ! man_parseln(man, lnn, ln.buf))
- goto bailout;
- if (mdoc && ! mdoc_parseln(mdoc, lnn, ln.buf))
- goto bailout;
- }
-
- /* NOTE a parser may not have been assigned, yet. */
-
- if ( ! (man || mdoc)) {
- fprintf(stderr, "%s: Not a manual\n", curp->file);
- goto bailout;
- }
-
- if (mdoc && ! mdoc_endparse(mdoc))
- goto bailout;
- if (man && ! man_endparse(man))
- goto bailout;