summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-04-02 16:37:40 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-04-02 16:37:40 +0000
commit283a645a5be6be0f447ac0aa651b641dbb6b5fc4 (patch)
tree1789dcdcfe31044b95be8b8148f2e278ca3d4523
parent0b8142b5d9c31e6631daceec8e79caefcaf45e4b (diff)
downloadmandoc-283a645a5be6be0f447ac0aa651b641dbb6b5fc4.tar.gz
mandoc-283a645a5be6be0f447ac0aa651b641dbb6b5fc4.tar.zst
mandoc-283a645a5be6be0f447ac0aa651b641dbb6b5fc4.zip
Added -p1003.1-2008 specification.
Fixed invalid memory accesses (concat()). Made -fign-macro be the default for libman.
-rw-r--r--main.c16
-rw-r--r--mdoc_action.c7
-rw-r--r--mdoc_validate.c4
-rw-r--r--st.in3
4 files changed, 20 insertions, 10 deletions
diff --git a/main.c b/main.c
index 7d764d5c..e6275b3c 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.19 2009/04/02 16:26:35 kristaps Exp $ */
+/* $Id: main.c,v 1.20 2009/04/02 16:37:40 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org>
*
@@ -76,6 +76,7 @@ struct curparse {
#define IGN_SCOPE (1 << 0) /* Ignore scope errors. */
#define IGN_ESCAPE (1 << 1) /* Ignore bad escapes. */
#define IGN_MACRO (1 << 2) /* Ignore unknown macros. */
+#define NO_IGN_MACRO (1 << 3)
typedef int (*out_run)(void *, const struct man *,
const struct mdoc *);
@@ -264,10 +265,13 @@ man_init(struct curparse *curp)
mancb.man_err = merr;
mancb.man_warn = manwarn;
- pflags = 0;
+ /* Set command defaults. */
+ pflags = MAN_IGN_MACRO;
if (curp->fflags & IGN_MACRO)
pflags |= MAN_IGN_MACRO;
+ if (curp->fflags & NO_IGN_MACRO)
+ pflags &= ~MAN_IGN_MACRO;
if (NULL == (man = man_alloc(curp, pflags, &mancb)))
warnx("memory exhausted");
@@ -540,12 +544,13 @@ static int
foptions(int *fflags, char *arg)
{
char *v;
- char *toks[4];
+ char *toks[5];
toks[0] = "ign-scope";
toks[1] = "ign-escape";
toks[2] = "ign-macro";
- toks[3] = NULL;
+ toks[4] = "no-ign-macro";
+ toks[5] = NULL;
while (*arg)
switch (getsubopt(&arg, toks, &v)) {
@@ -558,6 +563,9 @@ foptions(int *fflags, char *arg)
case (2):
*fflags |= IGN_MACRO;
break;
+ case (3):
+ *fflags |= NO_IGN_MACRO;
+ break;
default:
warnx("bad argument: -f%s", arg);
return(0);
diff --git a/mdoc_action.c b/mdoc_action.c
index cd423964..c22fd086 100644
--- a/mdoc_action.c
+++ b/mdoc_action.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_action.c,v 1.3 2009/04/02 06:51:44 kristaps Exp $ */
+/* $Id: mdoc_action.c,v 1.4 2009/04/02 16:37:40 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org>
*
@@ -195,7 +195,6 @@ const struct actions mdoc_actions[MDOC_MAX] = {
#ifdef __linux__
-extern size_t strlcpy(char *, const char *, size_t);
extern size_t strlcat(char *, const char *, size_t);
#endif
@@ -495,13 +494,15 @@ post_os(POST_ARGS)
if (m->meta.os)
free(m->meta.os);
+
+ buf[0] = 0;
if ( ! concat(m, m->last->child, buf, sizeof(buf)))
return(0);
if (0 == buf[0]) {
if (-1 == uname(&utsname))
return(mdoc_err(m, "utsname"));
- if (strlcpy(buf, utsname.sysname, 64) >= 64)
+ if (strlcat(buf, utsname.sysname, 64) >= 64)
return(verr(m, ETOOLONG));
if (strlcat(buf, " ", 64) >= 64)
return(verr(m, ETOOLONG));
diff --git a/mdoc_validate.c b/mdoc_validate.c
index fdd73dbc..c9070dcc 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.2 2009/03/31 13:50:19 kristaps Exp $ */
+/* $Id: mdoc_validate.c,v 1.3 2009/04/02 16:37:40 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org>
*
@@ -311,7 +311,6 @@ const struct valids mdoc_valids[MDOC_MAX] = {
#ifdef __linux__
-extern size_t strlcpy(char *, const char *, size_t);
extern size_t strlcat(char *, const char *, size_t);
#endif
@@ -1352,6 +1351,7 @@ post_sh_head(POST_ARGS)
/* This is just concat() inlined, which is irritating. */
+ buf[0] = 0;
for (n = mdoc->last->child; n; n = n->next) {
assert(MDOC_TEXT == n->type);
if (strlcat(buf, n->string, 64) >= 64)
diff --git a/st.in b/st.in
index b546c3b8..2727ae85 100644
--- a/st.in
+++ b/st.in
@@ -1,4 +1,4 @@
-/* $Id: st.in,v 1.3 2009/03/16 22:19:19 kristaps Exp $ */
+/* $Id: st.in,v 1.4 2009/04/02 16:37:40 kristaps Exp $ */
/*
* This file defines the .St macro arguments. If you add a new
@@ -14,6 +14,7 @@ LINE("-p1003.1-90", "IEEE Std 1003.1-1990 (\\(lqPOSIX\\(rq)")
LINE("-p1003.1-96", "ISO/IEC 9945-1:1996 (\\(lqPOSIX\\(rq)")
LINE("-p1003.1-2001", "IEEE Std 1003.1-2001 (\\(lqPOSIX\\(rq)")
LINE("-p1003.1-2004", "IEEE Std 1003.1-2004 (\\(lqPOSIX\\(rq)")
+LINE("-p1003.1-2008", "IEEE Std 1003.1-2008 (\\(lqPOSIX\\(rq)")
LINE("-p1003.1", "IEEE Std 1003.1 (\\(lqPOSIX\\(rq)")
LINE("-p1003.1b", "IEEE Std 1003.1b (\\(lqPOSIX\\(rq)")
LINE("-p1003.1b-93", "IEEE Std 1003.1b-1993 (\\(lqPOSIX\\(rq)")