summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile5
-rw-r--r--mlg.c44
-rw-r--r--roff.c13
-rw-r--r--roff.h2
4 files changed, 44 insertions, 20 deletions
diff --git a/Makefile b/Makefile
index e46ec8f9..b9bdef4c 100644
--- a/Makefile
+++ b/Makefile
@@ -22,12 +22,13 @@ INSTALL = Makefile $(HEADS) $(SRCS) $(MANS)
FAIL = test.0 test.1 test.2 test.3 test.4 test.5 test.6 \
test.15 test.20 test.22 test.24 test.26 test.27 test.30 \
- test.36 test.37 test.40
+ test.36 test.37 test.40 test.50
SUCCEED = test.7 test.8 test.9 test.10 test.11 test.12 test.13 \
test.14 test.16 test.17 test.18 test.19 test.21 test.23 \
test.25 test.28 test.29 test.31 test.32 test.33 test.34 \
- test.35 test.38 test.39 test.41
+ test.35 test.38 test.39 test.41 test.42 test.43 test.44 \
+ test.45 test.46 test.47 test.48 test.49 test.51 test.52
all: mdocml
diff --git a/mlg.c b/mlg.c
index 068988f4..948e93fe 100644
--- a/mlg.c
+++ b/mlg.c
@@ -62,6 +62,7 @@ struct md_mlg {
static char *mlg_literal(int);
static char *mlg_At_literal(const char *);
+static char *mlg_fmt(int);
static char *mlg_St_literal(int);
static void mlg_roffmsg(void *arg, enum roffmsg,
const char *, const char *, char *);
@@ -200,6 +201,7 @@ mlg_St_literal(int argc)
static char *
mlg_At_literal(const char *p)
{
+
if (NULL == p)
return("AT&T UNIX");
if (0 == strcmp(p, "v6"))
@@ -219,8 +221,32 @@ mlg_At_literal(const char *p)
static char *
+mlg_fmt(int tok)
+{
+
+ switch (tok) {
+ case (ROFF_Ex):
+ return ("The %s utility exits 0 on success, and "
+ ">0 if an error occurs.");
+ case (ROFF_Rv):
+ return ("The %s() function returns the value 0 if "
+ "successful; otherwise the value -1 "
+ "is returned and the global variable "
+ "<span class=\"inline-Va\">errno</span> "
+ "is set to indicate the error.");
+ default:
+ break;
+ }
+
+ abort();
+ /* NOTREACHED */
+}
+
+
+static char *
mlg_literal(int tok)
{
+
switch (tok) {
case (ROFF_Bt):
return("is currently in beta test.");
@@ -564,6 +590,7 @@ mlg_roffspecial(void *arg, int tok, const char *start,
const int *argc, const char **argv, char **more)
{
struct md_mlg *p;
+ char buf[256];
assert(arg);
p = (struct md_mlg *)arg;
@@ -633,19 +660,14 @@ mlg_roffspecial(void *arg, int tok, const char *start,
return(0);
assert(NULL == *more);
break;
+
case (ROFF_Ex):
+ /* NOTREACHED */
+ case (ROFF_Rv):
assert(*more);
- if ( ! ml_puts(p->mbuf, "The ", &p->pos))
- return(0);
- if ( ! mlg_begintag(p, MD_NS_INLINE, ROFF_Xr, NULL, NULL))
- return(0);
- if ( ! ml_puts(p->mbuf, *more++, &p->pos))
- return(0);
- if ( ! mlg_endtag(p, MD_NS_INLINE, ROFF_Xr))
- return(0);
- if ( ! ml_puts(p->mbuf, " utility exits 0 on success, "
- "and &gt;0 if an error "
- "occurs.", &p->pos))
+ (void)snprintf(buf, sizeof(buf),
+ mlg_fmt(tok), *more++);
+ if ( ! ml_puts(p->mbuf, buf, &p->pos))
return(0);
assert(NULL == *more);
break;
diff --git a/roff.c b/roff.c
index ab0c0170..6c45e8be 100644
--- a/roff.c
+++ b/roff.c
@@ -653,15 +653,16 @@ roffspecial(struct rofftree *tree, int tok, const char *start,
return(0);
break;
+ case (ROFF_Rv):
+ /* FALLTHROUGH*/
case (ROFF_Sx):
/* FALLTHROUGH*/
case (ROFF_Ex):
- if (1 != sz) {
- roff_err(tree, start, "`%s' expects one arg",
- toknames[tok]);
- return(0);
- }
- break;
+ if (1 == sz)
+ break;
+ roff_err(tree, start, "`%s' expects one arg",
+ toknames[tok]);
+ return(0);
case (ROFF_Sm):
if (1 != sz) {
diff --git a/roff.h b/roff.h
index 1e8de0a9..4687ddd1 100644
--- a/roff.h
+++ b/roff.h
@@ -132,7 +132,7 @@ static const struct rofftok tokens[ROFF_MAX] = {
{ roff_text, NULL, NULL, NULL, 0, ROFF_TEXT, ROFF_PARSED | ROFF_CALLABLE | ROFF_LSCOPE }, /* Op */
{ roff_depr, NULL, NULL, NULL, 0, ROFF_TEXT, 0 }, /* Ot */
{ roff_text, NULL, NULL, NULL, 0, ROFF_TEXT, ROFF_PARSED | ROFF_CALLABLE }, /* Pa */
- { roff_text, roffarg_Rv, NULL, NULL, 0, ROFF_TEXT, 0 }, /* Rv */
+/*Ok*/ {roff_ordered, roffarg_Rv, NULL, NULL, 0, ROFF_TEXT, 0 }, /* Rv */
/*Ok*/ {roff_ordered, roffarg_St, NULL, NULL, 0, ROFF_TEXT, ROFF_PARSED | ROFF_CALLABLE }, /* St */
/*Ok*/ { roff_text, NULL, NULL, NULL, 0, ROFF_TEXT, ROFF_PARSED | ROFF_CALLABLE }, /* Va */
/*Ok*/ { roff_text, NULL, NULL, NULL, 0, ROFF_TEXT, ROFF_PARSED | ROFF_CALLABLE }, /* Vt */ /* FIXME: section/linebreak. */