summaryrefslogtreecommitdiffstatshomepage
path: root/main.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-06-11 12:07:49 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-06-11 12:07:49 +0000
commit4d04de4d66adf8f2caa056966da460e722fdd6d3 (patch)
treed32d44420aa153f2987379a959d24e06df9c440d /main.c
parent7f83f64018902ad39b94705868df283386db95fa (diff)
downloadmandoc-4d04de4d66adf8f2caa056966da460e722fdd6d3.tar.gz
mandoc-4d04de4d66adf8f2caa056966da460e722fdd6d3.tar.zst
mandoc-4d04de4d66adf8f2caa056966da460e722fdd6d3.zip
Documented some un-clear parts of main.c.
Fixed footer to be new-groff style (OS DATE OS). Removed sanity check from mdoc_term (unnecessary).
Diffstat (limited to 'main.c')
-rw-r--r--main.c36
1 files changed, 32 insertions, 4 deletions
diff --git a/main.c b/main.c
index de6e4543..517dbc49 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.26 2009/06/10 20:18:43 kristaps Exp $ */
+/* $Id: main.c,v 1.27 2009/06/11 12:07:49 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -190,6 +190,8 @@ main(int argc, char *argv[])
free(blk.buf);
if (ln.buf)
free(ln.buf);
+
+ /* TODO: have a curp_free routine. */
if (curp.outfree)
(*curp.outfree)(curp.outdata);
if (curp.mdoc)
@@ -231,7 +233,14 @@ man_init(struct curparse *curp)
mancb.man_err = merr;
mancb.man_warn = manwarn;
- pflags = MAN_IGN_MACRO; /* XXX */
+ /*
+ * Default behaviour is to ignore unknown macros. This is
+ * specified in mandoc.1.
+ */
+
+ pflags = MAN_IGN_MACRO;
+
+ /* Override default behaviour... */
if (curp->fflags & NO_IGN_MACRO)
pflags &= ~MAN_IGN_MACRO;
@@ -254,8 +263,16 @@ mdoc_init(struct curparse *curp)
mdoccb.mdoc_err = merr;
mdoccb.mdoc_warn = mdocwarn;
+ /*
+ * Default behaviour is to ignore unknown macros, escape
+ * sequences and characters (very liberal). This is specified
+ * in mandoc.1.
+ */
+
pflags = MDOC_IGN_MACRO | MDOC_IGN_ESCAPE | MDOC_IGN_CHARS;
+ /* Override default behaviour... */
+
if (curp->fflags & IGN_SCOPE)
pflags |= MDOC_IGN_SCOPE;
if (curp->fflags & NO_IGN_ESCAPE)
@@ -363,7 +380,7 @@ fdesc(struct buf *blk, struct buf *ln, struct curparse *curp)
continue;
}
- /* Check for CPP-escaped newline. */
+ /* Check for CPP-escaped newline. */
if (pos > 0 && '\\' == ln->buf[pos - 1]) {
for (j = pos - 1; j >= 0; j--)
@@ -630,9 +647,10 @@ merr(void *arg, int line, int col, const char *msg)
struct curparse *curp;
curp = (struct curparse *)arg;
-
warnx("%s:%d: error: %s (column %d)",
curp->file, line, msg, col);
+
+ /* Always exit on errors... */
return(0);
}
@@ -666,6 +684,11 @@ mdocwarn(void *arg, int line, int col,
if ( ! (curp->wflags & WARN_WERR))
return(1);
+
+ /*
+ * If the -Werror flag is passed in, as in gcc, then all
+ * warnings are considered as errors.
+ */
warnx("%s: considering warnings as errors",
__progname);
@@ -689,6 +712,11 @@ manwarn(void *arg, int line, int col, const char *msg)
if ( ! (curp->wflags & WARN_WERR))
return(1);
+ /*
+ * If the -Werror flag is passed in, as in gcc, then all
+ * warnings are considered as errors.
+ */
+
warnx("%s: considering warnings as errors",
__progname);
return(0);