diff options
Diffstat (limited to 'usr.bin/mandoc/mdoc_action.c')
-rw-r--r-- | usr.bin/mandoc/mdoc_action.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/usr.bin/mandoc/mdoc_action.c b/usr.bin/mandoc/mdoc_action.c index 764093e35fa..2c62096fec9 100644 --- a/usr.bin/mandoc/mdoc_action.c +++ b/usr.bin/mandoc/mdoc_action.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_action.c,v 1.23 2009/10/19 16:27:52 schwarze Exp $ */ +/* $Id: mdoc_action.c,v 1.24 2009/10/27 21:40:07 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -14,13 +14,16 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef OSNAME #include <sys/utsname.h> +#endif #include <assert.h> #include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <time.h> #include "libmdoc.h" @@ -170,7 +173,7 @@ static const struct actions mdoc_actions[MDOC_MAX] = { { NULL, NULL }, /* Ud */ { NULL, post_lb }, /* Lb */ { NULL, NULL }, /* Lp */ - { NULL, post_tilde }, /* Lk */ + { NULL, NULL }, /* Lk */ { NULL, NULL }, /* Mt */ { NULL, NULL }, /* Brq */ { NULL, NULL }, /* Bro */ @@ -182,9 +185,10 @@ static const struct actions mdoc_actions[MDOC_MAX] = { { NULL, NULL }, /* %Q */ { NULL, NULL }, /* br */ { NULL, NULL }, /* sp */ + { NULL, NULL }, /* %U */ }; -#define RSORD_MAX 13 +#define RSORD_MAX 14 static const int rsord[RSORD_MAX] = { MDOC__A, @@ -199,7 +203,8 @@ static const int rsord[RSORD_MAX] = { MDOC__Q, MDOC__D, MDOC__O, - MDOC__C + MDOC__C, + MDOC__U }; @@ -516,7 +521,15 @@ static int post_os(POST_ARGS) { char buf[64]; +#ifndef OSNAME struct utsname utsname; +#endif + + /* + * Setting OSNAME to be the name of the target operating system, + * e.g., "OpenBSD 4.4", will result in the compile-time constant + * by supplied instead of the value in uname(). + */ if (m->meta.os) free(m->meta.os); @@ -526,6 +539,10 @@ post_os(POST_ARGS) return(0); if (0 == buf[0]) { +#ifdef OSNAME + if (strlcat(buf, OSNAME, 64) >= 64) + return(mdoc_nerr(m, n, EUTSNAME)); +#else if (-1 == uname(&utsname)) return(mdoc_nerr(m, n, EUTSNAME)); if (strlcat(buf, utsname.sysname, 64) >= 64) @@ -534,6 +551,7 @@ post_os(POST_ARGS) return(mdoc_nerr(m, n, ETOOLONG)); if (strlcat(buf, utsname.release, 64) >= 64) return(mdoc_nerr(m, n, ETOOLONG)); +#endif } if (NULL == (m->meta.os = strdup(buf))) @@ -753,7 +771,6 @@ post_tilde(POST_ARGS) np = n; m->next = MDOC_NEXT_CHILD; - /* XXX: not documented for `Lk'. */ if ( ! mdoc_word_alloc(m, n->line, n->pos, "~")) return(0); m->last = np; |