source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mandoc: store the operating system name obtained from uname(3) in the
@ 2021-10-04 14:19 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2021-10-04 14:19 UTC (permalink / raw)
  To: source

Log Message:
-----------
store the operating system name obtained from uname(3) in the adequate
struct together with similar state date rather than in a function-scope 
static variable, such that it can be free(3)d in roff_man_free();
no functional change

Modified Files:
--------------
    mandoc:
        mdoc_validate.c
        roff.c
        roff_int.h

Revision Data
-------------
Index: roff_int.h
===================================================================
RCS file: /home/cvs/mandoc/mandoc/roff_int.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -Lroff_int.h -Lroff_int.h -u -p -r1.17 -r1.18
--- roff_int.h
+++ 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. */
Index: roff.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/roff.c,v
retrieving revision 1.379
retrieving revision 1.380
diff -Lroff.c -Lroff.c -u -p -r1.379 -r1.380
--- roff.c
+++ 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);
 }
 
Index: mdoc_validate.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mdoc_validate.c,v
retrieving revision 1.389
retrieving revision 1.390
diff -Lmdoc_validate.c -Lmdoc_validate.c -u -p -r1.389 -r1.390
--- mdoc_validate.c
+++ 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:
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-10-04 14:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-04 14:19 mandoc: store the operating system name obtained from uname(3) in the schwarze

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).