summaryrefslogtreecommitdiffstatshomepage
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
commit300b892da5a31ca81913f814b09e60f8293d7b07 (patch)
tree2ac39a876af948ac94aa409adb4fdfbdc3df1817
parentaba875986bc99f62f2282c3bae2b1381db903e65 (diff)
downloadmandoc-300b892da5a31ca81913f814b09e60f8293d7b07.tar.gz
mandoc-300b892da5a31ca81913f814b09e60f8293d7b07.tar.zst
mandoc-300b892da5a31ca81913f814b09e60f8293d7b07.zip
Added ability to set OS name at compile-time with -DOSNAME="\"foo\"".
-rw-r--r--Makefile3
-rw-r--r--mdoc_action.c15
2 files changed, 16 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 2ad41901..2e3c867d 100644
--- a/Makefile
+++ b/Makefile
@@ -12,9 +12,10 @@ INSTALL_MAN = $(INSTALL_DATA)
VERSION = 1.9.9
VDATE = 21 October 2009
-VFLAGS = -DVERSION=\"$(VERSION)\"
+VFLAGS = -DVERSION="\"$(VERSION)\""
CFLAGS += -W -Wall -Wstrict-prototypes -Wno-unused-parameter -Wwrite-strings -g
CFLAGS += $(VFLAGS)
+#CFLAGS += -DOSNAME="\"OpenBSD 4.5\""
LINTFLAGS += $(VFLAGS)
MANDOCFLAGS = -Wall -fstrict
diff --git a/mdoc_action.c b/mdoc_action.c
index 844e1bf6..da44e937 100644
--- a/mdoc_action.c
+++ b/mdoc_action.c
@@ -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.42 2009/10/22 17:54:24 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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)))