summaryrefslogtreecommitdiffstatshomepage
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
commit32bc4a1e0a8ab255cd10e101dc9778b0c143f2f8 (patch)
tree9e29cf915b9f138f68c4a3b41ff27083c16d4326
parent4dd19dc815efe99e3ac82f119af43261f3c73520 (diff)
downloadmandoc-32bc4a1e0a8ab255cd10e101dc9778b0c143f2f8.tar.gz
mandoc-32bc4a1e0a8ab255cd10e101dc9778b0c143f2f8.tar.zst
mandoc-32bc4a1e0a8ab255cd10e101dc9778b0c143f2f8.zip
*** empty log message ***
-rw-r--r--dummy.c33
-rw-r--r--libmdocml.h6
-rw-r--r--mdocml.19
-rw-r--r--mdocml.c12
-rw-r--r--private.h10
-rw-r--r--roff.c24
6 files changed, 60 insertions, 34 deletions
diff --git a/dummy.c b/dummy.c
index 51ae1f29..980f14d6 100644
--- a/dummy.c
+++ b/dummy.c
@@ -1,4 +1,4 @@
-/* $Id: dummy.c,v 1.9 2008/11/27 16:54:58 kristaps Exp $ */
+/* $Id: dummy.c,v 1.10 2008/11/27 17:27:50 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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 221b751d..bc0e25a2 100644
--- a/libmdocml.h
+++ b/libmdocml.h
@@ -1,4 +1,4 @@
-/* $Id: libmdocml.h,v 1.7 2008/11/25 12:14:02 kristaps Exp $ */
+/* $Id: libmdocml.h,v 1.8 2008/11/27 17:27:50 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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 8df5c7f6..2f194334 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 d70aad13..a22a1092 100644
--- a/mdocml.c
+++ b/mdocml.c
@@ -1,4 +1,4 @@
-/* $Id: mdocml.c,v 1.12 2008/11/26 22:27:07 kristaps Exp $ */
+/* $Id: mdocml.c,v 1.13 2008/11/27 17:27:50 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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 b430c161..96b26b39 100644
--- a/private.h
+++ b/private.h
@@ -1,4 +1,4 @@
-/* $Id: private.h,v 1.12 2008/11/27 16:54:58 kristaps Exp $ */
+/* $Id: private.h,v 1.13 2008/11/27 17:27:50 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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 5708ad8c..774f0a70 100644
--- a/roff.c
+++ b/roff.c
@@ -1,4 +1,4 @@
-/* $Id: roff.c,v 1.12 2008/11/27 16:54:58 kristaps Exp $ */
+/* $Id: roff.c,v 1.13 2008/11/27 17:27:50 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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));
}