Fixed .Ex/.Rv -std usage.
Made Ar provide default value.
regress/test.escape.11 \
regress/test.escape.12 \
regress/test.escape.14 \
- regress/test.argv.01
+ regress/test.argv.01 \
+ regress/test.argv.02
SUCCEED = regress/test.prologue.05 \
regress/test.prologue.07 \
install -m 0444 mdocml-nport-$(VERSION).tar.gz $(PREFIX)/ports-netbsd/
install -m 0444 mdocml-nport-$(VERSION).tar.gz $(PREFIX)/ports-netbsd/mdocml.tar.gz
-regress: mdoclint
+regress: mdoclint $(FAIL) $(SUCCEED)
@for f in $(FAIL); do \
echo "./mdoclint $$f" ; \
./mdoclint $$f 2>/dev/null || continue ; exit 1 ; done
-/* $Id: action.c,v 1.29 2009/03/05 12:08:53 kristaps Exp $ */
+/* $Id: action.c,v 1.30 2009/03/05 13:12:12 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
/* Per-macro action routines. */
+static int post_ar(struct mdoc *);
static int post_bl(struct mdoc *);
static int post_bl_width(struct mdoc *);
static int post_bl_tagwidth(struct mdoc *);
static int post_dd(struct mdoc *);
static int post_dt(struct mdoc *);
-static int post_ex(struct mdoc *);
static int post_nm(struct mdoc *);
static int post_os(struct mdoc *);
static int post_sh(struct mdoc *);
+static int post_ex(struct mdoc *);
static int post_prologue(struct mdoc *);
{ NULL }, /* It */
{ NULL }, /* Ad */
{ NULL }, /* An */
- { NULL }, /* Ar */
+ { post_ar }, /* Ar */
{ NULL }, /* Cd */
{ NULL }, /* Cm */
{ NULL }, /* Dv */
if (0 == mdoc->last->data.elem.argc)
return(1);
-
- assert(1 == mdoc->last->data.elem.argc);
- if (1 == mdoc->last->data.elem.argv[0].sz)
+ if (mdoc->last->data.elem.argv[0].sz)
return(1);
- assert(0 == mdoc->last->data.elem.argv[0].sz);
- if (NULL == mdoc->meta.name)
- return(mdoc_err(mdoc, "default name not yet set"));
+ assert(mdoc->meta.name);
mdoc_msg(mdoc, "writing %s argument: %s",
mdoc_argnames[MDOC_Std], mdoc->meta.name);
}
+static int
+post_ar(struct mdoc *mdoc)
+{
+ struct mdoc_node *n;
+
+ if (mdoc->last->child)
+ return(1);
+
+ n = mdoc->last;
+
+ mdoc->next = MDOC_NEXT_CHILD;
+ mdoc_word_alloc(mdoc, mdoc->last->line,
+ mdoc->last->pos, "file");
+ mdoc->next = MDOC_NEXT_SIBLING;
+ mdoc_word_alloc(mdoc, mdoc->last->line,
+ mdoc->last->pos, "...");
+
+ mdoc->last = n;
+ mdoc->next = MDOC_NEXT_SIBLING;
+ return(1);
+}
+
+
static int
post_dd(struct mdoc *mdoc)
{
-/* $Id: argv.c,v 1.36 2009/03/05 12:08:53 kristaps Exp $ */
+/* $Id: argv.c,v 1.37 2009/03/05 13:12:12 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
static int argv_a2arg(int, const char *);
static int args(struct mdoc *, int, int *,
char *, int, char **);
-static int argv(struct mdoc *, int,
+static int argv(struct mdoc *, int, int,
struct mdoc_arg *, int *, char *);
static int argv_single(struct mdoc *, int,
struct mdoc_arg *, int *, char *);
ARGV_MULTI, /* MDOC_Column */
ARGV_SINGLE, /* MDOC_Width */
ARGV_NONE, /* MDOC_Compact */
- ARGV_OPT_SINGLE, /* MDOC_Std */
+ ARGV_SINGLE, /* MDOC_Std */
ARGV_NONE, /* MDOC_p1003_1_88 */
ARGV_NONE, /* MDOC_p1003_1_90 */
ARGV_NONE, /* MDOC_p1003_1_96 */
break;
i++;
/* There must be at least one space... */
- if (0 == buf[i] || ! isspace((int)buf[i]))
+ if (0 == buf[i] || ! isspace((u_char)buf[i]))
break;
i++;
- while (buf[i] && isspace((int)buf[i]))
+ while (buf[i] && isspace((u_char)buf[i]))
i++;
}
if (0 == buf[i]) {
if ( ! (ARGS_TABSEP & fl))
while (buf[*pos]) {
- if (isspace((int)buf[*pos]))
+ if (isspace((u_char)buf[*pos]))
if ('\\' != buf[*pos - 1])
break;
(*pos)++;
return(ARGS_WORD);
if ( ! (ARGS_TABSEP & fl))
- while (buf[*pos] && isspace((int)buf[*pos]))
+ while (buf[*pos] && isspace((u_char)buf[*pos]))
(*pos)++;
if (buf[*pos])
if (0 == buf[*pos])
return(ARGS_QWORD);
- while (buf[*pos] && isspace((int)buf[*pos]))
+ while (buf[*pos] && isspace((u_char)buf[*pos]))
(*pos)++;
if (buf[*pos])
* multiple parameters.
*/
static int
-argv(struct mdoc *mdoc, int line,
+argv(struct mdoc *mdoc, int tok, int line,
struct mdoc_arg *v, int *pos, char *buf)
{
+ int fl;
v->sz = 0;
v->value = NULL;
+ fl = mdoc_argvflags[v->arg];
- switch (mdoc_argvflags[v->arg]) {
+ /*
+ * Override the default per-argument value.
+ */
+
+ switch (tok) {
+ case (MDOC_Ex):
+ fl = ARGV_OPT_SINGLE;
+ break;
+ default:
+ break;
+ }
+
+ switch (fl) {
case (ARGV_SINGLE):
return(argv_single(mdoc, line, v, pos, buf));
case (ARGV_MULTI):
if (0 == buf[*pos])
return(ARGV_EOLN);
- assert( ! isspace((int)buf[*pos]));
+ assert( ! isspace((u_char)buf[*pos]));
if ('-' != buf[*pos])
return(ARGV_WORD);
/* LINTED */
while (buf[*pos]) {
- if (isspace((int)buf[*pos]))
+ if (isspace((u_char)buf[*pos]))
if ('\\' != buf[*pos - 1])
break;
(*pos)++;
return(ARGV_WORD);
}
- while (buf[*pos] && isspace((int)buf[*pos]))
+ while (buf[*pos] && isspace((u_char)buf[*pos]))
(*pos)++;
/* FIXME: whitespace if no value. */
- if ( ! argv(mdoc, line, v, pos, buf))
+ if ( ! argv(mdoc, tok, line, v, pos, buf))
return(ARGV_ERROR);
return(ARGV_ARG);
-/* $Id: mdoc.c,v 1.50 2009/03/02 17:14:46 kristaps Exp $ */
+/* $Id: mdoc.c,v 1.51 2009/03/05 13:12:12 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
return(1);
i = 1;
- while (buf[i] && ! isspace((int)buf[i]) && i < (int)sizeof(tmp))
+ while (buf[i] && ! isspace((u_char)buf[i]) &&
+ i < (int)sizeof(tmp))
i++;
if (i == (int)sizeof(tmp)) {
return(mdoc_perr(mdoc, line, 1, "unknown macro"));
}
- while (buf[i] && isspace((int)buf[i]))
+ while (buf[i] && isspace((u_char)buf[i]))
i++;
if ( ! mdoc_macro(mdoc, c, line, 1, &i, buf)) {
-/* $Id: mdocterm.c,v 1.32 2009/03/04 14:41:40 kristaps Exp $ */
+/* $Id: mdocterm.c,v 1.33 2009/03/05 13:12:12 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
/* LINTED */
for (j = i, vsz = 0; j < p->col; j++) {
- if (isspace((int)p->buf[j]))
+ if (isspace((u_char)p->buf[j]))
break;
else if (27 == p->buf[j]) {
assert(j + 4 <= p->col);
*/
for ( ; i < p->col; i++) {
- if (isspace((int)p->buf[i]))
+ if (isspace((u_char)p->buf[i]))
break;
putchar(p->buf[i]);
}
/* LINTED */
for (j = i = 0; i < len; i++) {
- if ( ! isspace((int)word[i])) {
+ if ( ! isspace((u_char)word[i])) {
j++;
continue;
}
/* Escaped spaces don't delimit... */
- if (i > 0 && isspace((int)word[i]) &&
+ if (i > 0 && isspace((u_char)word[i]) &&
'\\' == word[i - 1]) {
j++;
continue;
meta->title, pp ? pp : "");
for (bufp = title; *bufp; bufp++)
- *bufp = toupper(*bufp);
+ *bufp = toupper((u_char)*bufp);
p->offset = 0;
p->rmargin = (p->maxrmargin - strlen(buf)) / 2;
-/* $Id: strings.c,v 1.24 2009/03/02 17:14:46 kristaps Exp $ */
+/* $Id: strings.c,v 1.25 2009/03/05 13:12:12 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
case ('e'):
return(2);
case ('*'):
- if (0 == *++p || ! isgraph((int)*p))
+ if (0 == *++p || ! isgraph((u_char)*p))
return(0);
switch (*p) {
case ('('):
- if (0 == *++p || ! isgraph((int)*p))
+ if (0 == *++p || ! isgraph((u_char)*p))
return(0);
return(4);
case ('['):
for (c = 3, p++; *p && ']' != *p; p++, c++)
- if ( ! isgraph((int)*p))
+ if ( ! isgraph((u_char)*p))
break;
return(*p == ']' ? c : 0);
default:
}
return(3);
case ('('):
- if (0 == *++p || ! isgraph((int)*p))
+ if (0 == *++p || ! isgraph((u_char)*p))
return(0);
- if (0 == *++p || ! isgraph((int)*p))
+ if (0 == *++p || ! isgraph((u_char)*p))
return(0);
return(4);
case ('['):
}
for (c = 3, p++; *p && ']' != *p; p++, c++)
- if ( ! isgraph((int)*p))
+ if ( ! isgraph((u_char)*p))
break;
return(*p == ']' ? c : 0);
(void)memset(&tm, 0, sizeof(struct tm));
- if (xstrcmp(p, "$Mdocdate: March 2 2009 $"))
+ if (xstrcmp(p, "$Mdocdate: March 5 2009 $"))
return(time(NULL));
- if ((pp = strptime(p, "$Mdocdate: March 2 2009 $", &tm)) && 0 == *pp)
+ if ((pp = strptime(p, "$Mdocdate: March 5 2009 $", &tm)) && 0 == *pp)
return(mktime(&tm));
/* XXX - this matches "June 1999", which is wrong. */
if ((pp = strptime(p, "%b %d %Y", &tm)) && 0 == *pp)
-/* $Id: term.c,v 1.41 2009/03/04 14:41:40 kristaps Exp $ */
+/* $Id: term.c,v 1.42 2009/03/05 13:12:12 kristaps Exp $ */
/*
* Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
*
assert(len > 0);
for (i = 0; i < len - 1; i++)
- if ( ! isdigit((int)(*arg->value)[i]))
+ if ( ! isdigit((u_char)(*arg->value)[i]))
break;
if (i == len - 1) {
{
TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_CMD_ARG]);
- if (NULL == node->child) {
- word(p, "file");
- word(p, "...");
- }
return(1);
}
-/* $Id: validate.c,v 1.67 2009/03/04 13:57:35 kristaps Exp $ */
+/* $Id: validate.c,v 1.68 2009/03/05 13:12:12 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
static int check_text(struct mdoc *,
int, int, const char *);
+static int check_argv(struct mdoc *,
+ const struct mdoc_node *,
+ const struct mdoc_arg *);
static int err_child_lt(struct mdoc *, const char *, int);
static int warn_child_lt(struct mdoc *, const char *, int);
node->data.elem.argc;
for (i = 0; i < (int)argc; i++) {
- if (0 == argv[i].sz)
- continue;
for (j = 0; j < (int)argv[i].sz; j++) {
tp = argv[i].value[j];
line = argv[i].line;
if ( ! check_text(mdoc, line, pos, tp))
return(0);
}
+ if ( ! check_argv(mdoc, node, &argv[i]))
+ return(0);
}
}
}
+/*
+ * Check over an argument. When this has more stuff in it, make this
+ * into a table-driven function; until then, a switch is fine.
+ */
+static int
+check_argv(struct mdoc *mdoc,
+ const struct mdoc_node *node,
+ const struct mdoc_arg *argv)
+{
+
+
+ switch (argv->arg) {
+ case (MDOC_Std):
+ switch (node->tok) {
+ case (MDOC_Ex):
+ /*
+ * If the -std does not have an argument, then
+ * set it with the default name (if set). This
+ * only happens with MDOC_Ex.
+ */
+ if (1 == argv->sz)
+ return(1);
+ assert(0 == argv->sz);
+ if (mdoc->meta.name)
+ return(1);
+ return(mdoc_nerr(mdoc, node,
+ "default name not yet set"));
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+
+ return(1);
+}
+
+
static int
check_text(struct mdoc *mdoc, int line, int pos, const char *p)
{
/* XXX - indicate deprecated escapes \*(xx and \*x. */
for ( ; *p; p++) {
- if ( ! isprint((int)*p) && '\t' != *p)
+ if ( ! isprint((u_char)*p) && '\t' != *p)
return(mdoc_perr(mdoc, line, pos,
"invalid non-printing characters"));
if ('\\' != *p)