Use putenv+unsetenv instead of modifying environ directly.
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 8 Dec 2012 17:19:51 +0000 (09:19 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 8 Dec 2012 17:19:51 +0000 (09:19 -0800)
commit823218f58bee24cff294e93a2dff9fd7d7477e66
tree0c6a1621e53fa310ccd4b80983b340189ce7d2fe
parent529d914ecce623da8c43573ae17800ece16f90cc
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.
16 files changed:
ChangeLog
admin/ChangeLog
admin/merge-gnulib
lib/gnulib.mk
lib/putenv.c [new file with mode: 0644]
lib/unsetenv.c [new file with mode: 0644]
m4/gnulib-comp.m4
m4/putenv.m4 [new file with mode: 0644]
m4/setenv.m4 [new file with mode: 0644]
src/ChangeLog
src/alloc.c
src/dbusbind.c
src/editfns.c
src/emacs.c
src/lisp.h
src/xterm.c