Now on revision 111163. ------------------------------------------------------------ revno: 111163 committer: Chong Yidong branch nick: trunk timestamp: Sun 2012-12-09 11:40:09 +0800 message: * simple.el (set-mark-default-inactive): Delete accidentally-introduced option. (set-mark-command, exchange-point-and-mark): Remove calls. diff: === modified file 'etc/NEWS' --- etc/NEWS 2012-12-09 01:04:43 +0000 +++ etc/NEWS 2012-12-09 03:40:09 +0000 @@ -29,6 +29,10 @@ ** `eval-defun' on an already defined defcustom calls the :set function, if there is one. +** The option `set-mark-default-inactive' has been deleted. +This unfinished feature was introduced by accident in Emacs 23.1; +simply disabling Transient Mark mode does the same thing. + * Editing Changes in Emacs 24.4 === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-12-09 01:04:43 +0000 +++ lisp/ChangeLog 2012-12-09 03:40:09 +0000 @@ -1,3 +1,9 @@ +2012-12-09 Chong Yidong + + * simple.el (set-mark-default-inactive): Delete this + accidentally-introduced option. + (set-mark-command, exchange-point-and-mark): Remove calls. + 2012-12-09 Glenn Morris * emacs-lisp/lisp-mode.el (eval-defun-1): Doc fix. === modified file 'lisp/simple.el' --- lisp/simple.el 2012-12-03 01:08:31 +0000 +++ lisp/simple.el 2012-12-09 03:40:09 +0000 @@ -4134,14 +4134,6 @@ :type 'boolean :group 'editing-basics) -(defcustom set-mark-default-inactive nil - "If non-nil, setting the mark does not activate it. -This causes \\[set-mark-command] and \\[exchange-point-and-mark] to -behave the same whether or not `transient-mark-mode' is enabled." - :type 'boolean - :group 'editing-basics - :version "23.1") - (defun set-mark-command (arg) "Set the mark where point is, or jump to the mark. Setting the mark also alters the region, which is the text @@ -4203,8 +4195,7 @@ (activate-mark) (message "Mark activated"))) (t - (push-mark-command nil) - (if set-mark-default-inactive (deactivate-mark))))) + (push-mark-command nil)))) (defun push-mark (&optional location nomsg activate) "Set mark at LOCATION (point, by default) and push old mark on mark ring. @@ -4268,7 +4259,6 @@ (deactivate-mark) (set-mark (point)) (goto-char omark) - (if set-mark-default-inactive (deactivate-mark)) (cond (temp-highlight (setq transient-mark-mode (cons 'only transient-mark-mode))) ((or (and arg (region-active-p)) ; (xor arg (not (region-active-p))) ------------------------------------------------------------ revno: 111162 fixes bug: http://debbugs.gnu.org/13078 committer: Paul Eggert branch nick: trunk timestamp: Sat 2012-12-08 18:22:39 -0800 message: Allow spaces in some configuration vars (Bug#13078). * configure.ac (srcdir): Don't assume $PWD lacks spaces. (srcdir, MAKEINFO, PKG_CONFIG, PKG_CONFIG_MIN_VERSION): All uses quoted, to allow spaces in these vars. diff: === modified file 'ChangeLog' --- ChangeLog 2012-12-08 17:19:51 +0000 +++ ChangeLog 2012-12-09 02:22:39 +0000 @@ -1,3 +1,10 @@ +2012-12-09 Paul Eggert + + Allow spaces in some configuration vars (Bug#13078). + * configure.ac (srcdir): Don't assume $PWD lacks spaces. + (srcdir, MAKEINFO, PKG_CONFIG, PKG_CONFIG_MIN_VERSION): + All uses quoted, to allow spaces in these vars. + 2012-12-08 Paul Eggert Use putenv+unsetenv instead of modifying environ directly (Bug#13070). === modified file 'configure.ac' --- configure.ac 2012-12-08 06:56:26 +0000 +++ configure.ac 2012-12-09 02:22:39 +0000 @@ -130,7 +130,7 @@ dnl FIXME currently it is not the last. dnl This should be the last --with option, because --with-x is -dnl added later on when we find the path of X, and it's best to +dnl added later on when we find the file name of X, and it's best to dnl keep them together visually. AC_ARG_WITH([x-toolkit],[AS_HELP_STRING([--with-x-toolkit=KIT], [use an X toolkit (KIT one of: yes or gtk, gtk2, gtk3, lucid or athena, motif, no)])], @@ -205,8 +205,8 @@ AC_SUBST(GZIP_INFO) AC_ARG_WITH([pkg-config-prog],dnl -[AS_HELP_STRING([--with-pkg-config-prog=PATH], - [path to pkg-config for finding GTK and librsvg])]) +[AS_HELP_STRING([--with-pkg-config-prog=FILENAME], + [file name of pkg-config for finding GTK and librsvg])]) if test "X${with_pkg_config_prog}" != X; then if test "${with_pkg_config_prog}" != yes; then PKG_CONFIG="${with_pkg_config_prog}" @@ -226,7 +226,8 @@ test "X$gameuser" = X && gameuser=games AC_ARG_WITH([gnustep-conf],dnl -[AS_HELP_STRING([--with-gnustep-conf=PATH],[path to GNUstep.conf; default $GNUSTEP_CONFIG_FILE, or /etc/GNUstep/GNUstep.conf])]) +[AS_HELP_STRING([--with-gnustep-conf=FILENAME], + [name of GNUstep.conf; default $GNUSTEP_CONFIG_FILE, or /etc/GNUstep/GNUstep.conf])]) test "X${with_gnustep_conf}" != X && test "${with_gnustep_conf}" != yes && \ GNUSTEP_CONFIG_FILE="${with_gnustep_conf}" test "X$GNUSTEP_CONFIG_FILE" = "X" && \ @@ -354,7 +355,7 @@ [ac_enable_autodepend="${enableval}"],[ac_enable_autodepend=yes]) #### Make srcdir absolute, if it isn't already. It's important to -#### avoid running the path through pwd unnecessarily, since pwd can +#### avoid running the file name through pwd unnecessarily, since pwd can #### give you automounter prefixes, which can go away. We do all this #### so Emacs can find its files when run uninstalled. ## Make sure CDPATH doesn't affect cd (in case PWD is relative). @@ -364,17 +365,17 @@ . ) ## We may be able to use the $PWD environment variable to make this ## absolute. But sometimes PWD is inaccurate. - ## Note: we used to use ${PWD} at the end instead of `pwd`, + ## Note: we used to use $PWD at the end instead of `pwd`, ## but that tested only for a well-formed and valid PWD, ## it did not object when PWD was well-formed and valid but just wrong. - if test ".${PWD}" != "." && test ".`(cd ${PWD} ; sh -c pwd)`" = ".`pwd`" ; + if test ".$PWD" != "." && test ".`(cd "$PWD" ; sh -c pwd)`" = ".`pwd`" ; then srcdir="$PWD" else - srcdir="`(cd ${srcdir}; pwd)`" + srcdir=`(cd "$srcdir"; pwd)` fi ;; - * ) srcdir="`(cd ${srcdir}; pwd)`" ;; + * ) srcdir=`(cd "$srcdir"; pwd)` ;; esac ### Canonicalize the configuration name. @@ -810,9 +811,13 @@ AC_PATH_PROG(MAKEINFO, makeinfo, no) dnl By this stage, configure has already checked for egrep and set EGREP, dnl or exited with an error if no egrep was found. -if test "$MAKEINFO" != "no" && \ - test x"`$MAKEINFO --version 2> /dev/null | $EGREP 'texinfo[[^0-9]]*([[1-4]][[0-9]]+|[[5-9]]|4\.[[7-9]]|4\.[[1-6]][[0-9]]+)'`" = x; then - MAKEINFO=no +if test "$MAKEINFO" != "no"; then + case ` + "$MAKEINFO" --version 2> /dev/null | + $EGREP 'texinfo[[^0-9]]*([[1-4]][[0-9]]+|[[5-9]]|4\.[[7-9]]|4\.[[1-6]][[0-9]]+)' + ` in + '') MAKEINFO=no;; + esac fi ## Makeinfo is unusual. For a released Emacs, the manuals are @@ -830,7 +835,7 @@ MAKEINFO=makeinfo if test "x${with_makeinfo}" = "xno"; then HAVE_MAKEINFO=no - elif test ! -e $srcdir/info/emacs && test ! -e $srcdir/info/emacs.info; then + elif test ! -e "$srcdir/info/emacs" && test ! -e "$srcdir/info/emacs.info"; then AC_MSG_ERROR( [You do not seem to have makeinfo >= 4.7, and your source tree does not seem to have pre-built manuals in the `info' directory. Either install a suitable version of makeinfo, or re-run configure @@ -1186,15 +1191,15 @@ if test "$PKG_CONFIG" = "no" ; then ifelse([$4], , [AC_MSG_ERROR([ - *** The pkg-config script could not be found. Make sure it is in your path, or give the full path to pkg-config with the PKG_CONFIG environment variable or --with-pkg-config-prog. Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config.])], [$4]) + *** The pkg-config script could not be found. Make sure it is in your path, or give the full name of pkg-config with the PKG_CONFIG environment variable or --with-pkg-config-prog. Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config.])], [$4]) else PKG_CONFIG_MIN_VERSION=0.9.0 - if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then + if "$PKG_CONFIG" --atleast-pkgconfig-version "$PKG_CONFIG_MIN_VERSION"; then AC_MSG_CHECKING(for $2) - if $PKG_CONFIG --exists "$2" 2>&AS_MESSAGE_LOG_FD && - $1_CFLAGS=`$PKG_CONFIG --cflags "$2" 2>&AS_MESSAGE_LOG_FD` && - $1_LIBS=`$PKG_CONFIG --libs "$2" 2>&AS_MESSAGE_LOG_FD`; then + if "$PKG_CONFIG" --exists "$2" 2>&AS_MESSAGE_LOG_FD && + $1_CFLAGS=`"$PKG_CONFIG" --cflags "$2" 2>&AS_MESSAGE_LOG_FD` && + $1_LIBS=`"$PKG_CONFIG" --libs "$2" 2>&AS_MESSAGE_LOG_FD`; then edit_cflags=" s,///*,/,g s/^/ / @@ -1212,7 +1217,7 @@ ## If we have a custom action on failure, don't print errors, but ## do set a variable so people can do so. Do it in a subshell ## to capture any diagnostics in invoking pkg-config. - $1_PKG_ERRORS=`($PKG_CONFIG --print-errors "$2") 2>&1` + $1_PKG_ERRORS=`("$PKG_CONFIG" --print-errors "$2") 2>&1` ifelse([$4], ,echo "$$1_PKG_ERRORS",) fi @@ -2027,7 +2032,7 @@ AC_DEFINE(USE_GTK, 1, [Define to 1 if using GTK.]) GTK_OBJ="gtkutil.o $GTK_OBJ" USE_X_TOOLKIT=none - if $PKG_CONFIG --atleast-version=2.10 gtk+-2.0; then + if "$PKG_CONFIG" --atleast-version=2.10 gtk+-2.0; then : else AC_MSG_WARN([[Your version of Gtk+ will have problems with @@ -4508,7 +4513,7 @@ dnl test/ is not present in release tarfiles. opt_makefile=test/automated/Makefile -if test -f $srcdir/${opt_makefile}.in; then +if test -f "$srcdir/$opt_makefile.in"; then SUBDIR_MAKEFILES="$SUBDIR_MAKEFILES $opt_makefile" dnl Again, it's best not to use a variable. Though you can add dnl ", [], [opt_makefile='$opt_makefile']" and it should work. @@ -4519,7 +4524,7 @@ dnl admin/ may or may not be present. opt_makefile=admin/unidata/Makefile -if test -f $srcdir/${opt_makefile}.in; then +if test -f "$srcdir/$opt_makefile.in"; then SUBDIR_MAKEFILES="$SUBDIR_MAKEFILES $opt_makefile" AC_CONFIG_FILES([admin/unidata/Makefile]) fi @@ -4550,9 +4555,9 @@ ], [GCC="$GCC" CPPFLAGS="$CPPFLAGS"]) AC_CONFIG_COMMANDS([gdbinit], [ -if test ! -f src/.gdbinit && test -f $srcdir/src/.gdbinit; then +if test ! -f src/.gdbinit && test -f "$srcdir/src/.gdbinit"; then echo creating src/.gdbinit - echo source $srcdir/src/.gdbinit > src/.gdbinit + echo "source '$srcdir/src/.gdbinit'" > src/.gdbinit fi ]) ------------------------------------------------------------ revno: 111161 fixes bug: http://debbugs.gnu.org/109 committer: Glenn Morris branch nick: trunk timestamp: Sat 2012-12-08 17:04:43 -0800 message: Make eval-defun on a pre-defined defcustom call any :set function * lisp/emacs-lisp/lisp-mode.el (eval-defun-1): Doc fix. Respect a defcustom's :set function, if appropriate. (eval-defun): Doc fix. * doc/lispref/customize.texi (Variable Definitions): Mention eval-defun on a defcustom calls the :set function when appropriate. * etc/NEWS: Mention this. diff: === modified file 'doc/lispref/ChangeLog' --- doc/lispref/ChangeLog 2012-12-06 08:33:32 +0000 +++ doc/lispref/ChangeLog 2012-12-09 01:04:43 +0000 @@ -1,3 +1,8 @@ +2012-12-09 Glenn Morris + + * customize.texi (Variable Definitions): Mention eval-defun + on a defcustom calls the :set function when appropriate. + 2012-12-06 Paul Eggert * doclicense.texi, gpl.texi: Update to latest version from FSF. === modified file 'doc/lispref/customize.texi' --- doc/lispref/customize.texi 2012-12-05 22:27:56 +0000 +++ doc/lispref/customize.texi 2012-12-09 01:04:43 +0000 @@ -308,8 +308,10 @@ When you evaluate a @code{defcustom} form with @kbd{C-M-x} in Emacs Lisp mode (@code{eval-defun}), a special feature of @code{eval-defun} arranges to set the variable unconditionally, without testing whether -its value is void. (The same feature applies to @code{defvar}.) -@xref{Defining Variables}. +its value is void. (The same feature applies to @code{defvar}, +@pxref{Defining Variables}.) Using @code{eval-defun} on a defcustom +that is already defined calls the @code{:set} function (see below), +if there is one. If you put a @code{defcustom} in a pre-loaded Emacs Lisp file (@pxref{Building Emacs}), the standard value installed at dump time === modified file 'etc/NEWS' --- etc/NEWS 2012-12-07 04:37:14 +0000 +++ etc/NEWS 2012-12-09 01:04:43 +0000 @@ -24,6 +24,11 @@ * Installation Changes in Emacs 24.4 * Startup Changes in Emacs 24.4 * Changes in Emacs 24.4 + ++++ +** `eval-defun' on an already defined defcustom calls the :set function, +if there is one. + * Editing Changes in Emacs 24.4 === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-12-08 23:12:08 +0000 +++ lisp/ChangeLog 2012-12-09 01:04:43 +0000 @@ -1,3 +1,9 @@ +2012-12-09 Glenn Morris + + * emacs-lisp/lisp-mode.el (eval-defun-1): Doc fix. + Respect a defcustom's :set function, if appropriate. (Bug#109) + (eval-defun): Doc fix. + 2012-12-08 Juri Linkov * info.el (Info-copy-current-node-name, Info-breadcrumbs) === modified file 'lisp/emacs-lisp/lisp-mode.el' --- lisp/emacs-lisp/lisp-mode.el 2012-12-01 05:09:12 +0000 +++ lisp/emacs-lisp/lisp-mode.el 2012-12-09 01:04:43 +0000 @@ -830,6 +830,7 @@ (defun eval-defun-1 (form) "Treat some expressions specially. Reset the `defvar' and `defcustom' variables to the initial value. +\(For `defcustom', use the :set function if there is one.) Reinitialize the face according to the `defface' specification." ;; The code in edebug-defun should be consistent with this, but not ;; the same, since this gets a macroexpanded form. @@ -845,14 +846,19 @@ ;; `custom-declare-variable' with a quoted value arg. ((and (eq (car form) 'custom-declare-variable) (default-boundp (eval (nth 1 form) lexical-binding))) - ;; Force variable to be bound. - (set-default (eval (nth 1 form) lexical-binding) - ;; The second arg is an expression that evaluates to - ;; an expression. The second evaluation is the one - ;; normally performed not be normal execution but by - ;; custom-initialize-set (for example), which does not - ;; use lexical-binding. - (eval (eval (nth 2 form) lexical-binding))) + ;; Force variable to be bound, using :set function if specified. + (let ((setfunc (memq :set form))) + (when setfunc + (setq setfunc (car-safe (cdr-safe setfunc))) + (or (functionp setfunc) (setq setfunc nil))) + (funcall (or setfunc 'set-default) + (eval (nth 1 form) lexical-binding) + ;; The second arg is an expression that evaluates to + ;; an expression. The second evaluation is the one + ;; normally performed not by normal execution but by + ;; custom-initialize-set (for example), which does not + ;; use lexical-binding. + (eval (eval (nth 2 form) lexical-binding)))) form) ;; `defface' is macroexpanded to `custom-declare-face'. ((eq (car form) 'custom-declare-face) @@ -915,11 +921,12 @@ If the current defun is actually a call to `defvar' or `defcustom', evaluating it this way resets the variable using its initial value -expression even if the variable already has some other value. -\(Normally `defvar' and `defcustom' do not alter the value if there -already is one.) In an analogous way, evaluating a `defface' -overrides any customizations of the face, so that it becomes -defined exactly as the `defface' expression says. +expression (using the defcustom's :set function if there is one), even +if the variable already has some other value. \(Normally `defvar' and +`defcustom' do not alter the value if there already is one.) In an +analogous way, evaluating a `defface' overrides any customizations of +the face, so that it becomes defined exactly as the `defface' expression +says. If `eval-expression-debug-on-error' is non-nil, which is the default, this command arranges for all errors to enter the debugger. ------------------------------------------------------------ revno: 111160 fixes bug: http://debbugs.gnu.org/13016 committer: Juri Linkov branch nick: trunk timestamp: Sun 2012-12-09 01:12:08 +0200 message: * lisp/info.el (Info-copy-current-node-name, Info-breadcrumbs) (Info-fontify-node, Info-bookmark-make-record): Remove the file extension from Info-current-file. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-12-07 16:48:42 +0000 +++ lisp/ChangeLog 2012-12-08 23:12:08 +0000 @@ -1,3 +1,9 @@ +2012-12-08 Juri Linkov + + * info.el (Info-copy-current-node-name, Info-breadcrumbs) + (Info-fontify-node, Info-bookmark-make-record): Remove the + file extension from Info-current-file (Bug#13016). + 2012-12-07 Stefan Monnier * hi-lock.el (hi-lock-unface-buffer): If there's no matching regexp at === modified file 'lisp/info.el' --- lisp/info.el 2012-12-07 15:31:43 +0000 +++ lisp/info.el 2012-12-08 23:12:08 +0000 @@ -4034,7 +4034,9 @@ (unless Info-current-node (user-error "No current Info node")) (let ((node (if (stringp Info-current-file) - (concat "(" (file-name-nondirectory Info-current-file) ") " + (concat "(" (file-name-sans-extension + (file-name-nondirectory Info-current-file)) + ") " Info-current-node)))) (if (zerop (prefix-numeric-value arg)) (setq node (concat "(info \"" node "\")"))) @@ -4421,7 +4423,8 @@ (if (not (equal node "Top")) node (format "(%s)Top" (if (stringp Info-current-file) - (file-name-nondirectory Info-current-file) + (file-name-sans-extension + (file-name-nondirectory Info-current-file)) ;; Some legacy code can still use a symbol. Info-current-file))))) (setq line (concat @@ -4533,7 +4536,8 @@ (if (re-search-forward (format "File: %s\\([^,\n\t]+\\)," (if (stringp Info-current-file) - (file-name-nondirectory Info-current-file) + (file-name-sans-extension + (file-name-nondirectory Info-current-file)) Info-current-file)) header-end t) (put-text-property (match-beginning 1) (match-end 1) @@ -5071,7 +5075,8 @@ "This implements the `bookmark-make-record-function' type (which see) for Info nodes." (let* ((file (and (stringp Info-current-file) - (file-name-nondirectory Info-current-file))) + (file-name-sans-extension + (file-name-nondirectory Info-current-file)))) (bookmark-name (if file (concat "(" file ") " Info-current-node) Info-current-node)) ------------------------------------------------------------ revno: 111159 fixes bug: http://debbugs.gnu.org/13070 committer: Eli Zaretskii branch nick: trunk timestamp: Sat 2012-12-08 20:27:37 +0200 message: Fix putenv and unsetenv on MS-Windows. src/w32.c (unsetenv): Return 0 if the input string is too long. nt/inc/ms-w32.h (sys_putenv): Add prototype. diff: === modified file 'nt/ChangeLog' --- nt/ChangeLog 2012-12-08 11:32:10 +0000 +++ nt/ChangeLog 2012-12-08 18:27:37 +0000 @@ -1,6 +1,7 @@ 2012-12-08 Eli Zaretskii * inc/ms-w32.h (putenv): Redirect to sys_putenv. + (sys_putenv): Add prototype. * config.nt (HAVE_UNSETENV): Define to 1. === modified file 'nt/inc/ms-w32.h' --- nt/inc/ms-w32.h 2012-12-08 11:32:10 +0000 +++ nt/inc/ms-w32.h 2012-12-08 18:27:37 +0000 @@ -381,6 +381,7 @@ # undef putenv #endif #define putenv sys_putenv +extern int sys_putenv (char *); extern int getloadavg (double *, int); extern int getpagesize (void); === modified file 'src/ChangeLog' --- src/ChangeLog 2012-12-08 17:19:51 +0000 +++ src/ChangeLog 2012-12-08 18:27:37 +0000 @@ -1,3 +1,7 @@ +2012-12-08 Eli Zaretskii + + * w32.c (unsetenv): Return 0 if the input string is too long. + 2012-12-08 Paul Eggert Use putenv+unsetenv instead of modifying environ directly (Bug#13070). === modified file 'src/w32.c' --- src/w32.c 2012-12-08 11:32:10 +0000 +++ src/w32.c 2012-12-08 18:27:37 +0000 @@ -1562,7 +1562,7 @@ if (name_len > 32767) { errno = ENOMEM; - return -1; + return 0; } /* It is safe to use 'alloca' with 32K size, since the stack is at least 2MB, and we set it to 8MB in the link command line. */ ------------------------------------------------------------ revno: 111158 fixes bug: http://debbugs.gnu.org/13070 committer: Paul Eggert branch nick: trunk timestamp: Sat 2012-12-08 09:19:51 -0800 message: 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. diff: === modified file 'ChangeLog' --- ChangeLog 2012-12-08 09:57:43 +0000 +++ ChangeLog 2012-12-08 17:19:51 +0000 @@ -1,3 +1,10 @@ +2012-12-08 Paul Eggert + + Use putenv+unsetenv instead of modifying environ directly (Bug#13070). + * 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. + 2012-12-08 Eli Zaretskii * lib/makefile.w32-in ($(BLD)/sig2str.$(O)): New dependency. === modified file 'admin/ChangeLog' --- admin/ChangeLog 2012-12-08 06:56:26 +0000 +++ admin/ChangeLog 2012-12-08 17:19:51 +0000 @@ -1,5 +1,8 @@ 2012-12-08 Paul Eggert + Use putenv+unsetenv instead of modifying environ directly (Bug#13070). + * merge-gnulib (GNULIB_MODULES): Add putenv, unsetenv. + Simplify get_lim_data. * CPP-DEFINES (ULIMIT_BREAK_VALUE): Remove. === modified file 'admin/merge-gnulib' --- admin/merge-gnulib 2012-12-08 02:30:51 +0000 +++ admin/merge-gnulib 2012-12-08 17:19:51 +0000 @@ -31,10 +31,10 @@ dtoastr dtotimespec dup2 environ execinfo faccessat fcntl-h filemode getloadavg getopt-gnu gettime gettimeofday ignore-value intprops largefile lstat - manywarnings mktime pselect pthread_sigmask readlink + manywarnings mktime pselect pthread_sigmask putenv readlink sig2str socklen stat-time stdalign stdarg stdbool stdio strftime strtoimax strtoumax symlink sys_stat - sys_time time timer-time timespec-add timespec-sub utimens + sys_time time timer-time timespec-add timespec-sub unsetenv utimens warnings ' === modified file 'lib/gnulib.mk' --- lib/gnulib.mk 2012-12-08 02:30:51 +0000 +++ lib/gnulib.mk 2012-12-08 17:19:51 +0000 @@ -21,7 +21,7 @@ # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=at-internal --avoid=errno --avoid=fchdir --avoid=fcntl --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=openat-die --avoid=openat-h --avoid=raise --avoid=save-cwd --avoid=select --avoid=sigprocmask --avoid=sys_types --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt c-ctype c-strcase careadlinkat close-stream crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl-h filemode getloadavg getopt-gnu gettime gettimeofday ignore-value intprops largefile lstat manywarnings mktime pselect pthread_sigmask readlink sig2str socklen stat-time stdalign stdarg stdbool stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timer-time timespec-add timespec-sub utimens warnings +# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=at-internal --avoid=errno --avoid=fchdir --avoid=fcntl --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=openat-die --avoid=openat-h --avoid=raise --avoid=save-cwd --avoid=select --avoid=sigprocmask --avoid=sys_types --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt c-ctype c-strcase careadlinkat close-stream crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl-h filemode getloadavg getopt-gnu gettime gettimeofday ignore-value intprops largefile lstat manywarnings mktime pselect pthread_sigmask putenv readlink sig2str socklen stat-time stdalign stdarg stdbool stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timer-time timespec-add timespec-sub unsetenv utimens warnings MOSTLYCLEANFILES += core *.stackdump @@ -439,6 +439,15 @@ ## end gnulib module pthread_sigmask +## begin gnulib module putenv + + +EXTRA_DIST += putenv.c + +EXTRA_libgnu_a_SOURCES += putenv.c + +## end gnulib module putenv + ## begin gnulib module readlink @@ -1409,6 +1418,15 @@ ## end gnulib module unistd +## begin gnulib module unsetenv + + +EXTRA_DIST += unsetenv.c + +EXTRA_libgnu_a_SOURCES += unsetenv.c + +## end gnulib module unsetenv + ## begin gnulib module utimens libgnu_a_SOURCES += utimens.c === added file 'lib/putenv.c' --- lib/putenv.c 1970-01-01 00:00:00 +0000 +++ lib/putenv.c 2012-12-08 17:19:51 +0000 @@ -0,0 +1,134 @@ +/* Copyright (C) 1991, 1994, 1997-1998, 2000, 2003-2012 Free Software + Foundation, Inc. + + NOTE: The canonical source of this file is maintained with the GNU C + Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu. + + 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 3 of the License, or 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, see . */ + +#include + +/* Specification. */ +#include + +#include + +/* Include errno.h *after* sys/types.h to work around header problems + on AIX 3.2.5. */ +#include +#ifndef __set_errno +# define __set_errno(ev) ((errno) = (ev)) +#endif + +#include +#include + +#if _LIBC +# if HAVE_GNU_LD +# define environ __environ +# else +extern char **environ; +# endif +#endif + +#if _LIBC +/* This lock protects against simultaneous modifications of 'environ'. */ +# include +__libc_lock_define_initialized (static, envlock) +# define LOCK __libc_lock_lock (envlock) +# define UNLOCK __libc_lock_unlock (envlock) +#else +# define LOCK +# define UNLOCK +#endif + +static int +_unsetenv (const char *name) +{ + size_t len; + char **ep; + + if (name == NULL || *name == '\0' || strchr (name, '=') != NULL) + { + __set_errno (EINVAL); + return -1; + } + + len = strlen (name); + + LOCK; + + ep = environ; + while (*ep != NULL) + if (!strncmp (*ep, name, len) && (*ep)[len] == '=') + { + /* Found it. Remove this pointer by moving later ones back. */ + char **dp = ep; + + do + dp[0] = dp[1]; + while (*dp++); + /* Continue the loop in case NAME appears again. */ + } + else + ++ep; + + UNLOCK; + + return 0; +} + + +/* Put STRING, which is of the form "NAME=VALUE", in the environment. + If STRING contains no '=', then remove STRING from the environment. */ +int +putenv (char *string) +{ + const char *const name_end = strchr (string, '='); + register size_t size; + register char **ep; + + if (name_end == NULL) + { + /* Remove the variable from the environment. */ + return _unsetenv (string); + } + + 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 ((void *) new_environ, (void *) environ, + size * sizeof (char *)); + new_environ[size] = (char *) string; + new_environ[size + 1] = NULL; + free (last_environ); + last_environ = new_environ; + environ = new_environ; + } + else + *ep = string; + + return 0; +} === added file 'lib/unsetenv.c' --- lib/unsetenv.c 1970-01-01 00:00:00 +0000 +++ lib/unsetenv.c 2012-12-08 17:19:51 +0000 @@ -0,0 +1,127 @@ +/* Copyright (C) 1992, 1995-2002, 2005-2012 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 3 of the License, 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, see . */ + +#include + +/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc + optimizes away the name == NULL test below. */ +#define _GL_ARG_NONNULL(params) + +/* Specification. */ +#include + +#include +#if !_LIBC +# define __set_errno(ev) ((errno) = (ev)) +#endif + +#include +#include + +#if !_LIBC +# define __environ environ +#endif + +#if _LIBC +/* This lock protects against simultaneous modifications of 'environ'. */ +# include +__libc_lock_define_initialized (static, envlock) +# define LOCK __libc_lock_lock (envlock) +# define UNLOCK __libc_lock_unlock (envlock) +#else +# define LOCK +# define UNLOCK +#endif + +/* In the GNU C library we must keep the namespace clean. */ +#ifdef _LIBC +# define unsetenv __unsetenv +#endif + +#if _LIBC || !HAVE_UNSETENV + +int +unsetenv (const char *name) +{ + size_t len; + char **ep; + + if (name == NULL || *name == '\0' || strchr (name, '=') != NULL) + { + __set_errno (EINVAL); + return -1; + } + + len = strlen (name); + + LOCK; + + ep = __environ; + while (*ep != NULL) + if (!strncmp (*ep, name, len) && (*ep)[len] == '=') + { + /* Found it. Remove this pointer by moving later ones back. */ + char **dp = ep; + + do + dp[0] = dp[1]; + while (*dp++); + /* Continue the loop in case NAME appears again. */ + } + else + ++ep; + + UNLOCK; + + return 0; +} + +#ifdef _LIBC +# undef unsetenv +weak_alias (__unsetenv, unsetenv) +#endif + +#else /* HAVE_UNSETENV */ + +# undef unsetenv +# if !HAVE_DECL_UNSETENV +# if VOID_UNSETENV +extern void unsetenv (const char *); +# else +extern int unsetenv (const char *); +# endif +# endif + +/* Call the underlying unsetenv, in case there is hidden bookkeeping + that needs updating beyond just modifying environ. */ +int +rpl_unsetenv (const char *name) +{ + int result = 0; + if (!name || !*name || strchr (name, '=')) + { + errno = EINVAL; + return -1; + } + while (getenv (name)) +# if !VOID_UNSETENV + result = +# endif + unsetenv (name); + return result; +} + +#endif /* HAVE_UNSETENV */ === modified file 'm4/gnulib-comp.m4' --- m4/gnulib-comp.m4 2012-12-08 02:30:51 +0000 +++ m4/gnulib-comp.m4 2012-12-08 17:19:51 +0000 @@ -85,6 +85,7 @@ # Code from module pathmax: # Code from module pselect: # Code from module pthread_sigmask: + # Code from module putenv: # Code from module readlink: # Code from module root-uid: # Code from module sig2str: @@ -126,6 +127,7 @@ # Code from module timespec-sub: # Code from module u64: # Code from module unistd: + # Code from module unsetenv: # Code from module utimens: # Code from module verify: # Code from module warnings: @@ -240,6 +242,11 @@ gl_PREREQ_PTHREAD_SIGMASK fi gl_SIGNAL_MODULE_INDICATOR([pthread_sigmask]) + gl_FUNC_PUTENV + if test $REPLACE_PUTENV = 1; then + AC_LIBOBJ([putenv]) + fi + gl_STDLIB_MODULE_INDICATOR([putenv]) gl_FUNC_READLINK if test $HAVE_READLINK = 0 || test $REPLACE_READLINK = 1; then AC_LIBOBJ([readlink]) @@ -297,6 +304,12 @@ gl_TIMER_TIME gl_TIMESPEC gl_UNISTD_H + gl_FUNC_UNSETENV + if test $HAVE_UNSETENV = 0 || test $REPLACE_UNSETENV = 1; then + AC_LIBOBJ([unsetenv]) + gl_PREREQ_UNSETENV + fi + gl_STDLIB_MODULE_INDICATOR([unsetenv]) gl_UTIMENS gl_gnulib_enabled_dosname=false gl_gnulib_enabled_euidaccess=false @@ -679,6 +692,7 @@ lib/pathmax.h lib/pselect.c lib/pthread_sigmask.c + lib/putenv.c lib/readlink.c lib/root-uid.h lib/sha1.c @@ -723,6 +737,7 @@ lib/u64.h lib/unistd.c lib/unistd.in.h + lib/unsetenv.c lib/utimens.c lib/utimens.h lib/verify.h @@ -764,7 +779,9 @@ m4/pathmax.m4 m4/pselect.m4 m4/pthread_sigmask.m4 + m4/putenv.m4 m4/readlink.m4 + m4/setenv.m4 m4/sha1.m4 m4/sha256.m4 m4/sha512.m4 === added file 'm4/putenv.m4' --- m4/putenv.m4 1970-01-01 00:00:00 +0000 +++ m4/putenv.m4 2012-12-08 17:19:51 +0000 @@ -0,0 +1,50 @@ +# putenv.m4 serial 19 +dnl Copyright (C) 2002-2012 Free Software Foundation, Inc. +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 +]) === added file 'm4/setenv.m4' --- m4/setenv.m4 1970-01-01 00:00:00 +0000 +++ m4/setenv.m4 2012-12-08 17:19:51 +0000 @@ -0,0 +1,160 @@ +# setenv.m4 serial 26 +dnl Copyright (C) 2001-2004, 2006-2012 Free Software Foundation, Inc. +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. + +AC_DEFUN([gl_FUNC_SETENV], +[ + AC_REQUIRE([gl_FUNC_SETENV_SEPARATE]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + if test $ac_cv_func_setenv = no; then + HAVE_SETENV=0 + else + AC_CACHE_CHECK([whether setenv validates arguments], + [gl_cv_func_setenv_works], + [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ + #include + #include + #include + ]], [[ + int result = 0; + { + if (setenv ("", "", 0) != -1) + result |= 1; + else if (errno != EINVAL) + result |= 2; + } + { + if (setenv ("a", "=", 1) != 0) + result |= 4; + else if (strcmp (getenv ("a"), "=") != 0) + result |= 8; + } + return result; + ]])], + [gl_cv_func_setenv_works=yes], [gl_cv_func_setenv_works=no], + [case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_setenv_works="guessing yes" ;; + # If we don't know, assume the worst. + *) gl_cv_func_setenv_works="guessing no" ;; + esac + ])]) + case "$gl_cv_func_setenv_works" in + *yes) ;; + *) + REPLACE_SETENV=1 + ;; + esac + fi +]) + +# Like gl_FUNC_SETENV, except prepare for separate compilation +# (no REPLACE_SETENV, no AC_LIBOBJ). +AC_DEFUN([gl_FUNC_SETENV_SEPARATE], +[ + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + AC_CHECK_DECLS_ONCE([setenv]) + if test $ac_cv_have_decl_setenv = no; then + HAVE_DECL_SETENV=0 + fi + AC_CHECK_FUNCS_ONCE([setenv]) + gl_PREREQ_SETENV +]) + +AC_DEFUN([gl_FUNC_UNSETENV], +[ + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CHECK_DECLS_ONCE([unsetenv]) + if test $ac_cv_have_decl_unsetenv = no; then + HAVE_DECL_UNSETENV=0 + fi + AC_CHECK_FUNCS([unsetenv]) + if test $ac_cv_func_unsetenv = no; then + HAVE_UNSETENV=0 + else + HAVE_UNSETENV=1 + dnl Some BSDs return void, failing to do error checking. + AC_CACHE_CHECK([for unsetenv() return type], [gt_cv_func_unsetenv_ret], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ +#undef _BSD +#define _BSD 1 /* unhide unsetenv declaration in OSF/1 5.1 */ +#include +extern +#ifdef __cplusplus +"C" +#endif +int unsetenv (const char *name); + ]], + [[]])], + [gt_cv_func_unsetenv_ret='int'], + [gt_cv_func_unsetenv_ret='void'])]) + if test $gt_cv_func_unsetenv_ret = 'void'; then + AC_DEFINE([VOID_UNSETENV], [1], [Define to 1 if unsetenv returns void + instead of int.]) + REPLACE_UNSETENV=1 + fi + + dnl Solaris 10 unsetenv does not remove all copies of a name. + dnl Haiku alpha 2 unsetenv gets confused by assignment to environ. + dnl OpenBSD 4.7 unsetenv("") does not fail. + AC_CACHE_CHECK([whether unsetenv obeys POSIX], + [gl_cv_func_unsetenv_works], + [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ + #include + #include + extern char **environ; + ]], [[ + char entry1[] = "a=1"; + char entry2[] = "b=2"; + char *env[] = { entry1, entry2, NULL }; + if (putenv ((char *) "a=1")) return 1; + if (putenv (entry2)) return 2; + entry2[0] = 'a'; + unsetenv ("a"); + if (getenv ("a")) return 3; + if (!unsetenv ("") || errno != EINVAL) return 4; + entry2[0] = 'b'; + environ = env; + if (!getenv ("a")) return 5; + entry2[0] = 'a'; + unsetenv ("a"); + if (getenv ("a")) return 6; + ]])], + [gl_cv_func_unsetenv_works=yes], [gl_cv_func_unsetenv_works=no], + [case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_unsetenv_works="guessing yes" ;; + # If we don't know, assume the worst. + *) gl_cv_func_unsetenv_works="guessing no" ;; + esac + ])]) + case "$gl_cv_func_unsetenv_works" in + *yes) ;; + *) + REPLACE_UNSETENV=1 + ;; + esac + fi +]) + +# Prerequisites of lib/setenv.c. +AC_DEFUN([gl_PREREQ_SETENV], +[ + AC_REQUIRE([AC_FUNC_ALLOCA]) + AC_REQUIRE([gl_ENVIRON]) + AC_CHECK_HEADERS_ONCE([unistd.h]) + AC_CHECK_HEADERS([search.h]) + AC_CHECK_FUNCS([tsearch]) +]) + +# Prerequisites of lib/unsetenv.c. +AC_DEFUN([gl_PREREQ_UNSETENV], +[ + AC_REQUIRE([gl_ENVIRON]) + AC_CHECK_HEADERS_ONCE([unistd.h]) +]) === modified file 'src/ChangeLog' --- src/ChangeLog 2012-12-08 12:11:29 +0000 +++ src/ChangeLog 2012-12-08 17:19:51 +0000 @@ -1,3 +1,29 @@ +2012-12-08 Paul Eggert + + Use putenv+unsetenv instead of modifying environ directly (Bug#13070). + * alloc.c (xputenv): New function. + * dbusbind.c (Fdbus_init_bus): + * emacs.c (main): + * xterm.c (x_term_init): + Use xputenv instead of setenv or putenv, to detect memory exhaustion. + * 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. + * emacs.c (dump_tz) [HAVE_TZSET]: Now const. + * lisp.h (xputenv): New decl. + 2012-12-08 Fabrice Popineau * w32fns.c (emacs_abort): Don't do arithmetics on void pointers. === modified file 'src/alloc.c' --- src/alloc.c 2012-12-03 08:06:02 +0000 +++ src/alloc.c 2012-12-08 17:19:51 +0000 @@ -820,6 +820,15 @@ return p; } +/* Like putenv, but (1) use the equivalent of xmalloc and (2) the + argument is a const pointer. */ + +void +xputenv (char const *string) +{ + if (putenv ((char *) string) != 0) + memory_full (0); +} /* Unwind for SAFE_ALLOCA */ === modified file 'src/dbusbind.c' --- src/dbusbind.c 2012-10-31 11:45:40 +0000 +++ src/dbusbind.c 2012-12-08 17:19:51 +0000 @@ -1203,7 +1203,7 @@ xd_registered_buses = Fcons (Fcons (bus, val), xd_registered_buses); /* We do not want to abort. */ - putenv ((char *) "DBUS_FATAL_WARNINGS=0"); + xputenv ("DBUS_FATAL_WARNINGS=0"); /* Cleanup. */ dbus_error_free (&derror); === modified file 'src/editfns.c' --- src/editfns.c 2012-12-08 11:05:39 +0000 +++ src/editfns.c 2012-12-08 17:19:51 +0000 @@ -78,6 +78,15 @@ static Lisp_Object Qboundary; +/* The startup value of the TZ environment variable so it can be + restored if the user calls set-time-zone-rule with a nil + argument. If null, the TZ environment variable was unset. */ +static char const *initial_tz; + +/* True if the static variable tzvalbuf (defined in + set_time_zone_rule) is part of 'environ'. */ +static bool tzvalbuf_in_environ; + void init_editfns (void) @@ -96,6 +105,9 @@ return; #endif /* not CANNOT_DUMP */ + initial_tz = getenv ("TZ"); + tzvalbuf_in_environ = 0; + pw = getpwuid (getuid ()); #ifdef MSDOS /* We let the real user name default to "root" because that's quite @@ -1900,9 +1912,11 @@ } else { - char tzbuf[100]; + static char const tzbuf_format[] = "XXX%s%"pI"d:%02d:%02d"; + char tzbuf[sizeof tzbuf_format + INT_STRLEN_BOUND (EMACS_INT)]; + char *old_tzstring; const char *tzstring; - char **oldenv = environ, **newenv; + USE_SAFE_ALLOCA; if (EQ (zone, Qt)) tzstring = "UTC0"; @@ -1914,13 +1928,20 @@ EMACS_INT zone_hr = abszone / (60*60); int zone_min = (abszone/60) % 60; int zone_sec = abszone % 60; - sprintf (tzbuf, "XXX%s%"pI"d:%02d:%02d", "-" + (XINT (zone) < 0), + sprintf (tzbuf, tzbuf_format, "-" + (XINT (zone) < 0), zone_hr, zone_min, zone_sec); tzstring = tzbuf; } else error ("Invalid time zone specification"); + old_tzstring = getenv ("TZ"); + if (old_tzstring) + { + char *buf = SAFE_ALLOCA (strlen (old_tzstring) + 1); + old_tzstring = strcpy (buf, old_tzstring); + } + block_input (); /* Set TZ before calling mktime; merely adjusting mktime's returned @@ -1929,15 +1950,12 @@ value = mktime (&tm); - /* Restore TZ to previous value. */ - newenv = environ; - environ = oldenv; + set_time_zone_rule (old_tzstring); #ifdef LOCALTIME_CACHE tzset (); #endif unblock_input (); - - xfree (newenv); + SAFE_FREE (); } if (value == (time_t) -1) @@ -2067,16 +2085,6 @@ return list2 (zone_offset, zone_name); } -/* This holds the value of `environ' produced by the previous - call to Fset_time_zone_rule, or 0 if Fset_time_zone_rule - has never been called. */ -static char **environbuf; - -/* This holds the startup value of the TZ environment variable so it - can be restored if the user calls set-time-zone-rule with a nil - argument. */ -static char *initial_tz; - DEFUN ("set-time-zone-rule", Fset_time_zone_rule, Sset_time_zone_rule, 1, 1, 0, doc: /* Set the local time zone using TZ, a string specifying a time zone rule. If TZ is nil, use implementation-defined default time zone information. @@ -2089,18 +2097,10 @@ (Lisp_Object tz) { const char *tzstring; - char **old_environbuf; if (! (NILP (tz) || EQ (tz, Qt))) CHECK_STRING (tz); - block_input (); - - /* When called for the first time, save the original TZ. */ - old_environbuf = environbuf; - if (!old_environbuf) - initial_tz = (char *) getenv ("TZ"); - if (NILP (tz)) tzstring = initial_tz; else if (EQ (tz, Qt)) @@ -2108,106 +2108,97 @@ else tzstring = SSDATA (tz); + block_input (); set_time_zone_rule (tzstring); - environbuf = environ; - unblock_input (); - xfree (old_environbuf); return Qnil; } -#ifdef LOCALTIME_CACHE - -/* These two values are known to load tz files in buggy implementations, - i.e. Solaris 1 executables running under either Solaris 1 or Solaris 2. - Their values shouldn't matter in non-buggy implementations. - We don't use string literals for these strings, - since if a string in the environment is in readonly - storage, it runs afoul of bugs in SVR4 and Solaris 2.3. - See Sun bugs 1113095 and 1114114, ``Timezone routines - improperly modify environment''. */ - -static char set_time_zone_rule_tz1[] = "TZ=GMT+0"; -static char set_time_zone_rule_tz2[] = "TZ=GMT+1"; - -#endif - /* Set the local time zone rule to TZSTRING. - This allocates memory into `environ', which it is the caller's - responsibility to free. */ + + This function is not thread-safe, partly because putenv, unsetenv + and tzset are not, and partly because of the static storage it + updates. Other threads that invoke localtime etc. may be adversely + affected while this function is executing. */ void set_time_zone_rule (const char *tzstring) { - ptrdiff_t envptrs; - char **from, **to, **newenv; - - /* Make the ENVIRON vector longer with room for TZSTRING. */ - for (from = environ; *from; from++) - continue; - envptrs = from - environ + 2; - newenv = to = xmalloc (envptrs * sizeof *newenv - + (tzstring ? strlen (tzstring) + 4 : 0)); - - /* Add TZSTRING to the end of environ, as a value for TZ. */ + /* A buffer holding a string of the form "TZ=value", intended + to be part of the environment. */ + static char *tzvalbuf; + static ptrdiff_t tzvalbufsize; + + int tzeqlen = sizeof "TZ=" - 1; + +#ifdef LOCALTIME_CACHE + /* These two values are known to load tz files in buggy implementations, + i.e., Solaris 1 executables running under either Solaris 1 or Solaris 2. + Their values shouldn't matter in non-buggy implementations. + We don't use string literals for these strings, + since if a string in the environment is in readonly + storage, it runs afoul of bugs in SVR4 and Solaris 2.3. + See Sun bugs 1113095 and 1114114, ``Timezone routines + improperly modify environment''. */ + + static char set_time_zone_rule_tz[][sizeof "TZ=GMT+0"] + = { "TZ=GMT+0", "TZ=GMT+1" }; + + /* In SunOS 4.1.3_U1 and 4.1.4, if TZ has a value like + "US/Pacific" that loads a tz file, then changes to a value like + "XXX0" that does not load a tz file, and then changes back to + its original value, the last change is (incorrectly) ignored. + Also, if TZ changes twice in succession to values that do + not load a tz file, tzset can dump core (see Sun bug#1225179). + The following code works around these bugs. */ + if (tzstring) { - char *t = (char *) (to + envptrs); - strcpy (t, "TZ="); - strcat (t, tzstring); - *to++ = t; - } - - /* Copy the old environ vector elements into NEWENV, - but don't copy the TZ variable. - So we have only one definition of TZ, which came from TZSTRING. */ - for (from = environ; *from; from++) - if (strncmp (*from, "TZ=", 3) != 0) - *to++ = *from; - *to = 0; - - environ = newenv; - - /* If we do have a TZSTRING, NEWENV points to the vector slot where - the TZ variable is stored. If we do not have a TZSTRING, - TO points to the vector slot which has the terminating null. */ + /* Temporarily set TZ to a value that loads a tz file + and that differs from tzstring. */ + bool eq0 = strcmp (tzstring, set_time_zone_rule_tz[0] + tzeqlen) == 0; + xputenv (set_time_zone_rule_tz[eq0]); + } + else + { + /* The implied tzstring is unknown, so temporarily set TZ to + two different values that each load a tz file. */ + xputenv (set_time_zone_rule_tz[0]); + tzset (); + xputenv (set_time_zone_rule_tz[1]); + } + tzset (); +#endif + + if (!tzstring) + { + unsetenv ("TZ"); + tzvalbuf_in_environ = 0; + } + else + { + ptrdiff_t tzstringlen = strlen (tzstring); + + if (tzvalbufsize <= tzeqlen + tzstringlen) + { + unsetenv ("TZ"); + tzvalbuf_in_environ = 0; + tzvalbuf = xpalloc (tzvalbuf, &tzvalbufsize, + tzeqlen + tzstringlen - tzvalbufsize + 1, -1, 1); + memcpy (tzvalbuf, "TZ=", tzeqlen); + } + + strcpy (tzvalbuf + tzeqlen, tzstring); + + if (!tzvalbuf_in_environ) + { + xputenv (tzvalbuf); + tzvalbuf_in_environ = 1; + } + } #ifdef LOCALTIME_CACHE - { - /* In SunOS 4.1.3_U1 and 4.1.4, if TZ has a value like - "US/Pacific" that loads a tz file, then changes to a value like - "XXX0" that does not load a tz file, and then changes back to - its original value, the last change is (incorrectly) ignored. - Also, if TZ changes twice in succession to values that do - not load a tz file, tzset can dump core (see Sun bug#1225179). - The following code works around these bugs. */ - - if (tzstring) - { - /* Temporarily set TZ to a value that loads a tz file - and that differs from tzstring. */ - char *tz = *newenv; - *newenv = (strcmp (tzstring, set_time_zone_rule_tz1 + 3) == 0 - ? set_time_zone_rule_tz2 : set_time_zone_rule_tz1); - tzset (); - *newenv = tz; - } - else - { - /* The implied tzstring is unknown, so temporarily set TZ to - two different values that each load a tz file. */ - *to = set_time_zone_rule_tz1; - to[1] = 0; - tzset (); - *to = set_time_zone_rule_tz2; - tzset (); - *to = 0; - } - - /* Now TZ has the desired value, and tzset can be invoked safely. */ - } - tzset (); #endif } @@ -4800,9 +4791,6 @@ void syms_of_editfns (void) { - environbuf = 0; - initial_tz = 0; - DEFSYM (Qbuffer_access_fontify_functions, "buffer-access-fontify-functions"); DEFVAR_LISP ("inhibit-field-text-motion", Vinhibit_field_text_motion, === modified file 'src/emacs.c' --- src/emacs.c 2012-11-21 04:47:55 +0000 +++ src/emacs.c 2012-12-08 17:19:51 +0000 @@ -535,7 +535,7 @@ #ifdef HAVE_TZSET /* A valid but unlikely value for the TZ environment value. It is OK (though a bit slower) if the user actually chooses this value. */ -static char dump_tz[] = "UtC0"; +static char const dump_tz[] = "UtC0"; #endif #ifndef ORDINARY_LINK @@ -717,7 +717,7 @@ #ifdef G_SLICE_ALWAYS_MALLOC /* This is used by the Cygwin build. */ - setenv ("G_SLICE", "always-malloc", 1); + xputenv ("G_SLICE=always-malloc"); #endif #ifdef GNU_LINUX @@ -803,9 +803,8 @@ #ifdef HAVE_PERSONALITY_LINUX32 if (dumping && ! getenv ("EMACS_HEAP_EXEC")) { - static char heapexec[] = "EMACS_HEAP_EXEC=true"; /* Set this so we only do this once. */ - putenv (heapexec); + xputenv ("EMACS_HEAP_EXEC=true"); /* A flag to turn off address randomization which is introduced in linux kernel shipped with fedora core 4 */ @@ -1309,7 +1308,7 @@ don't pollute Vglobal_environment. */ /* Setting LANG here will defeat the startup locale processing... */ #ifdef AIX - putenv ("LANG=C"); + xputenv ("LANG=C"); #endif init_buffer (); /* Init default directory of main buffer. */ === modified file 'src/lisp.h' --- src/lisp.h 2012-12-04 15:15:30 +0000 +++ src/lisp.h 2012-12-08 17:19:51 +0000 @@ -3594,6 +3594,7 @@ extern void *xpalloc (void *, ptrdiff_t *, ptrdiff_t, ptrdiff_t, ptrdiff_t); extern char *xstrdup (const char *); +extern void xputenv (const char *); extern char *egetenv (const char *); === modified file 'src/xterm.c' --- src/xterm.c 2012-12-04 15:15:30 +0000 +++ src/xterm.c 2012-12-08 17:19:51 +0000 @@ -9908,10 +9908,7 @@ /* Emacs can only handle core input events, so make sure Gtk doesn't use Xinput or Xinput2 extensions. */ - { - static char fix_events[] = "GDK_CORE_DEVICE_EVENTS=1"; - putenv (fix_events); - } + xputenv ("GDK_CORE_DEVICE_EVENTS=1"); /* Work around GLib bug that outputs a faulty warning. See https://bugzilla.gnome.org/show_bug.cgi?id=563627. */ ------------------------------------------------------------ revno: 111157 author: Fabrice Popineau committer: Eli Zaretskii branch nick: trunk timestamp: Sat 2012-12-08 14:11:29 +0200 message: w32fns.c (emacs_abort): Don't do arithmetics on void pointers. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2012-12-08 11:32:10 +0000 +++ src/ChangeLog 2012-12-08 12:11:29 +0000 @@ -1,3 +1,7 @@ +2012-12-08 Fabrice Popineau + + * w32fns.c (emacs_abort): Don't do arithmetics on void pointers. + 2012-12-08 Eli Zaretskii * w32.c (unsetenv, sys_putenv): New functions. === modified file 'src/w32fns.c' --- src/w32fns.c 2012-12-06 13:48:11 +0000 +++ src/w32fns.c 2012-12-08 12:11:29 +0000 @@ -7784,7 +7784,7 @@ /* stack[] gives the return addresses, whereas we want the address of the call, so decrease each address by approximate size of 1 CALL instruction. */ - sprintf (buf, "0x%p\r\n", stack[j] - sizeof(void *)); + sprintf (buf, "0x%p\r\n", (char *)stack[j] - sizeof(void *)); if (stderr_fd >= 0) write (stderr_fd, buf, strlen (buf)); if (errfile_fd >= 0) ------------------------------------------------------------ revno: 111156 fixes bug: http://debbugs.gnu.org/13070 committer: Eli Zaretskii branch nick: trunk timestamp: Sat 2012-12-08 13:32:10 +0200 message: Provide unsetenv for MS-Windows and make putenv Posix-compatible. src/w32.c (unsetenv, sys_putenv): New functions. nt/inc/ms-w32.h (putenv): Redirect to sys_putenv. nt/config.nt (HAVE_UNSETENV): Define to 1. diff: === modified file 'nt/ChangeLog' --- nt/ChangeLog 2012-12-01 20:09:30 +0000 +++ nt/ChangeLog 2012-12-08 11:32:10 +0000 @@ -1,3 +1,9 @@ +2012-12-08 Eli Zaretskii + + * inc/ms-w32.h (putenv): Redirect to sys_putenv. + + * config.nt (HAVE_UNSETENV): Define to 1. + 2012-12-01 Juanma Barranquero * config.nt: Sync with autogen/config.in. === modified file 'nt/config.nt' --- nt/config.nt 2012-12-01 20:09:30 +0000 +++ nt/config.nt 2012-12-08 11:32:10 +0000 @@ -993,6 +993,9 @@ /* Define to 1 if the system has the type 'unsigned long long int'. */ #undef HAVE_UNSIGNED_LONG_LONG_INT +/* Define to 1 if you have the `unsetenv' function. */ +#define HAVE_UNSETENV 1 + /* Define to 1 if you have the header file. */ #undef HAVE_UTIL_H === modified file 'nt/inc/ms-w32.h' --- nt/inc/ms-w32.h 2012-11-27 03:10:32 +0000 +++ nt/inc/ms-w32.h 2012-12-08 11:32:10 +0000 @@ -376,6 +376,12 @@ #define sys_nerr _sys_nerr #endif +/* This must be after including stdlib.h, which defines putenv on MinGW. */ +#ifdef putenv +# undef putenv +#endif +#define putenv sys_putenv + extern int getloadavg (double *, int); extern int getpagesize (void); === modified file 'src/ChangeLog' --- src/ChangeLog 2012-12-08 11:05:39 +0000 +++ src/ChangeLog 2012-12-08 11:32:10 +0000 @@ -1,3 +1,7 @@ +2012-12-08 Eli Zaretskii + + * w32.c (unsetenv, sys_putenv): New functions. + 2012-12-08 Chong Yidong * editfns.c (Finsert_char): Make the error message more === modified file 'src/w32.c' --- src/w32.c 2012-12-03 01:08:31 +0000 +++ src/w32.c 2012-12-08 11:32:10 +0000 @@ -1544,6 +1544,50 @@ return 1; } +/* Emulate the Posix unsetenv. */ +int +unsetenv (const char *name) +{ + char *var; + size_t name_len; + int retval; + + if (name == NULL || *name == '\0' || strchr (name, '=') != NULL) + { + errno = EINVAL; + return -1; + } + name_len = strlen (name); + /* MS docs says an environment variable cannot be longer than 32K. */ + if (name_len > 32767) + { + errno = ENOMEM; + return -1; + } + /* It is safe to use 'alloca' with 32K size, since the stack is at + least 2MB, and we set it to 8MB in the link command line. */ + var = alloca (name_len + 2); + var[name_len++] = '='; + var[name_len] = '\0'; + return _putenv (var); +} + +/* MS _putenv doesn't support removing a variable when the argument + does not include the '=' character, so we fix that here. */ +int +sys_putenv (char *str) +{ + const char *const name_end = strchr (str, '='); + + if (name_end == NULL) + { + /* Remove the variable from the environment. */ + return unsetenv (str); + } + + return _putenv (str); +} + #define REG_ROOT "SOFTWARE\\GNU\\Emacs" LPBYTE ------------------------------------------------------------ revno: 111155 committer: Glenn Morris branch nick: trunk timestamp: Sat 2012-12-08 06:17:32 -0500 message: Auto-commit of generated files. diff: === modified file 'autogen/Makefile.in' --- autogen/Makefile.in 2012-12-01 11:17:32 +0000 +++ autogen/Makefile.in 2012-12-08 11:17:32 +0000 @@ -36,7 +36,7 @@ # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=at-internal --avoid=errno --avoid=fchdir --avoid=fcntl --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=openat-die --avoid=openat-h --avoid=raise --avoid=save-cwd --avoid=select --avoid=sigprocmask --avoid=sys_types --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt c-ctype c-strcase careadlinkat close-stream crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl-h filemode getloadavg getopt-gnu gettime gettimeofday ignore-value intprops largefile lstat manywarnings mktime pselect pthread_sigmask readlink socklen stat-time stdalign stdarg stdbool stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timer-time timespec-add timespec-sub utimens warnings +# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=at-internal --avoid=errno --avoid=fchdir --avoid=fcntl --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=openat-die --avoid=openat-h --avoid=raise --avoid=save-cwd --avoid=select --avoid=sigprocmask --avoid=sys_types --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt c-ctype c-strcase careadlinkat close-stream crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl-h filemode getloadavg getopt-gnu gettime gettimeofday ignore-value intprops largefile lstat manywarnings mktime pselect pthread_sigmask readlink sig2str socklen stat-time stdalign stdarg stdbool stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timer-time timespec-add timespec-sub utimens warnings VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ @@ -87,16 +87,17 @@ $(top_srcdir)/m4/pthread_sigmask.m4 \ $(top_srcdir)/m4/readlink.m4 $(top_srcdir)/m4/sha1.m4 \ $(top_srcdir)/m4/sha256.m4 $(top_srcdir)/m4/sha512.m4 \ - $(top_srcdir)/m4/signal_h.m4 $(top_srcdir)/m4/socklen.m4 \ - $(top_srcdir)/m4/ssize_t.m4 $(top_srcdir)/m4/st_dm_mode.m4 \ - $(top_srcdir)/m4/stat-time.m4 $(top_srcdir)/m4/stat.m4 \ - $(top_srcdir)/m4/stdalign.m4 $(top_srcdir)/m4/stdarg.m4 \ - $(top_srcdir)/m4/stdbool.m4 $(top_srcdir)/m4/stddef_h.m4 \ - $(top_srcdir)/m4/stdint.m4 $(top_srcdir)/m4/stdio_h.m4 \ - $(top_srcdir)/m4/stdlib_h.m4 $(top_srcdir)/m4/strftime.m4 \ - $(top_srcdir)/m4/strtoimax.m4 $(top_srcdir)/m4/strtoll.m4 \ - $(top_srcdir)/m4/strtoull.m4 $(top_srcdir)/m4/strtoumax.m4 \ - $(top_srcdir)/m4/symlink.m4 $(top_srcdir)/m4/sys_select_h.m4 \ + $(top_srcdir)/m4/sig2str.m4 $(top_srcdir)/m4/signal_h.m4 \ + $(top_srcdir)/m4/socklen.m4 $(top_srcdir)/m4/ssize_t.m4 \ + $(top_srcdir)/m4/st_dm_mode.m4 $(top_srcdir)/m4/stat-time.m4 \ + $(top_srcdir)/m4/stat.m4 $(top_srcdir)/m4/stdalign.m4 \ + $(top_srcdir)/m4/stdarg.m4 $(top_srcdir)/m4/stdbool.m4 \ + $(top_srcdir)/m4/stddef_h.m4 $(top_srcdir)/m4/stdint.m4 \ + $(top_srcdir)/m4/stdio_h.m4 $(top_srcdir)/m4/stdlib_h.m4 \ + $(top_srcdir)/m4/strftime.m4 $(top_srcdir)/m4/strtoimax.m4 \ + $(top_srcdir)/m4/strtoll.m4 $(top_srcdir)/m4/strtoull.m4 \ + $(top_srcdir)/m4/strtoumax.m4 $(top_srcdir)/m4/symlink.m4 \ + $(top_srcdir)/m4/sys_select_h.m4 \ $(top_srcdir)/m4/sys_socket_h.m4 \ $(top_srcdir)/m4/sys_stat_h.m4 $(top_srcdir)/m4/sys_time_h.m4 \ $(top_srcdir)/m4/time_h.m4 $(top_srcdir)/m4/time_r.m4 \ @@ -888,7 +889,8 @@ getopt_int.h gettimeofday.c group-member.c ignore-value.h \ intprops.h inttypes.in.h lstat.c mktime-internal.h mktime.c \ pathmax.h pselect.c pthread_sigmask.c readlink.c root-uid.h \ - signal.in.h $(top_srcdir)/build-aux/snippet/_Noreturn.h \ + sig2str.c sig2str.h signal.in.h \ + $(top_srcdir)/build-aux/snippet/_Noreturn.h \ $(top_srcdir)/build-aux/snippet/arg-nonnull.h \ $(top_srcdir)/build-aux/snippet/c++defs.h \ $(top_srcdir)/build-aux/snippet/warn-on-use.h stat.c \ @@ -922,9 +924,9 @@ EXTRA_libgnu_a_SOURCES = ftoastr.c dup2.c euidaccess.c execinfo.c \ at-func.c faccessat.c fpending.c getgroups.c getloadavg.c \ getopt.c getopt1.c gettimeofday.c group-member.c lstat.c \ - mktime.c pselect.c pthread_sigmask.c readlink.c stat.c \ - strtoimax.c strtol.c strtoll.c strtol.c strtoul.c strtoull.c \ - strtoimax.c strtoumax.c symlink.c time_r.c + mktime.c pselect.c pthread_sigmask.c readlink.c sig2str.c \ + stat.c strtoimax.c strtol.c strtoll.c strtol.c strtoul.c \ + strtoull.c strtoimax.c strtoumax.c symlink.c time_r.c # Because this Makefile snippet defines a variable used by other # gnulib Makefile snippets, it must be present in all Makefile.am that @@ -1014,6 +1016,7 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sha1.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sha256.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sha512.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sig2str.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stat-time.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stdio.Po@am__quote@ === modified file 'autogen/aclocal.m4' --- autogen/aclocal.m4 2012-11-14 11:17:36 +0000 +++ autogen/aclocal.m4 2012-12-08 11:17:32 +0000 @@ -1025,6 +1025,7 @@ m4_include([m4/sha1.m4]) m4_include([m4/sha256.m4]) m4_include([m4/sha512.m4]) +m4_include([m4/sig2str.m4]) m4_include([m4/signal_h.m4]) m4_include([m4/socklen.m4]) m4_include([m4/ssize_t.m4]) === modified file 'autogen/config.in' --- autogen/config.in 2012-12-01 11:17:32 +0000 +++ autogen/config.in 2012-12-08 11:17:32 +0000 @@ -784,6 +784,9 @@ /* Define to 1 if you have the `shutdown' function. */ #undef HAVE_SHUTDOWN +/* Define to 1 if you have the `sig2str' function. */ +#undef HAVE_SIG2STR + /* Define to 1 if 'sig_atomic_t' is a signed integer type. */ #undef HAVE_SIGNED_SIG_ATOMIC_T @@ -1328,9 +1331,6 @@ timespec. */ #undef TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC -/* Undocumented. */ -#undef ULIMIT_BREAK_VALUE - /* Define to 1 for Encore UMAX. */ #undef UMAX === modified file 'autogen/configure' --- autogen/configure 2012-12-06 11:17:45 +0000 +++ autogen/configure 2012-12-08 11:17:32 +0000 @@ -7026,6 +7026,7 @@ # Code from module pthread_sigmask: # Code from module readlink: # Code from module root-uid: + # Code from module sig2str: # Code from module signal-h: # Code from module snippet/_Noreturn: # Code from module snippet/arg-nonnull: @@ -15300,7 +15301,7 @@ $as_echo "#define FIRST_PTY_LETTER 'q'" >>confdefs.h - $as_echo "#define PTY_OPEN { struct sigaction ocstat, cstat; struct stat stb; char * name; sigemptyset(&cstat.sa_mask); cstat.sa_handler = SIG_DFL; cstat.sa_flags = 0; sigaction(SIGCLD, &cstat, &ocstat); name = _getpty (&fd, O_RDWR | O_NDELAY, 0600, 0); sigaction(SIGCLD, &ocstat, (struct sigaction *)0); if (name == 0) return -1; if (fd < 0) return -1; if (fstat (fd, &stb) < 0) return -1; strcpy (pty_name, name); }" >>confdefs.h + $as_echo "#define PTY_OPEN { struct sigaction ocstat, cstat; struct stat stb; char * name; sigemptyset(&cstat.sa_mask); cstat.sa_handler = SIG_DFL; cstat.sa_flags = 0; sigaction(SIGCHLD, &cstat, &ocstat); name = _getpty (&fd, O_RDWR | O_NDELAY, 0600, 0); sigaction(SIGCHLD, &ocstat, (struct sigaction *)0); if (name == 0) return -1; if (fd < 0) return -1; if (fstat (fd, &stb) < 0) return -1; strcpy (pty_name, name); }" >>confdefs.h $as_echo "#define PTY_NAME_SPRINTF /**/" >>confdefs.h @@ -15309,12 +15310,12 @@ ;; sol2* ) - $as_echo "#define PTY_TTY_NAME_SPRINTF { char *ptsname (int), *ptyname; int grantpt_result; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); grantpt_result = grantpt (fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (grantpt_result == -1 || unlockpt (fd) == -1 || !(ptyname = ptsname (fd))) { emacs_close (fd); return -1; } snprintf (pty_name, sizeof pty_name, \"%s\", ptyname); }" >>confdefs.h + $as_echo "#define PTY_TTY_NAME_SPRINTF { char *ptsname (int), *ptyname; int grantpt_result; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); grantpt_result = grantpt (fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (grantpt_result == -1 || unlockpt (fd) == -1 || !(ptyname = ptsname (fd))) { emacs_close (fd); return -1; } snprintf (pty_name, sizeof pty_name, \"%s\", ptyname); }" >>confdefs.h ;; unixware ) - $as_echo "#define PTY_TTY_NAME_SPRINTF { char *ptsname (int), *ptyname; int grantpt_result; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); grantpt_result = grantpt (fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (grantpt_result == -1) fatal(\"could not grant slave pty\"); if (unlockpt(fd) == -1) fatal(\"could not unlock slave pty\"); if (!(ptyname = ptsname(fd))) fatal (\"could not enable slave pty\"); snprintf (pty_name, sizeof pty_name, \"%s\", ptyname); }" >>confdefs.h + $as_echo "#define PTY_TTY_NAME_SPRINTF { char *ptsname (int), *ptyname; int grantpt_result; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); grantpt_result = grantpt (fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (grantpt_result == -1) fatal(\"could not grant slave pty\"); if (unlockpt(fd) == -1) fatal(\"could not unlock slave pty\"); if (!(ptyname = ptsname(fd))) fatal (\"could not enable slave pty\"); snprintf (pty_name, sizeof pty_name, \"%s\", ptyname); }" >>confdefs.h ;; esac @@ -15402,7 +15403,6 @@ - case $opsys in darwin) $as_echo "#define TAB3 OXTABS" >>confdefs.h ;; @@ -15416,27 +15416,6 @@ ;; gnu-linux | gnu-kfreebsd ) - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#ifndef __i386__ -# error "not i386" -#endif - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - $as_echo "#define ULIMIT_BREAK_VALUE (32*1024*1024)" >>confdefs.h - -fi -rm -f conftest.err conftest.$ac_ext - cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -15465,11 +15444,6 @@ $as_echo "#define RUN_TIME_REMAP 1" >>confdefs.h ;; - - irix6-5) - $as_echo "#define ULIMIT_BREAK_VALUE 0x14000000" >>confdefs.h - - ;; esac @@ -22496,6 +22470,34 @@ + for ac_func in sig2str +do : + ac_fn_c_check_func "$LINENO" "sig2str" "ac_cv_func_sig2str" +if test "x$ac_cv_func_sig2str" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SIG2STR 1 +_ACEOF + +fi +done + + + if test $ac_cv_func_sig2str = no; then + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS sig2str.$ac_objext" + + + : + + fi + ------------------------------------------------------------ revno: 111154 fixes bug: http://debbugs.gnu.org/12992 committer: Chong Yidong branch nick: trunk timestamp: Sat 2012-12-08 19:05:39 +0800 message: * src/editfns.c (Finsert_char): Make the error message more informative. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2012-12-08 06:56:26 +0000 +++ src/ChangeLog 2012-12-08 11:05:39 +0000 @@ -1,3 +1,8 @@ +2012-12-08 Chong Yidong + + * editfns.c (Finsert_char): Make the error message more + informative (Bug#12992). + 2012-12-08 Paul Eggert Simplify get_lim_data. === modified file 'src/editfns.c' --- src/editfns.c 2012-12-03 14:13:06 +0000 +++ src/editfns.c 2012-12-08 11:05:39 +0000 @@ -2351,9 +2351,10 @@ } DEFUN ("insert-char", Finsert_char, Sinsert_char, 1, 3, - "(list (read-char-by-name \"Insert character (Unicode name or hex): \")\ - (prefix-numeric-value current-prefix-arg)\ - t))", + "(list (or (read-char-by-name \"Insert character (Unicode name or hex): \")\ + (error \"You did not specify a valid character\"))\ + (prefix-numeric-value current-prefix-arg)\ + t))", doc: /* Insert COUNT copies of CHARACTER. Interactively, prompt for CHARACTER. You can specify CHARACTER in one of these ways: ------------------------------------------------------------ revno: 111153 fixes bug: http://debbugs.gnu.org/13026 committer: Eli Zaretskii branch nick: trunk timestamp: Sat 2012-12-08 11:57:43 +0200 message: Windows followup to revision 111151. lib/makefile.w32-in ($(BLD)/sig2str.$(O)): New dependency. Remove a stray character at the beginning of the file. diff: === modified file 'ChangeLog' --- ChangeLog 2012-12-08 06:56:26 +0000 +++ ChangeLog 2012-12-08 09:57:43 +0000 @@ -1,3 +1,9 @@ +2012-12-08 Eli Zaretskii + + * lib/makefile.w32-in ($(BLD)/sig2str.$(O)): New dependency. + Remove a stray character at the beginning of the file. + (Bug#13026) + 2012-12-08 Paul Eggert Simplify get_lim_data. === modified file 'lib/makefile.w32-in' --- lib/makefile.w32-in 2012-12-08 02:30:51 +0000 +++ lib/makefile.w32-in 2012-12-08 09:57:43 +0000 @@ -1,4 +1,4 @@ -2# -*- Makefile -*- for GNU Emacs on the Microsoft Windows API. +# -*- Makefile -*- for GNU Emacs on the Microsoft Windows API. # Copyright (C) 2011-2012 Free Software Foundation, Inc. # This file is part of GNU Emacs. @@ -240,6 +240,13 @@ $(CONFIG_H) \ $(FILEMODE_H) +$(BLD)/sig2str.$(O) : \ + $(GNU_LIB)/sig2str.c \ + $(CONFIG_H) \ + $(GNU_LIB)/sig2str.h \ + $(GNU_LIB)/intprops.h + + # The following dependencies are for supporting parallel builds, where # we must make sure $(BLD) exists before any compilation starts. # ------------------------------------------------------------ revno: 111152 committer: Paul Eggert branch nick: trunk timestamp: Fri 2012-12-07 22:56:26 -0800 message: Simplify get_lim_data. * admin/CPP-DEFINES (ULIMIT_BREAK_VALUE): Remove. * configure.ac (ULIMIT_BREAK_VALUE): Remove. * src/vm-limit.c (get_lim_data): Combine RLIMIT_AS and RLIMIT_DATA methods. Remove USG and vlimit methods; no longer used these days. Add #error catchall just in case. diff: === modified file 'ChangeLog' --- ChangeLog 2012-12-08 02:30:51 +0000 +++ ChangeLog 2012-12-08 06:56:26 +0000 @@ -1,5 +1,8 @@ 2012-12-08 Paul Eggert + Simplify get_lim_data. + * configure.ac (ULIMIT_BREAK_VALUE): Remove. + Assume POSIX 1003.1-1988 or later for signal.h (Bug#13026). * configure.ac (PTY_OPEN, PTY_TTY_NAME_SPRINTF): Use SIGCHLD rather than SIGCLD. === modified file 'admin/CPP-DEFINES' --- admin/CPP-DEFINES 2012-12-08 02:30:51 +0000 +++ admin/CPP-DEFINES 2012-12-08 06:56:26 +0000 @@ -429,7 +429,6 @@ TIME_WITH_SYS_TIME TIOCSIGSEND TM_IN_SYS_TIME -ULIMIT_BREAK_VALUE UNIX98_PTYS USE_TOOLKIT_SCROLL_BARS USG_SUBTTY_WORKS === modified file 'admin/ChangeLog' --- admin/ChangeLog 2012-12-08 02:30:51 +0000 +++ admin/ChangeLog 2012-12-08 06:56:26 +0000 @@ -1,3 +1,8 @@ +2012-12-08 Paul Eggert + + Simplify get_lim_data. + * CPP-DEFINES (ULIMIT_BREAK_VALUE): Remove. + 2012-12-03 Paul Eggert Assume POSIX 1003.1-1988 or later for signal.h (Bug#13026). === modified file 'configure.ac' --- configure.ac 2012-12-08 02:30:51 +0000 +++ configure.ac 2012-12-08 06:56:26 +0000 @@ -3688,7 +3688,6 @@ esac -AH_TEMPLATE(ULIMIT_BREAK_VALUE, [Undocumented.]) AH_TEMPLATE(TAB3, [Undocumented.]) case $opsys in @@ -3700,14 +3699,6 @@ ;; gnu-linux | gnu-kfreebsd ) - dnl libc-linux/sysdeps/linux/i386/ulimit.c says that due to shared - dnl library, we cannot get the maximum address for brk. - AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[ -#ifndef __i386__ -# error "not i386" -#endif - ]], [[]])], AC_DEFINE(ULIMIT_BREAK_VALUE, [(32*1024*1024)]), []) - AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[ #ifndef __ia64__ # error "not ia64" @@ -3721,11 +3712,6 @@ AC_DEFINE(RUN_TIME_REMAP, 1, [Define if emacs.c needs to call run_time_remap; for HPUX.]) ;; - - irix6-5) - dnl Ulimit(UL_GMEMLIM) is busted... - AC_DEFINE(ULIMIT_BREAK_VALUE, [0x14000000]) - ;; esac === modified file 'src/ChangeLog' --- src/ChangeLog 2012-12-08 02:30:51 +0000 +++ src/ChangeLog 2012-12-08 06:56:26 +0000 @@ -1,5 +1,10 @@ 2012-12-08 Paul Eggert + Simplify get_lim_data. + * vm-limit.c (get_lim_data): Combine RLIMIT_AS and RLIMIT_DATA methods. + Remove USG and vlimit methods; no longer used these days. + Add #error catchall just in case. + Assume POSIX 1003.1-1988 or later for signal.h (Bug#13026). Exceptions: do not assume SIGCONT, SIGSTOP, SIGTSTP, SIGTTIN, SIGTTOU, SIGUSR1, SIGUSR2, as Microsoft platforms lack these. === modified file 'src/vm-limit.c' --- src/vm-limit.c 2012-10-17 19:02:44 +0000 +++ src/vm-limit.c 2012-12-08 06:56:26 +0000 @@ -44,46 +44,26 @@ static size_t lim_data; -#if defined (HAVE_GETRLIMIT) && defined (RLIMIT_AS) +#ifdef HAVE_GETRLIMIT + +# ifndef RLIMIT_AS +# define RLIMIT_AS RLIMIT_DATA +# endif + static void get_lim_data (void) { + /* Set LIM_DATA to the minimum of the maximum object size and the + maximum address space. Don't bother to check for values like + RLIM_INFINITY since in practice they are not much less than SIZE_MAX. */ struct rlimit rlimit; - - getrlimit (RLIMIT_AS, &rlimit); - if (rlimit.rlim_cur == RLIM_INFINITY) - lim_data = -1; - else - lim_data = rlimit.rlim_cur; -} - -#else /* not HAVE_GETRLIMIT */ - -#ifdef USG - -static void -get_lim_data (void) -{ - extern long ulimit (); - - lim_data = -1; - - /* Use the ulimit call, if we seem to have it. */ -#if !defined (ULIMIT_BREAK_VALUE) || defined (GNU_LINUX) - lim_data = ulimit (3, 0); -#endif - - /* If that didn't work, just use the macro's value. */ -#ifdef ULIMIT_BREAK_VALUE - if (lim_data == -1) - lim_data = ULIMIT_BREAK_VALUE; -#endif - - lim_data -= (long) data_space_start; -} - -#else /* not USG */ -#ifdef WINDOWSNT + lim_data + = (getrlimit (RLIMIT_AS, &rlimit) == 0 && rlimit.rlim_cur <= SIZE_MAX + ? rlimit.rlim_cur + : SIZE_MAX); +} + +#elif defined WINDOWSNT #include "w32heap.h" @@ -94,10 +74,8 @@ lim_data = reserved_heap_size; } -#else -#if !defined (BSD4_2) && !defined (CYGWIN) +#elif defined MSDOS -#ifdef MSDOS void get_lim_data (void) { @@ -135,32 +113,9 @@ get_lim_data (); return lim_data; } -#else /* not MSDOS */ -static void -get_lim_data (void) -{ - lim_data = vlimit (LIM_DATA, -1); -} -#endif /* not MSDOS */ - -#else /* BSD4_2 || CYGWIN */ - -static void -get_lim_data (void) -{ - struct rlimit XXrlimit; - - getrlimit (RLIMIT_DATA, &XXrlimit); -#ifdef RLIM_INFINITY - lim_data = XXrlimit.rlim_cur & RLIM_INFINITY; /* soft limit */ #else - lim_data = XXrlimit.rlim_cur; /* soft limit */ +# error "get_lim_data not implemented on this machine" #endif -} -#endif /* BSD4_2 */ -#endif /* not WINDOWSNT */ -#endif /* not USG */ -#endif /* not HAVE_GETRLIMIT */ /* Verify amount of memory available, complaining if we're near the end. */