-/* $Id: libmdocml.c,v 1.10 2008/11/25 12:51:17 kristaps Exp $ */
+/* $Id: libmdocml.c,v 1.18 2008/12/03 14:39:59 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
}
-static int
-md_buf_flush(struct md_mbuf *buf)
+static int md_buf_flush(struct md_mbuf *buf)
{
ssize_t sz;
int
md_buf_putchar(struct md_mbuf *buf, char c)
{
+
+ assert(buf);
return(md_buf_puts(buf, &c, 1));
}
int
md_buf_putstring(struct md_mbuf *buf, const char *p)
{
+
+ assert(buf);
return(md_buf_puts(buf, p, strlen(p)));
}
/* Run exiters. */
switch (args->type) {
- case (MD_HTML4_STRICT):
- if ( ! md_exit_html4_strict(data, -1 == c ? 0 : 1))
+ case (MD_HTML):
+ if ( ! md_exit_html(data, -1 == c ? 0 : 1))
c = -1;
break;
default:
- if ( ! md_exit_dummy(data, -1 == c ? 0 : 1))
+ if ( ! md_exit_xml(data, -1 == c ? 0 : 1))
c = -1;
break;
}
/* Make final flush of buffer. */
- if ( ! md_buf_flush(mbuf))
+ if (-1 != c && ! md_buf_flush(mbuf))
return(-1);
return(c);
/* Function ptrs to line-parsers. */
switch (args->type) {
- case (MD_HTML4_STRICT):
- fp = md_line_html4_strict;
+ case (MD_HTML):
+ fp = md_line_html;
break;
default:
- fp = md_line_dummy;
+ fp = md_line_xml;
break;
}
return(md_run_leave(args, mbuf, rbuf, 0, p));
for (i = 0; i < sz; i++) {
+ /*
if ( ! isascii(rbuf->buf[i])) {
warnx("%s: non-ascii char (line %zu, col %zu)",
rbuf->name, rbuf->line, pos);
return(md_run_leave(args, mbuf, rbuf, -1, p));
}
+ */
if ('\n' != rbuf->buf[i]) {
if (pos < BUFFER_LINE) {
/* LINTED */
return(md_run_leave(args, mbuf, rbuf, -1, p));
}
- line[pos] = 0;
- if ( ! (*fp)(p, line, pos))
+ line[(int)pos] = 0;
+ if ( ! (*fp)(p, line))
return(md_run_leave(args, mbuf, rbuf, -1, p));
rbuf->line++;
pos = 0;
/* Run initialisers. */
switch (args->type) {
- case (MD_HTML4_STRICT):
- data = md_init_html4_strict
- (args, &mbuf, &rbuf);
+ case (MD_HTML):
+ data = md_init_html(args, &mbuf, &rbuf);
break;
default:
- data = md_init_dummy
- (args, &mbuf, &rbuf);
+ data = md_init_xml(args, &mbuf, &rbuf);
break;
}