gbranden pushed a commit to branch master
in repository groff.

commit 81e4c395916a5ac2eaeccc85172412d15b2df524
Author: G. Branden Robinson <[email protected]>
AuthorDate: Fri Nov 7 11:09:57 2025 -0600

    Retire our putenv(3) replacement.
    
    ...in favor of gnulib's.  groff's was copied from glibc in 1991 and
    changed very little since.
    
    * Makefile.am: Drop putenv-referencing annotations.
    
    * bootstrap.conf (gnulib_modules): Add "putenv".
    
    * configure.ac: Drop `GROFF_NEED_DECLARATION([putenv])` call.  Drop
      `putenv` from `AC_REPLACE_FUNCS()` call.
    
    * src/devices/grops/ps.cpp:
    * src/devices/grops/psrm.cpp:
    * src/roff/groff/groff.cpp:
    * src/roff/troff/input.cpp: Drop conditional declaration of `putenv()`
      symbol.
    
    * src/libs/libgroff/putenv.c: Delete.
    
    * src/libs/libgroff/libgroff.am (EXTRA_DIST): Drop "putenv.c".
    
    Continues fixing Savannah #66518.
---
 ChangeLog                     |  19 ++++++++
 Makefile.am                   |   5 +-
 bootstrap.conf                |   1 +
 configure.ac                  |   3 +-
 src/devices/grops/ps.cpp      |   6 ---
 src/devices/grops/psrm.cpp    |   6 ---
 src/libs/libgroff/libgroff.am |   1 -
 src/libs/libgroff/putenv.c    | 103 ------------------------------------------
 src/roff/groff/groff.cpp      |   6 ---
 src/roff/troff/input.cpp      |   6 ---
 10 files changed, 22 insertions(+), 134 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6c667ba73..dd145ed1d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2025-11-07  G. Branden Robinson <[email protected]>
+
+       Retire our putenv(3) replacement in favor of gnulib's.  groff's
+       was copied from glibc in 1991 and changed very little since.
+
+       * Makefile.am: Drop putenv-referencing annotations.
+       * bootstrap.conf (gnulib_modules): Add "putenv".
+       * configure.ac: Drop `GROFF_NEED_DECLARATION([putenv])` call.
+       Drop `putenv` from `AC_REPLACE_FUNCS()` call.
+       * src/devices/grops/ps.cpp:
+       * src/devices/grops/psrm.cpp:
+       * src/roff/groff/groff.cpp:
+       * src/roff/troff/input.cpp: Drop conditional declaration of
+       `putenv()` symbol.
+       * src/libs/libgroff/putenv.c: Delete.
+       * src/libs/libgroff/libgroff.am (EXTRA_DIST): Drop "putenv.c".
+
+       Continues fixing Savannah #66518.
+
 2025-11-07  G. Branden Robinson <[email protected]>
 
        [grops,groff,troff]: Parallelize diagnostic messages relating to
diff --git a/Makefile.am b/Makefile.am
index 65f639691..e1a4d65c7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -303,7 +303,6 @@ man7dir=$(manroot)/man$(man7ext)
 # HAVE_LANGINFO_CODESET        if you have nl_langinfo()
 # HAVE_MKSTEMP         if you have mkstemp()
 # HAVE_MMAP                    if you have mmap()
-# HAVE_PUTENV                  if you have putenv()
 # HAVE_RENAME                  if you have rename()
 # HAVE_SETLOCALE               if you have setlocale()
 # HAVE_STRCASECMP              if you have strcasecmp()
@@ -318,8 +317,6 @@ man7dir=$(manroot)/man$(man7ext)
 # NEED_DECLARATION_HYPOT       if your C++ <math.h> doesn't declare hypot()
 # NEED_DECLARATION_PCLOSE      if your C++ <stdio.h> doesn't declare pclose()
 # NEED_DECLARATION_POPEN       if your C++ <stdio.h> doesn't declare popen()
-# NEED_DECLARATION_PUTENV      if your C++ <stdlib.h> doesn't declare
-#                              putenv()
 # NEED_DECLARATION_RAND        if your C++ <stdlib.h> doesn't declare rand()
 # NEED_DECLARATION_SRAND       if your C++ <stdlib.h> doesn't declare srand()
 # NEED_DECLARATION_STRCASECMP  if your C++ <string.h> doesn't declare
@@ -355,7 +352,7 @@ man7dir=$(manroot)/man$(man7ext)
 
 # Include
 #
-#   {fmod,getcwd,mkstemp,putenv,
+#   {fmod,getcwd,mkstemp,
 #    strerror,strtol}.$(OBJEXT)
 #
 # in 'LIBOBJS' if your C library is missing the corresponding function.
diff --git a/bootstrap.conf b/bootstrap.conf
index 5c56a3c44..9780f515f 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -45,6 +45,7 @@ gnulib_modules="
     fprintf-posix
     snprintf
     vsnprintf
+    putenv
     stat
     stdbool-h-c99
     stdckdint-h
diff --git a/configure.ac b/configure.ac
index ce1e622db..4c065f08e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -91,7 +91,6 @@ GROFF_SRAND
 GROFF_NEED_DECLARATION([gettimeofday])
 GROFF_NEED_DECLARATION([popen])
 GROFF_NEED_DECLARATION([pclose])
-GROFF_NEED_DECLARATION([putenv])
 GROFF_NEED_DECLARATION([rand])
 GROFF_NEED_DECLARATION([srand])
 GROFF_NEED_DECLARATION([vfprintf])
@@ -126,7 +125,7 @@ AC_SUBST([LIBEXT],[$acl_libext])
 AC_FUNC_MMAP
 saved_libs="$LIBS"
 LIBS="$LIBS $LIBC $LIBM"
-AC_REPLACE_FUNCS([fmod getcwd putenv strtol])
+AC_REPLACE_FUNCS([fmod getcwd strtol])
 LIBS="$saved_libs"
 AC_CHECK_FUNCS([gettimeofday isatty kill rename setlocale strdup \
                 strsep])
diff --git a/src/devices/grops/ps.cpp b/src/devices/grops/ps.cpp
index cf4eb6f2e..a3b04bf5c 100644
--- a/src/devices/grops/ps.cpp
+++ b/src/devices/grops/ps.cpp
@@ -54,12 +54,6 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>. */
 
 #include "ps.h"
 
-#ifdef NEED_DECLARATION_PUTENV
-extern "C" {
-  int putenv(const char *);
-}
-#endif /* NEED_DECLARATION_PUTENV */
-
 extern "C" const char *Version_string;
 
 // Initialize inclusion search path with only the current directory.
diff --git a/src/devices/grops/psrm.cpp b/src/devices/grops/psrm.cpp
index 7d92bead8..7c25c239b 100644
--- a/src/devices/grops/psrm.cpp
+++ b/src/devices/grops/psrm.cpp
@@ -32,12 +32,6 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>. */
 
 #include "ps.h"
 
-#ifdef NEED_DECLARATION_PUTENV
-extern "C" {
-  int putenv(const char *);
-}
-#endif /* NEED_DECLARATION_PUTENV */
-
 #define GROPS_PROLOGUE "prologue"
 
 static void print_ps_string(const string &s, FILE *outfp);
diff --git a/src/libs/libgroff/libgroff.am b/src/libs/libgroff/libgroff.am
index 2631c7c6b..eb30f026b 100644
--- a/src/libs/libgroff/libgroff.am
+++ b/src/libs/libgroff/libgroff.am
@@ -83,7 +83,6 @@ EXTRA_DIST += \
   src/libs/libgroff/mkstemp.cpp \
   src/libs/libgroff/fmod.c \
   src/libs/libgroff/getcwd.c \
-  src/libs/libgroff/putenv.c \
   src/libs/libgroff/strtol.c \
   src/libs/libgroff/config.charset \
   src/libs/libgroff/ref-add.sin \
diff --git a/src/libs/libgroff/putenv.c b/src/libs/libgroff/putenv.c
deleted file mode 100644
index de8f657d3..000000000
--- a/src/libs/libgroff/putenv.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/* Copyright (C) 1991-2020 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
-
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-The GNU C Library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-/* Hacked slightly by [email protected] for groff. */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-
-#ifdef __STDC__
-#include <stddef.h>
-typedef void *PTR;
-typedef size_t SIZE_T;
-#else /* not __STDC__ */
-typedef char *PTR;
-typedef int SIZE_T;
-#endif /* not __STDC__ */
-
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#else /* not HAVE_STDLIB_H */
-PTR malloc();
-#endif /* not HAVE_STDLIB_H */
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-extern char **environ;
-
-/* Put STRING, which is of the form 'NAME=VALUE', in the environment.  */
-
-int putenv(const char *string)
-{
-  char *name_end = strchr(string, '=');
-  SIZE_T size;
-  char **ep;
-
-  if (name_end == NULL)
-    {
-      /* Remove the variable from the environment.  */
-      size = strlen(string);
-      for (ep = environ; *ep != NULL; ++ep)
-       if (!strncmp(*ep, string, size) && (*ep)[size] == '=')
-         {
-           while (ep[1] != NULL)
-             {
-               ep[0] = ep[1];
-               ++ep;
-             }
-           *ep = NULL;
-           return 0;
-         }
-    }
-
-  size = 0;
-  for (ep = environ; *ep != NULL; ++ep)
-    if (!strncmp(*ep, string, name_end - string)
-       && (*ep)[name_end - string] == '=')
-      break;
-    else
-      ++size;
-
-  if (*ep == NULL)
-    {
-      static char **last_environ = NULL;
-      char **new_environ = (char **) malloc((size + 2) * sizeof(char *));
-      if (new_environ == NULL)
-       return -1;
-      (void) memcpy((PTR) new_environ, (PTR) environ, size * sizeof(char *));
-      new_environ[size] = (char *) string;
-      new_environ[size + 1] = NULL;
-      if (last_environ != NULL)
-       free((PTR) last_environ);
-      last_environ = new_environ;
-      environ = new_environ;
-    }
-  else
-    *ep = (char *) string;
-
-  return 0;
-}
-
-// Local Variables:
-// fill-column: 72
-// mode: C++
-// End:
-// vim: set cindent noexpandtab shiftwidth=2 textwidth=72:
diff --git a/src/roff/groff/groff.cpp b/src/roff/groff/groff.cpp
index e38089ea5..dc41c0b4b 100644
--- a/src/roff/groff/groff.cpp
+++ b/src/roff/groff/groff.cpp
@@ -58,12 +58,6 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>. */
 // specified
 #define XREG ".X"
 
-#ifdef NEED_DECLARATION_PUTENV
-extern "C" {
-  int putenv(const char *);
-}
-#endif /* NEED_DECLARATION_PUTENV */
-
 // The number of commands must be in sync with MAX_COMMANDS in
 // pipeline.h.
 
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 5e2bf3df2..8eac2268a 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -64,12 +64,6 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>. */
 #include "posix.h"
 #include "nonposix.h"
 
-#ifdef NEED_DECLARATION_PUTENV
-extern "C" {
-  int putenv(const char *);
-}
-#endif /* NEED_DECLARATION_PUTENV */
-
 #define MACRO_PREFIX "tmac."
 #define MACRO_POSTFIX ".tmac"
 #define INITIAL_STARTUP_FILE "troffrc"

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to