aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakim Verona2013-01-12 00:04:04 +0100
committerJoakim Verona2013-01-12 00:04:04 +0100
commitc655adbbab4baf73b652c86dcc53a2fc049ea7a5 (patch)
treeb3198033222acb2c309652a0e11590f109d037c6
parent26f277ba01010776e63623d446f182f5b6f23dd3 (diff)
parentc88be99696aa39e3aed1e32ada7bf6e0cc472c90 (diff)
downloademacs-c655adbbab4baf73b652c86dcc53a2fc049ea7a5.tar.gz
emacs-c655adbbab4baf73b652c86dcc53a2fc049ea7a5.zip
auto upstream
-rw-r--r--ChangeLog4
-rw-r--r--lib/getopt_.h568
-rw-r--r--lisp/ChangeLog31
-rw-r--r--lisp/autorevert.el79
-rw-r--r--lisp/color.el4
-rw-r--r--lisp/emacs-lisp/ert.el2
-rw-r--r--lisp/erc/ChangeLog5
-rw-r--r--lisp/erc/erc-dcc.el4
-rw-r--r--lisp/gnus/ChangeLog12
-rw-r--r--lisp/gnus/gnus-art.el4
-rw-r--r--lisp/gnus/gnus-async.el2
-rw-r--r--lisp/gnus/mml-smime.el28
-rw-r--r--nt/ChangeLog5
-rw-r--r--nt/inc/unistd.h1
-rw-r--r--src/ChangeLog25
-rw-r--r--src/editfns.c12
-rw-r--r--src/insdel.c11
-rw-r--r--src/lisp.h3
-rw-r--r--src/sysdep.c26
-rw-r--r--src/term.c31
-rw-r--r--src/xml.c17
21 files changed, 517 insertions, 357 deletions
diff --git a/ChangeLog b/ChangeLog
index ba756946c56..2298c21a7fa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
12013-01-11 Eli Zaretskii <eliz@gnu.org>
2
3 * lib/getopt_.h: Regenerate.
4
12013-01-10 Paul Eggert <eggert@cs.ucla.edu> 52013-01-10 Paul Eggert <eggert@cs.ucla.edu>
2 6
3 Merge from gnulib, incorporating: 7 Merge from gnulib, incorporating:
diff --git a/lib/getopt_.h b/lib/getopt_.h
index 3f602dba2c6..10edb73f417 100644
--- a/lib/getopt_.h
+++ b/lib/getopt_.h
@@ -1,283 +1,285 @@
1/* Declarations for getopt. 1/* Declarations for getopt.
2 Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2007, 2009-2013 Free 2 Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2007, 2009-2013 Free Software
3 Software Foundation, Inc. 3 Foundation, Inc.
4 This file is part of the GNU C Library. 4 This file is part of the GNU C Library.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or 8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 18
19#ifndef _GL_GETOPT_H 19#ifndef _GL_GETOPT_H
20 20
21#if __GNUC__ >= 3 21#if __GNUC__ >= 3
22#pragma GCC system_header 22#pragma GCC system_header
23#endif 23#endif
24 24
25 25
26/* The include_next requires a split double-inclusion guard. We must 26/* The include_next requires a split double-inclusion guard. We must
27 also inform the replacement unistd.h to not recursively use 27 also inform the replacement unistd.h to not recursively use
28 <getopt.h>; our definitions will be present soon enough. */ 28 <getopt.h>; our definitions will be present soon enough. */
29#if HAVE_GETOPT_H 29#if HAVE_GETOPT_H
30# define _GL_SYSTEM_GETOPT 30# define _GL_SYSTEM_GETOPT
31# ifndef __GNUC__ 31# ifndef __GNUC__
32# include <next_getopt.h> 32# include <next_getopt.h>
33# else 33# else
34# include_next <getopt.h> 34# include_next <getopt.h>
35# endif 35# endif
36# undef _GL_SYSTEM_GETOPT 36# undef _GL_SYSTEM_GETOPT
37#endif 37#endif
38 38
39#ifndef _GL_GETOPT_H 39#ifndef _GL_GETOPT_H
40 40
41#ifndef __need_getopt 41#ifndef __need_getopt
42# define _GL_GETOPT_H 1 42# define _GL_GETOPT_H 1
43#endif 43#endif
44 44
45/* Standalone applications should #define __GETOPT_PREFIX to an 45/* Standalone applications should #define __GETOPT_PREFIX to an
46 identifier that prefixes the external functions and variables 46 identifier that prefixes the external functions and variables
47 defined in this header. When this happens, include the 47 defined in this header. When this happens, include the
48 headers that might declare getopt so that they will not cause 48 headers that might declare getopt so that they will not cause
49 confusion if included after this file (if the system had <getopt.h>, 49 confusion if included after this file (if the system had <getopt.h>,
50 we have already included it). Then systematically rename 50 we have already included it). Then systematically rename
51 identifiers so that they do not collide with the system functions 51 identifiers so that they do not collide with the system functions
52 and variables. Renaming avoids problems with some compilers and 52 and variables. Renaming avoids problems with some compilers and
53 linkers. */ 53 linkers. */
54#if defined __GETOPT_PREFIX && !defined __need_getopt 54#if defined __GETOPT_PREFIX && !defined __need_getopt
55# if !HAVE_GETOPT_H 55# if !HAVE_GETOPT_H
56# include <stdlib.h> 56# define __need_system_stdlib_h
57# include <stdio.h> 57# include <stdlib.h>
58# include <unistd.h> 58# undef __need_system_stdlib_h
59# endif 59# include <stdio.h>
60# undef __need_getopt 60# include <unistd.h>
61# undef getopt 61# endif
62# undef getopt_long 62# undef __need_getopt
63# undef getopt_long_only 63# undef getopt
64# undef optarg 64# undef getopt_long
65# undef opterr 65# undef getopt_long_only
66# undef optind 66# undef optarg
67# undef optopt 67# undef opterr
68# undef option 68# undef optind
69# define __GETOPT_CONCAT(x, y) x ## y 69# undef optopt
70# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y) 70# undef option
71# define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y) 71# define __GETOPT_CONCAT(x, y) x ## y
72# define getopt __GETOPT_ID (getopt) 72# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y)
73# define getopt_long __GETOPT_ID (getopt_long) 73# define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y)
74# define getopt_long_only __GETOPT_ID (getopt_long_only) 74# define getopt __GETOPT_ID (getopt)
75# define optarg __GETOPT_ID (optarg) 75# define getopt_long __GETOPT_ID (getopt_long)
76# define opterr __GETOPT_ID (opterr) 76# define getopt_long_only __GETOPT_ID (getopt_long_only)
77# define optind __GETOPT_ID (optind) 77# define optarg __GETOPT_ID (optarg)
78# define optopt __GETOPT_ID (optopt) 78# define opterr __GETOPT_ID (opterr)
79# define option __GETOPT_ID (option) 79# define optind __GETOPT_ID (optind)
80# define _getopt_internal __GETOPT_ID (getopt_internal) 80# define optopt __GETOPT_ID (optopt)
81#endif 81# define option __GETOPT_ID (option)
82 82# define _getopt_internal __GETOPT_ID (getopt_internal)
83/* Standalone applications get correct prototypes for getopt_long and 83#endif
84 getopt_long_only; they declare "char **argv". libc uses prototypes 84
85 with "char *const *argv" that are incorrect because getopt_long and 85/* Standalone applications get correct prototypes for getopt_long and
86 getopt_long_only can permute argv; this is required for backward 86 getopt_long_only; they declare "char **argv". libc uses prototypes
87 compatibility (e.g., for LSB 2.0.1). 87 with "char *const *argv" that are incorrect because getopt_long and
88 88 getopt_long_only can permute argv; this is required for backward
89 This used to be '#if defined __GETOPT_PREFIX && !defined __need_getopt', 89 compatibility (e.g., for LSB 2.0.1).
90 but it caused redefinition warnings if both unistd.h and getopt.h were 90
91 included, since unistd.h includes getopt.h having previously defined 91 This used to be '#if defined __GETOPT_PREFIX && !defined __need_getopt',
92 __need_getopt. 92 but it caused redefinition warnings if both unistd.h and getopt.h were
93 93 included, since unistd.h includes getopt.h having previously defined
94 The only place where __getopt_argv_const is used is in definitions 94 __need_getopt.
95 of getopt_long and getopt_long_only below, but these are visible 95
96 only if __need_getopt is not defined, so it is quite safe to rewrite 96 The only place where __getopt_argv_const is used is in definitions
97 the conditional as follows: 97 of getopt_long and getopt_long_only below, but these are visible
98*/ 98 only if __need_getopt is not defined, so it is quite safe to rewrite
99#if !defined __need_getopt 99 the conditional as follows:
100# if defined __GETOPT_PREFIX 100*/
101# define __getopt_argv_const /* empty */ 101#if !defined __need_getopt
102# else 102# if defined __GETOPT_PREFIX
103# define __getopt_argv_const const 103# define __getopt_argv_const /* empty */
104# endif 104# else
105#endif 105# define __getopt_argv_const const
106 106# endif
107/* If __GNU_LIBRARY__ is not already defined, either we are being used 107#endif
108 standalone, or this is the first header included in the source file. 108
109 If we are being used with glibc, we need to include <features.h>, but 109/* If __GNU_LIBRARY__ is not already defined, either we are being used
110 that does not exist if we are standalone. So: if __GNU_LIBRARY__ is 110 standalone, or this is the first header included in the source file.
111 not defined, include <ctype.h>, which will pull in <features.h> for us 111 If we are being used with glibc, we need to include <features.h>, but
112 if it's from glibc. (Why ctype.h? It's guaranteed to exist and it 112 that does not exist if we are standalone. So: if __GNU_LIBRARY__ is
113 doesn't flood the namespace with stuff the way some other headers do.) */ 113 not defined, include <ctype.h>, which will pull in <features.h> for us
114#if !defined __GNU_LIBRARY__ 114 if it's from glibc. (Why ctype.h? It's guaranteed to exist and it
115# include <ctype.h> 115 doesn't flood the namespace with stuff the way some other headers do.) */
116#endif 116#if !defined __GNU_LIBRARY__
117 117# include <ctype.h>
118#ifndef __THROW 118#endif
119# ifndef __GNUC_PREREQ 119
120# define __GNUC_PREREQ(maj, min) (0) 120#ifndef __THROW
121# endif 121# ifndef __GNUC_PREREQ
122# if defined __cplusplus && __GNUC_PREREQ (2,8) 122# define __GNUC_PREREQ(maj, min) (0)
123# define __THROW throw () 123# endif
124# else 124# if defined __cplusplus && __GNUC_PREREQ (2,8)
125# define __THROW 125# define __THROW throw ()
126# endif 126# else
127#endif 127# define __THROW
128 128# endif
129/* The definition of _GL_ARG_NONNULL is copied here. */ 129#endif
130/* A C macro for declaring that specific arguments must not be NULL. 130
131 Copyright (C) 2009-2012 Free Software Foundation, Inc. 131/* The definition of _GL_ARG_NONNULL is copied here. */
132 132/* A C macro for declaring that specific arguments must not be NULL.
133 This program is free software: you can redistribute it and/or modify it 133 Copyright (C) 2009-2013 Free Software Foundation, Inc.
134 under the terms of the GNU General Public License as published 134
135 by the Free Software Foundation; either version 3 of the License, or 135 This program is free software: you can redistribute it and/or modify it
136 (at your option) any later version. 136 under the terms of the GNU General Public License as published
137 137 by the Free Software Foundation; either version 3 of the License, or
138 This program is distributed in the hope that it will be useful, 138 (at your option) any later version.
139 but WITHOUT ANY WARRANTY; without even the implied warranty of 139
140 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 140 This program is distributed in the hope that it will be useful,
141 General Public License for more details. 141 but WITHOUT ANY WARRANTY; without even the implied warranty of
142 142 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
143 You should have received a copy of the GNU General Public License 143 General Public License for more details.
144 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 144
145 145 You should have received a copy of the GNU General Public License
146/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools 146 along with this program. If not, see <http://www.gnu.org/licenses/>. */
147 that the values passed as arguments n, ..., m must be non-NULL pointers. 147
148 n = 1 stands for the first argument, n = 2 for the second argument etc. */ 148/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
149#ifndef _GL_ARG_NONNULL 149 that the values passed as arguments n, ..., m must be non-NULL pointers.
150# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 150 n = 1 stands for the first argument, n = 2 for the second argument etc. */
151# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) 151#ifndef _GL_ARG_NONNULL
152# else 152# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
153# define _GL_ARG_NONNULL(params) 153# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
154# endif 154# else
155#endif 155# define _GL_ARG_NONNULL(params)
156 156# endif
157#ifdef __cplusplus 157#endif
158extern "C" { 158
159#endif 159#ifdef __cplusplus
160 160extern "C" {
161/* For communication from 'getopt' to the caller. 161#endif
162 When 'getopt' finds an option that takes an argument, 162
163 the argument value is returned here. 163/* For communication from 'getopt' to the caller.
164 Also, when 'ordering' is RETURN_IN_ORDER, 164 When 'getopt' finds an option that takes an argument,
165 each non-option ARGV-element is returned here. */ 165 the argument value is returned here.
166 166 Also, when 'ordering' is RETURN_IN_ORDER,
167extern char *optarg; 167 each non-option ARGV-element is returned here. */
168 168
169/* Index in ARGV of the next element to be scanned. 169extern char *optarg;
170 This is used for communication to and from the caller 170
171 and for communication between successive calls to 'getopt'. 171/* Index in ARGV of the next element to be scanned.
172 172 This is used for communication to and from the caller
173 On entry to 'getopt', zero means this is the first call; initialize. 173 and for communication between successive calls to 'getopt'.
174 174
175 When 'getopt' returns -1, this is the index of the first of the 175 On entry to 'getopt', zero means this is the first call; initialize.
176 non-option elements that the caller should itself scan. 176
177 177 When 'getopt' returns -1, this is the index of the first of the
178 Otherwise, 'optind' communicates from one call to the next 178 non-option elements that the caller should itself scan.
179 how much of ARGV has been scanned so far. */ 179
180 180 Otherwise, 'optind' communicates from one call to the next
181extern int optind; 181 how much of ARGV has been scanned so far. */
182 182
183/* Callers store zero here to inhibit the error message 'getopt' prints 183extern int optind;
184 for unrecognized options. */ 184
185 185/* Callers store zero here to inhibit the error message 'getopt' prints
186extern int opterr; 186 for unrecognized options. */
187 187
188/* Set to an option character which was unrecognized. */ 188extern int opterr;
189 189
190extern int optopt; 190/* Set to an option character which was unrecognized. */
191 191
192#ifndef __need_getopt 192extern int optopt;
193/* Describe the long-named options requested by the application. 193
194 The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector 194#ifndef __need_getopt
195 of 'struct option' terminated by an element containing a name which is 195/* Describe the long-named options requested by the application.
196 zero. 196 The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
197 197 of 'struct option' terminated by an element containing a name which is
198 The field 'has_arg' is: 198 zero.
199 no_argument (or 0) if the option does not take an argument, 199
200 required_argument (or 1) if the option requires an argument, 200 The field 'has_arg' is:
201 optional_argument (or 2) if the option takes an optional argument. 201 no_argument (or 0) if the option does not take an argument,
202 202 required_argument (or 1) if the option requires an argument,
203 If the field 'flag' is not NULL, it points to a variable that is set 203 optional_argument (or 2) if the option takes an optional argument.
204 to the value given in the field 'val' when the option is found, but 204
205 left unchanged if the option is not found. 205 If the field 'flag' is not NULL, it points to a variable that is set
206 206 to the value given in the field 'val' when the option is found, but
207 To have a long-named option do something other than set an 'int' to 207 left unchanged if the option is not found.
208 a compiled-in constant, such as set a value from 'optarg', set the 208
209 option's 'flag' field to zero and its 'val' field to a nonzero 209 To have a long-named option do something other than set an 'int' to
210 value (the equivalent single-letter option character, if there is 210 a compiled-in constant, such as set a value from 'optarg', set the
211 one). For long options that have a zero 'flag' field, 'getopt' 211 option's 'flag' field to zero and its 'val' field to a nonzero
212 returns the contents of the 'val' field. */ 212 value (the equivalent single-letter option character, if there is
213 213 one). For long options that have a zero 'flag' field, 'getopt'
214# if !GNULIB_defined_struct_option 214 returns the contents of the 'val' field. */
215struct option 215
216{ 216# if !GNULIB_defined_struct_option
217 const char *name; 217struct option
218 /* has_arg can't be an enum because some compilers complain about 218{
219 type mismatches in all the code that assumes it is an int. */ 219 const char *name;
220 int has_arg; 220 /* has_arg can't be an enum because some compilers complain about
221 int *flag; 221 type mismatches in all the code that assumes it is an int. */
222 int val; 222 int has_arg;
223}; 223 int *flag;
224# define GNULIB_defined_struct_option 1 224 int val;
225# endif 225};
226 226# define GNULIB_defined_struct_option 1
227/* Names for the values of the 'has_arg' field of 'struct option'. */ 227# endif
228 228
229# define no_argument 0 229/* Names for the values of the 'has_arg' field of 'struct option'. */
230# define required_argument 1 230
231# define optional_argument 2 231# define no_argument 0
232#endif /* need getopt */ 232# define required_argument 1
233 233# define optional_argument 2
234 234#endif /* need getopt */
235/* Get definitions and prototypes for functions to process the 235
236 arguments in ARGV (ARGC of them, minus the program name) for 236
237 options given in OPTS. 237/* Get definitions and prototypes for functions to process the
238 238 arguments in ARGV (ARGC of them, minus the program name) for
239 Return the option character from OPTS just read. Return -1 when 239 options given in OPTS.
240 there are no more options. For unrecognized options, or options 240
241 missing arguments, 'optopt' is set to the option letter, and '?' is 241 Return the option character from OPTS just read. Return -1 when
242 returned. 242 there are no more options. For unrecognized options, or options
243 243 missing arguments, 'optopt' is set to the option letter, and '?' is
244 The OPTS string is a list of characters which are recognized option 244 returned.
245 letters, optionally followed by colons, specifying that that letter 245
246 takes an argument, to be placed in 'optarg'. 246 The OPTS string is a list of characters which are recognized option
247 247 letters, optionally followed by colons, specifying that that letter
248 If a letter in OPTS is followed by two colons, its argument is 248 takes an argument, to be placed in 'optarg'.
249 optional. This behavior is specific to the GNU 'getopt'. 249
250 250 If a letter in OPTS is followed by two colons, its argument is
251 The argument '--' causes premature termination of argument 251 optional. This behavior is specific to the GNU 'getopt'.
252 scanning, explicitly telling 'getopt' that there are no more 252
253 options. 253 The argument '--' causes premature termination of argument
254 254 scanning, explicitly telling 'getopt' that there are no more
255 If OPTS begins with '-', then non-option arguments are treated as 255 options.
256 arguments to the option '\1'. This behavior is specific to the GNU 256
257 'getopt'. If OPTS begins with '+', or POSIXLY_CORRECT is set in 257 If OPTS begins with '-', then non-option arguments are treated as
258 the environment, then do not permute arguments. */ 258 arguments to the option '\1'. This behavior is specific to the GNU
259 259 'getopt'. If OPTS begins with '+', or POSIXLY_CORRECT is set in
260extern int getopt (int ___argc, char *const *___argv, const char *__shortopts) 260 the environment, then do not permute arguments. */
261 __THROW _GL_ARG_NONNULL ((2, 3)); 261
262 262extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
263#ifndef __need_getopt 263 __THROW _GL_ARG_NONNULL ((2, 3));
264extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv, 264
265 const char *__shortopts, 265#ifndef __need_getopt
266 const struct option *__longopts, int *__longind) 266extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv,
267 __THROW _GL_ARG_NONNULL ((2, 3)); 267 const char *__shortopts,
268extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv, 268 const struct option *__longopts, int *__longind)
269 const char *__shortopts, 269 __THROW _GL_ARG_NONNULL ((2, 3));
270 const struct option *__longopts, int *__longind) 270extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
271 __THROW _GL_ARG_NONNULL ((2, 3)); 271 const char *__shortopts,
272 272 const struct option *__longopts, int *__longind)
273#endif 273 __THROW _GL_ARG_NONNULL ((2, 3));
274 274
275#ifdef __cplusplus 275#endif
276} 276
277#endif 277#ifdef __cplusplus
278 278}
279/* Make sure we later can get all the definitions and declarations. */ 279#endif
280#undef __need_getopt 280
281 281/* Make sure we later can get all the definitions and declarations. */
282#endif /* _GL_GETOPT_H */ 282#undef __need_getopt
283#endif /* _GL_GETOPT_H */ 283
284#endif /* _GL_GETOPT_H */
285#endif /* _GL_GETOPT_H */
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 0d4566a91a6..7eef2c80382 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,34 @@
12013-01-11 Michael Albinus <michael.albinus@gmx.de>
2
3 * autorevert.el (top): Require 'cl in order to pacify byte compiler.
4 (auto-revert-notify-rm-watch): Ignore errors.
5 (auto-revert-notify-add-watch): Ignore errors. Use '(modify) for
6 inotify, and '(size last-write-time) for w32notify. Set
7 buffer-local `auto-revert-use-notify' to nil when adding a file
8 watch fails - this is a fallback to the file modification check.
9 (auto-revert-notify-event-p, auto-revert-notify-event-descriptor)
10 (auto-revert-notify-event-action)
11 (auto-revert-notify-event-file-name): New defuns.
12 (auto-revert-notify-handler): Use them. Implement first
13 plausibility checks.
14 (auto-revert-handler): Handle also `auto-revert-tail-mode'.
15
162013-01-11 Julien Danjou <julien@danjou.info>
17
18 * color.el (color-rgb-to-hsv): Fix conversion computing in case min and
19 max are almost equal. Also return the correct value for V which is
20 already between 0 and 1.
21
222013-01-11 Dmitry Antipov <dmantipov@yandex.ru>
23
24 * emacs-lisp/ert.el (ert-run-test): Use point-max-marker.
25
262013-01-11 Eli Zaretskii <eliz@gnu.org>
27
28 * autorevert.el (auto-revert-notify-rm-watch)
29 (auto-revert-notify-add-watch): Fix typos in w32notify function
30 names.
31
12013-01-10 Michael Albinus <michael.albinus@gmx.de> 322013-01-10 Michael Albinus <michael.albinus@gmx.de>
2 33
3 * autorevert.el (auto-revert-notify-enabled): Move up. 34 * autorevert.el (auto-revert-notify-enabled): Move up.
diff --git a/lisp/autorevert.el b/lisp/autorevert.el
index 4434ed21169..e78cecf0cc2 100644
--- a/lisp/autorevert.el
+++ b/lisp/autorevert.el
@@ -97,6 +97,7 @@
97 97
98;; Dependencies: 98;; Dependencies:
99 99
100(eval-when-compile (require 'cl))
100(require 'timer) 101(require 'timer)
101 102
102;; Custom Group: 103;; Custom Group:
@@ -466,8 +467,10 @@ will use an up-to-date value of `auto-revert-interval'"
466(defun auto-revert-notify-rm-watch () 467(defun auto-revert-notify-rm-watch ()
467 "Disable file watch for current buffer's associated file." 468 "Disable file watch for current buffer's associated file."
468 (when auto-revert-notify-watch-descriptor 469 (when auto-revert-notify-watch-descriptor
469 (funcall (if (fboundp 'inotify-rm-watch) 'inotify-rm-watch 'w32-rm-watch) 470 (ignore-errors
470 auto-revert-notify-watch-descriptor) 471 (funcall (if (fboundp 'inotify-rm-watch)
472 'inotify-rm-watch 'w32notify-rm-watch)
473 auto-revert-notify-watch-descriptor))
471 (remhash auto-revert-notify-watch-descriptor 474 (remhash auto-revert-notify-watch-descriptor
472 auto-revert-notify-watch-descriptor-hash-list)) 475 auto-revert-notify-watch-descriptor-hash-list))
473 (setq auto-revert-notify-watch-descriptor nil 476 (setq auto-revert-notify-watch-descriptor nil
@@ -478,21 +481,62 @@ will use an up-to-date value of `auto-revert-interval'"
478 (when (and buffer-file-name auto-revert-use-notify) 481 (when (and buffer-file-name auto-revert-use-notify)
479 (auto-revert-notify-rm-watch) 482 (auto-revert-notify-rm-watch)
480 (let ((func (if (fboundp 'inotify-add-watch) 483 (let ((func (if (fboundp 'inotify-add-watch)
481 'inotify-add-watch 'w32-add-watch)) 484 'inotify-add-watch 'w32notify-add-watch))
482 (aspect (if (fboundp 'inotify-add-watch) 485 (aspect (if (fboundp 'inotify-add-watch)
483 '(close-write) '(last-write-time)))) 486 '(modify) '(size last-write-time))))
484 (setq auto-revert-notify-watch-descriptor 487 (setq auto-revert-notify-watch-descriptor
485 (funcall func buffer-file-name aspect 'auto-revert-notify-handler)) 488 (ignore-errors
486 (puthash auto-revert-notify-watch-descriptor 489 (funcall
487 (current-buffer) 490 func buffer-file-name aspect 'auto-revert-notify-handler)))
488 auto-revert-notify-watch-descriptor-hash-list)))) 491 (if auto-revert-notify-watch-descriptor
492 (puthash auto-revert-notify-watch-descriptor
493 (current-buffer)
494 auto-revert-notify-watch-descriptor-hash-list)
495 ;; Fallback to file checks.
496 (set (make-local-variable 'auto-revert-use-notify) nil)))))
497
498(defun auto-revert-notify-event-p (event)
499 "Check that event is a file watch event."
500 (cond ((featurep 'inotify)
501 (and (listp event) (= (length event) 4)))
502 ((featurep 'w32notify)
503 (and (listp event) (= (length event) 3) (stringp (nth 2 event))))))
504
505(defun auto-revert-notify-event-descriptor (event)
506 "Return watch descriptor of notification event, or nil."
507 (and (auto-revert-notify-event-p event) (car event)))
508
509(defun auto-revert-notify-event-action (event)
510 "Return action of notification event, or nil."
511 (and (auto-revert-notify-event-p event) (nth 1 event)))
512
513(defun auto-revert-notify-event-file-name (event)
514 "Return file name of notification event, or nil."
515 (and (auto-revert-notify-event-p event)
516 (cond ((featurep 'inotify) (nth 3 event))
517 ((featurep 'w32notify) (nth 2 event)))))
489 518
490(defun auto-revert-notify-handler (event) 519(defun auto-revert-notify-handler (event)
491 "Handle an event returned from file watch." 520 "Handle an event returned from file watch."
492 (when (listp event) 521 (when (auto-revert-notify-event-p event)
493 (let ((buffer 522 (let* ((descriptor (auto-revert-notify-event-descriptor event))
494 (gethash (car event) auto-revert-notify-watch-descriptor-hash-list))) 523 (action (auto-revert-notify-event-action event))
495 (when (bufferp buffer) 524 (file (auto-revert-notify-event-file-name event))
525 (buffer (gethash descriptor
526 auto-revert-notify-watch-descriptor-hash-list)))
527 (ignore-errors
528 ;; Check, that event is meant for us.
529 ;; TODO: Filter events which stop watching, like `move' or `removed'.
530 (assert descriptor)
531 (when (featurep 'inotify) (assert (memq 'modify descriptor)))
532 (when (featurep 'w32notify) (assert (eq 'modified descriptor)))
533 (assert (bufferp buffer))
534 (when (stringp file)
535 (assert (string-equal
536 (directory-file-name file)
537 (directory-file-name (buffer-file-name buffer)))))
538
539 ;; Mark buffer modified.
496 (with-current-buffer buffer 540 (with-current-buffer buffer
497 (setq auto-revert-notify-modified-p t)))))) 541 (setq auto-revert-notify-modified-p t))))))
498 542
@@ -513,6 +557,8 @@ This is an internal function used by Auto-Revert Mode."
513 (let* ((buffer (current-buffer)) size 557 (let* ((buffer (current-buffer)) size
514 (revert 558 (revert
515 (or (and buffer-file-name 559 (or (and buffer-file-name
560 (or (not auto-revert-use-notify)
561 auto-revert-notify-modified-p)
516 (if auto-revert-tail-mode 562 (if auto-revert-tail-mode
517 ;; Tramp caches the file attributes. Setting 563 ;; Tramp caches the file attributes. Setting
518 ;; `remote-file-name-inhibit-cache' forces Tramp 564 ;; `remote-file-name-inhibit-cache' forces Tramp
@@ -523,12 +569,9 @@ This is an internal function used by Auto-Revert Mode."
523 (setq size 569 (setq size
524 (nth 7 (file-attributes 570 (nth 7 (file-attributes
525 buffer-file-name)))))) 571 buffer-file-name))))))
526 (if auto-revert-use-notify 572 (and (not (file-remote-p buffer-file-name))
527 ;; There are file watches. 573 (file-readable-p buffer-file-name)
528 auto-revert-notify-modified-p 574 (not (verify-visited-file-modtime buffer)))))
529 (and (not (file-remote-p buffer-file-name))
530 (file-readable-p buffer-file-name)
531 (not (verify-visited-file-modtime buffer))))))
532 (and (or auto-revert-mode 575 (and (or auto-revert-mode
533 global-auto-revert-non-file-buffers) 576 global-auto-revert-non-file-buffers)
534 revert-buffer-function 577 revert-buffer-function
diff --git a/lisp/color.el b/lisp/color.el
index 63326e7c5b3..50f6675bf4b 100644
--- a/lisp/color.el
+++ b/lisp/color.el
@@ -130,7 +130,7 @@ inclusive."
130 (max (max r g b)) 130 (max (max r g b))
131 (min (min r g b))) 131 (min (min r g b)))
132 (if (< (- max min) 1e-8) 132 (if (< (- max min) 1e-8)
133 (list 0.0 0.0 0.0) 133 (list 0.0 0.0 min)
134 (list 134 (list
135 (/ (* 2 float-pi 135 (/ (* 2 float-pi
136 (cond ((and (= r g) (= g b)) 0) 136 (cond ((and (= r g) (= g b)) 0)
@@ -146,7 +146,7 @@ inclusive."
146 (+ 240 (* 60 (/ (- r g) (- max min))))))) 146 (+ 240 (* 60 (/ (- r g) (- max min)))))))
147 360) 147 360)
148 (if (= max 0) 0 (- 1 (/ min max))) 148 (if (= max 0) 0 (- 1 (/ min max)))
149 (/ max 255.0))))) 149 max))))
150 150
151(defun color-rgb-to-hsl (red green blue) 151(defun color-rgb-to-hsl (red green blue)
152 "Convert RGB colors to their HSL representation. 152 "Convert RGB colors to their HSL representation.
diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el
index 70d6a6a4a5f..dd849362228 100644
--- a/lisp/emacs-lisp/ert.el
+++ b/lisp/emacs-lisp/ert.el
@@ -937,7 +937,7 @@ Returns the result and stores it in ERT-TEST's `most-recent-result' slot."
937 (cl-block error 937 (cl-block error
938 (let ((begin-marker 938 (let ((begin-marker
939 (with-current-buffer (get-buffer-create "*Messages*") 939 (with-current-buffer (get-buffer-create "*Messages*")
940 (set-marker (make-marker) (point-max))))) 940 (point-max-marker))))
941 (unwind-protect 941 (unwind-protect
942 (let ((info (make-ert--test-execution-info 942 (let ((info (make-ert--test-execution-info
943 :test ert-test 943 :test ert-test
diff --git a/lisp/erc/ChangeLog b/lisp/erc/ChangeLog
index 3a625eb215e..bbe551c735d 100644
--- a/lisp/erc/ChangeLog
+++ b/lisp/erc/ChangeLog
@@ -1,3 +1,8 @@
12013-01-11 Dmitry Antipov <dmantipov@yandex.ru>
2
3 * erc-dcc.el (erc-dcc-send-file): Use point-min-marker.
4 (erc-dcc-chat-setup): Use point-max-marker.
5
12013-01-04 Glenn Morris <rgm@gnu.org> 62013-01-04 Glenn Morris <rgm@gnu.org>
2 7
3 * erc-backend.el (312): Fix typo. (Bug#13235) 8 * erc-backend.el (312): Fix typo. (Bug#13235)
diff --git a/lisp/erc/erc-dcc.el b/lisp/erc/erc-dcc.el
index dc67d3b01df..c27bb629f9d 100644
--- a/lisp/erc/erc-dcc.el
+++ b/lisp/erc/erc-dcc.el
@@ -897,7 +897,7 @@ other client."
897 (let* ((buffer (erc-dcc-find-file file)) 897 (let* ((buffer (erc-dcc-find-file file))
898 (size (buffer-size buffer)) 898 (size (buffer-size buffer))
899 (start (with-current-buffer buffer 899 (start (with-current-buffer buffer
900 (set-marker (make-marker) (point-min)))) 900 (point-min-marker)))
901 (sproc (erc-dcc-server "dcc-send" 901 (sproc (erc-dcc-server "dcc-send"
902 'erc-dcc-send-filter 902 'erc-dcc-send-filter
903 'erc-dcc-send-sentinel)) 903 'erc-dcc-send-sentinel))
@@ -1166,7 +1166,7 @@ other client."
1166 (setq erc-dcc-from nick) 1166 (setq erc-dcc-from nick)
1167 (setq erc-dcc-entry-data entry) 1167 (setq erc-dcc-entry-data entry)
1168 (setq erc-dcc-unprocessed-output "") 1168 (setq erc-dcc-unprocessed-output "")
1169 (setq erc-insert-marker (set-marker (make-marker) (point-max))) 1169 (setq erc-insert-marker (point-max-marker))
1170 (setq erc-input-marker (make-marker)) 1170 (setq erc-input-marker (make-marker))
1171 (erc-display-prompt buffer (point-max)) 1171 (erc-display-prompt buffer (point-max))
1172 (set-process-buffer proc buffer) 1172 (set-process-buffer proc buffer)
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index dd93c7b22fe..0cea790792f 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,15 @@
12013-01-11 Dmitry Antipov <dmantipov@yandex.ru>
2
3 * gnus-art.el (gnus-mime-display-security): Use point-min-marker
4 and point-max-marker.
5 * gnus-async.el (gnus-async-article-callback): Use point-max-marker.
6
72013-01-10 Uwe Brauer <oub@mat.ucm.es> (tiny change)
8
9 * mml-smime.el (mml-smime-encrypt-to-self): New user option analogous
10 to mml2015-encrypt-to-self.
11 (mml-smime-epg-encrypt): Respect mml-smime-encrypt-to-self.
12
12013-01-09 Daiki Ueno <ueno@gnu.org> 132013-01-09 Daiki Ueno <ueno@gnu.org>
2 14
3 * mml-smime.el (epg-sub-key-fingerprint): Autoload for 15 * mml-smime.el (epg-sub-key-fingerprint): Autoload for
diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el
index 1b4cddc5009..25a555f3d8b 100644
--- a/lisp/gnus/gnus-art.el
+++ b/lisp/gnus/gnus-art.el
@@ -8688,9 +8688,7 @@ For example:
8688 gnus-mime-security-button-end-line-format)) 8688 gnus-mime-security-button-end-line-format))
8689 (gnus-insert-mime-security-button handle))) 8689 (gnus-insert-mime-security-button handle)))
8690 (mm-set-handle-multipart-parameter 8690 (mm-set-handle-multipart-parameter
8691 handle 'gnus-region 8691 handle 'gnus-region (cons (point-min-marker) (point-max-marker)))
8692 (cons (set-marker (make-marker) (point-min))
8693 (set-marker (make-marker) (point-max))))
8694 (goto-char (point-max)))) 8692 (goto-char (point-max))))
8695 8693
8696(defun gnus-mime-security-run-function (function) 8694(defun gnus-mime-security-run-function (function)
diff --git a/lisp/gnus/gnus-async.el b/lisp/gnus/gnus-async.el
index 41b0cc25006..c5d64332547 100644
--- a/lisp/gnus/gnus-async.el
+++ b/lisp/gnus/gnus-async.el
@@ -254,7 +254,7 @@ that was fetched."
254 gnus-async-article-alist 254 gnus-async-article-alist
255 (cons (list (intern (format "%s-%d" group article) 255 (cons (list (intern (format "%s-%d" group article)
256 gnus-async-hashtb) 256 gnus-async-hashtb)
257 mark (set-marker (make-marker) (point-max)) 257 mark (point-max-marker)
258 group article) 258 group article)
259 gnus-async-article-alist)))) 259 gnus-async-article-alist))))
260 (if (not (gnus-buffer-live-p summary)) 260 (if (not (gnus-buffer-live-p summary))
diff --git a/lisp/gnus/mml-smime.el b/lisp/gnus/mml-smime.el
index e5e99dedcbe..6ea55377e02 100644
--- a/lisp/gnus/mml-smime.el
+++ b/lisp/gnus/mml-smime.el
@@ -80,6 +80,12 @@ Whether the passphrase is cached at all is controlled by
80 :version "24.4" 80 :version "24.4"
81 :type 'boolean) 81 :type 'boolean)
82 82
83(defcustom mml-smime-encrypt-to-self nil
84 "If t, add your own key ID to recipient list when encryption."
85 :group 'mime-security
86 :version "24.4"
87 :type 'boolean)
88
83(defun mml-smime-sign (cont) 89(defun mml-smime-sign (cont)
84 (let ((func (nth 1 (assq mml-smime-use mml-smime-function-alist)))) 90 (let ((func (nth 1 (assq mml-smime-use mml-smime-function-alist))))
85 (if func 91 (if func
@@ -475,13 +481,17 @@ Content-Disposition: attachment; filename=smime.p7s
475 (goto-char (point-max)))) 481 (goto-char (point-max))))
476 482
477(defun mml-smime-epg-encrypt (cont) 483(defun mml-smime-epg-encrypt (cont)
478 (let ((inhibit-redisplay t) 484 (let* ((inhibit-redisplay t)
479 (context (epg-make-context 'CMS)) 485 (context (epg-make-context 'CMS))
480 (config (epg-configuration)) 486 (config (epg-configuration))
481 (recipients (message-options-get 'mml-smime-epg-recipients)) 487 (recipients (message-options-get 'mml-smime-epg-recipients))
482 cipher signers 488 cipher signers
483 (boundary (mml-compute-boundary cont)) 489 (sender (message-options-get 'message-sender))
484 recipient-key) 490 (signer-names (or mml-smime-signers
491 (if (and mml-smime-sign-with-sender sender)
492 (list (concat "<" sender ">")))))
493 (boundary (mml-compute-boundary cont))
494 recipient-key)
485 (unless recipients 495 (unless recipients
486 (setq recipients 496 (setq recipients
487 (apply #'nconc 497 (apply #'nconc
@@ -494,6 +504,10 @@ Content-Disposition: attachment; filename=smime.p7s
494 (message-options-set 'message-recipients 504 (message-options-set 'message-recipients
495 (read-string "Recipients: "))) 505 (read-string "Recipients: ")))
496 "[ \f\t\n\r\v,]+")))) 506 "[ \f\t\n\r\v,]+"))))
507 (when mml-smime-encrypt-to-self
508 (unless signer-names
509 (error "Neither message sender nor mml-smime-signers are set"))
510 (setq recipients (nconc recipients signer-names)))
497 (if (eq mm-encrypt-option 'guided) 511 (if (eq mm-encrypt-option 'guided)
498 (setq recipients 512 (setq recipients
499 (epa-select-keys context "\ 513 (epa-select-keys context "\
diff --git a/nt/ChangeLog b/nt/ChangeLog
index a1c9f3c7cd0..aca1236657b 100644
--- a/nt/ChangeLog
+++ b/nt/ChangeLog
@@ -1,3 +1,8 @@
12013-01-11 Eli Zaretskii <eliz@gnu.org>
2
3 * inc/unistd.h (O_IGNORE_CTTY): Define, as it is unconditionally
4 used in term.c. (Bug#13387)
5
12013-01-09 Juanma Barranquero <lekktu@gmail.com> 62013-01-09 Juanma Barranquero <lekktu@gmail.com>
2 7
3 * config.nt: Sync with autogen/config.in. 8 * config.nt: Sync with autogen/config.in.
diff --git a/nt/inc/unistd.h b/nt/inc/unistd.h
index 5fdd9c8eb88..9c8a64d5ed2 100644
--- a/nt/inc/unistd.h
+++ b/nt/inc/unistd.h
@@ -27,6 +27,7 @@ extern int faccessat (int, char const *, int, int);
27#define AT_SYMLINK_NOFOLLOW 4096 27#define AT_SYMLINK_NOFOLLOW 4096
28 28
29#define O_NOCTTY 0 29#define O_NOCTTY 0
30#define O_IGNORE_CTTY 0
30 31
31/* This is normally on stdlib.h, but we don't override that header. */ 32/* This is normally on stdlib.h, but we don't override that header. */
32extern int unsetenv (const char *); 33extern int unsetenv (const char *);
diff --git a/src/ChangeLog b/src/ChangeLog
index dd22c5388b0..13a1f1a3858 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,28 @@
12013-01-11 Dmitry Antipov <dmantipov@yandex.ru>
2
3 Avoid unnecessary byte position calculation for the gap movement.
4 Since all users of move_gap do CHAR_TO_BYTE for other purposes
5 anyway, all of them should use move_gap_both instead.
6 * lisp.h (move_gap): Remove prototype.
7 * insdel.c (move_gap): Remove.
8 (move_gap_both): Add eassert.
9 * editfns.c (Ftranspose_regions): Tweak to use move_gap_both.
10 * xml.c (parse_region): Likewise.
11
122013-01-11 Paul Eggert <eggert@cs.ucla.edu>
13
14 emacsclient -t should not suspend Emacs server (Bug#13387)
15 * lisp.h, sysdep.c (block_tty_out_signal, unblock_tty_out_signal):
16 New functions.
17 * term.c (init_tty): Use them instead of rolling our own code.
18 * sysdep.c (tcsetpgrp_without_stopping): Likewise. Here, this
19 switches from 'signal' to 'pthread_sigmask', which is safer in
20 multithreaded applications.
21 * term.c (Fresume_tty): Don't bother dissociating if O_IGNORE_CTTY,
22 which has already arranged for that.
23 (dissociate_if_controlling_tty): If setsid fails, fall back on TIOCNOTTY.
24 This is the main part of the bug fix.
25
12013-01-10 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> (tiny change) 262013-01-10 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> (tiny change)
2 27
3 * gtkutil.c (xg_initialize): Add ifdef HAVE_FREETYPE around 28 * gtkutil.c (xg_initialize): Add ifdef HAVE_FREETYPE around
diff --git a/src/editfns.c b/src/editfns.c
index 26dfdac3ba8..64269bab8df 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -4522,7 +4522,7 @@ Transposing beyond buffer boundaries is an error. */)
4522 (Lisp_Object startr1, Lisp_Object endr1, Lisp_Object startr2, Lisp_Object endr2, Lisp_Object leave_markers) 4522 (Lisp_Object startr1, Lisp_Object endr1, Lisp_Object startr2, Lisp_Object endr2, Lisp_Object leave_markers)
4523{ 4523{
4524 register ptrdiff_t start1, end1, start2, end2; 4524 register ptrdiff_t start1, end1, start2, end2;
4525 ptrdiff_t start1_byte, start2_byte, len1_byte, len2_byte; 4525 ptrdiff_t start1_byte, start2_byte, len1_byte, len2_byte, end2_byte;
4526 ptrdiff_t gap, len1, len_mid, len2; 4526 ptrdiff_t gap, len1, len_mid, len2;
4527 unsigned char *start1_addr, *start2_addr, *temp; 4527 unsigned char *start1_addr, *start2_addr, *temp;
4528 4528
@@ -4583,20 +4583,22 @@ Transposing beyond buffer boundaries is an error. */)
4583 the gap the minimum distance to get it out of the way, and then 4583 the gap the minimum distance to get it out of the way, and then
4584 deal with an unbroken array. */ 4584 deal with an unbroken array. */
4585 4585
4586 start1_byte = CHAR_TO_BYTE (start1);
4587 end2_byte = CHAR_TO_BYTE (end2);
4588
4586 /* Make sure the gap won't interfere, by moving it out of the text 4589 /* Make sure the gap won't interfere, by moving it out of the text
4587 we will operate on. */ 4590 we will operate on. */
4588 if (start1 < gap && gap < end2) 4591 if (start1 < gap && gap < end2)
4589 { 4592 {
4590 if (gap - start1 < end2 - gap) 4593 if (gap - start1 < end2 - gap)
4591 move_gap (start1); 4594 move_gap_both (start1, start1_byte);
4592 else 4595 else
4593 move_gap (end2); 4596 move_gap_both (end2, end2_byte);
4594 } 4597 }
4595 4598
4596 start1_byte = CHAR_TO_BYTE (start1);
4597 start2_byte = CHAR_TO_BYTE (start2); 4599 start2_byte = CHAR_TO_BYTE (start2);
4598 len1_byte = CHAR_TO_BYTE (end1) - start1_byte; 4600 len1_byte = CHAR_TO_BYTE (end1) - start1_byte;
4599 len2_byte = CHAR_TO_BYTE (end2) - start2_byte; 4601 len2_byte = end2_byte - start2_byte;
4600 4602
4601#ifdef BYTE_COMBINING_DEBUG 4603#ifdef BYTE_COMBINING_DEBUG
4602 if (end1 == start2) 4604 if (end1 == start2)
diff --git a/src/insdel.c b/src/insdel.c
index 905249d6714..c2a3cd42821 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -84,21 +84,14 @@ check_markers (void)
84 84
85#endif /* MARKER_DEBUG */ 85#endif /* MARKER_DEBUG */
86 86
87/* Move gap to position CHARPOS.
88 Note that this can quit! */
89
90void
91move_gap (ptrdiff_t charpos)
92{
93 move_gap_both (charpos, CHAR_TO_BYTE (charpos));
94}
95
96/* Move gap to byte position BYTEPOS, which is also char position CHARPOS. 87/* Move gap to byte position BYTEPOS, which is also char position CHARPOS.
97 Note that this can quit! */ 88 Note that this can quit! */
98 89
99void 90void
100move_gap_both (ptrdiff_t charpos, ptrdiff_t bytepos) 91move_gap_both (ptrdiff_t charpos, ptrdiff_t bytepos)
101{ 92{
93 eassert (charpos == BYTE_TO_CHAR (bytepos)
94 && bytepos == CHAR_TO_BYTE (charpos));
102 if (bytepos < GPT_BYTE) 95 if (bytepos < GPT_BYTE)
103 gap_left (charpos, bytepos, 0); 96 gap_left (charpos, bytepos, 0);
104 else if (bytepos > GPT_BYTE) 97 else if (bytepos > GPT_BYTE)
diff --git a/src/lisp.h b/src/lisp.h
index 6a22ce0b120..16f9c89e3cd 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2780,7 +2780,6 @@ extern void syms_of_image (void);
2780 2780
2781/* Defined in insdel.c. */ 2781/* Defined in insdel.c. */
2782extern Lisp_Object Qinhibit_modification_hooks; 2782extern Lisp_Object Qinhibit_modification_hooks;
2783extern void move_gap (ptrdiff_t);
2784extern void move_gap_both (ptrdiff_t, ptrdiff_t); 2783extern void move_gap_both (ptrdiff_t, ptrdiff_t);
2785extern _Noreturn void buffer_overflow (void); 2784extern _Noreturn void buffer_overflow (void);
2786extern void make_gap (ptrdiff_t); 2785extern void make_gap (ptrdiff_t);
@@ -3467,6 +3466,8 @@ extern void init_sigio (int);
3467extern void sys_subshell (void); 3466extern void sys_subshell (void);
3468extern void sys_suspend (void); 3467extern void sys_suspend (void);
3469extern void discard_tty_input (void); 3468extern void discard_tty_input (void);
3469extern void block_tty_out_signal (void);
3470extern void unblock_tty_out_signal (void);
3470extern void init_sys_modes (struct tty_display_info *); 3471extern void init_sys_modes (struct tty_display_info *);
3471extern void reset_sys_modes (struct tty_display_info *); 3472extern void reset_sys_modes (struct tty_display_info *);
3472extern void init_all_sys_modes (void); 3473extern void init_all_sys_modes (void);
diff --git a/src/sysdep.c b/src/sysdep.c
index 049eb85afe5..158d2f73eec 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -714,6 +714,27 @@ init_foreground_group (void)
714 inherited_pgroup = getpid () == pgrp ? 0 : pgrp; 714 inherited_pgroup = getpid () == pgrp ? 0 : pgrp;
715} 715}
716 716
717/* Block and unblock SIGTTOU. */
718
719void
720block_tty_out_signal (void)
721{
722#ifdef SIGTTOU
723 sigset_t blocked;
724 sigemptyset (&blocked);
725 sigaddset (&blocked, SIGTTOU);
726 pthread_sigmask (SIG_BLOCK, &blocked, 0);
727#endif
728}
729
730void
731unblock_tty_out_signal (void)
732{
733#ifdef SIGTTOU
734 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
735#endif
736}
737
717/* Safely set a controlling terminal FD's process group to PGID. 738/* Safely set a controlling terminal FD's process group to PGID.
718 If we are not in the foreground already, POSIX requires tcsetpgrp 739 If we are not in the foreground already, POSIX requires tcsetpgrp
719 to deliver a SIGTTOU signal, which would stop us. This is an 740 to deliver a SIGTTOU signal, which would stop us. This is an
@@ -725,11 +746,10 @@ static void
725tcsetpgrp_without_stopping (int fd, pid_t pgid) 746tcsetpgrp_without_stopping (int fd, pid_t pgid)
726{ 747{
727#ifdef SIGTTOU 748#ifdef SIGTTOU
728 signal_handler_t handler;
729 block_input (); 749 block_input ();
730 handler = signal (SIGTTOU, SIG_IGN); 750 block_tty_out_signal ();
731 tcsetpgrp (fd, pgid); 751 tcsetpgrp (fd, pgid);
732 signal (SIGTTOU, handler); 752 unblock_tty_out_signal ();
733 unblock_input (); 753 unblock_input ();
734#endif 754#endif
735} 755}
diff --git a/src/term.c b/src/term.c
index d76562bb4db..f66a0bddc33 100644
--- a/src/term.c
+++ b/src/term.c
@@ -2423,7 +2423,7 @@ frame's terminal). */)
2423 if (fd == -1) 2423 if (fd == -1)
2424 error ("Can not reopen tty device %s: %s", t->display_info.tty->name, strerror (errno)); 2424 error ("Can not reopen tty device %s: %s", t->display_info.tty->name, strerror (errno));
2425 2425
2426 if (strcmp (t->display_info.tty->name, DEV_TTY)) 2426 if (!O_IGNORE_CTTY && strcmp (t->display_info.tty->name, DEV_TTY) != 0)
2427 dissociate_if_controlling_tty (fd); 2427 dissociate_if_controlling_tty (fd);
2428 2428
2429 t->display_info.tty->output = fdopen (fd, "w+"); 2429 t->display_info.tty->output = fdopen (fd, "w+");
@@ -2903,13 +2903,23 @@ set_tty_hooks (struct terminal *terminal)
2903 terminal->delete_terminal_hook = &delete_tty; 2903 terminal->delete_terminal_hook = &delete_tty;
2904} 2904}
2905 2905
2906/* Drop the controlling terminal if fd is the same device. */ 2906/* If FD is the controlling terminal, drop it. */
2907static void 2907static void
2908dissociate_if_controlling_tty (int fd) 2908dissociate_if_controlling_tty (int fd)
2909{ 2909{
2910 pid_t pgid = tcgetpgrp (fd); /* If tcgetpgrp succeeds, fd is the ctty. */ 2910 /* If tcgetpgrp succeeds, fd is the controlling terminal,
2911 if (0 <= pgid) 2911 so dissociate it by invoking setsid. */
2912 setsid (); 2912 if (0 <= tcgetpgrp (fd) && setsid () < 0)
2913 {
2914#ifdef TIOCNOTTY
2915 /* setsid failed, presumably because Emacs is already a process
2916 group leader. Fall back on the obsolescent way to dissociate
2917 a controlling tty. */
2918 block_tty_out_signal ();
2919 ioctl (fd, TIOCNOTTY, 0);
2920 unblock_tty_out_signal ();
2921#endif
2922 }
2913} 2923}
2914 2924
2915/* Create a termcap display on the tty device with the given name and 2925/* 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)
3030 3040
3031 /* On some systems, tgetent tries to access the controlling 3041 /* On some systems, tgetent tries to access the controlling
3032 terminal. */ 3042 terminal. */
3033 { 3043 block_tty_out_signal ();
3034 sigset_t blocked; 3044 status = tgetent (tty->termcap_term_buffer, terminal_type);
3035 sigemptyset (&blocked); 3045 unblock_tty_out_signal ();
3036 sigaddset (&blocked, SIGTTOU);
3037 pthread_sigmask (SIG_BLOCK, &blocked, 0);
3038 status = tgetent (tty->termcap_term_buffer, terminal_type);
3039 pthread_sigmask (SIG_UNBLOCK, &blocked, 0);
3040 }
3041 3046
3042 if (status < 0) 3047 if (status < 0)
3043 { 3048 {
diff --git a/src/xml.c b/src/xml.c
index 5939c58a564..5a52b0c2a1e 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -180,8 +180,7 @@ parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, int html
180 xmlDoc *doc; 180 xmlDoc *doc;
181 Lisp_Object result = Qnil; 181 Lisp_Object result = Qnil;
182 const char *burl = ""; 182 const char *burl = "";
183 ptrdiff_t bytes; 183 ptrdiff_t istart, iend, istart_byte, iend_byte;
184 ptrdiff_t istart, iend;
185 184
186 fn_xmlCheckVersion (LIBXML_VERSION); 185 fn_xmlCheckVersion (LIBXML_VERSION);
187 186
@@ -189,9 +188,11 @@ parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, int html
189 188
190 istart = XINT (start); 189 istart = XINT (start);
191 iend = XINT (end); 190 iend = XINT (end);
191 istart_byte = CHAR_TO_BYTE (istart);
192 iend_byte = CHAR_TO_BYTE (iend);
192 193
193 if (istart < GPT && GPT < iend) 194 if (istart < GPT && GPT < iend)
194 move_gap (iend); 195 move_gap_both (iend, iend_byte);
195 196
196 if (! NILP (base_url)) 197 if (! NILP (base_url))
197 { 198 {
@@ -199,17 +200,15 @@ parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, int html
199 burl = SSDATA (base_url); 200 burl = SSDATA (base_url);
200 } 201 }
201 202
202 bytes = CHAR_TO_BYTE (iend) - CHAR_TO_BYTE (istart);
203
204 if (htmlp) 203 if (htmlp)
205 doc = fn_htmlReadMemory ((char *) BYTE_POS_ADDR (CHAR_TO_BYTE (istart)), 204 doc = fn_htmlReadMemory ((char *) BYTE_POS_ADDR (istart_byte),
206 bytes, burl, "utf-8", 205 iend_byte - istart_byte, burl, "utf-8",
207 HTML_PARSE_RECOVER|HTML_PARSE_NONET| 206 HTML_PARSE_RECOVER|HTML_PARSE_NONET|
208 HTML_PARSE_NOWARNING|HTML_PARSE_NOERROR| 207 HTML_PARSE_NOWARNING|HTML_PARSE_NOERROR|
209 HTML_PARSE_NOBLANKS); 208 HTML_PARSE_NOBLANKS);
210 else 209 else
211 doc = fn_xmlReadMemory ((char *) BYTE_POS_ADDR (CHAR_TO_BYTE (istart)), 210 doc = fn_xmlReadMemory ((char *) BYTE_POS_ADDR (istart_byte),
212 bytes, burl, "utf-8", 211 iend_byte - istart_byte, burl, "utf-8",
213 XML_PARSE_NONET|XML_PARSE_NOWARNING| 212 XML_PARSE_NONET|XML_PARSE_NOWARNING|
214 XML_PARSE_NOBLANKS |XML_PARSE_NOERROR); 213 XML_PARSE_NOBLANKS |XML_PARSE_NOERROR);
215 214