2013-03-13 07:15:17 +00:00
|
|
|
# putenv.m4 serial 20
|
2013-01-02 16:37:04 +00:00
|
|
|
dnl Copyright (C) 2002-2013 Free Software Foundation, Inc.
|
Use putenv+unsetenv instead of modifying environ directly.
* admin/merge-gnulib (GNULIB_MODULES): Add putenv, unsetenv.
* lib/putenv.c, lib/unsetenv.c, m4/putenv.m4, m4/setenv.m4:
New files, copied automatically from gnulib.
* lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
* src/alloc.c (xputenv): New function.
* src/dbusbind.c (Fdbus_init_bus):
* src/emacs.c (main):
* src/xterm.c (x_term_init):
Use xputenv instead of setenv or putenv, to detect memory exhaustion.
* src/editfns.c (initial_tz): Move static var decl up.
(tzvalbuf_in_environ): New static var.
(init_editfns): Initialize these two static vars.
(Fencode_time): Don't assume arbitrary limit on EMACS_INT width.
Save old TZ value on stack, if it's small.
(Fencode_time, set_time_zone_rule): Don't modify 'environ' directly;
instead, use xputenv+unsetenv to set and restore TZ.
(environbuf): Remove static var. All uses removed.
(Fset_time_zone_rule): Do not save TZ and environ;
no longer needed here.
(set_time_zone_rule_tz1, set_time_zone_rule_tz2) [LOCALTIME_CACHE]:
Move to inside set_time_zone_rule; they don't need file scope any more.
(set_time_zone_rule): Maintain the TZ=value string separately.
(syms_of_editfns): Don't initialize initial_tz;
init_editfns now does it.
* src/emacs.c (dump_tz) [HAVE_TZSET]: Now const.
* src/lisp.h (xputenv): New decl.
Fixes: debbugs:13070
2012-12-08 17:19:51 +00:00
|
|
|
dnl This file is free software; the Free Software Foundation
|
|
|
|
dnl gives unlimited permission to copy and/or distribute it,
|
|
|
|
dnl with or without modifications, as long as this notice is preserved.
|
|
|
|
|
|
|
|
dnl From Jim Meyering.
|
|
|
|
dnl
|
|
|
|
dnl Check whether putenv ("FOO") removes FOO from the environment.
|
|
|
|
dnl The putenv in libc on at least SunOS 4.1.4 does *not* do that.
|
|
|
|
|
|
|
|
AC_DEFUN([gl_FUNC_PUTENV],
|
|
|
|
[
|
|
|
|
AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
|
|
|
|
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
|
|
|
|
AC_CACHE_CHECK([for putenv compatible with GNU and SVID],
|
|
|
|
[gl_cv_func_svid_putenv],
|
|
|
|
[AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],[[
|
|
|
|
/* Put it in env. */
|
|
|
|
if (putenv ("CONFTEST_putenv=val"))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
/* Try to remove it. */
|
|
|
|
if (putenv ("CONFTEST_putenv"))
|
|
|
|
return 2;
|
|
|
|
|
|
|
|
/* Make sure it was deleted. */
|
|
|
|
if (getenv ("CONFTEST_putenv") != 0)
|
|
|
|
return 3;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
]])],
|
|
|
|
gl_cv_func_svid_putenv=yes,
|
|
|
|
gl_cv_func_svid_putenv=no,
|
|
|
|
dnl When crosscompiling, assume putenv is broken.
|
|
|
|
[case "$host_os" in
|
|
|
|
# Guess yes on glibc systems.
|
|
|
|
*-gnu*) gl_cv_func_svid_putenv="guessing yes" ;;
|
|
|
|
# If we don't know, assume the worst.
|
|
|
|
*) gl_cv_func_svid_putenv="guessing no" ;;
|
|
|
|
esac
|
|
|
|
])
|
|
|
|
])
|
|
|
|
case "$gl_cv_func_svid_putenv" in
|
|
|
|
*yes) ;;
|
|
|
|
*)
|
|
|
|
REPLACE_PUTENV=1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
])
|
2013-03-01 15:16:43 +00:00
|
|
|
|
|
|
|
# Prerequisites of lib/putenv.c.
|
|
|
|
AC_DEFUN([gl_PREREQ_PUTENV],
|
|
|
|
[
|
2013-03-13 07:15:17 +00:00
|
|
|
AC_CHECK_DECLS([_putenv])
|
2013-03-01 15:16:43 +00:00
|
|
|
])
|