source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mandoc.bsd.lv
To: source@mandoc.bsd.lv
Subject: mandoc: store the operating system name obtained from uname(3) in the
Date: Mon, 4 Oct 2021 09:19:45 -0500 (EST)	[thread overview]
Message-ID: <c2aaf6779fbc345b@mandoc.bsd.lv> (raw)

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


                 reply	other threads:[~2021-10-04 14:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c2aaf6779fbc345b@mandoc.bsd.lv \
    --to=schwarze@mandoc.bsd.lv \
    --cc=source@mandoc.bsd.lv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).