summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mdoc_validate.c11
-rw-r--r--roff.c3
-rw-r--r--roff_int.h1
3 files changed, 8 insertions, 7 deletions
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 170ae0bf..11b48a2f 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,6 +1,6 @@
/* $Id$ */
/*
- * Copyright (c) 2010-2020 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010-2021 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Joerg Sonnenberger <joerg@netbsd.org>
*
@@ -2872,7 +2872,6 @@ post_os(POST_ARGS)
{
#ifndef OSNAME
struct utsname utsname;
- static char *defbuf;
#endif
struct roff_node *n;
@@ -2909,15 +2908,15 @@ post_os(POST_ARGS)
#ifdef OSNAME
mdoc->meta.os = mandoc_strdup(OSNAME);
#else /*!OSNAME */
- if (defbuf == NULL) {
+ if (mdoc->os_r == NULL) {
if (uname(&utsname) == -1) {
mandoc_msg(MANDOCERR_OS_UNAME, n->line, n->pos, "Os");
- defbuf = mandoc_strdup("UNKNOWN");
+ mdoc->os_r = mandoc_strdup("UNKNOWN");
} else
- mandoc_asprintf(&defbuf, "%s %s",
+ mandoc_asprintf(&mdoc->os_r, "%s %s",
utsname.sysname, utsname.release);
}
- mdoc->meta.os = mandoc_strdup(defbuf);
+ mdoc->meta.os = mandoc_strdup(mdoc->os_r);
#endif /*!OSNAME*/
out:
diff --git a/roff.c b/roff.c
index 42a13e9e..932a0e1d 100644
--- a/roff.c
+++ b/roff.c
@@ -1,6 +1,6 @@
/* $Id$ */
/*
- * Copyright (c) 2010-2015, 2017-2020 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010-2015, 2017-2021 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -861,6 +861,7 @@ void
roff_man_free(struct roff_man *man)
{
roff_man_free1(man);
+ free(man->os_r);
free(man);
}
diff --git a/roff_int.h b/roff_int.h
index e0700a74..f7d688fd 100644
--- a/roff_int.h
+++ b/roff_int.h
@@ -35,6 +35,7 @@ struct roff_man {
struct ohash *mdocmac; /* Mdoc macro lookup table. */
struct ohash *manmac; /* Man macro lookup table. */
const char *os_s; /* Default operating system. */
+ char *os_r; /* Operating system name at run time. */
struct roff_node *last; /* The last node parsed. */
struct roff_node *last_es; /* The most recent Es node. */
int quick; /* Abort parse early. */