+2001-12-23 Bruno Haible <bruno@clisp.org>
+
+ * xsetenv.h: New file.
+ * xsetenv.c: New file.
+ * Makefile.am (libgettextlib_la_SOURCES): Add them.
+ * classpath.c (set_classpath): Use xsetenv instead of setenv.
+ (reset_classpath): Likewise.
+ * javacomp.c (compile_java_class): Likewise.
+ * javaexec.c (execute_java_class): Likewise.
+
2001-12-23 Bruno Haible <bruno@clisp.org>
* Makefile.am (libgettextlib_la_SOURCES): Add the contents of
tmpdir.h tmpdir.c \
wait-process.h wait-process.c \
xerror.h xerror.c \
- xmalloc.h xmalloc.c xstrdup.c
+ xmalloc.h xmalloc.c xstrdup.c \
+ xsetenv.h xsetenv.c
# Sources that are compiled only on platforms that lack the functions.
if (verbose)
printf ("CLASSPATH=%s ", new_CLASSPATH);
- setenv ("CLASSPATH", new_CLASSPATH, 1);
+ xsetenv ("CLASSPATH", new_CLASSPATH, 1);
free (new_CLASSPATH);
{
if (old_classpath != NULL)
{
- setenv ("CLASSPATH", old_classpath, 1);
+ xsetenv ("CLASSPATH", old_classpath, 1);
free (old_classpath);
}
else
#include "execute.h"
#include "pipe.h"
#include "wait-process.h"
-#include "setenv.h"
+#include "xsetenv.h"
#include "sh-quote.h"
#include "safe-read.h"
#include "xmalloc.h"
done2:
if (old_JAVA_HOME != NULL)
{
- setenv ("JAVA_HOME", old_JAVA_HOME, 1);
+ xsetenv ("JAVA_HOME", old_JAVA_HOME, 1);
free (old_JAVA_HOME);
}
#include <string.h>
#include "execute.h"
-#include "setenv.h"
+#include "xsetenv.h"
#include "sh-quote.h"
#include "xmalloc.h"
#include "error.h"
done2:
if (old_JAVA_HOME != NULL)
{
- setenv ("JAVA_HOME", old_JAVA_HOME, 1);
+ xsetenv ("JAVA_HOME", old_JAVA_HOME, 1);
free (old_JAVA_HOME);
}
--- /dev/null
+/* Setting environment variables, with out-of-memory checking.
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+/* Specification. */
+#include "xsetenv.h"
+
+#include "setenv.h"
+#include "error.h"
+#include "exit.h"
+#include "gettext.h"
+
+#define _(str) gettext (str)
+
+
+/* Set NAME to VALUE in the environment.
+ If REPLACE is nonzero, overwrite an existing value.
+ With error checking. */
+void
+xsetenv (name, value, replace)
+ const char *name;
+ const char *value;
+ int replace;
+{
+ if (setenv (name, value, replace) < 0)
+ error (EXIT_FAILURE, 0, _("memory exhausted"));
+}
--- /dev/null
+/* Setting environment variables, with out-of-memory checking.
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* Get unsetenv(). It can be used without error checking. */
+#include "setenv.h"
+
+/* Set NAME to VALUE in the environment.
+ If REPLACE is nonzero, overwrite an existing value.
+ With error checking. */
+extern void xsetenv PARAMS ((const char *name, const char *value, int replace));
+2001-12-23 Bruno Haible <bruno@clisp.org>
+
+ * msgexec.c (process_string): Use xsetenv instead of setenv.
+ * msginit.c (canonical_locale_charset): Likewise.
+ (get_title): Likewise.
+
2001-12-22 Bruno Haible <bruno@clisp.org>
* dir-list.c: Include <stddef.h> instead of <stdlib.h>.
#include "findprog.h"
#include "pipe.h"
#include "wait-process.h"
-#include "setenv.h"
+#include "xsetenv.h"
#include "gettext.h"
#define _(str) gettext (str)
int exitstatus;
/* Set environment variables for the subprocess. */
- setenv ("MSGEXEC_MSGID", mp->msgid, 1);
+ xsetenv ("MSGEXEC_MSGID", mp->msgid, 1);
location = xasprintf ("%s:%ld", mp->pos.file_name,
(long) mp->pos.line_number);
- setenv ("MSGEXEC_LOCATION", location, 1);
+ xsetenv ("MSGEXEC_LOCATION", location, 1);
free (location);
/* Open a pipe to a subprocess. */
#include "pipe.h"
#include "wait-process.h"
#include "getline.h"
-#include "setenv.h"
+#include "xsetenv.h"
#include "str-list.h"
#include "gettext.h"
tmp = getenv ("LC_ALL");
old_LC_ALL = (tmp != NULL ? xstrdup (tmp) : NULL);
- setenv ("LC_ALL", locale, 1);
+ xsetenv ("LC_ALL", locale, 1);
#ifdef HAVE_SETLOCALE
if (setlocale (LC_ALL, "") == NULL)
/* Restore LC_ALL environment variable. */
if (old_LC_ALL != NULL)
- setenv ("LC_ALL", old_LC_ALL, 1), free (old_LC_ALL);
+ xsetenv ("LC_ALL", old_LC_ALL, 1), free (old_LC_ALL);
else
unsetenv ("LC_ALL");
tmp = getenv ("OUTPUT_CHARSET");
old_OUTPUT_CHARSET = (tmp != NULL ? xstrdup (tmp) : NULL);
- setenv ("LC_ALL", locale, 1);
+ xsetenv ("LC_ALL", locale, 1);
unsetenv ("LANGUAGE");
- setenv ("OUTPUT_CHARSET", encoding, 1);
+ xsetenv ("OUTPUT_CHARSET", encoding, 1);
#ifdef HAVE_SETLOCALE
if (setlocale (LC_ALL, "") == NULL)
/* Restore LC_ALL, LANGUAGE, OUTPUT_CHARSET environment variables. */
if (old_LC_ALL != NULL)
- setenv ("LC_ALL", old_LC_ALL, 1), free (old_LC_ALL);
+ xsetenv ("LC_ALL", old_LC_ALL, 1), free (old_LC_ALL);
else
unsetenv ("LC_ALL");
if (old_LANGUAGE != NULL)
- setenv ("LANGUAGE", old_LANGUAGE, 1), free (old_LANGUAGE);
+ xsetenv ("LANGUAGE", old_LANGUAGE, 1), free (old_LANGUAGE);
else
unsetenv ("LANGUAGE");
if (old_OUTPUT_CHARSET != NULL)
- setenv ("OUTPUT_CHARSET", old_OUTPUT_CHARSET, 1), free (old_OUTPUT_CHARSET);
+ xsetenv ("OUTPUT_CHARSET", old_OUTPUT_CHARSET, 1), free (old_OUTPUT_CHARSET);
else
unsetenv ("OUTPUT_CHARSET");