Newline-escaped lines are concatenated.
Added -fign-macro option.
.SUFFIXES: .html .sgml
-VERSION = 1.4.2
-VDATE = 8 March 2009
+VERSION = 1.4.4
+VDATE = 9 March 2009
BINDIR = $(PREFIX)/bin
INCLUDEDIR = $(PREFIX)/include
-/* $Id: mdoc.c,v 1.57 2009/03/08 20:57:35 kristaps Exp $ */
+/* $Id: mdoc.c,v 1.58 2009/03/09 13:04:01 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
static int parsetext(struct mdoc *, int, char *);
static int parsemacro(struct mdoc *, int, char *);
+static int macrowarn(struct mdoc *, int, const char *);
const char *const __mdoc_macronames[MDOC_MAX] = {
}
+static int
+macrowarn(struct mdoc *m, int ln, const char *buf)
+{
+ if ( ! (MDOC_IGN_MACRO & m->pflags))
+ return(mdoc_perr(m, ln, 1, "unknown macro: %s%s",
+ buf, buf[3] ? "..." : ""));
+ return(mdoc_pwarn(m, ln, 1, WARN_SYNTAX,
+ "unknown macro: %s%s",
+ buf, buf[3] ? "..." : ""));
+}
+
+
+
/*
* Parse a macro line, that is, a line beginning with the control
* character.
mac[i - 1] = 0;
if (i == 5 || i <= 2) {
- (void)mdoc_perr(m, ln, 1, "unknown macro: %s%s",
- mac, i == 5 ? "..." : "");
- goto err;
+ if ( ! macrowarn(m, ln, mac))
+ goto err;
+ return(1);
}
if (MDOC_MAX == (c = mdoc_tokhash_find(m->htab, mac))) {
- (void)mdoc_perr(m, ln, 1, "unknown macro: %s", mac);
- goto err;
+ if ( ! macrowarn(m, ln, mac))
+ goto err;
+ return(1);
}
/* The macro is sane. Jump to the next word. */
-/* $Id: mdoc.h,v 1.42 2009/03/08 20:57:35 kristaps Exp $ */
+/* $Id: mdoc.h,v 1.43 2009/03/09 13:04:01 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
#define MDOC_IGN_SCOPE (1 << 0) /* Ignore scope violations. */
#define MDOC_IGN_ESCAPE (1 << 1) /* Ignore bad escape sequences. */
+#define MDOC_IGN_MACRO (1 << 2) /* Ignore unknown macros. */
/* Call-backs for parse messages. */
struct mdoc_cb {
-.\" $Id: mdoclint.1,v 1.2 2009/03/08 18:02:36 kristaps Exp $
+.\" $Id: mdoclint.1,v 1.3 2009/03/09 13:04:01 kristaps Exp $
.\"
.\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
.\"
.\" TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
.\" PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: March 8 2009 $
+.Dd $Mdocdate: March 9 2009 $
.Dt mdoclint 1
.Os
.\" SECTION
scope violations. This can seriously mangle the resulting tree.
.It Fl f Ns Ar ign-escape
Ignore invalid escape sequences.
+.It Fl f Ns Ar ign-macro
+Ignore unknown macros at the start of input lines.
.El
.\" PARAGRAPH
.Pp
options may be grouped and delimited with a comma. Using
.Fl f Ns Ar ign-scope,ign-escape ,
for example, will try to ignore scope and character-escape errors.
+.\" SUB-SECTION
+.Ss Input Encoding
+The
+.Nm
+utility expects its input to be 7-bit ASCII as defined in
+.Xr ascii 7 .
+The only non-graphing characters accepted are spaces,
+.Sq \ ,
+and tabs,
+.Sq \et .
+Tabs are only accepted in literal block-displays and as column
+delimiters.
+.Pp
+Only Unix-style newlines (\en) are accepted; if the newline is escaped,
+the line is concatenated with the next.
.\" SECTION
.Sh EXAMPLES
To validate this manual page:
-.\" $Id: mdocterm.1,v 1.15 2009/03/08 18:02:36 kristaps Exp $
+.\" $Id: mdocterm.1,v 1.16 2009/03/09 13:04:01 kristaps Exp $
.\"
.\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
.\"
.\" TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
.\" PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: March 8 2009 $
+.Dd $Mdocdate: March 9 2009 $
.Dt mdocterm 1
.Os
.\" SECTION
scope violations. This can seriously mangle the resulting tree.
.It Fl f Ns Ar ign-escape
Ignore invalid escape sequences.
+.It Fl f Ns Ar ign-macro
+Ignore unknown macros at the start of input lines.
.El
.\" PARAGRAPH
.Pp
.Fl f Ns Ar ign-scope,ign-escape ,
for example, will try to ignore scope and character-escape errors.
.\" SUB-SECTION
+.Ss Input Encoding
+The
+.Nm
+utility expects its input to be 7-bit ASCII as defined in
+.Xr ascii 7 .
+The only non-graphing characters accepted are spaces,
+.Sq \ ,
+and tabs,
+.Sq \et .
+Tabs are only accepted in literal block-displays and as column
+delimiters.
+.Pp
+Only Unix-style newlines (\en) are accepted; if the newline is escaped,
+the line is concatenated with the next.
+.\" SUB-SECTION
.Ss Character Escapes
This section documents the character-escapes accepted by
.Xr mdocterm 1 .
-.\" $Id: mdoctree.1,v 1.5 2009/03/08 18:02:36 kristaps Exp $
+.\" $Id: mdoctree.1,v 1.6 2009/03/09 13:04:01 kristaps Exp $
.\"
.\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
.\"
.\" TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
.\" PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: March 8 2009 $
+.Dd $Mdocdate: March 9 2009 $
.Dt mdoctree 1
.Os
.\" SECTION
scope violations. This can seriously mangle the resulting tree.
.It Fl f Ns Ar ign-escape
Ignore invalid escape sequences.
+.It Fl f Ns Ar ign-macro
+Ignore unknown macros at the start of input lines.
.El
.\" PARAGRAPH
.Pp
options may be grouped and delimited with a comma. Using
.Fl f Ns Ar ign-scope,ign-escape ,
for example, will try to ignore scope and character-escape errors.
+.\" SUB-SECTION
+.Ss Input Encoding
+The
+.Nm
+utility expects its input to be 7-bit ASCII as defined in
+.Xr ascii 7 .
+The only non-graphing characters accepted are spaces,
+.Sq \ ,
+and tabs,
+.Sq \et .
+Tabs are only accepted in literal block-displays and as column
+delimiters.
+.Pp
+Only Unix-style newlines (\en) are accepted; if the newline is escaped,
+the line is concatenated with the next.
+.\" SUB-SECTION
+.Ss Character Escapes
+Since
+.Nm
+doesn't format its output, character escapes are displayed as passed
+into the compiler.
.\" SECTION
.Sh EXAMPLES
To validate this manual page:
- /* $Id: mmain.c,v 1.9 2009/03/08 19:32:03 kristaps Exp $ */
+ /* $Id: mmain.c,v 1.10 2009/03/09 13:04:01 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
optsopt(struct mmain *p, char *arg)
{
char *v;
- char *toks[] = { "ign-scope", "ign-escape", NULL };
+ char *toks[] = { "ign-scope", "ign-escape",
+ "ign-macro", NULL };
while (*arg)
switch (getsubopt(&arg, toks, &v)) {
case (1):
p->pflags |= MDOC_IGN_ESCAPE;
break;
+ case (2):
+ p->pflags |= MDOC_IGN_MACRO;
+ break;
default:
- /* FIXME: report? */
+ warnx("unknown -f argument");
return(0);
}
p->warn |= MD_WARN_ERR;
break;
default:
- /* FIXME: report? */
+ warnx("unknown -W argument");
return(0);
}
parse(struct mmain *p)
{
ssize_t sz;
- int i, pos, len, lnn;
- char *line;
+ int j, i, pos, len, lnn;
+ char *ln;
- for (line = NULL, lnn = 1, len = pos = 0; ; ) {
+ for (ln = NULL, lnn = 1, len = pos = 0; ; ) {
if (-1 == (sz = read(p->fdin, p->buf, p->bufsz))) {
warn("%s", p->in);
return(0);
for (i = 0; i < (int)sz; i++) {
if (pos >= len) {
len += MD_LINE_SZ;
- line = realloc(line, (size_t)len);
- if (NULL == line)
+ ln = realloc(ln, (size_t)len);
+ if (NULL == ln)
err(1, "realloc");
}
if ('\n' != p->buf[i]) {
- line[pos++] = p->buf[i];
+ ln[pos++] = p->buf[i];
continue;
}
- line[pos] = 0;
- if ( ! mdoc_parseln(p->mdoc, lnn, line))
- return(0);
+ /* Check for escaped newline. */
+
+ if (pos > 0 && '\\' == ln[pos - 1]) {
+ for (j = pos - 1; j >= 0; j--)
+ if ('\\' != ln[j])
+ break;
+ if ( ! ((pos - j) % 2)) {
+ pos--;
+ lnn++;
+ continue;
+ }
+ }
+
+ ln[pos] = 0;
+ if ( ! mdoc_parseln(p->mdoc, lnn, ln))
+ return(0);
lnn++;
pos = 0;
}
}
- if (line)
- free(line);
+ if (pos > 0)
+ warnx("%s: file not eof-terminated", p->in);
+
+ if (ln)
+ free(ln);
return(mdoc_endparse(p->mdoc));
}