summaryrefslogtreecommitdiffstats
path: root/mdoc_action.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-10-22 17:54:24 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-10-22 17:54:24 +0000
commit8e7e152dca775ad259f5952da753603cc872f7d9 (patch)
tree5fde3029e668c87aa8dafa2317e9b965083abea5 /mdoc_action.c
parent0a568dac4cfdb231d027d380c6ad927cc6e0175d (diff)
downloadmandoc-8e7e152dca775ad259f5952da753603cc872f7d9.tar.gz
Added ability to set OS name at compile-time with -DOSNAME="\"foo\"".
Diffstat (limited to 'mdoc_action.c')
-rw-r--r--mdoc_action.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/mdoc_action.c b/mdoc_action.c
index 4acb1d29..b9d11289 100644
--- a/mdoc_action.c
+++ b/mdoc_action.c
@@ -520,7 +520,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);
@@ -530,6 +538,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 +550,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)))