summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2008-11-27 17:27:50 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2008-11-27 17:27:50 +0000
commit251cb31839ca20218450f57218e4d7935e6e0652 (patch)
tree0bc950bf849256933a3bc0f6b496b8b125bfd3c4
parent757654bf3db3f335e31ed99eff0744a5b6d0c5d1 (diff)
downloadmandoc-251cb31839ca20218450f57218e4d7935e6e0652.tar.gz
*** empty log message ***
-rw-r--r--dummy.c31
-rw-r--r--libmdocml.h4
-rw-r--r--mdocml.19
-rw-r--r--mdocml.c10
-rw-r--r--private.h8
-rw-r--r--roff.c22
6 files changed, 55 insertions, 29 deletions
diff --git a/dummy.c b/dummy.c
index 75ab173a..4930980c 100644
--- a/dummy.c
+++ b/dummy.c
@@ -29,10 +29,11 @@
#define strlcat strncat
#endif
-static int md_dummy_blk_in(int);
-static int md_dummy_blk_out(int);
-static int md_dummy_text_in(int, int *, char **);
-static int md_dummy_text_out(int);
+static int md_dummy_blk_in(const struct md_args *, int);
+static int md_dummy_blk_out(const struct md_args *, int);
+static int md_dummy_text_in(const struct md_args *, int,
+ int *, char **);
+static int md_dummy_text_out(const struct md_args *, int);
static int md_dummy_special(int);
static int md_dummy_head(void);
static int md_dummy_tail(void);
@@ -159,9 +160,12 @@ md_dummy_special(int tok)
static int
-md_dummy_blk_in(int tok)
+md_dummy_blk_in(const struct md_args *args, int tok)
{
+ if (args->verbosity < 1)
+ return(1);
+
dbg_prologue("blk");
(void)strlcat(dbg_line, toknames[tok], sizeof(dbg_line) - 1);
dbg_epilogue();
@@ -172,19 +176,25 @@ md_dummy_blk_in(int tok)
static int
-md_dummy_blk_out(int tok)
+md_dummy_blk_out(const struct md_args *args, int tok)
{
+ if (args->verbosity < 1)
+ return(1);
+
dbg_lvl--;
return(1);
}
-/* ARGSUSED */
static int
-md_dummy_text_in(int tok, int *argcp, char **argvp)
+md_dummy_text_in(const struct md_args *args,
+ int tok, int *argcp, char **argvp)
{
+ if (args->verbosity < 1)
+ return(1);
+
dbg_prologue("text");
(void)strlcat(dbg_line, toknames[tok], sizeof(dbg_line) - 1);
(void)strlcat(dbg_line, " ", sizeof(dbg_line) - 1);
@@ -210,7 +220,7 @@ md_dummy_text_in(int tok, int *argcp, char **argvp)
static int
-md_dummy_text_out(int tok)
+md_dummy_text_out(const struct md_args *args, int tok)
{
return(1);
@@ -226,6 +236,8 @@ md_dummy_msg(const struct md_args *args, enum roffmsg lvl,
switch (lvl) {
case (ROFF_WARN):
+ if ( ! (MD_WARN_ALL & args->warnings))
+ return;
p = "warning";
break;
case (ROFF_ERROR):
@@ -236,3 +248,4 @@ md_dummy_msg(const struct md_args *args, enum roffmsg lvl,
assert(pos >= buf);
(void)fprintf(stderr, "%s:%d: %s: %s\n", name, line, p, msg);
}
+
diff --git a/libmdocml.h b/libmdocml.h
index 5d7e9727..52bd3324 100644
--- a/libmdocml.h
+++ b/libmdocml.h
@@ -42,6 +42,10 @@ enum md_type {
struct md_args {
union md_params params;/* Parameters for parser. */
enum md_type type; /* Type of parser. */
+
+ int warnings;
+#define MD_WARN_ALL (1 << 0)
+ int verbosity;
};
struct md_buf {
diff --git a/mdocml.1 b/mdocml.1
index 6e4ebc02..79941da1 100644
--- a/mdocml.1
+++ b/mdocml.1
@@ -14,6 +14,7 @@
.\"
.Sh SYNOPSIS
.Nm mdocml
+.Op Fl W
.Op Fl o Ar outfile
.Op Ar infile
.\"
@@ -22,19 +23,21 @@ The
.Nm
utility compiles manpage source into a mark-up language. Its arguments
are as follows:
-.Bl -tag -width "-o outfile"
+.Bl -tag -width "\-o outfile"
.It Fl o Ar outfile
Place output in
.Ar outfile ,
which may be
-.Qq -
+.Qq \-
for standard output. The default is standard output.
.It Ar infile
Read input from
.Ar infile ,
which may be
-.Qq -
+.Qq \-
for standard input. The default is standard input.
+.It Fl W
+Print warnings.
.El
.\" The following requests should be uncommented and used where appropriate.
.\" This next request is for sections 2, 3, and 9 function return values only.
diff --git a/mdocml.c b/mdocml.c
index e699c4dc..eb71ddb6 100644
--- a/mdocml.c
+++ b/mdocml.c
@@ -58,11 +58,17 @@ main(int argc, char *argv[])
(void)memset(&args, 0, sizeof(struct md_args));
- while (-1 != (c = getopt(argc, argv, "o:")))
+ while (-1 != (c = getopt(argc, argv, "o:vW")))
switch (c) {
case ('o'):
out = optarg;
break;
+ case ('v'):
+ args.verbosity++;
+ break;
+ case ('W'):
+ args.warnings |= MD_WARN_ALL;
+ break;
default:
usage();
return(1);
@@ -213,5 +219,5 @@ usage(void)
{
extern char *__progname;
- (void)printf("usage: %s [-o outfile] [infile]\n", __progname);
+ (void)printf("usage: %s [-vW] [-o outfile] [infile]\n", __progname);
}
diff --git a/private.h b/private.h
index 93136610..f77a6773 100644
--- a/private.h
+++ b/private.h
@@ -214,10 +214,10 @@ struct roffcb {
int, char *);
int (*roffhead)(void);
int (*rofftail)(void);
- int (*roffin)(int, int *, char **);
- int (*roffout)(int);
- int (*roffblkin)(int);
- int (*roffblkout)(int);
+ int (*roffin)(const struct md_args *, int, int *, char **);
+ int (*roffout)(const struct md_args *, int);
+ int (*roffblkin)(const struct md_args *, int);
+ int (*roffblkout)(const struct md_args *, int);
int (*roffspecial)(int);
};
diff --git a/roff.c b/roff.c
index ea73a686..39f548f4 100644
--- a/roff.c
+++ b/roff.c
@@ -451,7 +451,7 @@ roffargs(const struct rofftree *tree,
while (*buf && '\"' != *buf)
buf++;
if (0 == *buf) {
- roff_err(tree, p, argv[i], "unclosed "
+ roff_err(tree, argv[i], "unclosed "
"quote in argument "
"list for `%s'",
toknames[tok]);
@@ -471,7 +471,7 @@ roffargs(const struct rofftree *tree,
assert(i > 0);
if (ROFF_MAXARG == i && *buf) {
- roff_err(tree, p, p, "too many arguments for `%s'", toknames
+ roff_err(tree, p, "too many arguments for `%s'", toknames
[tok]);
return(0);
}
@@ -898,7 +898,7 @@ roff_layout(ROFFCALL_ARGS)
if (ROFF_EXIT == type) {
roffnode_free(tok, tree);
- return((*tree->cb->roffblkout)(tok));
+ return((*tree->cb->roffblkout)(tree->args, tok));
}
i = 0;
@@ -920,16 +920,16 @@ roff_layout(ROFFCALL_ARGS)
if (NULL == roffnode_new(tok, tree))
return(0);
- if ( ! (*tree->cb->roffin)(tok, argcp, argvp))
+ if ( ! (*tree->cb->roffin)(tree->args, tok, argcp, argvp))
return(0);
if ( ! (ROFF_PARSED & tokens[tok].flags)) {
/* TODO: print all tokens. */
- if ( ! ((*tree->cb->roffout)(tok)))
+ if ( ! ((*tree->cb->roffout)(tree->args, tok)))
return(0);
- return((*tree->cb->roffblkin)(tok));
+ return((*tree->cb->roffblkin)(tree->args, tok));
}
while (*argv) {
@@ -950,10 +950,10 @@ roff_layout(ROFFCALL_ARGS)
argv++;
}
- if ( ! ((*tree->cb->roffout)(tok)))
+ if ( ! ((*tree->cb->roffout)(tree->args, tok)))
return(0);
- return((*tree->cb->roffblkin)(tok));
+ return((*tree->cb->roffblkin)(tree->args, tok));
}
@@ -986,14 +986,14 @@ roff_text(ROFFCALL_ARGS)
argcp[i] = ROFF_ARGMAX;
argvp[i] = NULL;
- if ( ! (*tree->cb->roffin)(tok, argcp, argvp))
+ if ( ! (*tree->cb->roffin)(tree->args, tok, argcp, argvp))
return(0);
if ( ! (ROFF_PARSED & tokens[tok].flags)) {
/* TODO: print all tokens. */
- return((*tree->cb->roffout)(tok));
+ return((*tree->cb->roffout)(tree->args, tok));
}
while (*argv) {
@@ -1014,7 +1014,7 @@ roff_text(ROFFCALL_ARGS)
argv++;
}
- return((*tree->cb->roffout)(tok));
+ return((*tree->cb->roffout)(tree->args, tok));
}