1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-22 05:31:01 -08:00

auto upstream

This commit is contained in:
Joakim Verona 2013-01-12 00:04:04 +01:00
commit c655adbbab
21 changed files with 517 additions and 357 deletions

View file

@ -1,3 +1,7 @@
2013-01-11 Eli Zaretskii <eliz@gnu.org>
* lib/getopt_.h: Regenerate.
2013-01-10 Paul Eggert <eggert@cs.ucla.edu> 2013-01-10 Paul Eggert <eggert@cs.ucla.edu>
Merge from gnulib, incorporating: Merge from gnulib, incorporating:

View file

@ -1,6 +1,6 @@
/* Declarations for getopt. /* Declarations for getopt.
Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2007, 2009-2013 Free Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2007, 2009-2013 Free Software
Software Foundation, Inc. Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
@ -53,7 +53,9 @@
linkers. */ linkers. */
#if defined __GETOPT_PREFIX && !defined __need_getopt #if defined __GETOPT_PREFIX && !defined __need_getopt
# if !HAVE_GETOPT_H # if !HAVE_GETOPT_H
# define __need_system_stdlib_h
# include <stdlib.h> # include <stdlib.h>
# undef __need_system_stdlib_h
# include <stdio.h> # include <stdio.h>
# include <unistd.h> # include <unistd.h>
# endif # endif
@ -128,7 +130,7 @@
/* The definition of _GL_ARG_NONNULL is copied here. */ /* The definition of _GL_ARG_NONNULL is copied here. */
/* A C macro for declaring that specific arguments must not be NULL. /* A C macro for declaring that specific arguments must not be NULL.
Copyright (C) 2009-2012 Free Software Foundation, Inc. Copyright (C) 2009-2013 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published under the terms of the GNU General Public License as published

View file

@ -1,3 +1,34 @@
2013-01-11 Michael Albinus <michael.albinus@gmx.de>
* autorevert.el (top): Require 'cl in order to pacify byte compiler.
(auto-revert-notify-rm-watch): Ignore errors.
(auto-revert-notify-add-watch): Ignore errors. Use '(modify) for
inotify, and '(size last-write-time) for w32notify. Set
buffer-local `auto-revert-use-notify' to nil when adding a file
watch fails - this is a fallback to the file modification check.
(auto-revert-notify-event-p, auto-revert-notify-event-descriptor)
(auto-revert-notify-event-action)
(auto-revert-notify-event-file-name): New defuns.
(auto-revert-notify-handler): Use them. Implement first
plausibility checks.
(auto-revert-handler): Handle also `auto-revert-tail-mode'.
2013-01-11 Julien Danjou <julien@danjou.info>
* color.el (color-rgb-to-hsv): Fix conversion computing in case min and
max are almost equal. Also return the correct value for V which is
already between 0 and 1.
2013-01-11 Dmitry Antipov <dmantipov@yandex.ru>
* emacs-lisp/ert.el (ert-run-test): Use point-max-marker.
2013-01-11 Eli Zaretskii <eliz@gnu.org>
* autorevert.el (auto-revert-notify-rm-watch)
(auto-revert-notify-add-watch): Fix typos in w32notify function
names.
2013-01-10 Michael Albinus <michael.albinus@gmx.de> 2013-01-10 Michael Albinus <michael.albinus@gmx.de>
* autorevert.el (auto-revert-notify-enabled): Move up. * autorevert.el (auto-revert-notify-enabled): Move up.

View file

@ -97,6 +97,7 @@
;; Dependencies: ;; Dependencies:
(eval-when-compile (require 'cl))
(require 'timer) (require 'timer)
;; Custom Group: ;; Custom Group:
@ -466,8 +467,10 @@ will use an up-to-date value of `auto-revert-interval'"
(defun auto-revert-notify-rm-watch () (defun auto-revert-notify-rm-watch ()
"Disable file watch for current buffer's associated file." "Disable file watch for current buffer's associated file."
(when auto-revert-notify-watch-descriptor (when auto-revert-notify-watch-descriptor
(funcall (if (fboundp 'inotify-rm-watch) 'inotify-rm-watch 'w32-rm-watch) (ignore-errors
auto-revert-notify-watch-descriptor) (funcall (if (fboundp 'inotify-rm-watch)
'inotify-rm-watch 'w32notify-rm-watch)
auto-revert-notify-watch-descriptor))
(remhash auto-revert-notify-watch-descriptor (remhash auto-revert-notify-watch-descriptor
auto-revert-notify-watch-descriptor-hash-list)) auto-revert-notify-watch-descriptor-hash-list))
(setq auto-revert-notify-watch-descriptor nil (setq auto-revert-notify-watch-descriptor nil
@ -478,21 +481,62 @@ will use an up-to-date value of `auto-revert-interval'"
(when (and buffer-file-name auto-revert-use-notify) (when (and buffer-file-name auto-revert-use-notify)
(auto-revert-notify-rm-watch) (auto-revert-notify-rm-watch)
(let ((func (if (fboundp 'inotify-add-watch) (let ((func (if (fboundp 'inotify-add-watch)
'inotify-add-watch 'w32-add-watch)) 'inotify-add-watch 'w32notify-add-watch))
(aspect (if (fboundp 'inotify-add-watch) (aspect (if (fboundp 'inotify-add-watch)
'(close-write) '(last-write-time)))) '(modify) '(size last-write-time))))
(setq auto-revert-notify-watch-descriptor (setq auto-revert-notify-watch-descriptor
(funcall func buffer-file-name aspect 'auto-revert-notify-handler)) (ignore-errors
(funcall
func buffer-file-name aspect 'auto-revert-notify-handler)))
(if auto-revert-notify-watch-descriptor
(puthash auto-revert-notify-watch-descriptor (puthash auto-revert-notify-watch-descriptor
(current-buffer) (current-buffer)
auto-revert-notify-watch-descriptor-hash-list)))) auto-revert-notify-watch-descriptor-hash-list)
;; Fallback to file checks.
(set (make-local-variable 'auto-revert-use-notify) nil)))))
(defun auto-revert-notify-event-p (event)
"Check that event is a file watch event."
(cond ((featurep 'inotify)
(and (listp event) (= (length event) 4)))
((featurep 'w32notify)
(and (listp event) (= (length event) 3) (stringp (nth 2 event))))))
(defun auto-revert-notify-event-descriptor (event)
"Return watch descriptor of notification event, or nil."
(and (auto-revert-notify-event-p event) (car event)))
(defun auto-revert-notify-event-action (event)
"Return action of notification event, or nil."
(and (auto-revert-notify-event-p event) (nth 1 event)))
(defun auto-revert-notify-event-file-name (event)
"Return file name of notification event, or nil."
(and (auto-revert-notify-event-p event)
(cond ((featurep 'inotify) (nth 3 event))
((featurep 'w32notify) (nth 2 event)))))
(defun auto-revert-notify-handler (event) (defun auto-revert-notify-handler (event)
"Handle an event returned from file watch." "Handle an event returned from file watch."
(when (listp event) (when (auto-revert-notify-event-p event)
(let ((buffer (let* ((descriptor (auto-revert-notify-event-descriptor event))
(gethash (car event) auto-revert-notify-watch-descriptor-hash-list))) (action (auto-revert-notify-event-action event))
(when (bufferp buffer) (file (auto-revert-notify-event-file-name event))
(buffer (gethash descriptor
auto-revert-notify-watch-descriptor-hash-list)))
(ignore-errors
;; Check, that event is meant for us.
;; TODO: Filter events which stop watching, like `move' or `removed'.
(assert descriptor)
(when (featurep 'inotify) (assert (memq 'modify descriptor)))
(when (featurep 'w32notify) (assert (eq 'modified descriptor)))
(assert (bufferp buffer))
(when (stringp file)
(assert (string-equal
(directory-file-name file)
(directory-file-name (buffer-file-name buffer)))))
;; Mark buffer modified.
(with-current-buffer buffer (with-current-buffer buffer
(setq auto-revert-notify-modified-p t)))))) (setq auto-revert-notify-modified-p t))))))
@ -513,6 +557,8 @@ This is an internal function used by Auto-Revert Mode."
(let* ((buffer (current-buffer)) size (let* ((buffer (current-buffer)) size
(revert (revert
(or (and buffer-file-name (or (and buffer-file-name
(or (not auto-revert-use-notify)
auto-revert-notify-modified-p)
(if auto-revert-tail-mode (if auto-revert-tail-mode
;; Tramp caches the file attributes. Setting ;; Tramp caches the file attributes. Setting
;; `remote-file-name-inhibit-cache' forces Tramp ;; `remote-file-name-inhibit-cache' forces Tramp
@ -523,12 +569,9 @@ This is an internal function used by Auto-Revert Mode."
(setq size (setq size
(nth 7 (file-attributes (nth 7 (file-attributes
buffer-file-name)))))) buffer-file-name))))))
(if auto-revert-use-notify
;; There are file watches.
auto-revert-notify-modified-p
(and (not (file-remote-p buffer-file-name)) (and (not (file-remote-p buffer-file-name))
(file-readable-p buffer-file-name) (file-readable-p buffer-file-name)
(not (verify-visited-file-modtime buffer)))))) (not (verify-visited-file-modtime buffer)))))
(and (or auto-revert-mode (and (or auto-revert-mode
global-auto-revert-non-file-buffers) global-auto-revert-non-file-buffers)
revert-buffer-function revert-buffer-function

View file

@ -130,7 +130,7 @@ inclusive."
(max (max r g b)) (max (max r g b))
(min (min r g b))) (min (min r g b)))
(if (< (- max min) 1e-8) (if (< (- max min) 1e-8)
(list 0.0 0.0 0.0) (list 0.0 0.0 min)
(list (list
(/ (* 2 float-pi (/ (* 2 float-pi
(cond ((and (= r g) (= g b)) 0) (cond ((and (= r g) (= g b)) 0)
@ -146,7 +146,7 @@ inclusive."
(+ 240 (* 60 (/ (- r g) (- max min))))))) (+ 240 (* 60 (/ (- r g) (- max min)))))))
360) 360)
(if (= max 0) 0 (- 1 (/ min max))) (if (= max 0) 0 (- 1 (/ min max)))
(/ max 255.0))))) max))))
(defun color-rgb-to-hsl (red green blue) (defun color-rgb-to-hsl (red green blue)
"Convert RGB colors to their HSL representation. "Convert RGB colors to their HSL representation.

View file

@ -937,7 +937,7 @@ Returns the result and stores it in ERT-TEST's `most-recent-result' slot."
(cl-block error (cl-block error
(let ((begin-marker (let ((begin-marker
(with-current-buffer (get-buffer-create "*Messages*") (with-current-buffer (get-buffer-create "*Messages*")
(set-marker (make-marker) (point-max))))) (point-max-marker))))
(unwind-protect (unwind-protect
(let ((info (make-ert--test-execution-info (let ((info (make-ert--test-execution-info
:test ert-test :test ert-test

View file

@ -1,3 +1,8 @@
2013-01-11 Dmitry Antipov <dmantipov@yandex.ru>
* erc-dcc.el (erc-dcc-send-file): Use point-min-marker.
(erc-dcc-chat-setup): Use point-max-marker.
2013-01-04 Glenn Morris <rgm@gnu.org> 2013-01-04 Glenn Morris <rgm@gnu.org>
* erc-backend.el (312): Fix typo. (Bug#13235) * erc-backend.el (312): Fix typo. (Bug#13235)

View file

@ -897,7 +897,7 @@ other client."
(let* ((buffer (erc-dcc-find-file file)) (let* ((buffer (erc-dcc-find-file file))
(size (buffer-size buffer)) (size (buffer-size buffer))
(start (with-current-buffer buffer (start (with-current-buffer buffer
(set-marker (make-marker) (point-min)))) (point-min-marker)))
(sproc (erc-dcc-server "dcc-send" (sproc (erc-dcc-server "dcc-send"
'erc-dcc-send-filter 'erc-dcc-send-filter
'erc-dcc-send-sentinel)) 'erc-dcc-send-sentinel))
@ -1166,7 +1166,7 @@ other client."
(setq erc-dcc-from nick) (setq erc-dcc-from nick)
(setq erc-dcc-entry-data entry) (setq erc-dcc-entry-data entry)
(setq erc-dcc-unprocessed-output "") (setq erc-dcc-unprocessed-output "")
(setq erc-insert-marker (set-marker (make-marker) (point-max))) (setq erc-insert-marker (point-max-marker))
(setq erc-input-marker (make-marker)) (setq erc-input-marker (make-marker))
(erc-display-prompt buffer (point-max)) (erc-display-prompt buffer (point-max))
(set-process-buffer proc buffer) (set-process-buffer proc buffer)

View file

@ -1,3 +1,15 @@
2013-01-11 Dmitry Antipov <dmantipov@yandex.ru>
* gnus-art.el (gnus-mime-display-security): Use point-min-marker
and point-max-marker.
* gnus-async.el (gnus-async-article-callback): Use point-max-marker.
2013-01-10 Uwe Brauer <oub@mat.ucm.es> (tiny change)
* mml-smime.el (mml-smime-encrypt-to-self): New user option analogous
to mml2015-encrypt-to-self.
(mml-smime-epg-encrypt): Respect mml-smime-encrypt-to-self.
2013-01-09 Daiki Ueno <ueno@gnu.org> 2013-01-09 Daiki Ueno <ueno@gnu.org>
* mml-smime.el (epg-sub-key-fingerprint): Autoload for * mml-smime.el (epg-sub-key-fingerprint): Autoload for

View file

@ -8688,9 +8688,7 @@ For example:
gnus-mime-security-button-end-line-format)) gnus-mime-security-button-end-line-format))
(gnus-insert-mime-security-button handle))) (gnus-insert-mime-security-button handle)))
(mm-set-handle-multipart-parameter (mm-set-handle-multipart-parameter
handle 'gnus-region handle 'gnus-region (cons (point-min-marker) (point-max-marker)))
(cons (set-marker (make-marker) (point-min))
(set-marker (make-marker) (point-max))))
(goto-char (point-max)))) (goto-char (point-max))))
(defun gnus-mime-security-run-function (function) (defun gnus-mime-security-run-function (function)

View file

@ -254,7 +254,7 @@ that was fetched."
gnus-async-article-alist gnus-async-article-alist
(cons (list (intern (format "%s-%d" group article) (cons (list (intern (format "%s-%d" group article)
gnus-async-hashtb) gnus-async-hashtb)
mark (set-marker (make-marker) (point-max)) mark (point-max-marker)
group article) group article)
gnus-async-article-alist)))) gnus-async-article-alist))))
(if (not (gnus-buffer-live-p summary)) (if (not (gnus-buffer-live-p summary))

View file

@ -80,6 +80,12 @@ Whether the passphrase is cached at all is controlled by
:version "24.4" :version "24.4"
:type 'boolean) :type 'boolean)
(defcustom mml-smime-encrypt-to-self nil
"If t, add your own key ID to recipient list when encryption."
:group 'mime-security
:version "24.4"
:type 'boolean)
(defun mml-smime-sign (cont) (defun mml-smime-sign (cont)
(let ((func (nth 1 (assq mml-smime-use mml-smime-function-alist)))) (let ((func (nth 1 (assq mml-smime-use mml-smime-function-alist))))
(if func (if func
@ -475,11 +481,15 @@ Content-Disposition: attachment; filename=smime.p7s
(goto-char (point-max)))) (goto-char (point-max))))
(defun mml-smime-epg-encrypt (cont) (defun mml-smime-epg-encrypt (cont)
(let ((inhibit-redisplay t) (let* ((inhibit-redisplay t)
(context (epg-make-context 'CMS)) (context (epg-make-context 'CMS))
(config (epg-configuration)) (config (epg-configuration))
(recipients (message-options-get 'mml-smime-epg-recipients)) (recipients (message-options-get 'mml-smime-epg-recipients))
cipher signers cipher signers
(sender (message-options-get 'message-sender))
(signer-names (or mml-smime-signers
(if (and mml-smime-sign-with-sender sender)
(list (concat "<" sender ">")))))
(boundary (mml-compute-boundary cont)) (boundary (mml-compute-boundary cont))
recipient-key) recipient-key)
(unless recipients (unless recipients
@ -494,6 +504,10 @@ Content-Disposition: attachment; filename=smime.p7s
(message-options-set 'message-recipients (message-options-set 'message-recipients
(read-string "Recipients: "))) (read-string "Recipients: ")))
"[ \f\t\n\r\v,]+")))) "[ \f\t\n\r\v,]+"))))
(when mml-smime-encrypt-to-self
(unless signer-names
(error "Neither message sender nor mml-smime-signers are set"))
(setq recipients (nconc recipients signer-names)))
(if (eq mm-encrypt-option 'guided) (if (eq mm-encrypt-option 'guided)
(setq recipients (setq recipients
(epa-select-keys context "\ (epa-select-keys context "\

View file

@ -1,3 +1,8 @@
2013-01-11 Eli Zaretskii <eliz@gnu.org>
* inc/unistd.h (O_IGNORE_CTTY): Define, as it is unconditionally
used in term.c. (Bug#13387)
2013-01-09 Juanma Barranquero <lekktu@gmail.com> 2013-01-09 Juanma Barranquero <lekktu@gmail.com>
* config.nt: Sync with autogen/config.in. * config.nt: Sync with autogen/config.in.

View file

@ -27,6 +27,7 @@ extern int faccessat (int, char const *, int, int);
#define AT_SYMLINK_NOFOLLOW 4096 #define AT_SYMLINK_NOFOLLOW 4096
#define O_NOCTTY 0 #define O_NOCTTY 0
#define O_IGNORE_CTTY 0
/* This is normally on stdlib.h, but we don't override that header. */ /* This is normally on stdlib.h, but we don't override that header. */
extern int unsetenv (const char *); extern int unsetenv (const char *);

View file

@ -1,3 +1,28 @@
2013-01-11 Dmitry Antipov <dmantipov@yandex.ru>
Avoid unnecessary byte position calculation for the gap movement.
Since all users of move_gap do CHAR_TO_BYTE for other purposes
anyway, all of them should use move_gap_both instead.
* lisp.h (move_gap): Remove prototype.
* insdel.c (move_gap): Remove.
(move_gap_both): Add eassert.
* editfns.c (Ftranspose_regions): Tweak to use move_gap_both.
* xml.c (parse_region): Likewise.
2013-01-11 Paul Eggert <eggert@cs.ucla.edu>
emacsclient -t should not suspend Emacs server (Bug#13387)
* lisp.h, sysdep.c (block_tty_out_signal, unblock_tty_out_signal):
New functions.
* term.c (init_tty): Use them instead of rolling our own code.
* sysdep.c (tcsetpgrp_without_stopping): Likewise. Here, this
switches from 'signal' to 'pthread_sigmask', which is safer in
multithreaded applications.
* term.c (Fresume_tty): Don't bother dissociating if O_IGNORE_CTTY,
which has already arranged for that.
(dissociate_if_controlling_tty): If setsid fails, fall back on TIOCNOTTY.
This is the main part of the bug fix.
2013-01-10 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> (tiny change) 2013-01-10 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> (tiny change)
* gtkutil.c (xg_initialize): Add ifdef HAVE_FREETYPE around * gtkutil.c (xg_initialize): Add ifdef HAVE_FREETYPE around

View file

@ -4522,7 +4522,7 @@ Transposing beyond buffer boundaries is an error. */)
(Lisp_Object startr1, Lisp_Object endr1, Lisp_Object startr2, Lisp_Object endr2, Lisp_Object leave_markers) (Lisp_Object startr1, Lisp_Object endr1, Lisp_Object startr2, Lisp_Object endr2, Lisp_Object leave_markers)
{ {
register ptrdiff_t start1, end1, start2, end2; register ptrdiff_t start1, end1, start2, end2;
ptrdiff_t start1_byte, start2_byte, len1_byte, len2_byte; ptrdiff_t start1_byte, start2_byte, len1_byte, len2_byte, end2_byte;
ptrdiff_t gap, len1, len_mid, len2; ptrdiff_t gap, len1, len_mid, len2;
unsigned char *start1_addr, *start2_addr, *temp; unsigned char *start1_addr, *start2_addr, *temp;
@ -4583,20 +4583,22 @@ Transposing beyond buffer boundaries is an error. */)
the gap the minimum distance to get it out of the way, and then the gap the minimum distance to get it out of the way, and then
deal with an unbroken array. */ deal with an unbroken array. */
start1_byte = CHAR_TO_BYTE (start1);
end2_byte = CHAR_TO_BYTE (end2);
/* Make sure the gap won't interfere, by moving it out of the text /* Make sure the gap won't interfere, by moving it out of the text
we will operate on. */ we will operate on. */
if (start1 < gap && gap < end2) if (start1 < gap && gap < end2)
{ {
if (gap - start1 < end2 - gap) if (gap - start1 < end2 - gap)
move_gap (start1); move_gap_both (start1, start1_byte);
else else
move_gap (end2); move_gap_both (end2, end2_byte);
} }
start1_byte = CHAR_TO_BYTE (start1);
start2_byte = CHAR_TO_BYTE (start2); start2_byte = CHAR_TO_BYTE (start2);
len1_byte = CHAR_TO_BYTE (end1) - start1_byte; len1_byte = CHAR_TO_BYTE (end1) - start1_byte;
len2_byte = CHAR_TO_BYTE (end2) - start2_byte; len2_byte = end2_byte - start2_byte;
#ifdef BYTE_COMBINING_DEBUG #ifdef BYTE_COMBINING_DEBUG
if (end1 == start2) if (end1 == start2)

View file

@ -84,21 +84,14 @@ check_markers (void)
#endif /* MARKER_DEBUG */ #endif /* MARKER_DEBUG */
/* Move gap to position CHARPOS.
Note that this can quit! */
void
move_gap (ptrdiff_t charpos)
{
move_gap_both (charpos, CHAR_TO_BYTE (charpos));
}
/* Move gap to byte position BYTEPOS, which is also char position CHARPOS. /* Move gap to byte position BYTEPOS, which is also char position CHARPOS.
Note that this can quit! */ Note that this can quit! */
void void
move_gap_both (ptrdiff_t charpos, ptrdiff_t bytepos) move_gap_both (ptrdiff_t charpos, ptrdiff_t bytepos)
{ {
eassert (charpos == BYTE_TO_CHAR (bytepos)
&& bytepos == CHAR_TO_BYTE (charpos));
if (bytepos < GPT_BYTE) if (bytepos < GPT_BYTE)
gap_left (charpos, bytepos, 0); gap_left (charpos, bytepos, 0);
else if (bytepos > GPT_BYTE) else if (bytepos > GPT_BYTE)

View file

@ -2780,7 +2780,6 @@ extern void syms_of_image (void);
/* Defined in insdel.c. */ /* Defined in insdel.c. */
extern Lisp_Object Qinhibit_modification_hooks; extern Lisp_Object Qinhibit_modification_hooks;
extern void move_gap (ptrdiff_t);
extern void move_gap_both (ptrdiff_t, ptrdiff_t); extern void move_gap_both (ptrdiff_t, ptrdiff_t);
extern _Noreturn void buffer_overflow (void); extern _Noreturn void buffer_overflow (void);
extern void make_gap (ptrdiff_t); extern void make_gap (ptrdiff_t);
@ -3467,6 +3466,8 @@ extern void init_sigio (int);
extern void sys_subshell (void); extern void sys_subshell (void);
extern void sys_suspend (void); extern void sys_suspend (void);
extern void discard_tty_input (void); extern void discard_tty_input (void);
extern void block_tty_out_signal (void);
extern void unblock_tty_out_signal (void);
extern void init_sys_modes (struct tty_display_info *); extern void init_sys_modes (struct tty_display_info *);
extern void reset_sys_modes (struct tty_display_info *); extern void reset_sys_modes (struct tty_display_info *);
extern void init_all_sys_modes (void); extern void init_all_sys_modes (void);

View file

@ -714,6 +714,27 @@ init_foreground_group (void)
inherited_pgroup = getpid () == pgrp ? 0 : pgrp; inherited_pgroup = getpid () == pgrp ? 0 : pgrp;
} }
/* Block and unblock SIGTTOU. */
void
block_tty_out_signal (void)
{
#ifdef SIGTTOU
sigset_t blocked;
sigemptyset (&blocked);
sigaddset (&blocked, SIGTTOU);
pthread_sigmask (SIG_BLOCK, &blocked, 0);
#endif
}
void
unblock_tty_out_signal (void)
{
#ifdef SIGTTOU
pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
#endif
}
/* Safely set a controlling terminal FD's process group to PGID. /* Safely set a controlling terminal FD's process group to PGID.
If we are not in the foreground already, POSIX requires tcsetpgrp If we are not in the foreground already, POSIX requires tcsetpgrp
to deliver a SIGTTOU signal, which would stop us. This is an to deliver a SIGTTOU signal, which would stop us. This is an
@ -725,11 +746,10 @@ static void
tcsetpgrp_without_stopping (int fd, pid_t pgid) tcsetpgrp_without_stopping (int fd, pid_t pgid)
{ {
#ifdef SIGTTOU #ifdef SIGTTOU
signal_handler_t handler;
block_input (); block_input ();
handler = signal (SIGTTOU, SIG_IGN); block_tty_out_signal ();
tcsetpgrp (fd, pgid); tcsetpgrp (fd, pgid);
signal (SIGTTOU, handler); unblock_tty_out_signal ();
unblock_input (); unblock_input ();
#endif #endif
} }

View file

@ -2423,7 +2423,7 @@ frame's terminal). */)
if (fd == -1) if (fd == -1)
error ("Can not reopen tty device %s: %s", t->display_info.tty->name, strerror (errno)); error ("Can not reopen tty device %s: %s", t->display_info.tty->name, strerror (errno));
if (strcmp (t->display_info.tty->name, DEV_TTY)) if (!O_IGNORE_CTTY && strcmp (t->display_info.tty->name, DEV_TTY) != 0)
dissociate_if_controlling_tty (fd); dissociate_if_controlling_tty (fd);
t->display_info.tty->output = fdopen (fd, "w+"); t->display_info.tty->output = fdopen (fd, "w+");
@ -2903,13 +2903,23 @@ set_tty_hooks (struct terminal *terminal)
terminal->delete_terminal_hook = &delete_tty; terminal->delete_terminal_hook = &delete_tty;
} }
/* Drop the controlling terminal if fd is the same device. */ /* If FD is the controlling terminal, drop it. */
static void static void
dissociate_if_controlling_tty (int fd) dissociate_if_controlling_tty (int fd)
{ {
pid_t pgid = tcgetpgrp (fd); /* If tcgetpgrp succeeds, fd is the ctty. */ /* If tcgetpgrp succeeds, fd is the controlling terminal,
if (0 <= pgid) so dissociate it by invoking setsid. */
setsid (); if (0 <= tcgetpgrp (fd) && setsid () < 0)
{
#ifdef TIOCNOTTY
/* setsid failed, presumably because Emacs is already a process
group leader. Fall back on the obsolescent way to dissociate
a controlling tty. */
block_tty_out_signal ();
ioctl (fd, TIOCNOTTY, 0);
unblock_tty_out_signal ();
#endif
}
} }
/* Create a termcap display on the tty device with the given name and /* Create a termcap display on the tty device with the given name and
@ -3030,14 +3040,9 @@ init_tty (const char *name, const char *terminal_type, int must_succeed)
/* On some systems, tgetent tries to access the controlling /* On some systems, tgetent tries to access the controlling
terminal. */ terminal. */
{ block_tty_out_signal ();
sigset_t blocked;
sigemptyset (&blocked);
sigaddset (&blocked, SIGTTOU);
pthread_sigmask (SIG_BLOCK, &blocked, 0);
status = tgetent (tty->termcap_term_buffer, terminal_type); status = tgetent (tty->termcap_term_buffer, terminal_type);
pthread_sigmask (SIG_UNBLOCK, &blocked, 0); unblock_tty_out_signal ();
}
if (status < 0) if (status < 0)
{ {

View file

@ -180,8 +180,7 @@ parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, int html
xmlDoc *doc; xmlDoc *doc;
Lisp_Object result = Qnil; Lisp_Object result = Qnil;
const char *burl = ""; const char *burl = "";
ptrdiff_t bytes; ptrdiff_t istart, iend, istart_byte, iend_byte;
ptrdiff_t istart, iend;
fn_xmlCheckVersion (LIBXML_VERSION); fn_xmlCheckVersion (LIBXML_VERSION);
@ -189,9 +188,11 @@ parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, int html
istart = XINT (start); istart = XINT (start);
iend = XINT (end); iend = XINT (end);
istart_byte = CHAR_TO_BYTE (istart);
iend_byte = CHAR_TO_BYTE (iend);
if (istart < GPT && GPT < iend) if (istart < GPT && GPT < iend)
move_gap (iend); move_gap_both (iend, iend_byte);
if (! NILP (base_url)) if (! NILP (base_url))
{ {
@ -199,17 +200,15 @@ parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, int html
burl = SSDATA (base_url); burl = SSDATA (base_url);
} }
bytes = CHAR_TO_BYTE (iend) - CHAR_TO_BYTE (istart);
if (htmlp) if (htmlp)
doc = fn_htmlReadMemory ((char *) BYTE_POS_ADDR (CHAR_TO_BYTE (istart)), doc = fn_htmlReadMemory ((char *) BYTE_POS_ADDR (istart_byte),
bytes, burl, "utf-8", iend_byte - istart_byte, burl, "utf-8",
HTML_PARSE_RECOVER|HTML_PARSE_NONET| HTML_PARSE_RECOVER|HTML_PARSE_NONET|
HTML_PARSE_NOWARNING|HTML_PARSE_NOERROR| HTML_PARSE_NOWARNING|HTML_PARSE_NOERROR|
HTML_PARSE_NOBLANKS); HTML_PARSE_NOBLANKS);
else else
doc = fn_xmlReadMemory ((char *) BYTE_POS_ADDR (CHAR_TO_BYTE (istart)), doc = fn_xmlReadMemory ((char *) BYTE_POS_ADDR (istart_byte),
bytes, burl, "utf-8", iend_byte - istart_byte, burl, "utf-8",
XML_PARSE_NONET|XML_PARSE_NOWARNING| XML_PARSE_NONET|XML_PARSE_NOWARNING|
XML_PARSE_NOBLANKS |XML_PARSE_NOERROR); XML_PARSE_NOBLANKS |XML_PARSE_NOERROR);