diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2008-11-23 23:12:47 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2008-11-23 23:12:47 +0000 |
commit | c2801a5823080e3d673e3b728cef8ba4b05d212d (patch) | |
tree | 85525c9cd2405abb6dcb1809bcaf8ea6eae41ac0 /libmdocml.c | |
parent | f095187c59066df4a733b3186d41bc6f83ad3069 (diff) | |
download | mandoc-c2801a5823080e3d673e3b728cef8ba4b05d212d.tar.gz |
Fixed clarity in libmdocml.c.
Fixed debugging messages.
Diffstat (limited to 'libmdocml.c')
-rw-r--r-- | libmdocml.c | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/libmdocml.c b/libmdocml.c index a38678d0..bb83e43a 100644 --- a/libmdocml.c +++ b/libmdocml.c @@ -27,12 +27,13 @@ #include "libmdocml.h" #include "private.h" -#define BUFFER_LINE BUFSIZ +#define BUFFER_LINE BUFSIZ /* Default line-buffer size. */ static int md_run_enter(const struct md_args *, struct md_mbuf *, struct md_rbuf *, void *); static int md_run_leave(const struct md_args *, struct md_mbuf *, struct md_rbuf *, int, void *); + static ssize_t md_buf_fill(struct md_rbuf *); static int md_buf_flush(struct md_mbuf *); @@ -170,46 +171,42 @@ md_run_enter(const struct md_args *args, struct md_mbuf *mbuf, case (MD_HTML4_STRICT): fp = md_line_html4_strict; break; - case (MD_DUMMY): + default: fp = md_line_dummy; break; - default: - abort(); } - /* LINTED */ - for (pos = 0; ; ) { - if (-1 == (sz = md_buf_fill(rbuf))) - return(md_run_leave(args, mbuf, rbuf, -1, p)); - else if (0 == sz) - break; - - for (i = 0; i < sz; i++) { - if ('\n' == rbuf->buf[i]) { - if ( ! (*fp)(args, mbuf, rbuf, line, pos, p)) - return(md_run_leave(args, mbuf, rbuf, - -1, p)); - rbuf->line++; - pos = 0; - continue; - } + pos = 0; +again: + if (-1 == (sz = md_buf_fill(rbuf))) { + return(md_run_leave(args, mbuf, rbuf, -1, p)); + } else if (0 == sz && 0 != pos) { + warnx("%s: no newline at end of file", rbuf->name); + return(md_run_leave(args, mbuf, rbuf, -1, p)); + } else if (0 == sz) + return(md_run_leave(args, mbuf, rbuf, 0, p)); + + for (i = 0; i < sz; i++) { + if ('\n' != rbuf->buf[i]) { if (pos < BUFFER_LINE) { /* LINTED */ line[pos++] = rbuf->buf[i]; continue; } - warnx("%s: line %zu too long", rbuf->name, rbuf->line); return(md_run_leave(args, mbuf, rbuf, -1, p)); } - } - if (0 != pos && ! (*fp)(args, mbuf, rbuf, line, pos, p)) - return(md_run_leave(args, mbuf, rbuf, -1, p)); + if ( ! (*fp)(args, mbuf, rbuf, line, pos, p)) + return(md_run_leave(args, mbuf, rbuf, -1, p)); + rbuf->line++; + pos = 0; + } - return(md_run_leave(args, mbuf, rbuf, 0, p)); + goto again; + /* NOTREACHED */ } |