Now on revision 113479. ------------------------------------------------------------ revno: 113479 committer: Paul Eggert branch nick: trunk timestamp: Sat 2013-07-20 23:53:47 -0700 message: Avoid vfork-related deadlock more cleanly. * callproc.c (child_setup): When the child's exec fails, output the program name, as that's more useful. Use O_NONBLOCK to avoid deadlock. * process.c (create_process_1): Remove; no longer needed. (create_process): Remove timer hack; no longer needed, now that the child avoids deadlock. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2013-07-21 02:53:19 +0000 +++ src/ChangeLog 2013-07-21 06:53:47 +0000 @@ -1,3 +1,13 @@ +2013-07-21 Paul Eggert + + Avoid vfork-related deadlock more cleanly. + * callproc.c (child_setup): When the child's exec fails, output + the program name, as that's more useful. Use O_NONBLOCK to avoid + deadlock. + * process.c (create_process_1): Remove; no longer needed. + (create_process): Remove timer hack; no longer needed, now that + the child avoids deadlock. + 2013-07-20 Glenn Morris * image.c (Fimage_flush): Fix doc typo. === modified file 'src/callproc.c' --- src/callproc.c 2013-07-17 04:37:27 +0000 +++ src/callproc.c 2013-07-21 06:53:47 +0000 @@ -1193,6 +1193,7 @@ { char **env; char *pwd_var; + int exec_errno; #ifdef WINDOWSNT int cpid; HANDLE handles[3]; @@ -1368,13 +1369,16 @@ tcsetpgrp (0, pid); execve (new_argv[0], new_argv, env); - - /* Don't output the program name here, as it can be arbitrarily long, - and a long write from a vforked child to its parent can cause a - deadlock. */ - emacs_perror ("child process"); - - _exit (errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE); + exec_errno = errno; + + /* Avoid deadlock if the child's perror writes to a full pipe; the + pipe's reader is the parent, but with vfork the parent can't + run until the child exits. Truncate the diagnostic instead. */ + fcntl (STDERR_FILENO, F_SETFL, O_NONBLOCK); + + errno = exec_errno; + emacs_perror (new_argv[0]); + _exit (exec_errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE); #else /* MSDOS */ pid = run_msdos_command (new_argv, pwd_var + 4, in, out, err, env); === modified file 'src/process.c' --- src/process.c 2013-07-20 15:33:00 +0000 +++ src/process.c 2013-07-21 06:53:47 +0000 @@ -1599,12 +1599,6 @@ remove_process (proc); } -static void -create_process_1 (struct atimer *timer) -{ - /* Nothing to do. */ -} - static void create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) @@ -1841,14 +1835,13 @@ unblock_child_signal (); unblock_input (); + if (forkin >= 0) + emacs_close (forkin); + if (forkin != forkout && forkout >= 0) + emacs_close (forkout); + if (pid < 0) - { - if (forkin >= 0) - emacs_close (forkin); - if (forkin != forkout && forkout >= 0) - emacs_close (forkout); - report_file_errno ("Doing vfork", Qnil, vfork_errno); - } + report_file_errno ("Doing vfork", Qnil, vfork_errno); else { /* vfork succeeded. */ @@ -1857,26 +1850,6 @@ register_child (pid, inchannel); #endif /* WINDOWSNT */ - /* If the subfork execv fails, and it exits, - this close hangs. I don't know why. - So have an interrupt jar it loose. */ - { - struct atimer *timer; - EMACS_TIME offset = make_emacs_time (1, 0); - - stop_polling (); - timer = start_atimer (ATIMER_RELATIVE, offset, create_process_1, 0); - - if (forkin >= 0) - emacs_close (forkin); - - cancel_atimer (timer); - start_polling (); - } - - if (forkin != forkout && forkout >= 0) - emacs_close (forkout); - pset_tty_name (XPROCESS (process), lisp_pty_name); #ifndef WINDOWSNT ------------------------------------------------------------ revno: 113478 committer: Paul Eggert branch nick: trunk timestamp: Sat 2013-07-20 21:22:33 -0700 message: Spelling fixes. diff: === modified file 'lisp/desktop.el' --- lisp/desktop.el 2013-07-21 02:42:11 +0000 +++ lisp/desktop.el 2013-07-21 04:22:33 +0000 @@ -1368,7 +1368,7 @@ (when (eq (cdr (assq 'minibuffer frame-cfg)) 'only) (setq frame-cfg (append '((tool-bar-lines . 0) (menu-bar-lines . 0)) frame-cfg)))) - (t ;; Frame depends on other frame's minibufer window. + (t ;; Frame depends on other frame's minibuffer window. (let ((mb-frame (cdr (assq (cadr d-mini) frame-mb-map)))) (unless (frame-live-p mb-frame) (error "Minibuffer frame %s not found" (cadr d-mini))) === modified file 'lisp/frame.el' --- lisp/frame.el 2013-07-18 16:50:05 +0000 +++ lisp/frame.el 2013-07-21 04:22:33 +0000 @@ -1740,7 +1740,7 @@ (setq blink-cursor-idle-timer nil)))) (defun blink-cursor-check () - "Check if cursot blinking shall be restarted. + "Check if cursor blinking shall be restarted. This is done when a frame gets focus. Blink timers may be stopped by `blink-cursor-suspend'." (when (and blink-cursor-mode === modified file 'src/eval.c' --- src/eval.c 2013-07-18 02:12:59 +0000 +++ src/eval.c 2013-07-21 04:22:33 +0000 @@ -459,7 +459,7 @@ return val; } -/* Evaluate BODY sequentually, discarding its value. Suitable for +/* Evaluate BODY sequentially, discarding its value. Suitable for record_unwind_protect. */ void ------------------------------------------------------------ revno: 113477 committer: Juanma Barranquero branch nick: trunk timestamp: Sun 2013-07-21 04:53:19 +0200 message: lisp/ChangeLog, src/ChangeLog: Fix typos. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-07-21 02:42:11 +0000 +++ lisp/ChangeLog 2013-07-21 02:53:19 +0000 @@ -25,16 +25,16 @@ 2013-07-20 Andreas Schwab - * progmodes/sh-script.el (sh-read-variable): Remove interactive - spec. (Bug#14826) + * progmodes/sh-script.el (sh-read-variable): Remove interactive spec. + (Bug#14826) * international/mule.el (coding-system-iso-2022-flags): Fix last change. 2013-07-20 Kenichi Handa - * international/mule.el (coding-system-iso-2022-flags): Add - `8-bit-level-4'. (Bug#8522) + * international/mule.el (coding-system-iso-2022-flags): + Add `8-bit-level-4'. (Bug#8522) 2013-07-19 Lars Magne Ingebrigtsen @@ -153,8 +153,8 @@ 2013-07-13 Dmitry Gutov - * progmodes/ruby-mode.el (ruby-font-lock-keywords): Highlight - conversion methods on Kernel. + * progmodes/ruby-mode.el (ruby-font-lock-keywords): + Highlight conversion methods on Kernel. 2013-07-13 Alan Mackenzie @@ -322,8 +322,8 @@ (tramp-process-actions): Use progress reporter. Delete process in case of error. Improve messages. - * net/tramp-sh.el (tramp-barf-if-no-shell-prompt): Use - condition-case. Call `tramp-error-with-buffer' with vector and buffer. + * net/tramp-sh.el (tramp-barf-if-no-shell-prompt): Use condition-case. + Call `tramp-error-with-buffer' with vector and buffer. (tramp-current-connection): Removed. (tramp-maybe-open-connection): The car of `tramp-current-connection' are the first 3 slots of the vector. === modified file 'src/ChangeLog' --- src/ChangeLog 2013-07-20 19:20:33 +0000 +++ src/ChangeLog 2013-07-21 02:53:19 +0000 @@ -592,7 +592,7 @@ initializers. Syntax cleanup, mostly replacing macros with functions. -` This removes the need for the syntax_temp hack. + This removes the need for the syntax_temp hack. * search.c: Include syntax.h after buffer.h, since syntax.h uses BVAR. * syntax.c (SYNTAX_INLINE): New macro. (SYNTAX_FLAGS_COMSTART_FIRST, SYNTAX_FLAGS_COMSTART_SECOND) @@ -690,7 +690,7 @@ (emacswrite_sig, emacs_perror): New functions. * xrdb.c (fatal): Don't invoke perror, since errno might be garbage. -2013-07-08 Magnus Henoch (tiny change). +2013-07-08 Magnus Henoch (tiny change). * image.c (imagemagick_load_image): Do not use MagickExportImagePixels on NS even if it is present. Pixmap on NS is a void*. @@ -1245,7 +1245,7 @@ * floatfns.c (Flog10): Move to Lisp (marked obsolete there). -2013-06-20 RĂ¼diger Sonderfeld +2013-06-20 RĂ¼diger Sonderfeld * floatfns.c (Flog) [HAVE_LOG2]: Use log2 if available and if the base is 2; this is more accurate. ------------------------------------------------------------ revno: 113476 committer: Juanma Barranquero branch nick: trunk timestamp: Sun 2013-07-21 04:42:11 +0200 message: lisp/desktop.el: Correctly restore iconified frames. (desktop--filter-iconified-position): New function. (desktop-filter-parameters-alist): Add entries for `top' and `left'. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-07-20 19:29:02 +0000 +++ lisp/ChangeLog 2013-07-21 02:42:11 +0000 @@ -1,3 +1,9 @@ +2013-07-21 Juanma Barranquero + + * desktop.el: Correctly restore iconified frames. + (desktop--filter-iconified-position): New function. + (desktop-filter-parameters-alist): Add entries for `top' and `left'. + 2013-07-20 Glenn Morris * progmodes/gdb-mi.el (gdb-delete-handler, gdb-stopped): === modified file 'lisp/desktop.el' --- lisp/desktop.el 2013-07-15 00:07:51 +0000 +++ lisp/desktop.el 2013-07-21 02:42:11 +0000 @@ -896,10 +896,12 @@ (foreground-color . desktop--filter-*-color) (fullscreen . desktop--filter-save-desktop-parm) (height . desktop--filter-save-desktop-parm) + (left . desktop--filter-iconified-position) (minibuffer . desktop--filter-minibuffer) (name . t) (outer-window-id . t) (parent-id . t) + (top . desktop--filter-iconified-position) (tty . desktop--filter-tty*) (tty-type . desktop--filter-tty*) (width . desktop--filter-save-desktop-parm) @@ -1004,6 +1006,11 @@ (cons (car current) val)))) (t t))) +(defun desktop--filter-iconified-position (_current parameters saving) + ;; When saving an iconified frame, top & left are meaningless, + ;; so remove them to allow restoring to a default position. + (not (and saving (eq (cdr (assq 'visibility parameters)) 'icon)))) + (defun desktop-restore-in-original-display-p () "True if saved frames' displays should be honored." (cond ((daemonp) t) ------------------------------------------------------------ revno: 113475 committer: Glenn Morris branch nick: trunk timestamp: Sat 2013-07-20 12:29:02 -0700 message: image-dired.el: use with-current-buffer * lisp/image-dired.el (image-dired-track-original-file): Use with-current-buffer. (image-dired-track-thumbnail): Use with-current-buffer. Avoid changing point of wrong window. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-07-20 19:25:05 +0000 +++ lisp/ChangeLog 2013-07-20 19:29:02 +0000 @@ -5,6 +5,11 @@ (def-gdb-preempt-display-buffer): Add explicit format. * image-dired.el (image-dired-track-original-file): + Use with-current-buffer. + (image-dired-track-thumbnail): Use with-current-buffer. + Avoid changing point of wrong window. + + * image-dired.el (image-dired-track-original-file): Avoid changing point of wrong window. (Bug#14909) 2013-07-20 Richard Copley (tiny change) === modified file 'lisp/image-dired.el' --- lisp/image-dired.el 2013-07-20 19:20:33 +0000 +++ lisp/image-dired.el 2013-07-20 19:29:02 +0000 @@ -1039,16 +1039,14 @@ See documentation for `image-dired-toggle-movement-tracking'. Interactive use only useful if `image-dired-track-movement' is nil." (interactive) - (let* ((old-buf (current-buffer)) - (dired-buf (image-dired-associated-dired-buffer)) + (let* ((dired-buf (image-dired-associated-dired-buffer)) (file-name (image-dired-original-file-name)) (window (image-dired-get-buffer-window dired-buf))) - (when (and (buffer-live-p dired-buf) file-name) - (set-buffer dired-buf) - (if (not (dired-goto-file file-name)) - (message "Could not track file") - (if window (set-window-point window (point)))) - (set-buffer old-buf)))) + (and (buffer-live-p dired-buf) file-name + (with-current-buffer dired-buf + (if (not (dired-goto-file file-name)) + (message "Could not track file") + (if window (set-window-point window (point)))))))) (defun image-dired-toggle-movement-tracking () "Turn on and off `image-dired-track-movement'. @@ -1065,24 +1063,22 @@ This is almost the same as what `image-dired-track-original-file' does, but the other way around." (let ((file (dired-get-filename)) - (old-buf (current-buffer)) - prop-val found) + prop-val found window) (when (get-buffer image-dired-thumbnail-buffer) - (set-buffer image-dired-thumbnail-buffer) - (goto-char (point-min)) - (while (and (not (eobp)) - (not found)) - (if (and (setq prop-val - (get-text-property (point) 'original-file-name)) - (string= prop-val file)) - (setq found t)) - (if (not found) - (forward-char 1))) - (when found - (set-window-point - (image-dired-thumbnail-window) (point)) - (image-dired-display-thumb-properties)) - (set-buffer old-buf)))) + (with-current-buffer image-dired-thumbnail-buffer + (goto-char (point-min)) + (while (and (not (eobp)) + (not found)) + (if (and (setq prop-val + (get-text-property (point) 'original-file-name)) + (string= prop-val file)) + (setq found t)) + (if (not found) + (forward-char 1))) + (when found + (if (setq window (image-dired-thumbnail-window)) + (set-window-point window (point))) + (image-dired-display-thumb-properties)))))) (defun image-dired-dired-next-line (&optional arg) "Call `dired-next-line', then track thumbnail. ------------------------------------------------------------ revno: 113474 committer: Glenn Morris branch nick: trunk timestamp: Sat 2013-07-20 12:25:05 -0700 message: Tweak some message calls in gdb-mi.el * lisp/progmodes/gdb-mi.el (gdb-delete-handler, gdb-stopped): Let `message' do the formatting. (def-gdb-preempt-display-buffer): Add explicit format. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-07-20 19:20:33 +0000 +++ lisp/ChangeLog 2013-07-20 19:25:05 +0000 @@ -1,5 +1,9 @@ 2013-07-20 Glenn Morris + * progmodes/gdb-mi.el (gdb-delete-handler, gdb-stopped): + Let `message' do the formatting. + (def-gdb-preempt-display-buffer): Add explicit format. + * image-dired.el (image-dired-track-original-file): Avoid changing point of wrong window. (Bug#14909) === modified file 'lisp/progmodes/gdb-mi.el' --- lisp/progmodes/gdb-mi.el 2013-07-20 19:20:33 +0000 +++ lisp/progmodes/gdb-mi.el 2013-07-20 19:25:05 +0000 @@ -290,9 +290,8 @@ (lambda (handler) "Discard any HANDLER with a token number `<=' than TOKEN-NUMBER." (when (< (gdb-handler-token-number handler) token-number) - (message (format - "WARNING! Discarding GDB handler with token #%d\n" - (gdb-handler-token-number handler)))) + (message "WARNING! Discarding GDB handler with token #%d\n" + (gdb-handler-token-number handler))) (<= (gdb-handler-token-number handler) token-number)) gdb-handler-list)) @@ -1490,7 +1489,7 @@ split-horizontal) `(defun ,name (&optional thread) ,(when doc doc) - (message thread) + (message "%s" thread) (gdb-preempt-existing-or-display-buffer (gdb-get-buffer-create ,buffer thread) ,split-horizontal))) @@ -2445,9 +2444,9 @@ (if (or (eq gdb-switch-reasons t) (member reason gdb-switch-reasons)) (when (not (string-equal gdb-thread-number thread-id)) - (message (concat "Switched to thread " thread-id)) + (message "Switched to thread %s" thread-id) (gdb-setq-thread-number thread-id)) - (message (format "Thread %s stopped" thread-id))))) + (message "Thread %s stopped" thread-id)))) ;; Print "(gdb)" to GUD console (when gdb-first-done-or-error ------------------------------------------------------------ revno: 113473 [merge] committer: Glenn Morris branch nick: trunk timestamp: Sat 2013-07-20 12:20:33 -0700 message: Merge from emacs-24; up to r111388 diff: === modified file 'INSTALL' --- INSTALL 2013-05-29 13:21:17 +0000 +++ INSTALL 2013-07-20 19:20:33 +0000 @@ -70,24 +70,17 @@ you, but there are no obvious errors, assume that `configure' did its job and proceed. - 4. If you need to run the `configure' script more than once (e.g., - with some non-default options), always clean the source - directories before running `configure' again: - - make distclean - ./configure - - 5. Invoke the `make' program: + 4. Invoke the `make' program: make - 6. If `make' succeeds, it will build an executable program `emacs' + 5. If `make' succeeds, it will build an executable program `emacs' in the `src' directory. You can try this program, to make sure it works: src/emacs -Q - 7. Assuming that the program `src/emacs' starts and displays its + 6. Assuming that the program `src/emacs' starts and displays its opening screen, you can install the program and its auxiliary files into their installation directories: @@ -101,6 +94,11 @@ You can delete the entire build directory if you do not plan to build Emacs again, but it can be useful to keep for debugging. + If you want to build Emacs again with different configure options, + first clean the source directories: + + make distclean + ./configure Note that the install automatically saves space by compressing (provided you have the `gzip' program) those installed Lisp source (.el) === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-07-20 15:41:38 +0000 +++ lisp/ChangeLog 2013-07-20 19:20:33 +0000 @@ -1,5 +1,18 @@ +2013-07-20 Glenn Morris + + * image-dired.el (image-dired-track-original-file): + Avoid changing point of wrong window. (Bug#14909) + +2013-07-20 Richard Copley (tiny change) + + * progmodes/gdb-mi.el (gdb-done-or-error): + Guard against "%" in gdb output. (Bug#14127) + 2013-07-20 Andreas Schwab + * progmodes/sh-script.el (sh-read-variable): Remove interactive + spec. (Bug#14826) + * international/mule.el (coding-system-iso-2022-flags): Fix last change. === modified file 'lisp/image-dired.el' --- lisp/image-dired.el 2013-06-13 05:10:48 +0000 +++ lisp/image-dired.el 2013-07-20 19:20:33 +0000 @@ -1039,15 +1039,15 @@ See documentation for `image-dired-toggle-movement-tracking'. Interactive use only useful if `image-dired-track-movement' is nil." (interactive) - (let ((old-buf (current-buffer)) + (let* ((old-buf (current-buffer)) (dired-buf (image-dired-associated-dired-buffer)) - (file-name (image-dired-original-file-name))) + (file-name (image-dired-original-file-name)) + (window (image-dired-get-buffer-window dired-buf))) (when (and (buffer-live-p dired-buf) file-name) (set-buffer dired-buf) (if (not (dired-goto-file file-name)) (message "Could not track file") - (set-window-point - (image-dired-get-buffer-window dired-buf) (point))) + (if window (set-window-point window (point)))) (set-buffer old-buf)))) (defun image-dired-toggle-movement-tracking () === modified file 'lisp/progmodes/gdb-mi.el' --- lisp/progmodes/gdb-mi.el 2013-07-12 18:17:17 +0000 +++ lisp/progmodes/gdb-mi.el 2013-07-20 19:20:33 +0000 @@ -2500,7 +2500,7 @@ ;; MI error - send to minibuffer (when (eq type 'error) ;; Skip "msg=" from `output-field' - (message (read (substring output-field 4))) + (message "%s" (read (substring output-field 4))) ;; Don't send to the console twice. (If it is a console error ;; it is also in the console stream.) (setq output-field nil))) === modified file 'lisp/progmodes/sh-script.el' --- lisp/progmodes/sh-script.el 2013-04-19 18:50:28 +0000 +++ lisp/progmodes/sh-script.el 2013-07-20 19:20:33 +0000 @@ -2401,7 +2401,6 @@ (defun sh-read-variable (var) "Read a new value for indentation variable VAR." - (interactive "*variable? ") ;; to test (let ((minibuffer-help-form `(sh-help-string-for-variable (quote ,var))) val) === modified file 'src/ChangeLog' --- src/ChangeLog 2013-07-20 15:33:00 +0000 +++ src/ChangeLog 2013-07-20 19:20:33 +0000 @@ -1,3 +1,7 @@ +2013-07-20 Glenn Morris + + * image.c (Fimage_flush): Fix doc typo. + 2013-07-20 Paul Eggert Fix array bounds violation when pty allocation fails. === modified file 'src/image.c' --- src/image.c 2013-07-19 18:09:23 +0000 +++ src/image.c 2013-07-20 19:20:33 +0000 @@ -1569,7 +1569,7 @@ DEFUN ("image-flush", Fimage_flush, Simage_flush, 1, 2, 0, - doc: /* Fush the image with specification SPEC on frame FRAME. + doc: /* Flush the image with specification SPEC on frame FRAME. This removes the image from the Emacs image cache. If SPEC specifies an image file, the next redisplay of this image will read from the current contents of that file. ------------------------------------------------------------ revno: 113472 committer: Andreas Schwab branch nick: emacs timestamp: Sat 2013-07-20 17:41:38 +0200 message: * international/mule.el (coding-system-iso-2022-flags): Fix last change. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-07-20 11:51:53 +0000 +++ lisp/ChangeLog 2013-07-20 15:41:38 +0000 @@ -1,3 +1,8 @@ +2013-07-20 Andreas Schwab + + * international/mule.el (coding-system-iso-2022-flags): Fix last + change. + 2013-07-20 Kenichi Handa * international/mule.el (coding-system-iso-2022-flags): Add === modified file 'lisp/international/mule.el' --- lisp/international/mule.el 2013-07-20 11:22:56 +0000 +++ lisp/international/mule.el 2013-07-20 15:41:38 +0000 @@ -519,7 +519,7 @@ euc-tw-shift use-roman use-oldjis - level-4) + 8-bit-level-4) "List of symbols that control ISO-2022 encoder/decoder. The value of the `:flags' attribute in the argument of the function @@ -583,7 +583,7 @@ JIS0208-1983. If `8-bit-level-4' is specified, the decoder assumes the -implementation lavel \"4\" for 8-bit codes which means that GL is +implementation level \"4\" for 8-bit codes which means that GL is identified as the single-shift area. The default implementation level for 8-bit code is \"4A\" which means that GR is identified as the single-shift area.") ------------------------------------------------------------ revno: 113471 committer: Paul Eggert branch nick: trunk timestamp: Sat 2013-07-20 08:33:00 -0700 message: Fix array bounds violation when pty allocation fails. * configure.ac (PTY_TTY_NAME_SPRINTF): Use PTY_NAME_SIZE, not sizeof pty_name, since pty_name is now a pointer to the array. * src/process.c (PTY_NAME_SIZE): New constant. (pty_name): Remove static variable; it's now auto. (allocate_pty): Define even if !HAVE_PTYS; that's simpler. Take pty_name as an arg rather than using a static variable. All callers changed. (create_process): Recover pty_flag from process, not from volatile local. (create_pty): Stay inside array even when pty allocation fails. (Fmake_serial_process): Omit unnecessary initializaiton of pty_flag. diff: === modified file 'ChangeLog' --- ChangeLog 2013-07-13 00:01:43 +0000 +++ ChangeLog 2013-07-20 15:33:00 +0000 @@ -1,3 +1,9 @@ +2013-07-20 Paul Eggert + + Fix array bounds violation when pty allocation fails. + * configure.ac (PTY_TTY_NAME_SPRINTF): Use PTY_NAME_SIZE, + not sizeof pty_name, since pty_name is now a pointer to the array. + 2013-07-13 Paul Eggert * configure.ac: Simplify --with-file-notification handling. === modified file 'configure.ac' --- configure.ac 2013-07-13 00:01:43 +0000 +++ configure.ac 2013-07-20 15:33:00 +0000 @@ -3938,7 +3938,7 @@ AC_DEFINE(PTY_ITERATION, [int i; for (i = 0; i < 1; i++)]) dnl Note that grantpt and unlockpt may fork. We must block SIGCHLD dnl to prevent sigchld_handler from intercepting the child's death. - AC_DEFINE(PTY_TTY_NAME_SPRINTF, [{ char *ptyname = 0; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); if (grantpt (fd) != -1 && unlockpt (fd) != -1) ptyname = ptsname(fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (!ptyname) { emacs_close (fd); return -1; } snprintf (pty_name, sizeof pty_name, "%s", ptyname); }]) + AC_DEFINE(PTY_TTY_NAME_SPRINTF, [{ char *ptyname = 0; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); if (grantpt (fd) != -1 && unlockpt (fd) != -1) ptyname = ptsname(fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (!ptyname) { emacs_close (fd); return -1; } snprintf (pty_name, PTY_NAME_SIZE, "%s", ptyname); }]) dnl if HAVE_POSIX_OPENPT if test "x$ac_cv_func_posix_openpt" = xyes; then AC_DEFINE(PTY_OPEN, [fd = posix_openpt (O_RDWR | O_CLOEXEC | O_NOCTTY)]) @@ -3986,12 +3986,12 @@ dnl On SysVr4, grantpt(3) forks a subprocess, so keep sigchld_handler() dnl from intercepting that death. If any child but grantpt's should die dnl within, it should be caught after sigrelse(2). - AC_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); }]) + AC_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, PTY_NAME_SIZE, "%s", ptyname); }]) ;; unixware ) dnl Comments are as per sol2*. - AC_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); }]) + AC_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, PTY_NAME_SIZE, "%s", ptyname); }]) ;; esac === modified file 'src/ChangeLog' --- src/ChangeLog 2013-07-20 14:21:25 +0000 +++ src/ChangeLog 2013-07-20 15:33:00 +0000 @@ -1,5 +1,15 @@ 2013-07-20 Paul Eggert + Fix array bounds violation when pty allocation fails. + * process.c (PTY_NAME_SIZE): New constant. + (pty_name): Remove static variable; it's now auto. + (allocate_pty): Define even if !HAVE_PTYS; that's simpler. + Take pty_name as an arg rather than using a static variable. + All callers changed. + (create_process): Recover pty_flag from process, not from volatile local. + (create_pty): Stay inside array even when pty allocation fails. + (Fmake_serial_process): Omit unnecessary initializaiton of pty_flag. + * lread.c (Fload): Avoid initialization only when lint checking. Mention that it's needed only for older GCCs. === modified file 'src/process.c' --- src/process.c 2013-07-19 18:09:23 +0000 +++ src/process.c 2013-07-20 15:33:00 +0000 @@ -640,19 +640,16 @@ return Fcopy_sequence (Fsymbol_name (symbol)); } -#ifdef HAVE_PTYS - -/* The file name of the pty opened by allocate_pty. */ -static char pty_name[24]; +enum { PTY_NAME_SIZE = 24 }; /* Open an available pty, returning a file descriptor. - Return -1 on failure. - The file name of the terminal corresponding to the pty - is left in the variable pty_name. */ + Store into PTY_NAME the file name of the terminal corresponding to the pty. + Return -1 on failure. */ static int -allocate_pty (void) +allocate_pty (char pty_name[PTY_NAME_SIZE]) { +#ifdef HAVE_PTYS int fd; #ifdef PTY_ITERATION @@ -697,9 +694,9 @@ return fd; } } +#endif /* HAVE_PTYS */ return -1; } -#endif /* HAVE_PTYS */ static Lisp_Object make_process (Lisp_Object name) @@ -1621,14 +1618,14 @@ #endif int forkin, forkout; bool pty_flag = 0; + char pty_name[PTY_NAME_SIZE]; Lisp_Object lisp_pty_name = Qnil; Lisp_Object encoded_current_dir; inchannel = outchannel = -1; -#ifdef HAVE_PTYS if (!NILP (Vprocess_connection_type)) - outchannel = inchannel = allocate_pty (); + outchannel = inchannel = allocate_pty (pty_name); if (inchannel >= 0) { @@ -1647,7 +1644,6 @@ lisp_pty_name = build_string (pty_name); } else -#endif /* HAVE_PTYS */ { if (emacs_pipe (sv) != 0) report_file_error ("Creating pipe", Qnil); @@ -1704,7 +1700,6 @@ Lisp_Object volatile encoded_current_dir_volatile = encoded_current_dir; Lisp_Object volatile lisp_pty_name_volatile = lisp_pty_name; Lisp_Object volatile process_volatile = process; - bool volatile pty_flag_volatile = pty_flag; char **volatile new_argv_volatile = new_argv; int volatile forkin_volatile = forkin; int volatile forkout_volatile = forkout; @@ -1716,12 +1711,13 @@ encoded_current_dir = encoded_current_dir_volatile; lisp_pty_name = lisp_pty_name_volatile; process = process_volatile; - pty_flag = pty_flag_volatile; new_argv = new_argv_volatile; forkin = forkin_volatile; forkout = forkout_volatile; wait_child_setup[0] = wait_child_setup_0_volatile; wait_child_setup[1] = wait_child_setup_1_volatile; + + pty_flag = XPROCESS (process)->pty_flag; } if (pid == 0) @@ -1791,15 +1787,15 @@ if (pty_flag) { - /* I wonder if emacs_close (emacs_open (pty_name, ...)) + /* I wonder if emacs_close (emacs_open (SSDATA (lisp_pty_name), ...)) would work? */ if (xforkin >= 0) emacs_close (xforkin); - xforkout = xforkin = emacs_open (pty_name, O_RDWR, 0); + xforkout = xforkin = emacs_open (SSDATA (lisp_pty_name), O_RDWR, 0); if (xforkin < 0) { - emacs_perror (pty_name); + emacs_perror (SSDATA (lisp_pty_name)); _exit (EXIT_CANCELED); } @@ -1899,17 +1895,16 @@ } } -void +static void create_pty (Lisp_Object process) { + char pty_name[PTY_NAME_SIZE]; int inchannel, outchannel; - bool pty_flag = 0; inchannel = outchannel = -1; -#ifdef HAVE_PTYS if (!NILP (Vprocess_connection_type)) - outchannel = inchannel = allocate_pty (); + outchannel = inchannel = allocate_pty (pty_name); if (inchannel >= 0) { @@ -1928,40 +1923,34 @@ child_setup_tty (forkout); #endif /* DONT_REOPEN_PTY */ #endif /* not USG, or USG_SUBTTY_WORKS */ - pty_flag = 1; + + fcntl (inchannel, F_SETFL, O_NONBLOCK); + fcntl (outchannel, F_SETFL, O_NONBLOCK); + + /* Record this as an active process, with its channels. + As a result, child_setup will close Emacs's side of the pipes. */ + chan_process[inchannel] = process; + XPROCESS (process)->infd = inchannel; + XPROCESS (process)->outfd = outchannel; + + /* Previously we recorded the tty descriptor used in the subprocess. + It was only used for getting the foreground tty process, so now + we just reopen the device (see emacs_get_tty_pgrp) as this is + more portable (see USG_SUBTTY_WORKS above). */ + + XPROCESS (process)->pty_flag = 1; + pset_status (XPROCESS (process), Qrun); + setup_process_coding_systems (process); + + FD_SET (inchannel, &input_wait_mask); + FD_SET (inchannel, &non_keyboard_wait_mask); + if (inchannel > max_process_desc) + max_process_desc = inchannel; + + pset_tty_name (XPROCESS (process), build_string (pty_name)); } -#endif /* HAVE_PTYS */ - - fcntl (inchannel, F_SETFL, O_NONBLOCK); - fcntl (outchannel, F_SETFL, O_NONBLOCK); - - /* Record this as an active process, with its channels. - As a result, child_setup will close Emacs's side of the pipes. */ - chan_process[inchannel] = process; - XPROCESS (process)->infd = inchannel; - XPROCESS (process)->outfd = outchannel; - - /* Previously we recorded the tty descriptor used in the subprocess. - It was only used for getting the foreground tty process, so now - we just reopen the device (see emacs_get_tty_pgrp) as this is - more portable (see USG_SUBTTY_WORKS above). */ - - XPROCESS (process)->pty_flag = pty_flag; - pset_status (XPROCESS (process), Qrun); - setup_process_coding_systems (process); - - FD_SET (inchannel, &input_wait_mask); - FD_SET (inchannel, &non_keyboard_wait_mask); - if (inchannel > max_process_desc) - max_process_desc = inchannel; XPROCESS (process)->pid = -2; -#ifdef HAVE_PTYS - if (pty_flag) - pset_tty_name (XPROCESS (process), build_string (pty_name)); - else -#endif - pset_tty_name (XPROCESS (process), Qnil); } @@ -2589,7 +2578,7 @@ p->kill_without_query = 1; if (tem = Fplist_get (contact, QCstop), !NILP (tem)) pset_command (p, Qt); - p->pty_flag = 0; + eassert (! p->pty_flag); if (!EQ (p->command, Qt)) { ------------------------------------------------------------ revno: 113470 committer: Paul Eggert branch nick: trunk timestamp: Sat 2013-07-20 07:21:25 -0700 message: * lread.c (Fload): Avoid initialization only when lint checking. Mention that it's needed only for older GCCs. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2013-07-20 11:51:53 +0000 +++ src/ChangeLog 2013-07-20 14:21:25 +0000 @@ -1,3 +1,8 @@ +2013-07-20 Paul Eggert + + * lread.c (Fload): Avoid initialization only when lint checking. + Mention that it's needed only for older GCCs. + 2013-07-20 Kenichi Handa * coding.c (CODING_ISO_FLAG_LEVEL_4): New macro. === modified file 'src/lread.c' --- src/lread.c 2013-07-20 08:25:46 +0000 +++ src/lread.c 2013-07-20 14:21:25 +0000 @@ -1044,7 +1044,7 @@ { FILE *stream; int fd; - int fd_index = 0; + int fd_index; ptrdiff_t count = SPECPDL_INDEX (); struct gcpro gcpro1, gcpro2, gcpro3; Lisp_Object found, efound, hist_file_name; @@ -1175,7 +1175,12 @@ #endif } - if (fd >= 0) + if (fd < 0) + { + /* Pacify older GCC with --enable-gcc-warnings. */ + IF_LINT (fd_index = 0); + } + else { fd_index = SPECPDL_INDEX (); record_unwind_protect_int (close_file_unwind, fd); ------------------------------------------------------------ revno: 113469 [merge] committer: K. Handa branch nick: trunk timestamp: Sat 2013-07-20 20:53:32 +0900 message: Fix Bug#8522. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-07-19 14:57:28 +0000 +++ lisp/ChangeLog 2013-07-20 11:51:53 +0000 @@ -1,3 +1,8 @@ +2013-07-20 Kenichi Handa + + * international/mule.el (coding-system-iso-2022-flags): Add + `8-bit-level-4'. (Bug#8522) + 2013-07-19 Lars Magne Ingebrigtsen * net/shr.el (shr-mouse-browse-url): New command and keystroke === modified file 'lisp/international/mule.el' --- lisp/international/mule.el 2013-07-13 10:55:21 +0000 +++ lisp/international/mule.el 2013-07-20 11:22:56 +0000 @@ -518,7 +518,8 @@ composition euc-tw-shift use-roman - use-oldjis) + use-oldjis + level-4) "List of symbols that control ISO-2022 encoder/decoder. The value of the `:flags' attribute in the argument of the function @@ -542,8 +543,9 @@ on decoding, and use locking-shift to invoke a graphic element on encoding. -If `single-shift' is specified, decode single-shift code correctly on -decoding, and use single-shift to invoke a graphic element on encoding. +If `single-shift' is specified, decode single-shift code +correctly on decoding, and use single-shift to invoke a graphic +element on encoding. See also `8-bit-level-4' specification. If `designation' is specified, decode designation code correctly on decoding, and use designation to designate a charset to a graphic @@ -578,7 +580,13 @@ of ASCII. If `use-oldjis' is specified, JIS0208-1976 is designated instead of -JIS0208-1983.") +JIS0208-1983. + +If `8-bit-level-4' is specified, the decoder assumes the +implementation lavel \"4\" for 8-bit codes which means that GL is +identified as the single-shift area. The default implementation +level for 8-bit code is \"4A\" which means that GR is identified +as the single-shift area.") (defun define-coding-system (name docstring &rest props) "Define NAME (a symbol) as a coding system with DOCSTRING and attributes. === modified file 'src/ChangeLog' --- src/ChangeLog 2013-07-20 08:25:46 +0000 +++ src/ChangeLog 2013-07-20 11:51:53 +0000 @@ -1,3 +1,8 @@ +2013-07-20 Kenichi Handa + + * coding.c (CODING_ISO_FLAG_LEVEL_4): New macro. + (decode_coding_iso_2022): Check the single-shift area. (Bug#8522) + 2013-07-20 Andreas Schwab * lread.c (Fload): Avoid uninitialized warning. === modified file 'src/coding.c' --- src/coding.c 2013-07-19 16:15:51 +0000 +++ src/coding.c 2013-07-20 11:51:53 +0000 @@ -493,6 +493,8 @@ #define CODING_ISO_FLAG_USE_OLDJIS 0x10000 +#define CODING_ISO_FLAG_LEVEL_4 0x20000 + #define CODING_ISO_FLAG_FULL_SUPPORT 0x100000 /* A character to be produced on output if encoding of the original @@ -3772,7 +3774,10 @@ else charset = CHARSET_FROM_ID (charset_id_2); ONE_MORE_BYTE (c1); - if (c1 < 0x20 || (c1 >= 0x80 && c1 < 0xA0)) + if (c1 < 0x20 || (c1 >= 0x80 && c1 < 0xA0) + || (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SEVEN_BITS) + && ((CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_LEVEL_4) + ? c1 >= 0x80 : c1 < 0x80))) goto invalid_code; break; @@ -3786,7 +3791,10 @@ else charset = CHARSET_FROM_ID (charset_id_3); ONE_MORE_BYTE (c1); - if (c1 < 0x20 || (c1 >= 0x80 && c1 < 0xA0)) + if (c1 < 0x20 || (c1 >= 0x80 && c1 < 0xA0) + || (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SEVEN_BITS) + && ((CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_LEVEL_4) + ? c1 >= 0x80 : c1 < 0x80))) goto invalid_code; break; ------------------------------------------------------------ revno: 113468 committer: Andreas Schwab branch nick: emacs timestamp: Sat 2013-07-20 10:25:46 +0200 message: * lread.c (Fload): Avoid uninitialized warning. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2013-07-19 18:09:23 +0000 +++ src/ChangeLog 2013-07-20 08:25:46 +0000 @@ -1,3 +1,7 @@ +2013-07-20 Andreas Schwab + + * lread.c (Fload): Avoid uninitialized warning. + 2013-07-19 Paul Eggert Fix some minor file descriptor leaks and related glitches. === modified file 'src/lread.c' --- src/lread.c 2013-07-18 02:12:59 +0000 +++ src/lread.c 2013-07-20 08:25:46 +0000 @@ -1044,7 +1044,7 @@ { FILE *stream; int fd; - int fd_index; + int fd_index = 0; ptrdiff_t count = SPECPDL_INDEX (); struct gcpro gcpro1, gcpro2, gcpro3; Lisp_Object found, efound, hist_file_name; @@ -1175,7 +1175,7 @@ #endif } - if (0 <= fd) + if (fd >= 0) { fd_index = SPECPDL_INDEX (); record_unwind_protect_int (close_file_unwind, fd); ------------------------------------------------------------ revno: 113467 author: Paul Eggert committer: Paul Eggert branch nick: trunk timestamp: Fri 2013-07-19 11:09:23 -0700 message: Fix some minor file descriptor leaks and related glitches. * filelock.c (create_lock_file) [!O_CLOEXEC]: Use fcntl with FD_CLOEXEC. (create_lock_file): Use write, not emacs_write. * image.c (slurp_file, png_load_body): * process.c (Fnetwork_interface_list, Fnetwork_interface_info) (server_accept_connection): Don't leak an fd on memory allocation failure. * image.c (slurp_file): Add a cheap heuristic for growing files. * xfaces.c (Fx_load_color_file): Block input around the fopen too, as that's what the other routines do. Maybe input need not be blocked at all, but it's better to be consistent. Avoid undefined behavior when strlen is zero. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2013-07-19 17:54:26 +0000 +++ src/ChangeLog 2013-07-19 18:09:23 +0000 @@ -1,5 +1,18 @@ 2013-07-19 Paul Eggert + Fix some minor file descriptor leaks and related glitches. + * filelock.c (create_lock_file) [!O_CLOEXEC]: Use fcntl with FD_CLOEXEC. + (create_lock_file): Use write, not emacs_write. + * image.c (slurp_file, png_load_body): + * process.c (Fnetwork_interface_list, Fnetwork_interface_info) + (server_accept_connection): + Don't leak an fd on memory allocation failure. + * image.c (slurp_file): Add a cheap heuristic for growing files. + * xfaces.c (Fx_load_color_file): Block input around the fopen too, + as that's what the other routines do. Maybe input need not be + blocked at all, but it's better to be consistent. + Avoid undefined behavior when strlen is zero. + * alloc.c (staticpro): Avoid buffer overrun on repeated calls. (NSTATICS): Now a constant; doesn't need to be a macro. === modified file 'src/filelock.c' --- src/filelock.c 2013-07-18 10:24:26 +0000 +++ src/filelock.c 2013-07-19 18:09:23 +0000 @@ -430,12 +430,14 @@ else { ptrdiff_t lock_info_len; -#if ! HAVE_MKOSTEMP +#if ! (HAVE_MKOSTEMP && O_CLOEXEC) fcntl (fd, F_SETFD, FD_CLOEXEC); #endif lock_info_len = strlen (lock_info_str); err = 0; - if (emacs_write (fd, lock_info_str, lock_info_len) != lock_info_len + /* Use 'write', not 'emacs_write', as garbage collection + might signal an error, which would leak FD. */ + if (write (fd, lock_info_str, lock_info_len) != lock_info_len || fchmod (fd, S_IRUSR | S_IRGRP | S_IROTH) != 0) err = errno; /* There is no need to call fsync here, as the contents of === modified file 'src/image.c' --- src/image.c 2013-07-16 06:39:49 +0000 +++ src/image.c 2013-07-19 18:09:23 +0000 @@ -2276,23 +2276,28 @@ unsigned char *buf = NULL; struct stat st; - if (fp && fstat (fileno (fp), &st) == 0 - && 0 <= st.st_size && st.st_size <= min (PTRDIFF_MAX, SIZE_MAX) - && (buf = xmalloc (st.st_size), - fread (buf, 1, st.st_size, fp) == st.st_size)) - { - *size = st.st_size; - fclose (fp); - } - else - { - if (fp) - fclose (fp); - if (buf) + if (fp) + { + ptrdiff_t count = SPECPDL_INDEX (); + record_unwind_protect_ptr (fclose_unwind, fp); + + if (fstat (fileno (fp), &st) == 0 + && 0 <= st.st_size && st.st_size < min (PTRDIFF_MAX, SIZE_MAX)) { - xfree (buf); - buf = NULL; + /* Report an error if we read past the purported EOF. + This can happen if the file grows as we read it. */ + ptrdiff_t buflen = st.st_size; + buf = xmalloc (buflen + 1); + if (fread (buf, 1, buflen + 1, fp) == buflen) + *size = buflen; + else + { + xfree (buf); + buf = NULL; + } } + + unbind_to (count, Qnil); } return buf; @@ -5732,8 +5737,8 @@ if (fread (sig, 1, sizeof sig, fp) != sizeof sig || fn_png_sig_cmp (sig, 0, sizeof sig)) { + fclose (fp); image_error ("Not a PNG file: `%s'", file, Qnil); - fclose (fp); return 0; } } === modified file 'src/process.c' --- src/process.c 2013-07-17 04:37:27 +0000 +++ src/process.c 2013-07-19 18:09:23 +0000 @@ -3526,10 +3526,13 @@ ptrdiff_t buf_size = 512; int s; Lisp_Object res; + ptrdiff_t count; s = socket (AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0); if (s < 0) return Qnil; + count = SPECPDL_INDEX (); + record_unwind_protect_int (close_file_unwind, s); do { @@ -3545,9 +3548,7 @@ } while (ifconf.ifc_len == buf_size); - emacs_close (s); - - res = Qnil; + res = unbind_to (count, Qnil); ifreq = ifconf.ifc_req; while ((char *) ifreq < (char *) ifconf.ifc_req + ifconf.ifc_len) { @@ -3672,6 +3673,7 @@ Lisp_Object elt; int s; bool any = 0; + ptrdiff_t count; #if (! (defined SIOCGIFHWADDR && defined HAVE_STRUCT_IFREQ_IFR_HWADDR) \ && defined HAVE_GETIFADDRS && defined LLADDR) struct ifaddrs *ifap; @@ -3686,6 +3688,8 @@ s = socket (AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0); if (s < 0) return Qnil; + count = SPECPDL_INDEX (); + record_unwind_protect_int (close_file_unwind, s); elt = Qnil; #if defined (SIOCGIFFLAGS) && defined (HAVE_STRUCT_IFREQ_IFR_FLAGS) @@ -3802,9 +3806,7 @@ #endif res = Fcons (elt, res); - emacs_close (s); - - return any ? res : Qnil; + return unbind_to (count, any ? res : Qnil); } #endif #endif /* defined (HAVE_NET_IF_H) */ @@ -3978,6 +3980,7 @@ #endif } saddr; socklen_t len = sizeof saddr; + ptrdiff_t count; s = accept4 (channel, &saddr.sa, &len, SOCK_CLOEXEC); @@ -4000,6 +4003,9 @@ return; } + count = SPECPDL_INDEX (); + record_unwind_protect_int (close_file_unwind, s); + connect_counter++; /* Setup a new process to handle the connection. */ @@ -4116,6 +4122,10 @@ pset_filter (p, ps->filter); pset_command (p, Qnil); p->pid = 0; + + /* Discard the unwind protect for closing S. */ + specpdl_ptr = specpdl + count; + p->infd = s; p->outfd = s; pset_status (p, Qrun); === modified file 'src/xfaces.c' --- src/xfaces.c 2013-07-16 06:39:49 +0000 +++ src/xfaces.c 2013-07-19 18:09:23 +0000 @@ -6283,6 +6283,7 @@ CHECK_STRING (filename); abspath = Fexpand_file_name (filename, Qnil); + block_input (); fp = emacs_fopen (SSDATA (abspath), "rt"); if (fp) { @@ -6290,29 +6291,24 @@ int red, green, blue; int num; - block_input (); - while (fgets (buf, sizeof (buf), fp) != NULL) { if (sscanf (buf, "%u %u %u %n", &red, &green, &blue, &num) == 3) { +#ifdef HAVE_NTGUI + int color = RGB (red, green, blue); +#else + int color = (red << 16) | (green << 8) | blue; +#endif char *name = buf + num; - num = strlen (name) - 1; - if (num >= 0 && name[num] == '\n') - name[num] = 0; - cmap = Fcons (Fcons (build_string (name), -#ifdef HAVE_NTGUI - make_number (RGB (red, green, blue))), -#else - make_number ((red << 16) | (green << 8) | blue)), -#endif + ptrdiff_t len = strlen (name); + len -= 0 < len && name[len - 1] == '\n'; + cmap = Fcons (Fcons (make_string (name, len), make_number (color)), cmap); } } fclose (fp); - - unblock_input (); } - + unblock_input (); return cmap; } #endif ------------------------------------------------------------ Use --include-merged or -n0 to see merged revisions.