=================================================================== RCS file: /cvs/mandoc/Attic/mdoc_action.c,v retrieving revision 1.41 retrieving revision 1.45 diff -u -p -r1.41 -r1.45 --- mandoc/Attic/mdoc_action.c 2009/09/25 13:03:25 1.41 +++ mandoc/Attic/mdoc_action.c 2009/10/26 10:36:46 1.45 @@ -1,4 +1,4 @@ -/* $Id: mdoc_action.c,v 1.41 2009/09/25 13:03:25 kristaps Exp $ */ +/* $Id: mdoc_action.c,v 1.45 2009/10/26 10:36:46 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -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 +#endif #include #include #include #include #include +#include #include "libmdoc.h" @@ -174,7 +177,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 */ @@ -186,9 +189,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, @@ -203,7 +207,8 @@ static const int rsord[RSORD_MAX] = { MDOC__Q, MDOC__D, MDOC__O, - MDOC__C + MDOC__C, + MDOC__U }; @@ -520,8 +525,16 @@ 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); @@ -530,6 +543,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) @@ -538,6 +555,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))) @@ -757,7 +775,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;