aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.in1
-rw-r--r--src/alloc.c59
-rw-r--r--src/buffer.c8
-rw-r--r--src/bytecode.c268
-rw-r--r--src/callproc.c20
-rw-r--r--src/charset.c17
-rw-r--r--src/chartab.c2
-rw-r--r--src/cm.c2
-rw-r--r--src/coding.c47
-rw-r--r--src/coding.h2
-rw-r--r--src/composite.c5
-rw-r--r--src/conf_post.h52
-rw-r--r--src/dbusbind.c4
-rw-r--r--src/dispextern.h47
-rw-r--r--src/doc.c30
-rw-r--r--src/editfns.c76
-rw-r--r--src/emacs.c84
-rw-r--r--src/emacsgtkfixed.c2
-rw-r--r--src/eval.c37
-rw-r--r--src/fileio.c38
-rw-r--r--src/floatfns.c4
-rw-r--r--src/fns.c30
-rw-r--r--src/font.c15
-rw-r--r--src/fontset.c7
-rw-r--r--src/frame.c154
-rw-r--r--src/frame.h96
-rw-r--r--src/fringe.c7
-rw-r--r--src/gmalloc.c2
-rw-r--r--src/gnutls.c7
-rw-r--r--src/gnutls.h2
-rw-r--r--src/gtkutil.c3
-rw-r--r--src/image.c34
-rw-r--r--src/indent.c23
-rw-r--r--src/insdel.c102
-rw-r--r--src/intervals.h2
-rw-r--r--src/keyboard.c31
-rw-r--r--src/keymap.c14
-rw-r--r--src/lisp.h31
-rw-r--r--src/lread.c60
-rw-r--r--src/macfont.m14
-rw-r--r--src/menu.c4
-rw-r--r--src/minibuf.c8
-rw-r--r--src/msdos.c6
-rw-r--r--src/nsfns.m8
-rw-r--r--src/nsfont.m3
-rw-r--r--src/nsmenu.m32
-rw-r--r--src/nsterm.h2
-rw-r--r--src/nsterm.m87
-rw-r--r--src/print.c2
-rw-r--r--src/process.c110
-rw-r--r--src/process.h5
-rw-r--r--src/regex.c209
-rw-r--r--src/sound.c2
-rw-r--r--src/syntax.c9
-rw-r--r--src/sysdep.c50
-rw-r--r--src/term.c20
-rw-r--r--src/textprop.c20
-rw-r--r--src/vm-limit.c6
-rw-r--r--src/w32console.c2
-rw-r--r--src/w32fns.c42
-rw-r--r--src/w32font.c4
-rw-r--r--src/w32menu.c17
-rw-r--r--src/w32term.c14
-rw-r--r--src/w32term.h2
-rw-r--r--src/window.c26
-rw-r--r--src/xdisp.c194
-rw-r--r--src/xfaces.c48
-rw-r--r--src/xfns.c25
-rw-r--r--src/xfont.c2
-rw-r--r--src/xmenu.c6
-rw-r--r--src/xterm.c18
-rw-r--r--src/xterm.h4
-rw-r--r--src/xwidget.c88
73 files changed, 1305 insertions, 1209 deletions
diff --git a/src/Makefile.in b/src/Makefile.in
index 8639effde86..89f7a921faa 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -407,7 +407,6 @@ base_obj = dispnew.o frame.o scroll.o xdisp.o menu.o $(XMENU_OBJ) window.o \
407 $(XWIDGETS_OBJ) \ 407 $(XWIDGETS_OBJ) \
408 profiler.o decompress.o \ 408 profiler.o decompress.o \
409 $(if $(HYBRID_MALLOC),sheap.o) \ 409 $(if $(HYBRID_MALLOC),sheap.o) \
410 $(SHEAP_OBJ) \
411 $(MSDOS_OBJ) $(MSDOS_X_OBJ) $(NS_OBJ) $(CYGWIN_OBJ) $(FONT_OBJ) \ 410 $(MSDOS_OBJ) $(MSDOS_X_OBJ) $(NS_OBJ) $(CYGWIN_OBJ) $(FONT_OBJ) \
412 $(W32_OBJ) $(WINDOW_SYSTEM_OBJ) $(XGSELOBJ) 411 $(W32_OBJ) $(WINDOW_SYSTEM_OBJ) $(XGSELOBJ)
413obj = $(base_obj) $(NS_OBJC_OBJ) 412obj = $(base_obj) $(NS_OBJC_OBJ)
diff --git a/src/alloc.c b/src/alloc.c
index 054e1ca23ca..e25d91ff8aa 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -20,6 +20,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20 20
21#include <config.h> 21#include <config.h>
22 22
23#include <errno.h>
23#include <stdio.h> 24#include <stdio.h>
24#include <limits.h> /* For CHAR_BIT. */ 25#include <limits.h> /* For CHAR_BIT. */
25#include <signal.h> /* For SIGABRT, SIGDANGER. */ 26#include <signal.h> /* For SIGABRT, SIGDANGER. */
@@ -150,7 +151,8 @@ malloc_initialize_hook (void)
150 } 151 }
151 } 152 }
152 153
153 malloc_set_state (malloc_state_ptr); 154 if (malloc_set_state (malloc_state_ptr) != 0)
155 emacs_abort ();
154# ifndef XMALLOC_OVERRUN_CHECK 156# ifndef XMALLOC_OVERRUN_CHECK
155 alloc_unexec_post (); 157 alloc_unexec_post ();
156# endif 158# endif
@@ -174,6 +176,8 @@ alloc_unexec_pre (void)
174{ 176{
175#ifdef DOUG_LEA_MALLOC 177#ifdef DOUG_LEA_MALLOC
176 malloc_state_ptr = malloc_get_state (); 178 malloc_state_ptr = malloc_get_state ();
179 if (!malloc_state_ptr)
180 fatal ("malloc_get_state: %s", strerror (errno));
177#endif 181#endif
178#ifdef HYBRID_MALLOC 182#ifdef HYBRID_MALLOC
179 bss_sbrk_did_unexec = true; 183 bss_sbrk_did_unexec = true;
@@ -485,7 +489,7 @@ static void *pure_alloc (size_t, int);
485/* Return PTR rounded up to the next multiple of ALIGNMENT. */ 489/* Return PTR rounded up to the next multiple of ALIGNMENT. */
486 490
487static void * 491static void *
488ALIGN (void *ptr, int alignment) 492pointer_align (void *ptr, int alignment)
489{ 493{
490 return (void *) ROUNDUP ((uintptr_t) ptr, alignment); 494 return (void *) ROUNDUP ((uintptr_t) ptr, alignment);
491} 495}
@@ -1174,16 +1178,18 @@ struct ablock
1174 char payload[BLOCK_BYTES]; 1178 char payload[BLOCK_BYTES];
1175 struct ablock *next_free; 1179 struct ablock *next_free;
1176 } x; 1180 } x;
1177 /* `abase' is the aligned base of the ablocks. */ 1181
1178 /* It is overloaded to hold the virtual `busy' field that counts 1182 /* ABASE is the aligned base of the ablocks. It is overloaded to
1179 the number of used ablock in the parent ablocks. 1183 hold a virtual "busy" field that counts twice the number of used
1180 The first ablock has the `busy' field, the others have the `abase' 1184 ablock values in the parent ablocks, plus one if the real base of
1181 field. To tell the difference, we assume that pointers will have 1185 the parent ablocks is ABASE (if the "busy" field is even, the
1182 integer values larger than 2 * ABLOCKS_SIZE. The lowest bit of `busy' 1186 word before the first ablock holds a pointer to the real base).
1183 is used to tell whether the real base of the parent ablocks is `abase' 1187 The first ablock has a "busy" ABASE, and the others have an
1184 (if not, the word before the first ablock holds a pointer to the 1188 ordinary pointer ABASE. To tell the difference, the code assumes
1185 real base). */ 1189 that pointers, when cast to uintptr_t, are at least 2 *
1190 ABLOCKS_SIZE + 1. */
1186 struct ablocks *abase; 1191 struct ablocks *abase;
1192
1187 /* The padding of all but the last ablock is unused. The padding of 1193 /* The padding of all but the last ablock is unused. The padding of
1188 the last ablock in an ablocks is not allocated. */ 1194 the last ablock in an ablocks is not allocated. */
1189#if BLOCK_PADDING 1195#if BLOCK_PADDING
@@ -1202,18 +1208,18 @@ struct ablocks
1202 1208
1203#define ABLOCK_ABASE(block) \ 1209#define ABLOCK_ABASE(block) \
1204 (((uintptr_t) (block)->abase) <= (1 + 2 * ABLOCKS_SIZE) \ 1210 (((uintptr_t) (block)->abase) <= (1 + 2 * ABLOCKS_SIZE) \
1205 ? (struct ablocks *)(block) \ 1211 ? (struct ablocks *) (block) \
1206 : (block)->abase) 1212 : (block)->abase)
1207 1213
1208/* Virtual `busy' field. */ 1214/* Virtual `busy' field. */
1209#define ABLOCKS_BUSY(abase) ((abase)->blocks[0].abase) 1215#define ABLOCKS_BUSY(a_base) ((a_base)->blocks[0].abase)
1210 1216
1211/* Pointer to the (not necessarily aligned) malloc block. */ 1217/* Pointer to the (not necessarily aligned) malloc block. */
1212#ifdef USE_ALIGNED_ALLOC 1218#ifdef USE_ALIGNED_ALLOC
1213#define ABLOCKS_BASE(abase) (abase) 1219#define ABLOCKS_BASE(abase) (abase)
1214#else 1220#else
1215#define ABLOCKS_BASE(abase) \ 1221#define ABLOCKS_BASE(abase) \
1216 (1 & (intptr_t) ABLOCKS_BUSY (abase) ? abase : ((void **)abase)[-1]) 1222 (1 & (intptr_t) ABLOCKS_BUSY (abase) ? abase : ((void **) (abase))[-1])
1217#endif 1223#endif
1218 1224
1219/* The list of free ablock. */ 1225/* The list of free ablock. */
@@ -1239,7 +1245,7 @@ lisp_align_malloc (size_t nbytes, enum mem_type type)
1239 if (!free_ablock) 1245 if (!free_ablock)
1240 { 1246 {
1241 int i; 1247 int i;
1242 intptr_t aligned; /* int gets warning casting to 64-bit pointer. */ 1248 bool aligned;
1243 1249
1244#ifdef DOUG_LEA_MALLOC 1250#ifdef DOUG_LEA_MALLOC
1245 if (!mmap_lisp_allowed_p ()) 1251 if (!mmap_lisp_allowed_p ())
@@ -1250,7 +1256,7 @@ lisp_align_malloc (size_t nbytes, enum mem_type type)
1250 abase = base = aligned_alloc (BLOCK_ALIGN, ABLOCKS_BYTES); 1256 abase = base = aligned_alloc (BLOCK_ALIGN, ABLOCKS_BYTES);
1251#else 1257#else
1252 base = malloc (ABLOCKS_BYTES); 1258 base = malloc (ABLOCKS_BYTES);
1253 abase = ALIGN (base, BLOCK_ALIGN); 1259 abase = pointer_align (base, BLOCK_ALIGN);
1254#endif 1260#endif
1255 1261
1256 if (base == 0) 1262 if (base == 0)
@@ -1295,13 +1301,14 @@ lisp_align_malloc (size_t nbytes, enum mem_type type)
1295 abase->blocks[i].x.next_free = free_ablock; 1301 abase->blocks[i].x.next_free = free_ablock;
1296 free_ablock = &abase->blocks[i]; 1302 free_ablock = &abase->blocks[i];
1297 } 1303 }
1298 ABLOCKS_BUSY (abase) = (struct ablocks *) aligned; 1304 intptr_t ialigned = aligned;
1305 ABLOCKS_BUSY (abase) = (struct ablocks *) ialigned;
1299 1306
1300 eassert (0 == ((uintptr_t) abase) % BLOCK_ALIGN); 1307 eassert ((uintptr_t) abase % BLOCK_ALIGN == 0);
1301 eassert (ABLOCK_ABASE (&abase->blocks[3]) == abase); /* 3 is arbitrary */ 1308 eassert (ABLOCK_ABASE (&abase->blocks[3]) == abase); /* 3 is arbitrary */
1302 eassert (ABLOCK_ABASE (&abase->blocks[0]) == abase); 1309 eassert (ABLOCK_ABASE (&abase->blocks[0]) == abase);
1303 eassert (ABLOCKS_BASE (abase) == base); 1310 eassert (ABLOCKS_BASE (abase) == base);
1304 eassert (aligned == (intptr_t) ABLOCKS_BUSY (abase)); 1311 eassert ((intptr_t) ABLOCKS_BUSY (abase) == aligned);
1305 } 1312 }
1306 1313
1307 abase = ABLOCK_ABASE (free_ablock); 1314 abase = ABLOCK_ABASE (free_ablock);
@@ -1337,12 +1344,14 @@ lisp_align_free (void *block)
1337 ablock->x.next_free = free_ablock; 1344 ablock->x.next_free = free_ablock;
1338 free_ablock = ablock; 1345 free_ablock = ablock;
1339 /* Update busy count. */ 1346 /* Update busy count. */
1340 ABLOCKS_BUSY (abase) 1347 intptr_t busy = (intptr_t) ABLOCKS_BUSY (abase) - 2;
1341 = (struct ablocks *) (-2 + (intptr_t) ABLOCKS_BUSY (abase)); 1348 eassume (0 <= busy && busy <= 2 * ABLOCKS_SIZE - 1);
1349 ABLOCKS_BUSY (abase) = (struct ablocks *) busy;
1342 1350
1343 if (2 > (intptr_t) ABLOCKS_BUSY (abase)) 1351 if (busy < 2)
1344 { /* All the blocks are free. */ 1352 { /* All the blocks are free. */
1345 int i = 0, aligned = (intptr_t) ABLOCKS_BUSY (abase); 1353 int i = 0;
1354 bool aligned = busy;
1346 struct ablock **tem = &free_ablock; 1355 struct ablock **tem = &free_ablock;
1347 struct ablock *atop = &abase->blocks[aligned ? ABLOCKS_SIZE : ABLOCKS_SIZE - 1]; 1356 struct ablock *atop = &abase->blocks[aligned ? ABLOCKS_SIZE : ABLOCKS_SIZE - 1];
1348 1357
@@ -5169,7 +5178,7 @@ pure_alloc (size_t size, int type)
5169 { 5178 {
5170 /* Allocate space for a Lisp object from the beginning of the free 5179 /* Allocate space for a Lisp object from the beginning of the free
5171 space with taking account of alignment. */ 5180 space with taking account of alignment. */
5172 result = ALIGN (purebeg + pure_bytes_used_lisp, GCALIGNMENT); 5181 result = pointer_align (purebeg + pure_bytes_used_lisp, GCALIGNMENT);
5173 pure_bytes_used_lisp = ((char *)result - (char *)purebeg) + size; 5182 pure_bytes_used_lisp = ((char *)result - (char *)purebeg) + size;
5174 } 5183 }
5175 else 5184 else
@@ -6126,7 +6135,7 @@ mark_face_cache (struct face_cache *c)
6126 int i, j; 6135 int i, j;
6127 for (i = 0; i < c->used; ++i) 6136 for (i = 0; i < c->used; ++i)
6128 { 6137 {
6129 struct face *face = FACE_OPT_FROM_ID (c->f, i); 6138 struct face *face = FACE_FROM_ID_OR_NULL (c->f, i);
6130 6139
6131 if (face) 6140 if (face)
6132 { 6141 {
diff --git a/src/buffer.c b/src/buffer.c
index 534b9e40da3..8756cbbbd7d 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -30,7 +30,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
30#include <verify.h> 30#include <verify.h>
31 31
32#include "lisp.h" 32#include "lisp.h"
33#include "coding.h"
34#include "intervals.h" 33#include "intervals.h"
35#include "systime.h" 34#include "systime.h"
36#include "window.h" 35#include "window.h"
@@ -1985,7 +1984,9 @@ the current buffer's major mode. */)
1985 function = BVAR (current_buffer, major_mode); 1984 function = BVAR (current_buffer, major_mode);
1986 } 1985 }
1987 1986
1988 if (NILP (function) || EQ (function, Qfundamental_mode)) 1987 if (NILP (function)) /* If function is `fundamental-mode', allow it to run
1988 so that `run-mode-hooks' and thus
1989 `hack-local-variables' get run. */
1989 return Qnil; 1990 return Qnil;
1990 1991
1991 count = SPECPDL_INDEX (); 1992 count = SPECPDL_INDEX ();
@@ -3907,7 +3908,8 @@ buffer. */)
3907 struct buffer *b, *ob = 0; 3908 struct buffer *b, *ob = 0;
3908 Lisp_Object obuffer; 3909 Lisp_Object obuffer;
3909 ptrdiff_t count = SPECPDL_INDEX (); 3910 ptrdiff_t count = SPECPDL_INDEX ();
3910 ptrdiff_t n_beg, n_end, o_beg IF_LINT (= 0), o_end IF_LINT (= 0); 3911 ptrdiff_t n_beg, n_end;
3912 ptrdiff_t o_beg UNINIT, o_end UNINIT;
3911 3913
3912 CHECK_OVERLAY (overlay); 3914 CHECK_OVERLAY (overlay);
3913 if (NILP (buffer)) 3915 if (NILP (buffer))
diff --git a/src/bytecode.c b/src/bytecode.c
index fb9f617b514..ee1b79f1826 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -17,22 +17,6 @@ GNU General Public License for more details.
17You should have received a copy of the GNU General Public License 17You should have received a copy of the GNU General Public License
18along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ 18along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19 19
20/*
21hacked on by jwz@lucid.com 17-jun-91
22 o added a compile-time switch to turn on simple sanity checking;
23 o put back the obsolete byte-codes for error-detection;
24 o added a new instruction, unbind_all, which I will use for
25 tail-recursion elimination;
26 o made temp_output_buffer_show be called with the right number
27 of args;
28 o made the new bytecodes be called with args in the right order;
29 o added metering support.
30
31by Hallvard:
32 o added relative jump instructions;
33 o all conditionals now only do QUIT if they jump.
34 */
35
36#include <config.h> 20#include <config.h>
37 21
38#include "lisp.h" 22#include "lisp.h"
@@ -43,9 +27,9 @@ by Hallvard:
43#include "syntax.h" 27#include "syntax.h"
44#include "window.h" 28#include "window.h"
45 29
46#ifdef CHECK_FRAME_FONT 30/* Work around GCC bug 54561. */
47#include "frame.h" 31#if GNUC_PREREQ (4, 3, 0)
48#include "xterm.h" 32# pragma GCC diagnostic ignored "-Wclobbered"
49#endif 33#endif
50 34
51/* 35/*
@@ -294,9 +278,6 @@ enum byte_code_op
294 Bset_mark = 0163, /* this loser is no longer generated as of v18 */ 278 Bset_mark = 0163, /* this loser is no longer generated as of v18 */
295#endif 279#endif
296}; 280};
297
298/* Whether to maintain a `top' and `bottom' field in the stack frame. */
299#define BYTE_MAINTAIN_TOP BYTE_CODE_SAFE
300 281
301/* Structure describing a value stack used during byte-code execution 282/* Structure describing a value stack used during byte-code execution
302 in Fbyte_code. */ 283 in Fbyte_code. */
@@ -307,15 +288,14 @@ struct byte_stack
307 and is relocated when that string is relocated. */ 288 and is relocated when that string is relocated. */
308 const unsigned char *pc; 289 const unsigned char *pc;
309 290
310 /* Top and bottom of stack. The bottom points to an area of memory 291 /* bottom of stack. The bottom points to an area of memory
311 allocated with alloca in Fbyte_code. */ 292 allocated with alloca in Fbyte_code. */
312#if BYTE_MAINTAIN_TOP 293#ifdef BYTE_CODE_SAFE
313 Lisp_Object *top, *bottom; 294 Lisp_Object *bottom;
314#endif 295#endif
315 296
316 /* The string containing the byte-code, and its current address. 297 /* The string containing the byte-code, and its current address.
317 Storing this here protects it from GC because mark_byte_stack 298 Storing this here protects it from GC. */
318 marks it. */
319 Lisp_Object byte_string; 299 Lisp_Object byte_string;
320 const unsigned char *byte_string_start; 300 const unsigned char *byte_string_start;
321 301
@@ -364,12 +344,10 @@ relocate_byte_stack (void)
364 344
365#define FETCH2 (op = FETCH, op + (FETCH << 8)) 345#define FETCH2 (op = FETCH, op + (FETCH << 8))
366 346
367/* Push x onto the execution stack. This used to be #define PUSH(x) 347/* Push X onto the execution stack. The expression X should not
368 (*++stackp = (x)) This oddity is necessary because Alliant can't be 348 contain TOP, to avoid competing side effects. */
369 bothered to compile the preincrement operator properly, as of 4/91.
370 -JimB */
371 349
372#define PUSH(x) (top++, *top = (x)) 350#define PUSH(x) (*++top = (x))
373 351
374/* Pop a value off the execution stack. */ 352/* Pop a value off the execution stack. */
375 353
@@ -384,27 +362,6 @@ relocate_byte_stack (void)
384 362
385#define TOP (*top) 363#define TOP (*top)
386 364
387/* Actions that must be performed before and after calling a function
388 that might GC. */
389
390#if !BYTE_MAINTAIN_TOP
391#define BEFORE_POTENTIAL_GC() ((void)0)
392#define AFTER_POTENTIAL_GC() ((void)0)
393#else
394#define BEFORE_POTENTIAL_GC() stack.top = top
395#define AFTER_POTENTIAL_GC() stack.top = NULL
396#endif
397
398/* Garbage collect if we have consed enough since the last time.
399 We do this at every branch, to avoid loops that never GC. */
400
401#define MAYBE_GC() \
402 do { \
403 BEFORE_POTENTIAL_GC (); \
404 maybe_gc (); \
405 AFTER_POTENTIAL_GC (); \
406 } while (0)
407
408/* Check for jumping out of range. */ 365/* Check for jumping out of range. */
409 366
410#ifdef BYTE_CODE_SAFE 367#ifdef BYTE_CODE_SAFE
@@ -427,11 +384,9 @@ relocate_byte_stack (void)
427 { \ 384 { \
428 Lisp_Object flag = Vquit_flag; \ 385 Lisp_Object flag = Vquit_flag; \
429 Vquit_flag = Qnil; \ 386 Vquit_flag = Qnil; \
430 BEFORE_POTENTIAL_GC (); \
431 if (EQ (Vthrow_on_input, flag)) \ 387 if (EQ (Vthrow_on_input, flag)) \
432 Fthrow (Vthrow_on_input, Qt); \ 388 Fthrow (Vthrow_on_input, Qt); \
433 Fsignal (Qquit, Qnil); \ 389 quit (); \
434 AFTER_POTENTIAL_GC (); \
435 } \ 390 } \
436 else if (pending_signals) \ 391 else if (pending_signals) \
437 process_pending_signals (); \ 392 process_pending_signals (); \
@@ -485,16 +440,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
485 Lisp_Object result; 440 Lisp_Object result;
486 enum handlertype type; 441 enum handlertype type;
487 442
488#if 0 /* CHECK_FRAME_FONT */
489 {
490 struct frame *f = SELECTED_FRAME ();
491 if (FRAME_X_P (f)
492 && FRAME_FONT (f)->direction != 0
493 && FRAME_FONT (f)->direction != 1)
494 emacs_abort ();
495 }
496#endif
497
498 CHECK_STRING (bytestr); 443 CHECK_STRING (bytestr);
499 CHECK_VECTOR (vector); 444 CHECK_VECTOR (vector);
500 CHECK_NATNUM (maxdepth); 445 CHECK_NATNUM (maxdepth);
@@ -521,9 +466,8 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
521 if (MAX_ALLOCA / word_size <= XFASTINT (maxdepth)) 466 if (MAX_ALLOCA / word_size <= XFASTINT (maxdepth))
522 memory_full (SIZE_MAX); 467 memory_full (SIZE_MAX);
523 top = alloca ((XFASTINT (maxdepth) + 1) * sizeof *top); 468 top = alloca ((XFASTINT (maxdepth) + 1) * sizeof *top);
524#if BYTE_MAINTAIN_TOP 469#ifdef BYTE_CODE_SAFE
525 stack.bottom = top + 1; 470 stack.bottom = top + 1;
526 stack.top = NULL;
527#endif 471#endif
528 stack.next = byte_stack_list; 472 stack.next = byte_stack_list;
529 byte_stack_list = &stack; 473 byte_stack_list = &stack;
@@ -637,7 +581,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
637 the table clearer. */ 581 the table clearer. */
638#define LABEL(OP) [OP] = &&insn_ ## OP 582#define LABEL(OP) [OP] = &&insn_ ## OP
639 583
640#if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) 584#if GNUC_PREREQ (4, 6, 0)
641# pragma GCC diagnostic push 585# pragma GCC diagnostic push
642# pragma GCC diagnostic ignored "-Woverride-init" 586# pragma GCC diagnostic ignored "-Woverride-init"
643#elif defined __clang__ 587#elif defined __clang__
@@ -656,7 +600,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
656#undef DEFINE 600#undef DEFINE
657 }; 601 };
658 602
659#if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) || defined __clang__ 603#if GNUC_PREREQ (4, 6, 0) || defined __clang__
660# pragma GCC diagnostic pop 604# pragma GCC diagnostic pop
661#endif 605#endif
662 606
@@ -693,16 +637,12 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
693 || (v2 = SYMBOL_VAL (XSYMBOL (v1)), 637 || (v2 = SYMBOL_VAL (XSYMBOL (v1)),
694 EQ (v2, Qunbound))) 638 EQ (v2, Qunbound)))
695 { 639 {
696 BEFORE_POTENTIAL_GC ();
697 v2 = Fsymbol_value (v1); 640 v2 = Fsymbol_value (v1);
698 AFTER_POTENTIAL_GC ();
699 } 641 }
700 } 642 }
701 else 643 else
702 { 644 {
703 BEFORE_POTENTIAL_GC ();
704 v2 = Fsymbol_value (v1); 645 v2 = Fsymbol_value (v1);
705 AFTER_POTENTIAL_GC ();
706 } 646 }
707 PUSH (v2); 647 PUSH (v2);
708 NEXT; 648 NEXT;
@@ -711,7 +651,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
711 CASE (Bgotoifnil): 651 CASE (Bgotoifnil):
712 { 652 {
713 Lisp_Object v1; 653 Lisp_Object v1;
714 MAYBE_GC (); 654 maybe_gc ();
715 op = FETCH2; 655 op = FETCH2;
716 v1 = POP; 656 v1 = POP;
717 if (NILP (v1)) 657 if (NILP (v1))
@@ -733,7 +673,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
733 TOP = Qnil; 673 TOP = Qnil;
734 else 674 else
735 { 675 {
736 BEFORE_POTENTIAL_GC ();
737 wrong_type_argument (Qlistp, v1); 676 wrong_type_argument (Qlistp, v1);
738 } 677 }
739 NEXT; 678 NEXT;
@@ -750,10 +689,8 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
750 CASE (Bmemq): 689 CASE (Bmemq):
751 { 690 {
752 Lisp_Object v1; 691 Lisp_Object v1;
753 BEFORE_POTENTIAL_GC ();
754 v1 = POP; 692 v1 = POP;
755 TOP = Fmemq (TOP, v1); 693 TOP = Fmemq (TOP, v1);
756 AFTER_POTENTIAL_GC ();
757 NEXT; 694 NEXT;
758 } 695 }
759 696
@@ -767,7 +704,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
767 TOP = Qnil; 704 TOP = Qnil;
768 else 705 else
769 { 706 {
770 BEFORE_POTENTIAL_GC ();
771 wrong_type_argument (Qlistp, v1); 707 wrong_type_argument (Qlistp, v1);
772 } 708 }
773 NEXT; 709 NEXT;
@@ -803,9 +739,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
803 SET_SYMBOL_VAL (XSYMBOL (sym), val); 739 SET_SYMBOL_VAL (XSYMBOL (sym), val);
804 else 740 else
805 { 741 {
806 BEFORE_POTENTIAL_GC ();
807 set_internal (sym, val, Qnil, 0); 742 set_internal (sym, val, Qnil, 0);
808 AFTER_POTENTIAL_GC ();
809 } 743 }
810 } 744 }
811 (void) POP; 745 (void) POP;
@@ -838,9 +772,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
838 op -= Bvarbind; 772 op -= Bvarbind;
839 varbind: 773 varbind:
840 /* Specbind can signal and thus GC. */ 774 /* Specbind can signal and thus GC. */
841 BEFORE_POTENTIAL_GC ();
842 specbind (vectorp[op], POP); 775 specbind (vectorp[op], POP);
843 AFTER_POTENTIAL_GC ();
844 NEXT; 776 NEXT;
845 777
846 CASE (Bcall6): 778 CASE (Bcall6):
@@ -860,7 +792,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
860 op -= Bcall; 792 op -= Bcall;
861 docall: 793 docall:
862 { 794 {
863 BEFORE_POTENTIAL_GC ();
864 DISCARD (op); 795 DISCARD (op);
865#ifdef BYTE_CODE_METER 796#ifdef BYTE_CODE_METER
866 if (byte_metering_on && SYMBOLP (TOP)) 797 if (byte_metering_on && SYMBOLP (TOP))
@@ -878,7 +809,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
878 } 809 }
879#endif 810#endif
880 TOP = Ffuncall (op + 1, &TOP); 811 TOP = Ffuncall (op + 1, &TOP);
881 AFTER_POTENTIAL_GC ();
882 NEXT; 812 NEXT;
883 } 813 }
884 814
@@ -898,21 +828,17 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
898 CASE (Bunbind5): 828 CASE (Bunbind5):
899 op -= Bunbind; 829 op -= Bunbind;
900 dounbind: 830 dounbind:
901 BEFORE_POTENTIAL_GC ();
902 unbind_to (SPECPDL_INDEX () - op, Qnil); 831 unbind_to (SPECPDL_INDEX () - op, Qnil);
903 AFTER_POTENTIAL_GC ();
904 NEXT; 832 NEXT;
905 833
906 CASE (Bunbind_all): /* Obsolete. Never used. */ 834 CASE (Bunbind_all): /* Obsolete. Never used. */
907 /* To unbind back to the beginning of this frame. Not used yet, 835 /* To unbind back to the beginning of this frame. Not used yet,
908 but will be needed for tail-recursion elimination. */ 836 but will be needed for tail-recursion elimination. */
909 BEFORE_POTENTIAL_GC ();
910 unbind_to (count, Qnil); 837 unbind_to (count, Qnil);
911 AFTER_POTENTIAL_GC ();
912 NEXT; 838 NEXT;
913 839
914 CASE (Bgoto): 840 CASE (Bgoto):
915 MAYBE_GC (); 841 maybe_gc ();
916 BYTE_CODE_QUIT; 842 BYTE_CODE_QUIT;
917 op = FETCH2; /* pc = FETCH2 loses since FETCH2 contains pc++ */ 843 op = FETCH2; /* pc = FETCH2 loses since FETCH2 contains pc++ */
918 CHECK_RANGE (op); 844 CHECK_RANGE (op);
@@ -922,7 +848,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
922 CASE (Bgotoifnonnil): 848 CASE (Bgotoifnonnil):
923 { 849 {
924 Lisp_Object v1; 850 Lisp_Object v1;
925 MAYBE_GC (); 851 maybe_gc ();
926 op = FETCH2; 852 op = FETCH2;
927 v1 = POP; 853 v1 = POP;
928 if (!NILP (v1)) 854 if (!NILP (v1))
@@ -935,7 +861,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
935 } 861 }
936 862
937 CASE (Bgotoifnilelsepop): 863 CASE (Bgotoifnilelsepop):
938 MAYBE_GC (); 864 maybe_gc ();
939 op = FETCH2; 865 op = FETCH2;
940 if (NILP (TOP)) 866 if (NILP (TOP))
941 { 867 {
@@ -947,7 +873,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
947 NEXT; 873 NEXT;
948 874
949 CASE (Bgotoifnonnilelsepop): 875 CASE (Bgotoifnonnilelsepop):
950 MAYBE_GC (); 876 maybe_gc ();
951 op = FETCH2; 877 op = FETCH2;
952 if (!NILP (TOP)) 878 if (!NILP (TOP))
953 { 879 {
@@ -959,7 +885,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
959 NEXT; 885 NEXT;
960 886
961 CASE (BRgoto): 887 CASE (BRgoto):
962 MAYBE_GC (); 888 maybe_gc ();
963 BYTE_CODE_QUIT; 889 BYTE_CODE_QUIT;
964 stack.pc += (int) *stack.pc - 127; 890 stack.pc += (int) *stack.pc - 127;
965 NEXT; 891 NEXT;
@@ -967,7 +893,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
967 CASE (BRgotoifnil): 893 CASE (BRgotoifnil):
968 { 894 {
969 Lisp_Object v1; 895 Lisp_Object v1;
970 MAYBE_GC (); 896 maybe_gc ();
971 v1 = POP; 897 v1 = POP;
972 if (NILP (v1)) 898 if (NILP (v1))
973 { 899 {
@@ -981,7 +907,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
981 CASE (BRgotoifnonnil): 907 CASE (BRgotoifnonnil):
982 { 908 {
983 Lisp_Object v1; 909 Lisp_Object v1;
984 MAYBE_GC (); 910 maybe_gc ();
985 v1 = POP; 911 v1 = POP;
986 if (!NILP (v1)) 912 if (!NILP (v1))
987 { 913 {
@@ -993,7 +919,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
993 } 919 }
994 920
995 CASE (BRgotoifnilelsepop): 921 CASE (BRgotoifnilelsepop):
996 MAYBE_GC (); 922 maybe_gc ();
997 op = *stack.pc++; 923 op = *stack.pc++;
998 if (NILP (TOP)) 924 if (NILP (TOP))
999 { 925 {
@@ -1004,7 +930,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1004 NEXT; 930 NEXT;
1005 931
1006 CASE (BRgotoifnonnilelsepop): 932 CASE (BRgotoifnonnilelsepop):
1007 MAYBE_GC (); 933 maybe_gc ();
1008 op = *stack.pc++; 934 op = *stack.pc++;
1009 if (!NILP (TOP)) 935 if (!NILP (TOP))
1010 { 936 {
@@ -1041,10 +967,8 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1041 ptrdiff_t count1 = SPECPDL_INDEX (); 967 ptrdiff_t count1 = SPECPDL_INDEX ();
1042 record_unwind_protect (restore_window_configuration, 968 record_unwind_protect (restore_window_configuration,
1043 Fcurrent_window_configuration (Qnil)); 969 Fcurrent_window_configuration (Qnil));
1044 BEFORE_POTENTIAL_GC ();
1045 TOP = Fprogn (TOP); 970 TOP = Fprogn (TOP);
1046 unbind_to (count1, TOP); 971 unbind_to (count1, TOP);
1047 AFTER_POTENTIAL_GC ();
1048 NEXT; 972 NEXT;
1049 } 973 }
1050 974
@@ -1056,10 +980,8 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1056 CASE (Bcatch): /* Obsolete since 24.4. */ 980 CASE (Bcatch): /* Obsolete since 24.4. */
1057 { 981 {
1058 Lisp_Object v1; 982 Lisp_Object v1;
1059 BEFORE_POTENTIAL_GC ();
1060 v1 = POP; 983 v1 = POP;
1061 TOP = internal_catch (TOP, eval_sub, v1); 984 TOP = internal_catch (TOP, eval_sub, v1);
1062 AFTER_POTENTIAL_GC ();
1063 NEXT; 985 NEXT;
1064 } 986 }
1065 987
@@ -1115,30 +1037,24 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1115 Lisp_Object handlers, body; 1037 Lisp_Object handlers, body;
1116 handlers = POP; 1038 handlers = POP;
1117 body = POP; 1039 body = POP;
1118 BEFORE_POTENTIAL_GC ();
1119 TOP = internal_lisp_condition_case (TOP, body, handlers); 1040 TOP = internal_lisp_condition_case (TOP, body, handlers);
1120 AFTER_POTENTIAL_GC ();
1121 NEXT; 1041 NEXT;
1122 } 1042 }
1123 1043
1124 CASE (Btemp_output_buffer_setup): /* Obsolete since 24.1. */ 1044 CASE (Btemp_output_buffer_setup): /* Obsolete since 24.1. */
1125 BEFORE_POTENTIAL_GC ();
1126 CHECK_STRING (TOP); 1045 CHECK_STRING (TOP);
1127 temp_output_buffer_setup (SSDATA (TOP)); 1046 temp_output_buffer_setup (SSDATA (TOP));
1128 AFTER_POTENTIAL_GC ();
1129 TOP = Vstandard_output; 1047 TOP = Vstandard_output;
1130 NEXT; 1048 NEXT;
1131 1049
1132 CASE (Btemp_output_buffer_show): /* Obsolete since 24.1. */ 1050 CASE (Btemp_output_buffer_show): /* Obsolete since 24.1. */
1133 { 1051 {
1134 Lisp_Object v1; 1052 Lisp_Object v1;
1135 BEFORE_POTENTIAL_GC ();
1136 v1 = POP; 1053 v1 = POP;
1137 temp_output_buffer_show (TOP); 1054 temp_output_buffer_show (TOP);
1138 TOP = v1; 1055 TOP = v1;
1139 /* pop binding of standard-output */ 1056 /* pop binding of standard-output */
1140 unbind_to (SPECPDL_INDEX () - 1, Qnil); 1057 unbind_to (SPECPDL_INDEX () - 1, Qnil);
1141 AFTER_POTENTIAL_GC ();
1142 NEXT; 1058 NEXT;
1143 } 1059 }
1144 1060
@@ -1146,7 +1062,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1146 { 1062 {
1147 Lisp_Object v1, v2; 1063 Lisp_Object v1, v2;
1148 EMACS_INT n; 1064 EMACS_INT n;
1149 BEFORE_POTENTIAL_GC ();
1150 v1 = POP; 1065 v1 = POP;
1151 v2 = TOP; 1066 v2 = TOP;
1152 CHECK_NUMBER (v2); 1067 CHECK_NUMBER (v2);
@@ -1156,7 +1071,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1156 v1 = XCDR (v1); 1071 v1 = XCDR (v1);
1157 immediate_quit = 0; 1072 immediate_quit = 0;
1158 TOP = CAR (v1); 1073 TOP = CAR (v1);
1159 AFTER_POTENTIAL_GC ();
1160 NEXT; 1074 NEXT;
1161 } 1075 }
1162 1076
@@ -1217,110 +1131,84 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1217 NEXT; 1131 NEXT;
1218 1132
1219 CASE (Blength): 1133 CASE (Blength):
1220 BEFORE_POTENTIAL_GC ();
1221 TOP = Flength (TOP); 1134 TOP = Flength (TOP);
1222 AFTER_POTENTIAL_GC ();
1223 NEXT; 1135 NEXT;
1224 1136
1225 CASE (Baref): 1137 CASE (Baref):
1226 { 1138 {
1227 Lisp_Object v1; 1139 Lisp_Object v1;
1228 BEFORE_POTENTIAL_GC ();
1229 v1 = POP; 1140 v1 = POP;
1230 TOP = Faref (TOP, v1); 1141 TOP = Faref (TOP, v1);
1231 AFTER_POTENTIAL_GC ();
1232 NEXT; 1142 NEXT;
1233 } 1143 }
1234 1144
1235 CASE (Baset): 1145 CASE (Baset):
1236 { 1146 {
1237 Lisp_Object v1, v2; 1147 Lisp_Object v1, v2;
1238 BEFORE_POTENTIAL_GC ();
1239 v2 = POP; v1 = POP; 1148 v2 = POP; v1 = POP;
1240 TOP = Faset (TOP, v1, v2); 1149 TOP = Faset (TOP, v1, v2);
1241 AFTER_POTENTIAL_GC ();
1242 NEXT; 1150 NEXT;
1243 } 1151 }
1244 1152
1245 CASE (Bsymbol_value): 1153 CASE (Bsymbol_value):
1246 BEFORE_POTENTIAL_GC ();
1247 TOP = Fsymbol_value (TOP); 1154 TOP = Fsymbol_value (TOP);
1248 AFTER_POTENTIAL_GC ();
1249 NEXT; 1155 NEXT;
1250 1156
1251 CASE (Bsymbol_function): 1157 CASE (Bsymbol_function):
1252 BEFORE_POTENTIAL_GC ();
1253 TOP = Fsymbol_function (TOP); 1158 TOP = Fsymbol_function (TOP);
1254 AFTER_POTENTIAL_GC ();
1255 NEXT; 1159 NEXT;
1256 1160
1257 CASE (Bset): 1161 CASE (Bset):
1258 { 1162 {
1259 Lisp_Object v1; 1163 Lisp_Object v1;
1260 BEFORE_POTENTIAL_GC ();
1261 v1 = POP; 1164 v1 = POP;
1262 TOP = Fset (TOP, v1); 1165 TOP = Fset (TOP, v1);
1263 AFTER_POTENTIAL_GC ();
1264 NEXT; 1166 NEXT;
1265 } 1167 }
1266 1168
1267 CASE (Bfset): 1169 CASE (Bfset):
1268 { 1170 {
1269 Lisp_Object v1; 1171 Lisp_Object v1;
1270 BEFORE_POTENTIAL_GC ();
1271 v1 = POP; 1172 v1 = POP;
1272 TOP = Ffset (TOP, v1); 1173 TOP = Ffset (TOP, v1);
1273 AFTER_POTENTIAL_GC ();
1274 NEXT; 1174 NEXT;
1275 } 1175 }
1276 1176
1277 CASE (Bget): 1177 CASE (Bget):
1278 { 1178 {
1279 Lisp_Object v1; 1179 Lisp_Object v1;
1280 BEFORE_POTENTIAL_GC ();
1281 v1 = POP; 1180 v1 = POP;
1282 TOP = Fget (TOP, v1); 1181 TOP = Fget (TOP, v1);
1283 AFTER_POTENTIAL_GC ();
1284 NEXT; 1182 NEXT;
1285 } 1183 }
1286 1184
1287 CASE (Bsubstring): 1185 CASE (Bsubstring):
1288 { 1186 {
1289 Lisp_Object v1, v2; 1187 Lisp_Object v1, v2;
1290 BEFORE_POTENTIAL_GC ();
1291 v2 = POP; v1 = POP; 1188 v2 = POP; v1 = POP;
1292 TOP = Fsubstring (TOP, v1, v2); 1189 TOP = Fsubstring (TOP, v1, v2);
1293 AFTER_POTENTIAL_GC ();
1294 NEXT; 1190 NEXT;
1295 } 1191 }
1296 1192
1297 CASE (Bconcat2): 1193 CASE (Bconcat2):
1298 BEFORE_POTENTIAL_GC ();
1299 DISCARD (1); 1194 DISCARD (1);
1300 TOP = Fconcat (2, &TOP); 1195 TOP = Fconcat (2, &TOP);
1301 AFTER_POTENTIAL_GC ();
1302 NEXT; 1196 NEXT;
1303 1197
1304 CASE (Bconcat3): 1198 CASE (Bconcat3):
1305 BEFORE_POTENTIAL_GC ();
1306 DISCARD (2); 1199 DISCARD (2);
1307 TOP = Fconcat (3, &TOP); 1200 TOP = Fconcat (3, &TOP);
1308 AFTER_POTENTIAL_GC ();
1309 NEXT; 1201 NEXT;
1310 1202
1311 CASE (Bconcat4): 1203 CASE (Bconcat4):
1312 BEFORE_POTENTIAL_GC ();
1313 DISCARD (3); 1204 DISCARD (3);
1314 TOP = Fconcat (4, &TOP); 1205 TOP = Fconcat (4, &TOP);
1315 AFTER_POTENTIAL_GC ();
1316 NEXT; 1206 NEXT;
1317 1207
1318 CASE (BconcatN): 1208 CASE (BconcatN):
1319 op = FETCH; 1209 op = FETCH;
1320 BEFORE_POTENTIAL_GC ();
1321 DISCARD (op - 1); 1210 DISCARD (op - 1);
1322 TOP = Fconcat (op, &TOP); 1211 TOP = Fconcat (op, &TOP);
1323 AFTER_POTENTIAL_GC ();
1324 NEXT; 1212 NEXT;
1325 1213
1326 CASE (Bsub1): 1214 CASE (Bsub1):
@@ -1334,9 +1222,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1334 } 1222 }
1335 else 1223 else
1336 { 1224 {
1337 BEFORE_POTENTIAL_GC ();
1338 TOP = Fsub1 (v1); 1225 TOP = Fsub1 (v1);
1339 AFTER_POTENTIAL_GC ();
1340 } 1226 }
1341 NEXT; 1227 NEXT;
1342 } 1228 }
@@ -1352,9 +1238,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1352 } 1238 }
1353 else 1239 else
1354 { 1240 {
1355 BEFORE_POTENTIAL_GC ();
1356 TOP = Fadd1 (v1); 1241 TOP = Fadd1 (v1);
1357 AFTER_POTENTIAL_GC ();
1358 } 1242 }
1359 NEXT; 1243 NEXT;
1360 } 1244 }
@@ -1362,11 +1246,9 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1362 CASE (Beqlsign): 1246 CASE (Beqlsign):
1363 { 1247 {
1364 Lisp_Object v1, v2; 1248 Lisp_Object v1, v2;
1365 BEFORE_POTENTIAL_GC ();
1366 v2 = POP; v1 = TOP; 1249 v2 = POP; v1 = TOP;
1367 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (v1); 1250 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (v1);
1368 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (v2); 1251 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (v2);
1369 AFTER_POTENTIAL_GC ();
1370 if (FLOATP (v1) || FLOATP (v2)) 1252 if (FLOATP (v1) || FLOATP (v2))
1371 { 1253 {
1372 double f1, f2; 1254 double f1, f2;
@@ -1383,48 +1265,38 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1383 CASE (Bgtr): 1265 CASE (Bgtr):
1384 { 1266 {
1385 Lisp_Object v1; 1267 Lisp_Object v1;
1386 BEFORE_POTENTIAL_GC ();
1387 v1 = POP; 1268 v1 = POP;
1388 TOP = arithcompare (TOP, v1, ARITH_GRTR); 1269 TOP = arithcompare (TOP, v1, ARITH_GRTR);
1389 AFTER_POTENTIAL_GC ();
1390 NEXT; 1270 NEXT;
1391 } 1271 }
1392 1272
1393 CASE (Blss): 1273 CASE (Blss):
1394 { 1274 {
1395 Lisp_Object v1; 1275 Lisp_Object v1;
1396 BEFORE_POTENTIAL_GC ();
1397 v1 = POP; 1276 v1 = POP;
1398 TOP = arithcompare (TOP, v1, ARITH_LESS); 1277 TOP = arithcompare (TOP, v1, ARITH_LESS);
1399 AFTER_POTENTIAL_GC ();
1400 NEXT; 1278 NEXT;
1401 } 1279 }
1402 1280
1403 CASE (Bleq): 1281 CASE (Bleq):
1404 { 1282 {
1405 Lisp_Object v1; 1283 Lisp_Object v1;
1406 BEFORE_POTENTIAL_GC ();
1407 v1 = POP; 1284 v1 = POP;
1408 TOP = arithcompare (TOP, v1, ARITH_LESS_OR_EQUAL); 1285 TOP = arithcompare (TOP, v1, ARITH_LESS_OR_EQUAL);
1409 AFTER_POTENTIAL_GC ();
1410 NEXT; 1286 NEXT;
1411 } 1287 }
1412 1288
1413 CASE (Bgeq): 1289 CASE (Bgeq):
1414 { 1290 {
1415 Lisp_Object v1; 1291 Lisp_Object v1;
1416 BEFORE_POTENTIAL_GC ();
1417 v1 = POP; 1292 v1 = POP;
1418 TOP = arithcompare (TOP, v1, ARITH_GRTR_OR_EQUAL); 1293 TOP = arithcompare (TOP, v1, ARITH_GRTR_OR_EQUAL);
1419 AFTER_POTENTIAL_GC ();
1420 NEXT; 1294 NEXT;
1421 } 1295 }
1422 1296
1423 CASE (Bdiff): 1297 CASE (Bdiff):
1424 BEFORE_POTENTIAL_GC ();
1425 DISCARD (1); 1298 DISCARD (1);
1426 TOP = Fminus (2, &TOP); 1299 TOP = Fminus (2, &TOP);
1427 AFTER_POTENTIAL_GC ();
1428 NEXT; 1300 NEXT;
1429 1301
1430 CASE (Bnegate): 1302 CASE (Bnegate):
@@ -1438,55 +1310,41 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1438 } 1310 }
1439 else 1311 else
1440 { 1312 {
1441 BEFORE_POTENTIAL_GC ();
1442 TOP = Fminus (1, &TOP); 1313 TOP = Fminus (1, &TOP);
1443 AFTER_POTENTIAL_GC ();
1444 } 1314 }
1445 NEXT; 1315 NEXT;
1446 } 1316 }
1447 1317
1448 CASE (Bplus): 1318 CASE (Bplus):
1449 BEFORE_POTENTIAL_GC ();
1450 DISCARD (1); 1319 DISCARD (1);
1451 TOP = Fplus (2, &TOP); 1320 TOP = Fplus (2, &TOP);
1452 AFTER_POTENTIAL_GC ();
1453 NEXT; 1321 NEXT;
1454 1322
1455 CASE (Bmax): 1323 CASE (Bmax):
1456 BEFORE_POTENTIAL_GC ();
1457 DISCARD (1); 1324 DISCARD (1);
1458 TOP = Fmax (2, &TOP); 1325 TOP = Fmax (2, &TOP);
1459 AFTER_POTENTIAL_GC ();
1460 NEXT; 1326 NEXT;
1461 1327
1462 CASE (Bmin): 1328 CASE (Bmin):
1463 BEFORE_POTENTIAL_GC ();
1464 DISCARD (1); 1329 DISCARD (1);
1465 TOP = Fmin (2, &TOP); 1330 TOP = Fmin (2, &TOP);
1466 AFTER_POTENTIAL_GC ();
1467 NEXT; 1331 NEXT;
1468 1332
1469 CASE (Bmult): 1333 CASE (Bmult):
1470 BEFORE_POTENTIAL_GC ();
1471 DISCARD (1); 1334 DISCARD (1);
1472 TOP = Ftimes (2, &TOP); 1335 TOP = Ftimes (2, &TOP);
1473 AFTER_POTENTIAL_GC ();
1474 NEXT; 1336 NEXT;
1475 1337
1476 CASE (Bquo): 1338 CASE (Bquo):
1477 BEFORE_POTENTIAL_GC ();
1478 DISCARD (1); 1339 DISCARD (1);
1479 TOP = Fquo (2, &TOP); 1340 TOP = Fquo (2, &TOP);
1480 AFTER_POTENTIAL_GC ();
1481 NEXT; 1341 NEXT;
1482 1342
1483 CASE (Brem): 1343 CASE (Brem):
1484 { 1344 {
1485 Lisp_Object v1; 1345 Lisp_Object v1;
1486 BEFORE_POTENTIAL_GC ();
1487 v1 = POP; 1346 v1 = POP;
1488 TOP = Frem (TOP, v1); 1347 TOP = Frem (TOP, v1);
1489 AFTER_POTENTIAL_GC ();
1490 NEXT; 1348 NEXT;
1491 } 1349 }
1492 1350
@@ -1499,23 +1357,17 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1499 } 1357 }
1500 1358
1501 CASE (Bgoto_char): 1359 CASE (Bgoto_char):
1502 BEFORE_POTENTIAL_GC ();
1503 TOP = Fgoto_char (TOP); 1360 TOP = Fgoto_char (TOP);
1504 AFTER_POTENTIAL_GC ();
1505 NEXT; 1361 NEXT;
1506 1362
1507 CASE (Binsert): 1363 CASE (Binsert):
1508 BEFORE_POTENTIAL_GC ();
1509 TOP = Finsert (1, &TOP); 1364 TOP = Finsert (1, &TOP);
1510 AFTER_POTENTIAL_GC ();
1511 NEXT; 1365 NEXT;
1512 1366
1513 CASE (BinsertN): 1367 CASE (BinsertN):
1514 op = FETCH; 1368 op = FETCH;
1515 BEFORE_POTENTIAL_GC ();
1516 DISCARD (op - 1); 1369 DISCARD (op - 1);
1517 TOP = Finsert (op, &TOP); 1370 TOP = Finsert (op, &TOP);
1518 AFTER_POTENTIAL_GC ();
1519 NEXT; 1371 NEXT;
1520 1372
1521 CASE (Bpoint_max): 1373 CASE (Bpoint_max):
@@ -1535,17 +1387,13 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1535 } 1387 }
1536 1388
1537 CASE (Bchar_after): 1389 CASE (Bchar_after):
1538 BEFORE_POTENTIAL_GC ();
1539 TOP = Fchar_after (TOP); 1390 TOP = Fchar_after (TOP);
1540 AFTER_POTENTIAL_GC ();
1541 NEXT; 1391 NEXT;
1542 1392
1543 CASE (Bfollowing_char): 1393 CASE (Bfollowing_char):
1544 { 1394 {
1545 Lisp_Object v1; 1395 Lisp_Object v1;
1546 BEFORE_POTENTIAL_GC ();
1547 v1 = Ffollowing_char (); 1396 v1 = Ffollowing_char ();
1548 AFTER_POTENTIAL_GC ();
1549 PUSH (v1); 1397 PUSH (v1);
1550 NEXT; 1398 NEXT;
1551 } 1399 }
@@ -1553,9 +1401,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1553 CASE (Bpreceding_char): 1401 CASE (Bpreceding_char):
1554 { 1402 {
1555 Lisp_Object v1; 1403 Lisp_Object v1;
1556 BEFORE_POTENTIAL_GC ();
1557 v1 = Fprevious_char (); 1404 v1 = Fprevious_char ();
1558 AFTER_POTENTIAL_GC ();
1559 PUSH (v1); 1405 PUSH (v1);
1560 NEXT; 1406 NEXT;
1561 } 1407 }
@@ -1563,17 +1409,13 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1563 CASE (Bcurrent_column): 1409 CASE (Bcurrent_column):
1564 { 1410 {
1565 Lisp_Object v1; 1411 Lisp_Object v1;
1566 BEFORE_POTENTIAL_GC ();
1567 XSETFASTINT (v1, current_column ()); 1412 XSETFASTINT (v1, current_column ());
1568 AFTER_POTENTIAL_GC ();
1569 PUSH (v1); 1413 PUSH (v1);
1570 NEXT; 1414 NEXT;
1571 } 1415 }
1572 1416
1573 CASE (Bindent_to): 1417 CASE (Bindent_to):
1574 BEFORE_POTENTIAL_GC ();
1575 TOP = Findent_to (TOP, Qnil); 1418 TOP = Findent_to (TOP, Qnil);
1576 AFTER_POTENTIAL_GC ();
1577 NEXT; 1419 NEXT;
1578 1420
1579 CASE (Beolp): 1421 CASE (Beolp):
@@ -1597,62 +1439,46 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1597 NEXT; 1439 NEXT;
1598 1440
1599 CASE (Bset_buffer): 1441 CASE (Bset_buffer):
1600 BEFORE_POTENTIAL_GC ();
1601 TOP = Fset_buffer (TOP); 1442 TOP = Fset_buffer (TOP);
1602 AFTER_POTENTIAL_GC ();
1603 NEXT; 1443 NEXT;
1604 1444
1605 CASE (Binteractive_p): /* Obsolete since 24.1. */ 1445 CASE (Binteractive_p): /* Obsolete since 24.1. */
1606 BEFORE_POTENTIAL_GC ();
1607 PUSH (call0 (intern ("interactive-p"))); 1446 PUSH (call0 (intern ("interactive-p")));
1608 AFTER_POTENTIAL_GC ();
1609 NEXT; 1447 NEXT;
1610 1448
1611 CASE (Bforward_char): 1449 CASE (Bforward_char):
1612 BEFORE_POTENTIAL_GC ();
1613 TOP = Fforward_char (TOP); 1450 TOP = Fforward_char (TOP);
1614 AFTER_POTENTIAL_GC ();
1615 NEXT; 1451 NEXT;
1616 1452
1617 CASE (Bforward_word): 1453 CASE (Bforward_word):
1618 BEFORE_POTENTIAL_GC ();
1619 TOP = Fforward_word (TOP); 1454 TOP = Fforward_word (TOP);
1620 AFTER_POTENTIAL_GC ();
1621 NEXT; 1455 NEXT;
1622 1456
1623 CASE (Bskip_chars_forward): 1457 CASE (Bskip_chars_forward):
1624 { 1458 {
1625 Lisp_Object v1; 1459 Lisp_Object v1;
1626 BEFORE_POTENTIAL_GC ();
1627 v1 = POP; 1460 v1 = POP;
1628 TOP = Fskip_chars_forward (TOP, v1); 1461 TOP = Fskip_chars_forward (TOP, v1);
1629 AFTER_POTENTIAL_GC ();
1630 NEXT; 1462 NEXT;
1631 } 1463 }
1632 1464
1633 CASE (Bskip_chars_backward): 1465 CASE (Bskip_chars_backward):
1634 { 1466 {
1635 Lisp_Object v1; 1467 Lisp_Object v1;
1636 BEFORE_POTENTIAL_GC ();
1637 v1 = POP; 1468 v1 = POP;
1638 TOP = Fskip_chars_backward (TOP, v1); 1469 TOP = Fskip_chars_backward (TOP, v1);
1639 AFTER_POTENTIAL_GC ();
1640 NEXT; 1470 NEXT;
1641 } 1471 }
1642 1472
1643 CASE (Bforward_line): 1473 CASE (Bforward_line):
1644 BEFORE_POTENTIAL_GC ();
1645 TOP = Fforward_line (TOP); 1474 TOP = Fforward_line (TOP);
1646 AFTER_POTENTIAL_GC ();
1647 NEXT; 1475 NEXT;
1648 1476
1649 CASE (Bchar_syntax): 1477 CASE (Bchar_syntax):
1650 { 1478 {
1651 int c; 1479 int c;
1652 1480
1653 BEFORE_POTENTIAL_GC ();
1654 CHECK_CHARACTER (TOP); 1481 CHECK_CHARACTER (TOP);
1655 AFTER_POTENTIAL_GC ();
1656 c = XFASTINT (TOP); 1482 c = XFASTINT (TOP);
1657 if (NILP (BVAR (current_buffer, enable_multibyte_characters))) 1483 if (NILP (BVAR (current_buffer, enable_multibyte_characters)))
1658 MAKE_CHAR_MULTIBYTE (c); 1484 MAKE_CHAR_MULTIBYTE (c);
@@ -1663,97 +1489,73 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1663 CASE (Bbuffer_substring): 1489 CASE (Bbuffer_substring):
1664 { 1490 {
1665 Lisp_Object v1; 1491 Lisp_Object v1;
1666 BEFORE_POTENTIAL_GC ();
1667 v1 = POP; 1492 v1 = POP;
1668 TOP = Fbuffer_substring (TOP, v1); 1493 TOP = Fbuffer_substring (TOP, v1);
1669 AFTER_POTENTIAL_GC ();
1670 NEXT; 1494 NEXT;
1671 } 1495 }
1672 1496
1673 CASE (Bdelete_region): 1497 CASE (Bdelete_region):
1674 { 1498 {
1675 Lisp_Object v1; 1499 Lisp_Object v1;
1676 BEFORE_POTENTIAL_GC ();
1677 v1 = POP; 1500 v1 = POP;
1678 TOP = Fdelete_region (TOP, v1); 1501 TOP = Fdelete_region (TOP, v1);
1679 AFTER_POTENTIAL_GC ();
1680 NEXT; 1502 NEXT;
1681 } 1503 }
1682 1504
1683 CASE (Bnarrow_to_region): 1505 CASE (Bnarrow_to_region):
1684 { 1506 {
1685 Lisp_Object v1; 1507 Lisp_Object v1;
1686 BEFORE_POTENTIAL_GC ();
1687 v1 = POP; 1508 v1 = POP;
1688 TOP = Fnarrow_to_region (TOP, v1); 1509 TOP = Fnarrow_to_region (TOP, v1);
1689 AFTER_POTENTIAL_GC ();
1690 NEXT; 1510 NEXT;
1691 } 1511 }
1692 1512
1693 CASE (Bwiden): 1513 CASE (Bwiden):
1694 BEFORE_POTENTIAL_GC ();
1695 PUSH (Fwiden ()); 1514 PUSH (Fwiden ());
1696 AFTER_POTENTIAL_GC ();
1697 NEXT; 1515 NEXT;
1698 1516
1699 CASE (Bend_of_line): 1517 CASE (Bend_of_line):
1700 BEFORE_POTENTIAL_GC ();
1701 TOP = Fend_of_line (TOP); 1518 TOP = Fend_of_line (TOP);
1702 AFTER_POTENTIAL_GC ();
1703 NEXT; 1519 NEXT;
1704 1520
1705 CASE (Bset_marker): 1521 CASE (Bset_marker):
1706 { 1522 {
1707 Lisp_Object v1, v2; 1523 Lisp_Object v1, v2;
1708 BEFORE_POTENTIAL_GC ();
1709 v1 = POP; 1524 v1 = POP;
1710 v2 = POP; 1525 v2 = POP;
1711 TOP = Fset_marker (TOP, v2, v1); 1526 TOP = Fset_marker (TOP, v2, v1);
1712 AFTER_POTENTIAL_GC ();
1713 NEXT; 1527 NEXT;
1714 } 1528 }
1715 1529
1716 CASE (Bmatch_beginning): 1530 CASE (Bmatch_beginning):
1717 BEFORE_POTENTIAL_GC ();
1718 TOP = Fmatch_beginning (TOP); 1531 TOP = Fmatch_beginning (TOP);
1719 AFTER_POTENTIAL_GC ();
1720 NEXT; 1532 NEXT;
1721 1533
1722 CASE (Bmatch_end): 1534 CASE (Bmatch_end):
1723 BEFORE_POTENTIAL_GC ();
1724 TOP = Fmatch_end (TOP); 1535 TOP = Fmatch_end (TOP);
1725 AFTER_POTENTIAL_GC ();
1726 NEXT; 1536 NEXT;
1727 1537
1728 CASE (Bupcase): 1538 CASE (Bupcase):
1729 BEFORE_POTENTIAL_GC ();
1730 TOP = Fupcase (TOP); 1539 TOP = Fupcase (TOP);
1731 AFTER_POTENTIAL_GC ();
1732 NEXT; 1540 NEXT;
1733 1541
1734 CASE (Bdowncase): 1542 CASE (Bdowncase):
1735 BEFORE_POTENTIAL_GC ();
1736 TOP = Fdowncase (TOP); 1543 TOP = Fdowncase (TOP);
1737 AFTER_POTENTIAL_GC ();
1738 NEXT; 1544 NEXT;
1739 1545
1740 CASE (Bstringeqlsign): 1546 CASE (Bstringeqlsign):
1741 { 1547 {
1742 Lisp_Object v1; 1548 Lisp_Object v1;
1743 BEFORE_POTENTIAL_GC ();
1744 v1 = POP; 1549 v1 = POP;
1745 TOP = Fstring_equal (TOP, v1); 1550 TOP = Fstring_equal (TOP, v1);
1746 AFTER_POTENTIAL_GC ();
1747 NEXT; 1551 NEXT;
1748 } 1552 }
1749 1553
1750 CASE (Bstringlss): 1554 CASE (Bstringlss):
1751 { 1555 {
1752 Lisp_Object v1; 1556 Lisp_Object v1;
1753 BEFORE_POTENTIAL_GC ();
1754 v1 = POP; 1557 v1 = POP;
1755 TOP = Fstring_lessp (TOP, v1); 1558 TOP = Fstring_lessp (TOP, v1);
1756 AFTER_POTENTIAL_GC ();
1757 NEXT; 1559 NEXT;
1758 } 1560 }
1759 1561
@@ -1768,10 +1570,8 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1768 CASE (Bnthcdr): 1570 CASE (Bnthcdr):
1769 { 1571 {
1770 Lisp_Object v1; 1572 Lisp_Object v1;
1771 BEFORE_POTENTIAL_GC ();
1772 v1 = POP; 1573 v1 = POP;
1773 TOP = Fnthcdr (TOP, v1); 1574 TOP = Fnthcdr (TOP, v1);
1774 AFTER_POTENTIAL_GC ();
1775 NEXT; 1575 NEXT;
1776 } 1576 }
1777 1577
@@ -1782,11 +1582,9 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1782 { 1582 {
1783 /* Exchange args and then do nth. */ 1583 /* Exchange args and then do nth. */
1784 EMACS_INT n; 1584 EMACS_INT n;
1785 BEFORE_POTENTIAL_GC ();
1786 v2 = POP; 1585 v2 = POP;
1787 v1 = TOP; 1586 v1 = TOP;
1788 CHECK_NUMBER (v2); 1587 CHECK_NUMBER (v2);
1789 AFTER_POTENTIAL_GC ();
1790 n = XINT (v2); 1588 n = XINT (v2);
1791 immediate_quit = 1; 1589 immediate_quit = 1;
1792 while (--n >= 0 && CONSP (v1)) 1590 while (--n >= 0 && CONSP (v1))
@@ -1796,10 +1594,8 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1796 } 1594 }
1797 else 1595 else
1798 { 1596 {
1799 BEFORE_POTENTIAL_GC ();
1800 v1 = POP; 1597 v1 = POP;
1801 TOP = Felt (TOP, v1); 1598 TOP = Felt (TOP, v1);
1802 AFTER_POTENTIAL_GC ();
1803 } 1599 }
1804 NEXT; 1600 NEXT;
1805 } 1601 }
@@ -1807,46 +1603,36 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1807 CASE (Bmember): 1603 CASE (Bmember):
1808 { 1604 {
1809 Lisp_Object v1; 1605 Lisp_Object v1;
1810 BEFORE_POTENTIAL_GC ();
1811 v1 = POP; 1606 v1 = POP;
1812 TOP = Fmember (TOP, v1); 1607 TOP = Fmember (TOP, v1);
1813 AFTER_POTENTIAL_GC ();
1814 NEXT; 1608 NEXT;
1815 } 1609 }
1816 1610
1817 CASE (Bassq): 1611 CASE (Bassq):
1818 { 1612 {
1819 Lisp_Object v1; 1613 Lisp_Object v1;
1820 BEFORE_POTENTIAL_GC ();
1821 v1 = POP; 1614 v1 = POP;
1822 TOP = Fassq (TOP, v1); 1615 TOP = Fassq (TOP, v1);
1823 AFTER_POTENTIAL_GC ();
1824 NEXT; 1616 NEXT;
1825 } 1617 }
1826 1618
1827 CASE (Bnreverse): 1619 CASE (Bnreverse):
1828 BEFORE_POTENTIAL_GC ();
1829 TOP = Fnreverse (TOP); 1620 TOP = Fnreverse (TOP);
1830 AFTER_POTENTIAL_GC ();
1831 NEXT; 1621 NEXT;
1832 1622
1833 CASE (Bsetcar): 1623 CASE (Bsetcar):
1834 { 1624 {
1835 Lisp_Object v1; 1625 Lisp_Object v1;
1836 BEFORE_POTENTIAL_GC ();
1837 v1 = POP; 1626 v1 = POP;
1838 TOP = Fsetcar (TOP, v1); 1627 TOP = Fsetcar (TOP, v1);
1839 AFTER_POTENTIAL_GC ();
1840 NEXT; 1628 NEXT;
1841 } 1629 }
1842 1630
1843 CASE (Bsetcdr): 1631 CASE (Bsetcdr):
1844 { 1632 {
1845 Lisp_Object v1; 1633 Lisp_Object v1;
1846 BEFORE_POTENTIAL_GC ();
1847 v1 = POP; 1634 v1 = POP;
1848 TOP = Fsetcdr (TOP, v1); 1635 TOP = Fsetcdr (TOP, v1);
1849 AFTER_POTENTIAL_GC ();
1850 NEXT; 1636 NEXT;
1851 } 1637 }
1852 1638
@@ -1867,10 +1653,8 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1867 } 1653 }
1868 1654
1869 CASE (Bnconc): 1655 CASE (Bnconc):
1870 BEFORE_POTENTIAL_GC ();
1871 DISCARD (1); 1656 DISCARD (1);
1872 TOP = Fnconc (2, &TOP); 1657 TOP = Fnconc (2, &TOP);
1873 AFTER_POTENTIAL_GC ();
1874 NEXT; 1658 NEXT;
1875 1659
1876 CASE (Bnumberp): 1660 CASE (Bnumberp):
@@ -1887,14 +1671,10 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1887 interpreter. */ 1671 interpreter. */
1888 1672
1889 case Bset_mark: 1673 case Bset_mark:
1890 BEFORE_POTENTIAL_GC ();
1891 error ("set-mark is an obsolete bytecode"); 1674 error ("set-mark is an obsolete bytecode");
1892 AFTER_POTENTIAL_GC ();
1893 break; 1675 break;
1894 case Bscan_buffer: 1676 case Bscan_buffer:
1895 BEFORE_POTENTIAL_GC ();
1896 error ("scan-buffer is an obsolete bytecode"); 1677 error ("scan-buffer is an obsolete bytecode");
1897 AFTER_POTENTIAL_GC ();
1898 break; 1678 break;
1899#endif 1679#endif
1900 1680
diff --git a/src/callproc.c b/src/callproc.c
index 07297820cac..487115d60c3 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -1094,7 +1094,7 @@ add_env (char **env, char **new_env, char *string)
1094 char *p = *ep, *q = string; 1094 char *p = *ep, *q = string;
1095 while (ok) 1095 while (ok)
1096 { 1096 {
1097 if (*q != *p) 1097 if (*p && *q != *p)
1098 break; 1098 break;
1099 if (*q == 0) 1099 if (*q == 0)
1100 /* The string is a lone variable name; keep it for now, we 1100 /* The string is a lone variable name; keep it for now, we
@@ -1317,8 +1317,8 @@ child_setup (int in, int out, int err, char **new_argv, bool set_pgrp,
1317 setpgid (0, 0); 1317 setpgid (0, 0);
1318 tcsetpgrp (0, pid); 1318 tcsetpgrp (0, pid);
1319 1319
1320 execve (new_argv[0], new_argv, env); 1320 int errnum = emacs_exec_file (new_argv[0], new_argv, env);
1321 exec_failed (new_argv[0], errno); 1321 exec_failed (new_argv[0], errnum);
1322 1322
1323#else /* MSDOS */ 1323#else /* MSDOS */
1324 pid = run_msdos_command (new_argv, pwd_var + 4, in, out, err, env); 1324 pid = run_msdos_command (new_argv, pwd_var + 4, in, out, err, env);
@@ -1375,6 +1375,20 @@ getenv_internal (const char *var, ptrdiff_t varlen, char **value,
1375 Vprocess_environment)) 1375 Vprocess_environment))
1376 return *value ? 1 : 0; 1376 return *value ? 1 : 0;
1377 1377
1378 /* On Windows we make some modifications to Emacs' environment
1379 without recording them in Vprocess_environment. */
1380#ifdef WINDOWSNT
1381 {
1382 char* tmpval = getenv (var);
1383 if (tmpval)
1384 {
1385 *value = tmpval;
1386 *valuelen = strlen (tmpval);
1387 return 1;
1388 }
1389 }
1390#endif
1391
1378 /* For DISPLAY try to get the values from the frame or the initial env. */ 1392 /* For DISPLAY try to get the values from the frame or the initial env. */
1379 if (strcmp (var, "DISPLAY") == 0) 1393 if (strcmp (var, "DISPLAY") == 0)
1380 { 1394 {
diff --git a/src/charset.c b/src/charset.c
index 1a135849539..05469aa2650 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -240,7 +240,8 @@ struct charset_map_entries
240static void 240static void
241load_charset_map (struct charset *charset, struct charset_map_entries *entries, int n_entries, int control_flag) 241load_charset_map (struct charset *charset, struct charset_map_entries *entries, int n_entries, int control_flag)
242{ 242{
243 Lisp_Object vec, table IF_LINT (= Qnil); 243 Lisp_Object vec;
244 Lisp_Object table UNINIT;
244 unsigned max_code = CHARSET_MAX_CODE (charset); 245 unsigned max_code = CHARSET_MAX_CODE (charset);
245 bool ascii_compatible_p = charset->ascii_compatible_p; 246 bool ascii_compatible_p = charset->ascii_compatible_p;
246 int min_char, max_char, nonascii_min_char; 247 int min_char, max_char, nonascii_min_char;
@@ -842,9 +843,9 @@ usage: (define-charset-internal ...) */)
842 int nchars; 843 int nchars;
843 844
844 if (nargs != charset_arg_max) 845 if (nargs != charset_arg_max)
845 return Fsignal (Qwrong_number_of_arguments, 846 Fsignal (Qwrong_number_of_arguments,
846 Fcons (intern ("define-charset-internal"), 847 Fcons (intern ("define-charset-internal"),
847 make_number (nargs))); 848 make_number (nargs)));
848 849
849 attrs = Fmake_vector (make_number (charset_attr_max), Qnil); 850 attrs = Fmake_vector (make_number (charset_attr_max), Qnil);
850 851
@@ -1838,12 +1839,12 @@ encode_char (struct charset *charset, int c)
1838} 1839}
1839 1840
1840 1841
1841DEFUN ("decode-char", Fdecode_char, Sdecode_char, 2, 3, 0, 1842DEFUN ("decode-char", Fdecode_char, Sdecode_char, 2, 2, 0,
1842 doc: /* Decode the pair of CHARSET and CODE-POINT into a character. 1843 doc: /* Decode the pair of CHARSET and CODE-POINT into a character.
1843Return nil if CODE-POINT is not valid in CHARSET. 1844Return nil if CODE-POINT is not valid in CHARSET.
1844 1845
1845CODE-POINT may be a cons (HIGHER-16-BIT-VALUE . LOWER-16-BIT-VALUE). */) 1846CODE-POINT may be a cons (HIGHER-16-BIT-VALUE . LOWER-16-BIT-VALUE). */)
1846 (Lisp_Object charset, Lisp_Object code_point, Lisp_Object restriction) 1847 (Lisp_Object charset, Lisp_Object code_point)
1847{ 1848{
1848 int c, id; 1849 int c, id;
1849 unsigned code; 1850 unsigned code;
@@ -1857,10 +1858,10 @@ CODE-POINT may be a cons (HIGHER-16-BIT-VALUE . LOWER-16-BIT-VALUE). */)
1857} 1858}
1858 1859
1859 1860
1860DEFUN ("encode-char", Fencode_char, Sencode_char, 2, 3, 0, 1861DEFUN ("encode-char", Fencode_char, Sencode_char, 2, 2, 0,
1861 doc: /* Encode the character CH into a code-point of CHARSET. 1862 doc: /* Encode the character CH into a code-point of CHARSET.
1862Return nil if CHARSET doesn't include CH. */) 1863Return nil if CHARSET doesn't include CH. */)
1863 (Lisp_Object ch, Lisp_Object charset, Lisp_Object restriction) 1864 (Lisp_Object ch, Lisp_Object charset)
1864{ 1865{
1865 int c, id; 1866 int c, id;
1866 unsigned code; 1867 unsigned code;
diff --git a/src/chartab.c b/src/chartab.c
index 6cf8fea0b6d..fa5a8e41164 100644
--- a/src/chartab.c
+++ b/src/chartab.c
@@ -492,7 +492,7 @@ char_table_set_range (Lisp_Object table, int from, int to, Lisp_Object val)
492 int lim = CHARTAB_IDX (to, 0, 0); 492 int lim = CHARTAB_IDX (to, 0, 0);
493 int i, c; 493 int i, c;
494 494
495 for (i = CHARTAB_IDX (from, 0, 0), c = 0; i <= lim; 495 for (i = CHARTAB_IDX (from, 0, 0), c = i * chartab_chars[0]; i <= lim;
496 i++, c += chartab_chars[0]) 496 i++, c += chartab_chars[0])
497 { 497 {
498 if (c > to) 498 if (c > to)
diff --git a/src/cm.c b/src/cm.c
index 4f94c079315..e135889f17c 100644
--- a/src/cm.c
+++ b/src/cm.c
@@ -321,7 +321,7 @@ cmgoto (struct tty_display_info *tty, int row, int col)
321 llcost, 321 llcost,
322 relcost, 322 relcost,
323 directcost; 323 directcost;
324 int use IF_LINT (= 0); 324 int use UNINIT;
325 char *p; 325 char *p;
326 const char *dcm; 326 const char *dcm;
327 327
diff --git a/src/coding.c b/src/coding.c
index a28fec1efe4..a8ddc817565 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -2365,7 +2365,8 @@ decode_coding_emacs_mule (struct coding_system *coding)
2365 2365
2366 while (1) 2366 while (1)
2367 { 2367 {
2368 int c, id IF_LINT (= 0); 2368 int c;
2369 int id UNINIT;
2369 2370
2370 src_base = src; 2371 src_base = src;
2371 consumed_chars_base = consumed_chars; 2372 consumed_chars_base = consumed_chars;
@@ -2410,7 +2411,7 @@ decode_coding_emacs_mule (struct coding_system *coding)
2410 } 2411 }
2411 else 2412 else
2412 { 2413 {
2413 int nchars IF_LINT (= 0), nbytes IF_LINT (= 0); 2414 int nchars UNINIT, nbytes UNINIT;
2414 /* emacs_mule_char can load a charset map from a file, which 2415 /* emacs_mule_char can load a charset map from a file, which
2415 allocates a large structure and might cause buffer text 2416 allocates a large structure and might cause buffer text
2416 to be relocated as result. Thus, we need to remember the 2417 to be relocated as result. Thus, we need to remember the
@@ -6825,7 +6826,14 @@ decode_eol (struct coding_system *coding)
6825 6826
6826 while (pos_byte < pos_end) 6827 while (pos_byte < pos_end)
6827 { 6828 {
6829 int incr;
6830
6828 p = BYTE_POS_ADDR (pos_byte); 6831 p = BYTE_POS_ADDR (pos_byte);
6832 if (coding->dst_multibyte)
6833 incr = BYTES_BY_CHAR_HEAD (*p);
6834 else
6835 incr = 1;
6836
6829 if (*p == '\r' && p[1] == '\n') 6837 if (*p == '\r' && p[1] == '\n')
6830 { 6838 {
6831 del_range_2 (pos, pos_byte, pos + 1, pos_byte + 1, 0); 6839 del_range_2 (pos, pos_byte, pos + 1, pos_byte + 1, 0);
@@ -6833,10 +6841,7 @@ decode_eol (struct coding_system *coding)
6833 pos_end--; 6841 pos_end--;
6834 } 6842 }
6835 pos++; 6843 pos++;
6836 if (coding->dst_multibyte) 6844 pos_byte += incr;
6837 pos_byte += BYTES_BY_CHAR_HEAD (*p);
6838 else
6839 pos_byte++;
6840 } 6845 }
6841 coding->produced -= n; 6846 coding->produced -= n;
6842 coding->produced_char -= n; 6847 coding->produced_char -= n;
@@ -8565,8 +8570,8 @@ detect_coding_system (const unsigned char *src,
8565 base_category = XINT (CODING_ATTR_CATEGORY (attrs)); 8570 base_category = XINT (CODING_ATTR_CATEGORY (attrs));
8566 if (base_category == coding_category_undecided) 8571 if (base_category == coding_category_undecided)
8567 { 8572 {
8568 enum coding_category category IF_LINT (= 0); 8573 enum coding_category category UNINIT;
8569 struct coding_system *this IF_LINT (= NULL); 8574 struct coding_system *this UNINIT;
8570 int c, i; 8575 int c, i;
8571 bool inhibit_nbd = inhibit_flag (coding.spec.undecided.inhibit_nbd, 8576 bool inhibit_nbd = inhibit_flag (coding.spec.undecided.inhibit_nbd,
8572 inhibit_null_byte_detection); 8577 inhibit_null_byte_detection);
@@ -10541,9 +10546,9 @@ usage: (define-coding-system-internal ...) */)
10541 return Qnil; 10546 return Qnil;
10542 10547
10543 short_args: 10548 short_args:
10544 return Fsignal (Qwrong_number_of_arguments, 10549 Fsignal (Qwrong_number_of_arguments,
10545 Fcons (intern ("define-coding-system-internal"), 10550 Fcons (intern ("define-coding-system-internal"),
10546 make_number (nargs))); 10551 make_number (nargs)));
10547} 10552}
10548 10553
10549 10554
@@ -11302,24 +11307,4 @@ internal character representation. */);
11302#endif 11307#endif
11303 staticpro (&system_eol_type); 11308 staticpro (&system_eol_type);
11304} 11309}
11305
11306char *
11307emacs_strerror (int error_number)
11308{
11309 char *str;
11310
11311 synchronize_system_messages_locale ();
11312 str = strerror (error_number);
11313
11314 if (! NILP (Vlocale_coding_system))
11315 {
11316 Lisp_Object dec = code_convert_string_norecord (build_string (str),
11317 Vlocale_coding_system,
11318 0);
11319 str = SSDATA (dec);
11320 }
11321
11322 return str;
11323}
11324
11325#endif /* emacs */ 11310#endif /* emacs */
diff --git a/src/coding.h b/src/coding.h
index 93ddff0c6bd..426be6277ca 100644
--- a/src/coding.h
+++ b/src/coding.h
@@ -768,8 +768,6 @@ extern Lisp_Object preferred_coding_system (void);
768 768
769#ifdef emacs 769#ifdef emacs
770 770
771extern char *emacs_strerror (int);
772
773/* Coding system to be used to encode text for terminal display when 771/* Coding system to be used to encode text for terminal display when
774 terminal coding system is nil. */ 772 terminal coding system is nil. */
775extern struct coding_system safe_terminal_coding; 773extern struct coding_system safe_terminal_coding;
diff --git a/src/composite.c b/src/composite.c
index 49b00036361..8aa69746595 100644
--- a/src/composite.c
+++ b/src/composite.c
@@ -891,7 +891,6 @@ autocmp_chars (Lisp_Object rule, ptrdiff_t charpos, ptrdiff_t bytepos,
891 if (len <= 0) 891 if (len <= 0)
892 return unbind_to (count, Qnil); 892 return unbind_to (count, Qnil);
893 to = limit = charpos + len; 893 to = limit = charpos + len;
894#ifdef HAVE_WINDOW_SYSTEM
895 if (FRAME_WINDOW_P (f)) 894 if (FRAME_WINDOW_P (f))
896 { 895 {
897 font_object = font_range (charpos, bytepos, &to, win, face, string); 896 font_object = font_range (charpos, bytepos, &to, win, face, string);
@@ -902,7 +901,6 @@ autocmp_chars (Lisp_Object rule, ptrdiff_t charpos, ptrdiff_t bytepos,
902 return unbind_to (count, Qnil); 901 return unbind_to (count, Qnil);
903 } 902 }
904 else 903 else
905#endif /* not HAVE_WINDOW_SYSTEM */
906 font_object = win->frame; 904 font_object = win->frame;
907 lgstring = Fcomposition_get_gstring (pos, make_number (to), font_object, 905 lgstring = Fcomposition_get_gstring (pos, make_number (to), font_object,
908 string); 906 string);
@@ -1308,7 +1306,8 @@ composition_reseat_it (struct composition_it *cmp_it, ptrdiff_t charpos,
1308int 1306int
1309composition_update_it (struct composition_it *cmp_it, ptrdiff_t charpos, ptrdiff_t bytepos, Lisp_Object string) 1307composition_update_it (struct composition_it *cmp_it, ptrdiff_t charpos, ptrdiff_t bytepos, Lisp_Object string)
1310{ 1308{
1311 int i, c IF_LINT (= 0); 1309 int i;
1310 int c UNINIT;
1312 1311
1313 if (cmp_it->ch < 0) 1312 if (cmp_it->ch < 0)
1314 { 1313 {
diff --git a/src/conf_post.h b/src/conf_post.h
index 762aa7727fd..865d0183a57 100644
--- a/src/conf_post.h
+++ b/src/conf_post.h
@@ -34,6 +34,18 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
34 34
35#include <stdbool.h> 35#include <stdbool.h>
36 36
37/* GNUC_PREREQ (V, W, X) is true if this is GNU C version V.W.X or later.
38 It can be used in a preprocessor expression. */
39#ifndef __GNUC_MINOR__
40# define GNUC_PREREQ(v, w, x) false
41#elif ! defined __GNUC_PATCHLEVEL__
42# define GNUC_PREREQ(v, w, x) \
43 ((v) < __GNUC__ + ((w) < __GNUC_MINOR__ + ((x) == 0))
44#else
45# define GNUC_PREREQ(v, w, x) \
46 ((v) < __GNUC__ + ((w) < __GNUC_MINOR__ + ((x) <= __GNUC_PATCHLEVEL__)))
47#endif
48
37/* The type of bool bitfields. Needed to compile Objective-C with 49/* The type of bool bitfields. Needed to compile Objective-C with
38 standard GCC. It was also needed to port to pre-C99 compilers, 50 standard GCC. It was also needed to port to pre-C99 compilers,
39 although we don't care about that any more. */ 51 although we don't care about that any more. */
@@ -55,13 +67,11 @@ typedef bool bool_bf;
55 on arguments like alloc_size that are handled in this simulation. */ 67 on arguments like alloc_size that are handled in this simulation. */
56#ifndef __has_attribute 68#ifndef __has_attribute
57# define __has_attribute(a) __has_attribute_##a 69# define __has_attribute(a) __has_attribute_##a
58# define __has_attribute_alloc_size (4 < __GNUC__ + (3 <= __GNUC_MINOR__)) 70# define __has_attribute_alloc_size GNUC_PREREQ (4, 3, 0)
59# define __has_attribute_cleanup (3 < __GNUC__ + (4 <= __GNUC_MINOR__)) 71# define __has_attribute_cleanup GNUC_PREREQ (3, 4, 0)
60# define __has_attribute_externally_visible \ 72# define __has_attribute_externally_visible GNUC_PREREQ (4, 1, 0)
61 (4 < __GNUC__ + (1 <= __GNUC_MINOR__))
62# define __has_attribute_no_address_safety_analysis false 73# define __has_attribute_no_address_safety_analysis false
63# define __has_attribute_no_sanitize_address \ 74# define __has_attribute_no_sanitize_address GNUC_PREREQ (4, 8, 0)
64 (4 < __GNUC__ + (8 <= __GNUC_MINOR__))
65#endif 75#endif
66 76
67/* Simulate __has_builtin on compilers that lack it. It is used only 77/* Simulate __has_builtin on compilers that lack it. It is used only
@@ -69,8 +79,7 @@ typedef bool bool_bf;
69 simulation. */ 79 simulation. */
70#ifndef __has_builtin 80#ifndef __has_builtin
71# define __has_builtin(a) __has_builtin_##a 81# define __has_builtin(a) __has_builtin_##a
72# define __has_builtin___builtin_assume_aligned \ 82# define __has_builtin___builtin_assume_aligned GNUC_PREREQ (4, 7, 0)
73 (4 < __GNUC__ + (7 <= __GNUC_MINOR__))
74#endif 83#endif
75 84
76/* Simulate __has_feature on compilers that lack it. It is used only 85/* Simulate __has_feature on compilers that lack it. It is used only
@@ -88,7 +97,7 @@ typedef bool bool_bf;
88 97
89/* Yield PTR, which must be aligned to ALIGNMENT. */ 98/* Yield PTR, which must be aligned to ALIGNMENT. */
90#if ! __has_builtin (__builtin_assume_aligned) 99#if ! __has_builtin (__builtin_assume_aligned)
91# define __builtin_assume_aligned(ptr, alignment, ...) ((void *) (ptr)) 100# define __builtin_assume_aligned(ptr, ...) ((void *) (ptr))
92#endif 101#endif
93 102
94#ifdef DARWIN_OS 103#ifdef DARWIN_OS
@@ -203,7 +212,7 @@ You lose; /* Emacs for DOS must be compiled with DJGPP */
203extern void _DebPrint (const char *fmt, ...); 212extern void _DebPrint (const char *fmt, ...);
204# define DebPrint(stuff) _DebPrint stuff 213# define DebPrint(stuff) _DebPrint stuff
205# else 214# else
206# define DebPrint(stuff) 215# define DebPrint(stuff) ((void) 0)
207# endif 216# endif
208#endif 217#endif
209 218
@@ -245,19 +254,21 @@ extern int emacs_setenv_TZ (char const *);
245#define EXTERNALLY_VISIBLE 254#define EXTERNALLY_VISIBLE
246#endif 255#endif
247 256
248#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) 257#if GNUC_PREREQ (2, 7, 0)
249# define ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) 258# define ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
250#else 259#else
251# define ATTRIBUTE_FORMAT(spec) /* empty */ 260# define ATTRIBUTE_FORMAT(spec) /* empty */
252#endif 261#endif
253 262
254#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) 263#if GNUC_PREREQ (4, 4, 0) && defined __GLIBC_MINOR__
255# define ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \ 264# define PRINTF_ARCHETYPE __gnu_printf__
256 ATTRIBUTE_FORMAT ((__gnu_printf__, formatstring_parameter, first_argument)) 265#elif GNUC_PREREQ (4, 4, 0) && defined __MINGW32__
266# define PRINTF_ARCHETYPE __ms_printf__
257#else 267#else
258# define ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \ 268# define PRINTF_ARCHETYPE __printf__
259 ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument))
260#endif 269#endif
270#define ATTRIBUTE_FORMAT_PRINTF(string_index, first_to_check) \
271 ATTRIBUTE_FORMAT ((PRINTF_ARCHETYPE, string_index, first_to_check))
261 272
262#define ATTRIBUTE_CONST _GL_ATTRIBUTE_CONST 273#define ATTRIBUTE_CONST _GL_ATTRIBUTE_CONST
263#define ATTRIBUTE_UNUSED _GL_UNUSED 274#define ATTRIBUTE_UNUSED _GL_UNUSED
@@ -281,7 +292,7 @@ extern int emacs_setenv_TZ (char const *);
281 no_sanitize_address attribute. This bug is fixed in GCC 4.9.0 and 292 no_sanitize_address attribute. This bug is fixed in GCC 4.9.0 and
282 clang 3.4. */ 293 clang 3.4. */
283#if (! ADDRESS_SANITIZER \ 294#if (! ADDRESS_SANITIZER \
284 || ((4 < __GNUC__ + (9 <= __GNUC_MINOR__)) \ 295 || (GNUC_PREREQ (4, 9, 0) \
285 || 3 < __clang_major__ + (4 <= __clang_minor__))) 296 || 3 < __clang_major__ + (4 <= __clang_minor__)))
286# define ADDRESS_SANITIZER_WORKAROUND /* No workaround needed. */ 297# define ADDRESS_SANITIZER_WORKAROUND /* No workaround needed. */
287#else 298#else
@@ -357,11 +368,12 @@ extern int emacs_setenv_TZ (char const *);
357# define FLEXIBLE_ARRAY_MEMBER 368# define FLEXIBLE_ARRAY_MEMBER
358#endif 369#endif
359 370
360/* Use CODE only if lint checking is in effect. */ 371/* 'int x UNINIT;' is equivalent to 'int x;', except it cajoles GCC
372 into not warning incorrectly about use of an uninitialized variable. */
361#if defined GCC_LINT || defined lint 373#if defined GCC_LINT || defined lint
362# define IF_LINT(Code) Code 374# define UNINIT = {0,}
363#else 375#else
364# define IF_LINT(Code) /* empty */ 376# define UNINIT /* empty */
365#endif 377#endif
366 378
367/* conf_post.h ends here */ 379/* conf_post.h ends here */
diff --git a/src/dbusbind.c b/src/dbusbind.c
index 618176dd452..7a94c81eeab 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -943,7 +943,7 @@ xd_get_connection_references (DBusConnection *connection)
943static DBusConnection* 943static DBusConnection*
944xd_lisp_dbus_to_dbus (Lisp_Object bus) 944xd_lisp_dbus_to_dbus (Lisp_Object bus)
945{ 945{
946 return (DBusConnection *) (intptr_t) XFASTINT (bus); 946 return (DBusConnection *) XSAVE_POINTER (bus, 0);
947} 947}
948 948
949/* Return D-Bus connection address. BUS is either a Lisp symbol, 949/* Return D-Bus connection address. BUS is either a Lisp symbol,
@@ -1186,7 +1186,7 @@ this connection to those buses. */)
1186 XD_SIGNAL1 (build_string ("Cannot add watch functions")); 1186 XD_SIGNAL1 (build_string ("Cannot add watch functions"));
1187 1187
1188 /* Add bus to list of registered buses. */ 1188 /* Add bus to list of registered buses. */
1189 XSETFASTINT (val, (intptr_t) connection); 1189 val = make_save_ptr (connection);
1190 xd_registered_buses = Fcons (Fcons (bus, val), xd_registered_buses); 1190 xd_registered_buses = Fcons (Fcons (bus, val), xd_registered_buses);
1191 1191
1192 /* Cleanup. */ 1192 /* Cleanup. */
diff --git a/src/dispextern.h b/src/dispextern.h
index e83b7c7fc83..1325ff9da28 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -82,6 +82,7 @@ typedef XImagePtr XImagePtr_or_DC;
82 82
83#ifdef HAVE_WINDOW_SYSTEM 83#ifdef HAVE_WINDOW_SYSTEM
84# include <time.h> 84# include <time.h>
85# include "fontset.h"
85#endif 86#endif
86 87
87#ifndef HAVE_WINDOW_SYSTEM 88#ifndef HAVE_WINDOW_SYSTEM
@@ -1811,7 +1812,7 @@ struct face_cache
1811 bool_bf menu_face_changed_p : 1; 1812 bool_bf menu_face_changed_p : 1;
1812}; 1813};
1813 1814
1814/* Return a pointer to the cached face with ID on frame F. */ 1815/* Return a non-null pointer to the cached face with ID on frame F. */
1815 1816
1816#define FACE_FROM_ID(F, ID) \ 1817#define FACE_FROM_ID(F, ID) \
1817 (eassert (UNSIGNED_CMP (ID, <, FRAME_FACE_CACHE (F)->used)), \ 1818 (eassert (UNSIGNED_CMP (ID, <, FRAME_FACE_CACHE (F)->used)), \
@@ -1820,33 +1821,37 @@ struct face_cache
1820/* Return a pointer to the face with ID on frame F, or null if such a 1821/* Return a pointer to the face with ID on frame F, or null if such a
1821 face doesn't exist. */ 1822 face doesn't exist. */
1822 1823
1823#define FACE_OPT_FROM_ID(F, ID) \ 1824#define FACE_FROM_ID_OR_NULL(F, ID) \
1824 (UNSIGNED_CMP (ID, <, FRAME_FACE_CACHE (F)->used) \ 1825 (UNSIGNED_CMP (ID, <, FRAME_FACE_CACHE (F)->used) \
1825 ? FACE_FROM_ID (F, ID) \ 1826 ? FRAME_FACE_CACHE (F)->faces_by_id[ID] \
1826 : NULL) 1827 : NULL)
1827 1828
1829/* True if FACE is suitable for displaying ASCII characters. */
1830INLINE bool
1831FACE_SUITABLE_FOR_ASCII_CHAR_P (struct face *face)
1832{
1828#ifdef HAVE_WINDOW_SYSTEM 1833#ifdef HAVE_WINDOW_SYSTEM
1829 1834 return face == face->ascii_face;
1830/* Non-zero if FACE is suitable for displaying character CHAR. */ 1835#else
1831 1836 return true;
1832#define FACE_SUITABLE_FOR_ASCII_CHAR_P(FACE, CHAR) \ 1837#endif
1833 ((FACE) == (FACE)->ascii_face) 1838}
1834 1839
1835/* Return the id of the realized face on frame F that is like the face 1840/* Return the id of the realized face on frame F that is like the face
1836 FACE, but is suitable for displaying character CHAR at buffer or 1841 FACE, but is suitable for displaying character CHARACTER at buffer or
1837 string position POS. OBJECT is the string object, or nil for 1842 string position POS. OBJECT is the string object, or nil for
1838 buffer. This macro is only meaningful for multibyte character 1843 buffer. This macro is only meaningful for multibyte character
1839 CHAR. */ 1844 CHAR. */
1840 1845INLINE int
1841#define FACE_FOR_CHAR(F, FACE, CHAR, POS, OBJECT) \ 1846FACE_FOR_CHAR (struct frame *f, struct face *face, int character,
1842 face_for_char ((F), (FACE), (CHAR), (POS), (OBJECT)) 1847 ptrdiff_t pos, Lisp_Object object)
1843 1848{
1844#else /* not HAVE_WINDOW_SYSTEM */ 1849#ifdef HAVE_WINDOW_SYSTEM
1845 1850 return face_for_char (f, face, character, pos, object);
1846#define FACE_SUITABLE_FOR_ASCII_CHAR_P(FACE, CHAR) true 1851#else
1847#define FACE_FOR_CHAR(F, FACE, CHAR, POS, OBJECT) ((FACE)->id) 1852 return face->id;
1848 1853#endif
1849#endif /* not HAVE_WINDOW_SYSTEM */ 1854}
1850 1855
1851/* Return true if G contains a valid character code. */ 1856/* Return true if G contains a valid character code. */
1852INLINE bool 1857INLINE bool
@@ -3088,7 +3093,7 @@ struct image_cache
3088}; 3093};
3089 3094
3090 3095
3091/* A pointer to the image with id ID on frame F. */ 3096/* A non-null pointer to the image with id ID on frame F. */
3092 3097
3093#define IMAGE_FROM_ID(F, ID) \ 3098#define IMAGE_FROM_ID(F, ID) \
3094 (eassert (UNSIGNED_CMP (ID, <, FRAME_IMAGE_CACHE (F)->used)), \ 3099 (eassert (UNSIGNED_CMP (ID, <, FRAME_IMAGE_CACHE (F)->used)), \
@@ -3099,7 +3104,7 @@ struct image_cache
3099 3104
3100#define IMAGE_OPT_FROM_ID(F, ID) \ 3105#define IMAGE_OPT_FROM_ID(F, ID) \
3101 (UNSIGNED_CMP (ID, <, FRAME_IMAGE_CACHE (F)->used) \ 3106 (UNSIGNED_CMP (ID, <, FRAME_IMAGE_CACHE (F)->used) \
3102 ? IMAGE_FROM_ID (F, ID) \ 3107 ? FRAME_IMAGE_CACHE (F)->images[ID] \
3103 : NULL) 3108 : NULL)
3104 3109
3105/* Size of bucket vector of image caches. Should be prime. */ 3110/* Size of bucket vector of image caches. Should be prime. */
diff --git a/src/doc.c b/src/doc.c
index 017dd173d0a..6ffdad10f03 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -339,16 +339,7 @@ string is passed through `substitute-command-keys'. */)
339 if (CONSP (fun) && EQ (XCAR (fun), Qmacro)) 339 if (CONSP (fun) && EQ (XCAR (fun), Qmacro))
340 fun = XCDR (fun); 340 fun = XCDR (fun);
341 if (SUBRP (fun)) 341 if (SUBRP (fun))
342 { 342 doc = make_number (XSUBR (fun)->doc);
343 if (XSUBR (fun)->doc == 0)
344 return Qnil;
345 /* FIXME: This is not portable, as it assumes that string
346 pointers have the top bit clear. */
347 else if ((intptr_t) XSUBR (fun)->doc >= 0)
348 doc = build_string (XSUBR (fun)->doc);
349 else
350 doc = make_number ((intptr_t) XSUBR (fun)->doc);
351 }
352 else if (COMPILEDP (fun)) 343 else if (COMPILEDP (fun))
353 { 344 {
354 if ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) <= COMPILED_DOC_STRING) 345 if ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) <= COMPILED_DOC_STRING)
@@ -473,7 +464,7 @@ aren't strings. */)
473/* Scanning the DOC files and placing docstring offsets into functions. */ 464/* Scanning the DOC files and placing docstring offsets into functions. */
474 465
475static void 466static void
476store_function_docstring (Lisp_Object obj, ptrdiff_t offset) 467store_function_docstring (Lisp_Object obj, EMACS_INT offset)
477{ 468{
478 /* Don't use indirect_function here, or defaliases will apply their 469 /* Don't use indirect_function here, or defaliases will apply their
479 docstrings to the base functions (Bug#2603). */ 470 docstrings to the base functions (Bug#2603). */
@@ -481,15 +472,10 @@ store_function_docstring (Lisp_Object obj, ptrdiff_t offset)
481 472
482 /* The type determines where the docstring is stored. */ 473 /* The type determines where the docstring is stored. */
483 474
484 /* Lisp_Subrs have a slot for it. */
485 if (SUBRP (fun))
486 {
487 intptr_t negative_offset = - offset;
488 XSUBR (fun)->doc = (char *) negative_offset;
489 }
490
491 /* If it's a lisp form, stick it in the form. */ 475 /* If it's a lisp form, stick it in the form. */
492 else if (CONSP (fun)) 476 if (CONSP (fun) && EQ (XCAR (fun), Qmacro))
477 fun = XCDR (fun);
478 if (CONSP (fun))
493 { 479 {
494 Lisp_Object tem; 480 Lisp_Object tem;
495 481
@@ -503,10 +489,12 @@ store_function_docstring (Lisp_Object obj, ptrdiff_t offset)
503 correctness is quite delicate. */ 489 correctness is quite delicate. */
504 XSETCAR (tem, make_number (offset)); 490 XSETCAR (tem, make_number (offset));
505 } 491 }
506 else if (EQ (tem, Qmacro))
507 store_function_docstring (XCDR (fun), offset);
508 } 492 }
509 493
494 /* Lisp_Subrs have a slot for it. */
495 else if (SUBRP (fun))
496 XSUBR (fun)->doc = offset;
497
510 /* Bytecode objects sometimes have slots for it. */ 498 /* Bytecode objects sometimes have slots for it. */
511 else if (COMPILEDP (fun)) 499 else if (COMPILEDP (fun))
512 { 500 {
diff --git a/src/editfns.c b/src/editfns.c
index 6b0996d65eb..61b2a871b73 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -146,6 +146,9 @@ xtzfree (timezone_t tz)
146static timezone_t 146static timezone_t
147tzlookup (Lisp_Object zone, bool settz) 147tzlookup (Lisp_Object zone, bool settz)
148{ 148{
149 static char const tzbuf_format[] = "<%+.*"pI"d>%s%"pI"d:%02d:%02d";
150 char const *trailing_tzbuf_format = tzbuf_format + sizeof "<%+.*"pI"d" - 1;
151 char tzbuf[sizeof tzbuf_format + 2 * INT_STRLEN_BOUND (EMACS_INT)];
149 char const *zone_string; 152 char const *zone_string;
150 timezone_t new_tz; 153 timezone_t new_tz;
151 154
@@ -158,9 +161,6 @@ tzlookup (Lisp_Object zone, bool settz)
158 } 161 }
159 else 162 else
160 { 163 {
161 static char const tzbuf_format[] = "<%+.*"pI"d>%s%"pI"d:%02d:%02d";
162 char const *trailing_tzbuf_format = tzbuf_format + sizeof "<%+.*"pI"d" - 1;
163 char tzbuf[sizeof tzbuf_format + 2 * INT_STRLEN_BOUND (EMACS_INT)];
164 bool plain_integer = INTEGERP (zone); 164 bool plain_integer = INTEGERP (zone);
165 165
166 if (EQ (zone, Qwall)) 166 if (EQ (zone, Qwall))
@@ -216,6 +216,7 @@ tzlookup (Lisp_Object zone, bool settz)
216 { 216 {
217 block_input (); 217 block_input ();
218 emacs_setenv_TZ (zone_string); 218 emacs_setenv_TZ (zone_string);
219 tzset ();
219 timezone_t old_tz = local_tz; 220 timezone_t old_tz = local_tz;
220 local_tz = new_tz; 221 local_tz = new_tz;
221 tzfree (old_tz); 222 tzfree (old_tz);
@@ -2176,17 +2177,16 @@ usage: (decode-time &optional TIME ZONE) */)
2176} 2177}
2177 2178
2178/* Return OBJ - OFFSET, checking that OBJ is a valid fixnum and that 2179/* Return OBJ - OFFSET, checking that OBJ is a valid fixnum and that
2179 the result is representable as an int. Assume OFFSET is small and 2180 the result is representable as an int. */
2180 nonnegative. */
2181static int 2181static int
2182check_tm_member (Lisp_Object obj, int offset) 2182check_tm_member (Lisp_Object obj, int offset)
2183{ 2183{
2184 EMACS_INT n;
2185 CHECK_NUMBER (obj); 2184 CHECK_NUMBER (obj);
2186 n = XINT (obj); 2185 EMACS_INT n = XINT (obj);
2187 if (! (INT_MIN + offset <= n && n - offset <= INT_MAX)) 2186 int result;
2187 if (INT_SUBTRACT_WRAPV (n, offset, &result))
2188 time_overflow (); 2188 time_overflow ();
2189 return n - offset; 2189 return result;
2190} 2190}
2191 2191
2192DEFUN ("encode-time", Fencode_time, Sencode_time, 6, MANY, 0, 2192DEFUN ("encode-time", Fencode_time, Sencode_time, 6, MANY, 0,
@@ -2459,23 +2459,24 @@ emacs_setenv_TZ (const char *tzstring)
2459 tzval[tzeqlen] = 0; 2459 tzval[tzeqlen] = 0;
2460 } 2460 }
2461 2461
2462 if (new_tzvalbuf 2462
2463#ifdef WINDOWSNT 2463#ifndef WINDOWSNT
2464 /* MS-Windows implementation of 'putenv' copies the argument 2464 /* Modifying *TZVAL merely requires calling tzset (which is the
2465 string into a block it allocates, so modifying tzval string 2465 caller's responsibility). However, modifying TZVAL requires
2466 does not change the environment. OTOH, the other threads run 2466 calling putenv; although this is not thread-safe, in practice this
2467 by Emacs on MS-Windows never call 'xputenv' or 'putenv' or 2467 runs only on startup when there is only one thread. */
2468 'unsetenv', so the original cause for the dicey in-place 2468 bool need_putenv = new_tzvalbuf;
2469 modification technique doesn't exist there in the first 2469#else
2470 place. */ 2470 /* MS-Windows 'putenv' copies the argument string into a block it
2471 || 1 2471 allocates, so modifying *TZVAL will not change the environment.
2472 However, the other threads run by Emacs on MS-Windows never call
2473 'xputenv' or 'putenv' or 'unsetenv', so the original cause for the
2474 dicey in-place modification technique doesn't exist there in the
2475 first place. */
2476 bool need_putenv = true;
2472#endif 2477#endif
2473 ) 2478 if (need_putenv)
2474 { 2479 xputenv (tzval);
2475 /* Although this is not thread-safe, in practice this runs only
2476 on startup when there is only one thread. */
2477 xputenv (tzval);
2478 }
2479 2480
2480 return 0; 2481 return 0;
2481} 2482}
@@ -3363,7 +3364,7 @@ It returns the number of characters changed. */)
3363 ptrdiff_t size; /* Size of translate table. */ 3364 ptrdiff_t size; /* Size of translate table. */
3364 ptrdiff_t pos, pos_byte, end_pos; 3365 ptrdiff_t pos, pos_byte, end_pos;
3365 bool multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters)); 3366 bool multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters));
3366 bool string_multibyte IF_LINT (= 0); 3367 bool string_multibyte UNINIT;
3367 3368
3368 validate_region (&start, &end); 3369 validate_region (&start, &end);
3369 if (CHAR_TABLE_P (table)) 3370 if (CHAR_TABLE_P (table))
@@ -3884,6 +3885,9 @@ precision specifier says how many decimal places to show; if zero, the
3884decimal point itself is omitted. For %s and %S, the precision 3885decimal point itself is omitted. For %s and %S, the precision
3885specifier truncates the string to the given width. 3886specifier truncates the string to the given width.
3886 3887
3888Text properties, if any, are copied from the format-string to the
3889produced text.
3890
3887usage: (format STRING &rest OBJECTS) */) 3891usage: (format STRING &rest OBJECTS) */)
3888 (ptrdiff_t nargs, Lisp_Object *args) 3892 (ptrdiff_t nargs, Lisp_Object *args)
3889{ 3893{
@@ -3918,7 +3922,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
3918 ptrdiff_t bufsize = sizeof initial_buffer; 3922 ptrdiff_t bufsize = sizeof initial_buffer;
3919 ptrdiff_t max_bufsize = STRING_BYTES_BOUND + 1; 3923 ptrdiff_t max_bufsize = STRING_BYTES_BOUND + 1;
3920 char *p; 3924 char *p;
3921 ptrdiff_t buf_save_value_index IF_LINT (= 0); 3925 ptrdiff_t buf_save_value_index UNINIT;
3922 char *format, *end; 3926 char *format, *end;
3923 ptrdiff_t nchars; 3927 ptrdiff_t nchars;
3924 /* When we make a multibyte string, we must pay attention to the 3928 /* When we make a multibyte string, we must pay attention to the
@@ -4177,6 +4181,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
4177 p += padding; 4181 p += padding;
4178 nchars += padding; 4182 nchars += padding;
4179 } 4183 }
4184 info[n].start = nchars;
4180 4185
4181 if (p > buf 4186 if (p > buf
4182 && multibyte 4187 && multibyte
@@ -4189,9 +4194,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
4189 nbytes, 4194 nbytes,
4190 STRING_MULTIBYTE (args[n]), multibyte); 4195 STRING_MULTIBYTE (args[n]), multibyte);
4191 4196
4192 info[n].start = nchars;
4193 nchars += nchars_string; 4197 nchars += nchars_string;
4194 info[n].end = nchars;
4195 4198
4196 if (minus_flag) 4199 if (minus_flag)
4197 { 4200 {
@@ -4199,6 +4202,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
4199 p += padding; 4202 p += padding;
4200 nchars += padding; 4203 nchars += padding;
4201 } 4204 }
4205 info[n].end = nchars;
4202 4206
4203 /* If this argument has text properties, record where 4207 /* If this argument has text properties, record where
4204 in the result string it appears. */ 4208 in the result string it appears. */
@@ -4416,6 +4420,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
4416 exponent_bytes = src + sprintf_bytes - e; 4420 exponent_bytes = src + sprintf_bytes - e;
4417 } 4421 }
4418 4422
4423 info[n].start = nchars;
4419 if (! minus_flag) 4424 if (! minus_flag)
4420 { 4425 {
4421 memset (p, ' ', padding); 4426 memset (p, ' ', padding);
@@ -4438,9 +4443,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
4438 memcpy (p, src, exponent_bytes); 4443 memcpy (p, src, exponent_bytes);
4439 p += exponent_bytes; 4444 p += exponent_bytes;
4440 4445
4441 info[n].start = nchars;
4442 nchars += leading_zeros + sprintf_bytes + trailing_zeros; 4446 nchars += leading_zeros + sprintf_bytes + trailing_zeros;
4443 info[n].end = nchars;
4444 4447
4445 if (minus_flag) 4448 if (minus_flag)
4446 { 4449 {
@@ -4448,6 +4451,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
4448 p += padding; 4451 p += padding;
4449 nchars += padding; 4452 nchars += padding;
4450 } 4453 }
4454 info[n].end = nchars;
4451 4455
4452 continue; 4456 continue;
4453 } 4457 }
@@ -4627,7 +4631,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
4627 len = make_number (SCHARS (args[i])); 4631 len = make_number (SCHARS (args[i]));
4628 Lisp_Object new_len = make_number (info[i].end - info[i].start); 4632 Lisp_Object new_len = make_number (info[i].end - info[i].start);
4629 props = text_property_list (args[i], make_number (0), len, Qnil); 4633 props = text_property_list (args[i], make_number (0), len, Qnil);
4630 props = extend_property_ranges (props, new_len); 4634 props = extend_property_ranges (props, len, new_len);
4631 /* If successive arguments have properties, be sure that 4635 /* If successive arguments have properties, be sure that
4632 the value of `composition' property be the copy. */ 4636 the value of `composition' property be the copy. */
4633 if (1 < i && info[i - 1].end) 4637 if (1 < i && info[i - 1].end)
@@ -5054,6 +5058,14 @@ Transposing beyond buffer boundaries is an error. */)
5054 start2_byte, start2_byte + len2_byte); 5058 start2_byte, start2_byte + len2_byte);
5055 fix_start_end_in_overlays (start1, end2); 5059 fix_start_end_in_overlays (start1, end2);
5056 } 5060 }
5061 else
5062 {
5063 /* The character positions of the markers remain intact, but we
5064 still need to update their byte positions, because the
5065 transposed regions might include multibyte sequences which
5066 make some original byte positions of the markers invalid. */
5067 adjust_markers_bytepos (start1, start1_byte, end2, end2_byte, 0);
5068 }
5057 5069
5058 signal_after_change (start1, end2 - start1, end2 - start1); 5070 signal_after_change (start1, end2 - start1, end2 - start1);
5059 return Qnil; 5071 return Qnil;
diff --git a/src/emacs.c b/src/emacs.c
index b8ba86f7356..53bcc9879a9 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -66,7 +66,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
66#include TERM_HEADER 66#include TERM_HEADER
67#endif /* HAVE_WINDOW_SYSTEM */ 67#endif /* HAVE_WINDOW_SYSTEM */
68 68
69#include "coding.h"
70#include "intervals.h" 69#include "intervals.h"
71#include "character.h" 70#include "character.h"
72#include "buffer.h" 71#include "buffer.h"
@@ -113,10 +112,6 @@ extern void moncontrol (int mode);
113#include <sys/resource.h> 112#include <sys/resource.h>
114#endif 113#endif
115 114
116#ifdef HAVE_PERSONALITY_LINUX32
117#include <sys/personality.h>
118#endif
119
120static const char emacs_version[] = PACKAGE_VERSION; 115static const char emacs_version[] = PACKAGE_VERSION;
121static const char emacs_copyright[] = COPYRIGHT; 116static const char emacs_copyright[] = COPYRIGHT;
122static const char emacs_bugreport[] = PACKAGE_BUGREPORT; 117static const char emacs_bugreport[] = PACKAGE_BUGREPORT;
@@ -686,6 +681,30 @@ main (int argc, char **argv)
686 681
687 stack_base = &dummy; 682 stack_base = &dummy;
688 683
684 dumping = !initialized && (strcmp (argv[argc - 1], "dump") == 0
685 || strcmp (argv[argc - 1], "bootstrap") == 0);
686
687 /* True if address randomization interferes with memory allocaiton. */
688# ifdef __PPC64__
689 bool disable_aslr = true;
690# else
691 bool disable_aslr = dumping;
692# endif
693
694 if (disable_aslr && disable_address_randomization ())
695 {
696 /* Set this so the personality will be reverted before execs
697 after this one. */
698 xputenv ("EMACS_HEAP_EXEC=true");
699
700 /* Address randomization was enabled, but is now disabled.
701 Re-execute Emacs to get a clean slate. */
702 execvp (argv[0], argv);
703
704 /* If the exec fails, warn and then try anyway. */
705 perror (argv[0]);
706 }
707
689#ifndef CANNOT_DUMP 708#ifndef CANNOT_DUMP
690 might_dump = !initialized; 709 might_dump = !initialized;
691#endif 710#endif
@@ -794,28 +813,6 @@ main (int argc, char **argv)
794 } 813 }
795 } 814 }
796 815
797 dumping = !initialized && (strcmp (argv[argc - 1], "dump") == 0
798 || strcmp (argv[argc - 1], "bootstrap") == 0);
799
800#ifdef HAVE_PERSONALITY_LINUX32
801 if (dumping && ! getenv ("EMACS_HEAP_EXEC"))
802 {
803 /* Set this so we only do this once. */
804 xputenv ("EMACS_HEAP_EXEC=true");
805
806 /* A flag to turn off address randomization which is introduced
807 in linux kernel shipped with fedora core 4 */
808#define ADD_NO_RANDOMIZE 0x0040000
809 personality (PER_LINUX32 | ADD_NO_RANDOMIZE);
810#undef ADD_NO_RANDOMIZE
811
812 execvp (argv[0], argv);
813
814 /* If the exec fails, try to dump anyway. */
815 emacs_perror (argv[0]);
816 }
817#endif /* HAVE_PERSONALITY_LINUX32 */
818
819#if defined (HAVE_SETRLIMIT) && defined (RLIMIT_STACK) && !defined (CYGWIN) 816#if defined (HAVE_SETRLIMIT) && defined (RLIMIT_STACK) && !defined (CYGWIN)
820 /* Extend the stack space available. Don't do that if dumping, 817 /* Extend the stack space available. Don't do that if dumping,
821 since some systems (e.g. DJGPP) might define a smaller stack 818 since some systems (e.g. DJGPP) might define a smaller stack
@@ -1352,16 +1349,6 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1352 globals_of_gfilenotify (); 1349 globals_of_gfilenotify ();
1353#endif 1350#endif
1354 1351
1355#ifdef WINDOWSNT
1356 globals_of_w32 ();
1357#ifdef HAVE_W32NOTIFY
1358 globals_of_w32notify ();
1359#endif
1360 /* Initialize environment from registry settings. */
1361 init_environment (argv);
1362 init_ntproc (dumping); /* must precede init_editfns. */
1363#endif
1364
1365#ifdef HAVE_NS 1352#ifdef HAVE_NS
1366 /* Initialize the locale from user defaults. */ 1353 /* Initialize the locale from user defaults. */
1367 ns_init_locale (); 1354 ns_init_locale ();
@@ -1378,6 +1365,20 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1378 if (! dumping) 1365 if (! dumping)
1379 set_initial_environment (); 1366 set_initial_environment ();
1380 1367
1368#ifdef WINDOWSNT
1369 globals_of_w32 ();
1370#ifdef HAVE_W32NOTIFY
1371 globals_of_w32notify ();
1372#endif
1373 /* Initialize environment from registry settings. Make sure to do
1374 this only after calling set_initial_environment so that
1375 Vinitial_environment and Vprocess_environment will contain only
1376 variables from the parent process without modifications from
1377 Emacs. */
1378 init_environment (argv);
1379 init_ntproc (dumping); /* must precede init_editfns. */
1380#endif
1381
1381 /* AIX crashes are reported in system versions 3.2.3 and 3.2.4 1382 /* AIX crashes are reported in system versions 3.2.3 and 3.2.4
1382 if this is not done. Do it after set_global_environment so that we 1383 if this is not done. Do it after set_global_environment so that we
1383 don't pollute Vglobal_environment. */ 1384 don't pollute Vglobal_environment. */
@@ -2226,6 +2227,15 @@ synchronize_system_messages_locale (void)
2226#endif 2227#endif
2227} 2228}
2228#endif /* HAVE_SETLOCALE */ 2229#endif /* HAVE_SETLOCALE */
2230
2231/* Return a diagnostic string for ERROR_NUMBER, in the wording
2232 and encoding appropriate for the current locale. */
2233char *
2234emacs_strerror (int error_number)
2235{
2236 synchronize_system_messages_locale ();
2237 return strerror (error_number);
2238}
2229 2239
2230 2240
2231Lisp_Object 2241Lisp_Object
diff --git a/src/emacsgtkfixed.c b/src/emacsgtkfixed.c
index ca0bbfbb866..c04adf28b36 100644
--- a/src/emacsgtkfixed.c
+++ b/src/emacsgtkfixed.c
@@ -27,7 +27,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
27#include "emacsgtkfixed.h" 27#include "emacsgtkfixed.h"
28 28
29/* Silence a bogus diagnostic; see GNOME bug 683906. */ 29/* Silence a bogus diagnostic; see GNOME bug 683906. */
30#if 4 < __GNUC__ + (7 <= __GNUC_MINOR__) && ! GLIB_CHECK_VERSION (2, 35, 7) 30#if GNUC_PREREQ (4, 7, 0) && ! GLIB_CHECK_VERSION (2, 35, 7)
31# pragma GCC diagnostic push 31# pragma GCC diagnostic push
32# pragma GCC diagnostic ignored "-Wunused-local-typedefs" 32# pragma GCC diagnostic ignored "-Wunused-local-typedefs"
33#endif 33#endif
diff --git a/src/eval.c b/src/eval.c
index 72facd5db64..33b82f74b64 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1431,6 +1431,7 @@ push_handler_nosignal (Lisp_Object tag_ch_val, enum handlertype handlertype)
1431} 1431}
1432 1432
1433 1433
1434static Lisp_Object signal_or_quit (Lisp_Object, Lisp_Object, bool);
1434static Lisp_Object find_handler_clause (Lisp_Object, Lisp_Object); 1435static Lisp_Object find_handler_clause (Lisp_Object, Lisp_Object);
1435static bool maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig, 1436static bool maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig,
1436 Lisp_Object data); 1437 Lisp_Object data);
@@ -1444,7 +1445,7 @@ process_quit_flag (void)
1444 Fkill_emacs (Qnil); 1445 Fkill_emacs (Qnil);
1445 if (EQ (Vthrow_on_input, flag)) 1446 if (EQ (Vthrow_on_input, flag))
1446 Fthrow (Vthrow_on_input, Qt); 1447 Fthrow (Vthrow_on_input, Qt);
1447 Fsignal (Qquit, Qnil); 1448 quit ();
1448} 1449}
1449 1450
1450DEFUN ("signal", Fsignal, Ssignal, 2, 2, 0, 1451DEFUN ("signal", Fsignal, Ssignal, 2, 2, 0,
@@ -1460,9 +1461,29 @@ DATA should be a list. Its elements are printed as part of the error message.
1460See Info anchor `(elisp)Definition of signal' for some details on how this 1461See Info anchor `(elisp)Definition of signal' for some details on how this
1461error message is constructed. 1462error message is constructed.
1462If the signal is handled, DATA is made available to the handler. 1463If the signal is handled, DATA is made available to the handler.
1463See also the function `condition-case'. */) 1464See also the function `condition-case'. */
1465 attributes: noreturn)
1464 (Lisp_Object error_symbol, Lisp_Object data) 1466 (Lisp_Object error_symbol, Lisp_Object data)
1465{ 1467{
1468 signal_or_quit (error_symbol, data, false);
1469 eassume (false);
1470}
1471
1472/* Quit, in response to a keyboard quit request. */
1473Lisp_Object
1474quit (void)
1475{
1476 return signal_or_quit (Qquit, Qnil, true);
1477}
1478
1479/* Signal an error, or quit. ERROR_SYMBOL and DATA are as with Fsignal.
1480 If KEYBOARD_QUIT, this is a quit; ERROR_SYMBOL should be
1481 Qquit and DATA should be Qnil, and this function may return.
1482 Otherwise this function is like Fsignal and does not return. */
1483
1484static Lisp_Object
1485signal_or_quit (Lisp_Object error_symbol, Lisp_Object data, bool keyboard_quit)
1486{
1466 /* When memory is full, ERROR-SYMBOL is nil, 1487 /* When memory is full, ERROR-SYMBOL is nil,
1467 and DATA is (REAL-ERROR-SYMBOL . REAL-DATA). 1488 and DATA is (REAL-ERROR-SYMBOL . REAL-DATA).
1468 That is a special case--don't do this in other situations. */ 1489 That is a special case--don't do this in other situations. */
@@ -1542,7 +1563,7 @@ See also the function `condition-case'. */)
1542 = maybe_call_debugger (conditions, error_symbol, data); 1563 = maybe_call_debugger (conditions, error_symbol, data);
1543 /* We can't return values to code which signaled an error, but we 1564 /* We can't return values to code which signaled an error, but we
1544 can continue code which has signaled a quit. */ 1565 can continue code which has signaled a quit. */
1545 if (debugger_called && EQ (real_error_symbol, Qquit)) 1566 if (keyboard_quit && debugger_called && EQ (real_error_symbol, Qquit))
1546 return Qnil; 1567 return Qnil;
1547 } 1568 }
1548 1569
@@ -1569,16 +1590,6 @@ See also the function `condition-case'. */)
1569 fatal ("%s", SDATA (string)); 1590 fatal ("%s", SDATA (string));
1570} 1591}
1571 1592
1572/* Internal version of Fsignal that never returns.
1573 Used for anything but Qquit (which can return from Fsignal). */
1574
1575void
1576xsignal (Lisp_Object error_symbol, Lisp_Object data)
1577{
1578 Fsignal (error_symbol, data);
1579 emacs_abort ();
1580}
1581
1582/* Like xsignal, but takes 0, 1, 2, or 3 args instead of a list. */ 1593/* Like xsignal, but takes 0, 1, 2, or 3 args instead of a list. */
1583 1594
1584void 1595void
diff --git a/src/fileio.c b/src/fileio.c
index 5615639a5e1..66ea761ca56 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -185,8 +185,7 @@ void
185report_file_errno (char const *string, Lisp_Object name, int errorno) 185report_file_errno (char const *string, Lisp_Object name, int errorno)
186{ 186{
187 Lisp_Object data = CONSP (name) || NILP (name) ? name : list1 (name); 187 Lisp_Object data = CONSP (name) || NILP (name) ? name : list1 (name);
188 synchronize_system_messages_locale (); 188 char *str = emacs_strerror (errorno);
189 char *str = strerror (errorno);
190 AUTO_STRING (unibyte_str, str); 189 AUTO_STRING (unibyte_str, str);
191 Lisp_Object errstring 190 Lisp_Object errstring
192 = code_convert_string_norecord (unibyte_str, Vlocale_coding_system, 0); 191 = code_convert_string_norecord (unibyte_str, Vlocale_coding_system, 0);
@@ -214,12 +213,11 @@ report_file_error (char const *string, Lisp_Object name)
214void 213void
215report_file_notify_error (const char *string, Lisp_Object name) 214report_file_notify_error (const char *string, Lisp_Object name)
216{ 215{
217 Lisp_Object data = CONSP (name) || NILP (name) ? name : list1 (name); 216 char *str = emacs_strerror (errno);
218 synchronize_system_messages_locale ();
219 char *str = strerror (errno);
220 AUTO_STRING (unibyte_str, str); 217 AUTO_STRING (unibyte_str, str);
221 Lisp_Object errstring 218 Lisp_Object errstring
222 = code_convert_string_norecord (unibyte_str, Vlocale_coding_system, 0); 219 = code_convert_string_norecord (unibyte_str, Vlocale_coding_system, 0);
220 Lisp_Object data = CONSP (name) || NILP (name) ? name : list1 (name);
223 Lisp_Object errdata = Fcons (errstring, data); 221 Lisp_Object errdata = Fcons (errstring, data);
224 222
225 xsignal (Qfile_notify_error, Fcons (build_string (string), errdata)); 223 xsignal (Qfile_notify_error, Fcons (build_string (string), errdata));
@@ -3361,6 +3359,21 @@ restore_window_points (Lisp_Object window_markers, ptrdiff_t inserted,
3361 } 3359 }
3362} 3360}
3363 3361
3362/* Make sure the gap is at Z_BYTE. This is required to treat buffer
3363 text as a linear C char array. */
3364static void
3365maybe_move_gap (struct buffer *b)
3366{
3367 if (BUF_GPT_BYTE (b) != BUF_Z_BYTE (b))
3368 {
3369 struct buffer *cb = current_buffer;
3370
3371 set_buffer_internal (b);
3372 move_gap_both (Z, Z_BYTE);
3373 set_buffer_internal (cb);
3374 }
3375}
3376
3364/* FIXME: insert-file-contents should be split with the top-level moved to 3377/* FIXME: insert-file-contents should be split with the top-level moved to
3365 Elisp and only the core kept in C. */ 3378 Elisp and only the core kept in C. */
3366 3379
@@ -3944,6 +3957,7 @@ by calling `format-decode', which see. */)
3944 3957
3945 coding_system = CODING_ID_NAME (coding.id); 3958 coding_system = CODING_ID_NAME (coding.id);
3946 set_coding_system = true; 3959 set_coding_system = true;
3960 maybe_move_gap (XBUFFER (conversion_buffer));
3947 decoded = BUF_BEG_ADDR (XBUFFER (conversion_buffer)); 3961 decoded = BUF_BEG_ADDR (XBUFFER (conversion_buffer));
3948 inserted = (BUF_Z_BYTE (XBUFFER (conversion_buffer)) 3962 inserted = (BUF_Z_BYTE (XBUFFER (conversion_buffer))
3949 - BUF_BEG_BYTE (XBUFFER (conversion_buffer))); 3963 - BUF_BEG_BYTE (XBUFFER (conversion_buffer)));
@@ -4499,7 +4513,7 @@ by calling `format-decode', which see. */)
4499 PT - BEG, Z - PT - inserted); 4513 PT - BEG, Z - PT - inserted);
4500 4514
4501 if (read_quit) 4515 if (read_quit)
4502 Fsignal (Qquit, Qnil); 4516 quit ();
4503 4517
4504 /* Retval needs to be dealt with in all cases consistently. */ 4518 /* Retval needs to be dealt with in all cases consistently. */
4505 if (NILP (val)) 4519 if (NILP (val))
@@ -4687,7 +4701,7 @@ write_region (Lisp_Object start, Lisp_Object end, Lisp_Object filename,
4687{ 4701{
4688 int open_flags; 4702 int open_flags;
4689 int mode; 4703 int mode;
4690 off_t offset IF_LINT (= 0); 4704 off_t offset UNINIT;
4691 bool open_and_close_file = desc < 0; 4705 bool open_and_close_file = desc < 0;
4692 bool ok; 4706 bool ok;
4693 int save_errno = 0; 4707 int save_errno = 0;
@@ -4695,7 +4709,7 @@ write_region (Lisp_Object start, Lisp_Object end, Lisp_Object filename,
4695 struct stat st; 4709 struct stat st;
4696 struct timespec modtime; 4710 struct timespec modtime;
4697 ptrdiff_t count = SPECPDL_INDEX (); 4711 ptrdiff_t count = SPECPDL_INDEX ();
4698 ptrdiff_t count1 IF_LINT (= 0); 4712 ptrdiff_t count1 UNINIT;
4699 Lisp_Object handler; 4713 Lisp_Object handler;
4700 Lisp_Object visit_file; 4714 Lisp_Object visit_file;
4701 Lisp_Object annotations; 4715 Lisp_Object annotations;
@@ -5376,17 +5390,13 @@ An argument specifies the modification time value to use
5376static Lisp_Object 5390static Lisp_Object
5377auto_save_error (Lisp_Object error_val) 5391auto_save_error (Lisp_Object error_val)
5378{ 5392{
5379 Lisp_Object msg;
5380 int i;
5381
5382 auto_save_error_occurred = 1; 5393 auto_save_error_occurred = 1;
5383 5394
5384 ring_bell (XFRAME (selected_frame)); 5395 ring_bell (XFRAME (selected_frame));
5385 5396
5386 AUTO_STRING (format, "Auto-saving %s: %s"); 5397 AUTO_STRING (format, "Auto-saving %s: %s");
5387 msg = CALLN (Fformat, format, BVAR (current_buffer, name), 5398 Lisp_Object msg = CALLN (Fformat, format, BVAR (current_buffer, name),
5388 Ferror_message_string (error_val)); 5399 Ferror_message_string (error_val));
5389
5390 call3 (intern ("display-warning"), 5400 call3 (intern ("display-warning"),
5391 intern ("auto-save"), msg, intern ("error")); 5401 intern ("auto-save"), msg, intern ("error"));
5392 5402
diff --git a/src/floatfns.c b/src/floatfns.c
index c1bd25877e3..f514fcbea8c 100644
--- a/src/floatfns.c
+++ b/src/floatfns.c
@@ -185,8 +185,8 @@ If X is zero, both parts (SGNFCAND and EXP) are zero. */)
185} 185}
186 186
187DEFUN ("ldexp", Fldexp, Sldexp, 2, 2, 0, 187DEFUN ("ldexp", Fldexp, Sldexp, 2, 2, 0,
188 doc: /* Return X * 2**EXP, as a floating point number. 188 doc: /* Return SGNFCAND * 2**EXPONENT, as a floating point number.
189EXP must be an integer. */) 189EXPONENT must be an integer. */)
190 (Lisp_Object sgnfcand, Lisp_Object exponent) 190 (Lisp_Object sgnfcand, Lisp_Object exponent)
191{ 191{
192 CHECK_NUMBER (exponent); 192 CHECK_NUMBER (exponent);
diff --git a/src/fns.c b/src/fns.c
index 731f0a899a9..c318608e4ce 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -226,7 +226,7 @@ Like in `substring', negative values are counted from the end.
226The strings are compared by the numeric values of their characters. 226The strings are compared by the numeric values of their characters.
227For instance, STR1 is "less than" STR2 if its first differing 227For instance, STR1 is "less than" STR2 if its first differing
228character has a smaller numeric value. If IGNORE-CASE is non-nil, 228character has a smaller numeric value. If IGNORE-CASE is non-nil,
229characters are converted to lower-case before comparing them. Unibyte 229characters are converted to upper-case before comparing them. Unibyte
230strings are converted to multibyte for comparison. 230strings are converted to multibyte for comparison.
231 231
232The value is t if the strings (or specified portions) match. 232The value is t if the strings (or specified portions) match.
@@ -2654,6 +2654,30 @@ SEQUENCE may be a list, a vector, a bool-vector, or a string. */)
2654 2654
2655 return sequence; 2655 return sequence;
2656} 2656}
2657
2658DEFUN ("mapcan", Fmapcan, Smapcan, 2, 2, 0,
2659 doc: /* Apply FUNCTION to each element of SEQUENCE, and concatenate
2660the results by altering them (using `nconc').
2661SEQUENCE may be a list, a vector, a bool-vector, or a string. */)
2662 (Lisp_Object function, Lisp_Object sequence)
2663{
2664 register EMACS_INT leni;
2665 register Lisp_Object *args;
2666 Lisp_Object ret;
2667 USE_SAFE_ALLOCA;
2668
2669 if (CHAR_TABLE_P (sequence))
2670 wrong_type_argument (Qlistp, sequence);
2671
2672 leni = XFASTINT (Flength (sequence));
2673 SAFE_ALLOCA_LISP (args, leni);
2674 mapcar1 (leni, args, function, sequence);
2675 ret = Fnconc (leni, args);
2676
2677 SAFE_FREE ();
2678
2679 return ret;
2680}
2657 2681
2658/* This is how C code calls `yes-or-no-p' and allows the user 2682/* This is how C code calls `yes-or-no-p' and allows the user
2659 to redefine it. */ 2683 to redefine it. */
@@ -5123,6 +5147,9 @@ syms_of_fns (void)
5123 doc: /* A list of symbols which are the features of the executing Emacs. 5147 doc: /* A list of symbols which are the features of the executing Emacs.
5124Used by `featurep' and `require', and altered by `provide'. */); 5148Used by `featurep' and `require', and altered by `provide'. */);
5125 Vfeatures = list1 (Qemacs); 5149 Vfeatures = list1 (Qemacs);
5150 DEFSYM (Qfeatures, "features");
5151 /* Let people use lexically scoped vars named `features'. */
5152 Fmake_var_non_special (Qfeatures);
5126 DEFSYM (Qsubfeatures, "subfeatures"); 5153 DEFSYM (Qsubfeatures, "subfeatures");
5127 DEFSYM (Qfuncall, "funcall"); 5154 DEFSYM (Qfuncall, "funcall");
5128 5155
@@ -5203,6 +5230,7 @@ this variable. */);
5203 defsubr (&Snconc); 5230 defsubr (&Snconc);
5204 defsubr (&Smapcar); 5231 defsubr (&Smapcar);
5205 defsubr (&Smapc); 5232 defsubr (&Smapc);
5233 defsubr (&Smapcan);
5206 defsubr (&Smapconcat); 5234 defsubr (&Smapconcat);
5207 defsubr (&Syes_or_no_p); 5235 defsubr (&Syes_or_no_p);
5208 defsubr (&Sload_average); 5236 defsubr (&Sload_average);
diff --git a/src/font.c b/src/font.c
index 6dbda40d52f..144ba07c42a 100644
--- a/src/font.c
+++ b/src/font.c
@@ -2234,7 +2234,8 @@ font_sort_entities (Lisp_Object list, Lisp_Object prefer,
2234 struct font_sort_data *data; 2234 struct font_sort_data *data;
2235 unsigned best_score; 2235 unsigned best_score;
2236 Lisp_Object best_entity; 2236 Lisp_Object best_entity;
2237 Lisp_Object tail, vec IF_LINT (= Qnil); 2237 Lisp_Object tail;
2238 Lisp_Object vec UNINIT;
2238 USE_SAFE_ALLOCA; 2239 USE_SAFE_ALLOCA;
2239 2240
2240 for (i = FONT_WEIGHT_INDEX; i <= FONT_AVGWIDTH_INDEX; i++) 2241 for (i = FONT_WEIGHT_INDEX; i <= FONT_AVGWIDTH_INDEX; i++)
@@ -2862,7 +2863,7 @@ font_open_entity (struct frame *f, Lisp_Object entity, int pixel_size)
2862 struct font_driver_list *driver_list; 2863 struct font_driver_list *driver_list;
2863 Lisp_Object objlist, size, val, font_object; 2864 Lisp_Object objlist, size, val, font_object;
2864 struct font *font; 2865 struct font *font;
2865 int min_width, height, psize; 2866 int height, psize;
2866 2867
2867 eassert (FONT_ENTITY_P (entity)); 2868 eassert (FONT_ENTITY_P (entity));
2868 size = AREF (entity, FONT_SIZE_INDEX); 2869 size = AREF (entity, FONT_SIZE_INDEX);
@@ -2906,10 +2907,12 @@ font_open_entity (struct frame *f, Lisp_Object entity, int pixel_size)
2906 Fcons (font_object, AREF (entity, FONT_OBJLIST_INDEX))); 2907 Fcons (font_object, AREF (entity, FONT_OBJLIST_INDEX)));
2907 2908
2908 font = XFONT_OBJECT (font_object); 2909 font = XFONT_OBJECT (font_object);
2909 min_width = (font->min_width ? font->min_width 2910#ifdef HAVE_WINDOW_SYSTEM
2910 : font->average_width ? font->average_width 2911 int min_width = (font->min_width ? font->min_width
2911 : font->space_width ? font->space_width 2912 : font->average_width ? font->average_width
2912 : 1); 2913 : font->space_width ? font->space_width
2914 : 1);
2915#endif
2913 2916
2914 int font_ascent, font_descent; 2917 int font_ascent, font_descent;
2915 get_font_ascent_descent (font, &font_ascent, &font_descent); 2918 get_font_ascent_descent (font, &font_ascent, &font_descent);
diff --git a/src/fontset.c b/src/fontset.c
index d87901d42b8..67696d0fead 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -750,7 +750,8 @@ fontset_find_font (Lisp_Object fontset, int c, struct face *face,
750static Lisp_Object 750static Lisp_Object
751fontset_font (Lisp_Object fontset, int c, struct face *face, int id) 751fontset_font (Lisp_Object fontset, int c, struct face *face, int id)
752{ 752{
753 Lisp_Object rfont_def, default_rfont_def IF_LINT (= Qnil); 753 Lisp_Object rfont_def;
754 Lisp_Object default_rfont_def UNINIT;
754 Lisp_Object base_fontset; 755 Lisp_Object base_fontset;
755 756
756 /* Try a font-group of FONTSET. */ 757 /* Try a font-group of FONTSET. */
@@ -1304,7 +1305,7 @@ free_realized_fontsets (Lisp_Object base)
1304 { 1305 {
1305 struct frame *f = XFRAME (FONTSET_FRAME (this)); 1306 struct frame *f = XFRAME (FONTSET_FRAME (this));
1306 int face_id = XINT (XCDR (XCAR (tail))); 1307 int face_id = XINT (XCDR (XCAR (tail)));
1307 struct face *face = FACE_OPT_FROM_ID (f, face_id); 1308 struct face *face = FACE_FROM_ID_OR_NULL (f, face_id);
1308 1309
1309 /* Face THIS itself is also freed by the following call. */ 1310 /* Face THIS itself is also freed by the following call. */
1310 free_realized_face (f, face); 1311 free_realized_face (f, face);
@@ -1636,7 +1637,7 @@ appended. By default, FONT-SPEC overrides the previous settings. */)
1636 continue; 1637 continue;
1637 if (fontset_id != FRAME_FONTSET (f)) 1638 if (fontset_id != FRAME_FONTSET (f))
1638 continue; 1639 continue;
1639 face = FACE_OPT_FROM_ID (f, DEFAULT_FACE_ID); 1640 face = FACE_FROM_ID_OR_NULL (f, DEFAULT_FACE_ID);
1640 if (face) 1641 if (face)
1641 font_object = font_load_for_lface (f, face->lface, font_spec); 1642 font_object = font_load_for_lface (f, face->lface, font_spec);
1642 else 1643 else
diff --git a/src/frame.c b/src/frame.c
index df9753905b2..22143ab26bf 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -106,31 +106,32 @@ decode_any_frame (register Lisp_Object frame)
106} 106}
107 107
108#ifdef HAVE_WINDOW_SYSTEM 108#ifdef HAVE_WINDOW_SYSTEM
109
110bool 109bool
111window_system_available (struct frame *f) 110display_available (void)
112{ 111{
113 return f ? FRAME_WINDOW_P (f) || FRAME_MSDOS_P (f) : x_display_list != NULL; 112 return x_display_list != NULL;
114} 113}
115 114#endif
116#endif /* HAVE_WINDOW_SYSTEM */
117 115
118struct frame * 116struct frame *
119decode_window_system_frame (Lisp_Object frame) 117decode_window_system_frame (Lisp_Object frame)
120{ 118{
121 struct frame *f = decode_live_frame (frame); 119 struct frame *f = decode_live_frame (frame);
122 120 check_window_system (f);
123 if (!window_system_available (f)) 121#ifdef HAVE_WINDOW_SYSTEM
124 error ("Window system frame should be used");
125 return f; 122 return f;
123#endif
126} 124}
127 125
128void 126void
129check_window_system (struct frame *f) 127check_window_system (struct frame *f)
130{ 128{
131 if (!window_system_available (f)) 129#ifdef HAVE_WINDOW_SYSTEM
132 error (f ? "Window system frame should be used" 130 if (window_system_available (f))
133 : "Window system is not in use or not initialized"); 131 return;
132#endif
133 error (f ? "Window system frame should be used"
134 : "Window system is not in use or not initialized");
134} 135}
135 136
136/* Return the value of frame parameter PROP in frame FRAME. */ 137/* Return the value of frame parameter PROP in frame FRAME. */
@@ -2135,10 +2136,12 @@ If omitted, FRAME defaults to the currently selected frame. */)
2135 check_minibuf_window (frame, EQ (minibuf_window, selected_window)); 2136 check_minibuf_window (frame, EQ (minibuf_window, selected_window));
2136 2137
2137 /* I think this should be done with a hook. */ 2138 /* I think this should be done with a hook. */
2138#ifdef HAVE_WINDOW_SYSTEM
2139 if (FRAME_WINDOW_P (f)) 2139 if (FRAME_WINDOW_P (f))
2140 {
2141#ifdef HAVE_WINDOW_SYSTEM
2140 x_iconify_frame (f); 2142 x_iconify_frame (f);
2141#endif 2143#endif
2144 }
2142 2145
2143 /* Make menu bar update for the Buffers and Frames menus. */ 2146 /* Make menu bar update for the Buffers and Frames menus. */
2144 windows_or_buffers_changed = 17; 2147 windows_or_buffers_changed = 17;
@@ -2604,6 +2607,22 @@ If FRAME is nil, describe the currently selected frame. */)
2604 /* Avoid consing in frequent cases. */ 2607 /* Avoid consing in frequent cases. */
2605 if (EQ (parameter, Qname)) 2608 if (EQ (parameter, Qname))
2606 value = f->name; 2609 value = f->name;
2610#ifdef HAVE_WINDOW_SYSTEM
2611 /* These are used by vertical motion commands. */
2612 else if (EQ (parameter, Qvertical_scroll_bars))
2613 value = (f->vertical_scroll_bar_type == vertical_scroll_bar_none
2614 ? Qnil
2615 : (f->vertical_scroll_bar_type == vertical_scroll_bar_left
2616 ? Qleft : Qright));
2617 else if (EQ (parameter, Qhorizontal_scroll_bars))
2618 value = f->horizontal_scroll_bars ? Qt : Qnil;
2619 else if (EQ (parameter, Qline_spacing) && f->extra_line_spacing == 0)
2620 /* If this is non-zero, we can't determine whether the user specified
2621 an integer or float value without looking through 'param_alist'. */
2622 value = make_number (0);
2623 else if (EQ (parameter, Qfont) && FRAME_X_P (f))
2624 value = FRAME_FONT (f)->props[FONT_NAME_INDEX];
2625#endif /* HAVE_WINDOW_SYSTEM */
2607#ifdef HAVE_X_WINDOWS 2626#ifdef HAVE_X_WINDOWS
2608 else if (EQ (parameter, Qdisplay) && FRAME_X_P (f)) 2627 else if (EQ (parameter, Qdisplay) && FRAME_X_P (f))
2609 value = XCAR (FRAME_DISPLAY_INFO (f)->name_list_element); 2628 value = XCAR (FRAME_DISPLAY_INFO (f)->name_list_element);
@@ -3001,16 +3020,18 @@ or bottom edge of the outer frame of FRAME relative to the right or
3001bottom edge of FRAME's display. */) 3020bottom edge of FRAME's display. */)
3002 (Lisp_Object frame, Lisp_Object x, Lisp_Object y) 3021 (Lisp_Object frame, Lisp_Object x, Lisp_Object y)
3003{ 3022{
3004 register struct frame *f = decode_live_frame (frame); 3023 struct frame *f = decode_live_frame (frame);
3005 3024
3006 CHECK_TYPE_RANGED_INTEGER (int, x); 3025 CHECK_TYPE_RANGED_INTEGER (int, x);
3007 CHECK_TYPE_RANGED_INTEGER (int, y); 3026 CHECK_TYPE_RANGED_INTEGER (int, y);
3008 3027
3009 /* I think this should be done with a hook. */ 3028 /* I think this should be done with a hook. */
3010#ifdef HAVE_WINDOW_SYSTEM
3011 if (FRAME_WINDOW_P (f)) 3029 if (FRAME_WINDOW_P (f))
3012 x_set_offset (f, XINT (x), XINT (y), 1); 3030 {
3031#ifdef HAVE_WINDOW_SYSTEM
3032 x_set_offset (f, XINT (x), XINT (y), 1);
3013#endif 3033#endif
3034 }
3014 3035
3015 return Qt; 3036 return Qt;
3016} 3037}
@@ -3105,70 +3126,58 @@ x_set_frame_parameters (struct frame *f, Lisp_Object alist)
3105 /* Record in these vectors all the parms specified. */ 3126 /* Record in these vectors all the parms specified. */
3106 Lisp_Object *parms; 3127 Lisp_Object *parms;
3107 Lisp_Object *values; 3128 Lisp_Object *values;
3108 ptrdiff_t i, p; 3129 ptrdiff_t i, j, size;
3109 bool left_no_change = 0, top_no_change = 0; 3130 bool left_no_change = 0, top_no_change = 0;
3110#ifdef HAVE_X_WINDOWS 3131#ifdef HAVE_X_WINDOWS
3111 bool icon_left_no_change = 0, icon_top_no_change = 0; 3132 bool icon_left_no_change = 0, icon_top_no_change = 0;
3112#endif 3133#endif
3113 3134
3114 i = 0; 3135 for (size = 0, tail = alist; CONSP (tail); tail = XCDR (tail))
3115 for (tail = alist; CONSP (tail); tail = XCDR (tail)) 3136 size++;
3116 i++;
3117 3137
3118 USE_SAFE_ALLOCA; 3138 USE_SAFE_ALLOCA;
3119 SAFE_ALLOCA_LISP (parms, 2 * i); 3139 SAFE_ALLOCA_LISP (parms, 2 * size);
3120 values = parms + i; 3140 values = parms + size;
3121 3141
3122 /* Extract parm names and values into those vectors. */ 3142 /* Extract parm names and values into those vectors. */
3123 3143
3124 i = 0; 3144 i = 0, j = size - 1;
3125 for (tail = alist; CONSP (tail); tail = XCDR (tail)) 3145 for (tail = alist; CONSP (tail); tail = XCDR (tail))
3126 { 3146 {
3127 Lisp_Object elt; 3147 Lisp_Object elt = XCAR (tail), prop = Fcar (elt), val = Fcdr (elt);
3128
3129 elt = XCAR (tail);
3130 parms[i] = Fcar (elt);
3131 values[i] = Fcdr (elt);
3132 i++;
3133 }
3134 /* TAIL and ALIST are not used again below here. */
3135 alist = tail = Qnil;
3136 3148
3137 top = left = Qunbound; 3149 /* Some properties are independent of other properties, but other
3138 icon_left = icon_top = Qunbound; 3150 properties are dependent upon them. These special properties
3139 3151 are foreground_color, background_color (affects cursor_color)
3140 /* Process foreground_color and background_color before anything else. 3152 and font (affects fringe widths); they're recorded starting
3141 They are independent of other properties, but other properties (e.g., 3153 from the end of PARMS and VALUES to process them first by using
3142 cursor_color) are dependent upon them. */ 3154 reverse iteration. */
3143 /* Process default font as well, since fringe widths depends on it. */
3144 for (p = 0; p < i; p++)
3145 {
3146 Lisp_Object prop, val;
3147 3155
3148 prop = parms[p];
3149 val = values[p];
3150 if (EQ (prop, Qforeground_color) 3156 if (EQ (prop, Qforeground_color)
3151 || EQ (prop, Qbackground_color) 3157 || EQ (prop, Qbackground_color)
3152 || EQ (prop, Qfont)) 3158 || EQ (prop, Qfont))
3153 { 3159 {
3154 register Lisp_Object param_index, old_value; 3160 parms[j] = prop;
3155 3161 values[j] = val;
3156 old_value = get_frame_param (f, prop); 3162 j--;
3157 if (NILP (Fequal (val, old_value))) 3163 }
3158 { 3164 else
3159 store_frame_param (f, prop, val); 3165 {
3160 3166 parms[i] = prop;
3161 param_index = Fget (prop, Qx_frame_parameter); 3167 values[i] = val;
3162 if (NATNUMP (param_index) 3168 i++;
3163 && XFASTINT (param_index) < ARRAYELTS (frame_parms)
3164 && FRAME_RIF (f)->frame_parm_handlers[XINT (param_index)])
3165 (*(FRAME_RIF (f)->frame_parm_handlers[XINT (param_index)])) (f, val, old_value);
3166 }
3167 } 3169 }
3168 } 3170 }
3169 3171
3170 /* Now process them in reverse of specified order. */ 3172 /* TAIL and ALIST are not used again below here. */
3171 while (i-- != 0) 3173 alist = tail = Qnil;
3174
3175 top = left = Qunbound;
3176 icon_left = icon_top = Qunbound;
3177
3178 /* Reverse order is used to make sure that special
3179 properties noticed above are processed first. */
3180 for (i = size - 1; i >= 0; i--)
3172 { 3181 {
3173 Lisp_Object prop, val; 3182 Lisp_Object prop, val;
3174 3183
@@ -3216,11 +3225,6 @@ x_set_frame_parameters (struct frame *f, Lisp_Object alist)
3216 fullscreen = val; 3225 fullscreen = val;
3217 fullscreen_change = true; 3226 fullscreen_change = true;
3218 } 3227 }
3219 else if (EQ (prop, Qforeground_color)
3220 || EQ (prop, Qbackground_color)
3221 || EQ (prop, Qfont))
3222 /* Processed above. */
3223 continue;
3224 else 3228 else
3225 { 3229 {
3226 register Lisp_Object param_index, old_value; 3230 register Lisp_Object param_index, old_value;
@@ -3739,8 +3743,8 @@ x_set_left_fringe (struct frame *f, Lisp_Object new_value, Lisp_Object old_value
3739 3743
3740 if (new_width != old_width) 3744 if (new_width != old_width)
3741 { 3745 {
3742 FRAME_LEFT_FRINGE_WIDTH (f) = new_width; 3746 f->left_fringe_width = new_width;
3743 FRAME_FRINGE_COLS (f) /* Round up. */ 3747 f->fringe_cols /* Round up. */
3744 = (new_width + FRAME_RIGHT_FRINGE_WIDTH (f) + unit - 1) / unit; 3748 = (new_width + FRAME_RIGHT_FRINGE_WIDTH (f) + unit - 1) / unit;
3745 3749
3746 if (FRAME_X_WINDOW (f) != 0) 3750 if (FRAME_X_WINDOW (f) != 0)
@@ -3763,8 +3767,8 @@ x_set_right_fringe (struct frame *f, Lisp_Object new_value, Lisp_Object old_valu
3763 3767
3764 if (new_width != old_width) 3768 if (new_width != old_width)
3765 { 3769 {
3766 FRAME_RIGHT_FRINGE_WIDTH (f) = new_width; 3770 f->right_fringe_width = new_width;
3767 FRAME_FRINGE_COLS (f) /* Round up. */ 3771 f->fringe_cols /* Round up. */
3768 = (new_width + FRAME_LEFT_FRINGE_WIDTH (f) + unit - 1) / unit; 3772 = (new_width + FRAME_LEFT_FRINGE_WIDTH (f) + unit - 1) / unit;
3769 3773
3770 if (FRAME_X_WINDOW (f) != 0) 3774 if (FRAME_X_WINDOW (f) != 0)
@@ -3793,13 +3797,11 @@ void
3793x_set_right_divider_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval) 3797x_set_right_divider_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
3794{ 3798{
3795 int old = FRAME_RIGHT_DIVIDER_WIDTH (f); 3799 int old = FRAME_RIGHT_DIVIDER_WIDTH (f);
3796
3797 CHECK_TYPE_RANGED_INTEGER (int, arg); 3800 CHECK_TYPE_RANGED_INTEGER (int, arg);
3798 FRAME_RIGHT_DIVIDER_WIDTH (f) = XINT (arg); 3801 int new = max (0, XINT (arg));
3799 if (FRAME_RIGHT_DIVIDER_WIDTH (f) < 0) 3802 if (new != old)
3800 FRAME_RIGHT_DIVIDER_WIDTH (f) = 0;
3801 if (FRAME_RIGHT_DIVIDER_WIDTH (f) != old)
3802 { 3803 {
3804 f->right_divider_width = new;
3803 adjust_frame_size (f, -1, -1, 4, 0, Qright_divider_width); 3805 adjust_frame_size (f, -1, -1, 4, 0, Qright_divider_width);
3804 adjust_frame_glyphs (f); 3806 adjust_frame_glyphs (f);
3805 SET_FRAME_GARBAGED (f); 3807 SET_FRAME_GARBAGED (f);
@@ -3811,13 +3813,11 @@ void
3811x_set_bottom_divider_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval) 3813x_set_bottom_divider_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
3812{ 3814{
3813 int old = FRAME_BOTTOM_DIVIDER_WIDTH (f); 3815 int old = FRAME_BOTTOM_DIVIDER_WIDTH (f);
3814
3815 CHECK_TYPE_RANGED_INTEGER (int, arg); 3816 CHECK_TYPE_RANGED_INTEGER (int, arg);
3816 FRAME_BOTTOM_DIVIDER_WIDTH (f) = XINT (arg); 3817 int new = max (0, XINT (arg));
3817 if (FRAME_BOTTOM_DIVIDER_WIDTH (f) < 0) 3818 if (new != old)
3818 FRAME_BOTTOM_DIVIDER_WIDTH (f) = 0;
3819 if (FRAME_BOTTOM_DIVIDER_WIDTH (f) != old)
3820 { 3819 {
3820 f->bottom_divider_width = new;
3821 adjust_frame_size (f, -1, -1, 4, 0, Qbottom_divider_width); 3821 adjust_frame_size (f, -1, -1, 4, 0, Qbottom_divider_width);
3822 adjust_frame_glyphs (f); 3822 adjust_frame_glyphs (f);
3823 SET_FRAME_GARBAGED (f); 3823 SET_FRAME_GARBAGED (f);
diff --git a/src/frame.h b/src/frame.h
index 9de672c8635..5e3ee68942a 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -1102,7 +1102,14 @@ extern Lisp_Object selected_frame;
1102extern int frame_default_tool_bar_height; 1102extern int frame_default_tool_bar_height;
1103#endif 1103#endif
1104 1104
1105extern struct frame *decode_window_system_frame (Lisp_Object); 1105#ifdef HAVE_WINDOW_SYSTEM
1106# define WINDOW_SYSTEM_RETURN
1107#else
1108# define WINDOW_SYSTEM_RETURN _Noreturn
1109#endif
1110
1111extern WINDOW_SYSTEM_RETURN struct frame *
1112 decode_window_system_frame (Lisp_Object);
1106extern struct frame *decode_live_frame (Lisp_Object); 1113extern struct frame *decode_live_frame (Lisp_Object);
1107extern struct frame *decode_any_frame (Lisp_Object); 1114extern struct frame *decode_any_frame (Lisp_Object);
1108extern struct frame *make_initial_frame (void); 1115extern struct frame *make_initial_frame (void);
@@ -1112,11 +1119,20 @@ extern struct frame *make_minibuffer_frame (void);
1112extern struct frame *make_frame_without_minibuffer (Lisp_Object, 1119extern struct frame *make_frame_without_minibuffer (Lisp_Object,
1113 struct kboard *, 1120 struct kboard *,
1114 Lisp_Object); 1121 Lisp_Object);
1115extern bool window_system_available (struct frame *); 1122extern bool display_available (void);
1116#else /* not HAVE_WINDOW_SYSTEM */ 1123#endif
1117#define window_system_available(f) ((void) (f), false) 1124
1118#endif /* HAVE_WINDOW_SYSTEM */ 1125INLINE bool
1119extern void check_window_system (struct frame *); 1126window_system_available (struct frame *f)
1127{
1128#ifdef HAVE_WINDOW_SYSTEM
1129 return f ? FRAME_WINDOW_P (f) || FRAME_MSDOS_P (f) : display_available ();
1130#else
1131 return false;
1132#endif
1133}
1134
1135extern WINDOW_SYSTEM_RETURN void check_window_system (struct frame *);
1120extern void frame_make_pointer_invisible (struct frame *); 1136extern void frame_make_pointer_invisible (struct frame *);
1121extern void frame_make_pointer_visible (struct frame *); 1137extern void frame_make_pointer_visible (struct frame *);
1122extern Lisp_Object delete_frame (Lisp_Object, Lisp_Object); 1138extern Lisp_Object delete_frame (Lisp_Object, Lisp_Object);
@@ -1150,46 +1166,68 @@ extern Lisp_Object Vframe_list;
1150 This value currently equals the average width of the default font of F. */ 1166 This value currently equals the average width of the default font of F. */
1151#define FRAME_COLUMN_WIDTH(F) ((F)->column_width) 1167#define FRAME_COLUMN_WIDTH(F) ((F)->column_width)
1152 1168
1153/* Pixel width of areas used to display truncation marks, continuation 1169/* Get a frame's window system dimension. If no window system, this is 0. */
1154 marks, overlay arrows. This is 0 for terminal frames. */
1155 1170
1171INLINE int
1172frame_dimension (int x)
1173{
1156#ifdef HAVE_WINDOW_SYSTEM 1174#ifdef HAVE_WINDOW_SYSTEM
1175 return x;
1176#else
1177 return 0;
1178#endif
1179}
1157 1180
1158/* Total width of fringes reserved for drawing truncation bitmaps, 1181/* Total width of fringes reserved for drawing truncation bitmaps,
1159 continuation bitmaps and alike. The width is in canonical char 1182 continuation bitmaps and alike. The width is in canonical char
1160 units of the frame. This must currently be the case because window 1183 units of the frame. This must currently be the case because window
1161 sizes aren't pixel values. If it weren't the case, we wouldn't be 1184 sizes aren't pixel values. If it weren't the case, we wouldn't be
1162 able to split windows horizontally nicely. */ 1185 able to split windows horizontally nicely. */
1163#define FRAME_FRINGE_COLS(F) ((F)->fringe_cols) 1186INLINE int
1187FRAME_FRINGE_COLS (struct frame *f)
1188{
1189 return frame_dimension (f->fringe_cols);
1190}
1164 1191
1165/* Pixel-width of the left and right fringe. */ 1192/* Pixel-width of the left and right fringe. */
1166 1193
1167#define FRAME_LEFT_FRINGE_WIDTH(F) ((F)->left_fringe_width) 1194INLINE int
1168#define FRAME_RIGHT_FRINGE_WIDTH(F) ((F)->right_fringe_width) 1195FRAME_LEFT_FRINGE_WIDTH (struct frame *f)
1196{
1197 return frame_dimension (f->left_fringe_width);
1198}
1199INLINE int
1200FRAME_RIGHT_FRINGE_WIDTH (struct frame *f)
1201{
1202 return frame_dimension (f->right_fringe_width);
1203}
1169 1204
1170/* Total width of fringes in pixels. */ 1205/* Total width of fringes in pixels. */
1171 1206
1172#define FRAME_TOTAL_FRINGE_WIDTH(F) \ 1207INLINE int
1173 (FRAME_LEFT_FRINGE_WIDTH (F) + FRAME_RIGHT_FRINGE_WIDTH (F)) 1208FRAME_TOTAL_FRINGE_WIDTH (struct frame *f)
1209{
1210 return FRAME_LEFT_FRINGE_WIDTH (f) + FRAME_RIGHT_FRINGE_WIDTH (f);
1211}
1174 1212
1175/* Pixel-width of internal border lines */ 1213/* Pixel-width of internal border lines */
1176#define FRAME_INTERNAL_BORDER_WIDTH(F) ((F)->internal_border_width) 1214INLINE int
1215FRAME_INTERNAL_BORDER_WIDTH (struct frame *f)
1216{
1217 return frame_dimension (f->internal_border_width);
1218}
1177 1219
1178/* Pixel-size of window border lines */ 1220/* Pixel-size of window border lines */
1179#define FRAME_RIGHT_DIVIDER_WIDTH(F) ((F)->right_divider_width) 1221INLINE int
1180#define FRAME_BOTTOM_DIVIDER_WIDTH(F) ((F)->bottom_divider_width) 1222FRAME_RIGHT_DIVIDER_WIDTH (struct frame *f)
1181 1223{
1182#else /* not HAVE_WINDOW_SYSTEM */ 1224 return frame_dimension (f->right_divider_width);
1183 1225}
1184#define FRAME_FRINGE_COLS(F) 0 1226INLINE int
1185#define FRAME_TOTAL_FRINGE_WIDTH(F) 0 1227FRAME_BOTTOM_DIVIDER_WIDTH (struct frame *f)
1186#define FRAME_LEFT_FRINGE_WIDTH(F) 0 1228{
1187#define FRAME_RIGHT_FRINGE_WIDTH(F) 0 1229 return frame_dimension (f->bottom_divider_width);
1188#define FRAME_INTERNAL_BORDER_WIDTH(F) 0 1230}
1189#define FRAME_RIGHT_DIVIDER_WIDTH(F) 0
1190#define FRAME_BOTTOM_DIVIDER_WIDTH(F) 0
1191
1192#endif /* not HAVE_WINDOW_SYSTEM */
1193 1231
1194/*********************************************************************** 1232/***********************************************************************
1195 Conversion between canonical units and pixels 1233 Conversion between canonical units and pixels
@@ -1470,7 +1508,7 @@ INLINE_HEADER_END
1470/* Suppress -Wsuggest-attribute=const if there are no scroll bars. 1508/* Suppress -Wsuggest-attribute=const if there are no scroll bars.
1471 This is for functions like x_set_horizontal_scroll_bars that have 1509 This is for functions like x_set_horizontal_scroll_bars that have
1472 no effect in this case. */ 1510 no effect in this case. */
1473#if ! USE_HORIZONTAL_SCROLL_BARS && 4 < __GNUC__ + (6 <= __GNUC_MINOR__) 1511#if ! USE_HORIZONTAL_SCROLL_BARS && GNUC_PREREQ (4, 6, 0)
1474# pragma GCC diagnostic ignored "-Wsuggest-attribute=const" 1512# pragma GCC diagnostic ignored "-Wsuggest-attribute=const"
1475#endif 1513#endif
1476 1514
diff --git a/src/fringe.c b/src/fringe.c
index 55f37b88787..986bde16f09 100644
--- a/src/fringe.c
+++ b/src/fringe.c
@@ -620,8 +620,7 @@ draw_fringe_bitmap_1 (struct window *w, struct glyph_row *row, int left_p, int o
620 break; 620 break;
621 } 621 }
622 622
623 p.face = FACE_OPT_FROM_ID (f, face_id); 623 p.face = FACE_FROM_ID_OR_NULL (f, face_id);
624
625 if (p.face == NULL) 624 if (p.face == NULL)
626 { 625 {
627 /* This could happen after clearing face cache. 626 /* This could happen after clearing face cache.
@@ -956,7 +955,7 @@ update_window_fringes (struct window *w, bool keep_current_p)
956 row->indicate_bob_p is set, so it's OK that top_row_ends_at_zv_p 955 row->indicate_bob_p is set, so it's OK that top_row_ends_at_zv_p
957 is not initialized here. Similarly for bot_ind_rn, 956 is not initialized here. Similarly for bot_ind_rn,
958 row->indicate_eob_p and bot_row_ends_at_zv_p. */ 957 row->indicate_eob_p and bot_row_ends_at_zv_p. */
959 int top_row_ends_at_zv_p IF_LINT (= 0), bot_row_ends_at_zv_p IF_LINT (= 0); 958 int top_row_ends_at_zv_p UNINIT, bot_row_ends_at_zv_p UNINIT;
960 959
961 if (w->pseudo_window_p) 960 if (w->pseudo_window_p)
962 return 0; 961 return 0;
@@ -1627,7 +1626,7 @@ If FACE is nil, reset face to default fringe face. */)
1627 { 1626 {
1628 struct frame *f = SELECTED_FRAME (); 1627 struct frame *f = SELECTED_FRAME ();
1629 1628
1630 if (FACE_OPT_FROM_ID (f, FRINGE_FACE_ID) 1629 if (FACE_FROM_ID_OR_NULL (f, FRINGE_FACE_ID)
1631 && lookup_derived_face (f, face, FRINGE_FACE_ID, 1) < 0) 1630 && lookup_derived_face (f, face, FRINGE_FACE_ID, 1) < 0)
1632 error ("No such face"); 1631 error ("No such face");
1633 } 1632 }
diff --git a/src/gmalloc.c b/src/gmalloc.c
index d795c13f616..483d05c5c61 100644
--- a/src/gmalloc.c
+++ b/src/gmalloc.c
@@ -44,7 +44,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
44#endif 44#endif
45 45
46#ifdef HAVE_MALLOC_H 46#ifdef HAVE_MALLOC_H
47# if 4 < __GNUC__ + (2 <= __GNUC_MINOR__) 47# if GNUC_PREREQ (4, 2, 0)
48# pragma GCC diagnostic ignored "-Wdeprecated-declarations" 48# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
49# endif 49# endif
50# include <malloc.h> 50# include <malloc.h>
diff --git a/src/gnutls.c b/src/gnutls.c
index 8ee066f46b5..7f05ac4bc47 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -383,13 +383,6 @@ gnutls_log_function2 (int level, const char *string, const char *extra)
383 message ("gnutls.c: [%d] %s %s", level, string, extra); 383 message ("gnutls.c: [%d] %s %s", level, string, extra);
384} 384}
385 385
386/* Log a message and an integer. */
387static void
388gnutls_log_function2i (int level, const char *string, int extra)
389{
390 message ("gnutls.c: [%d] %s %d", level, string, extra);
391}
392
393int 386int
394gnutls_try_handshake (struct Lisp_Process *proc) 387gnutls_try_handshake (struct Lisp_Process *proc)
395{ 388{
diff --git a/src/gnutls.h b/src/gnutls.h
index 47e11f2905f..41769a47f54 100644
--- a/src/gnutls.h
+++ b/src/gnutls.h
@@ -71,7 +71,7 @@ typedef enum
71#define GNUTLS_LOG2i(level, max, string, extra) \ 71#define GNUTLS_LOG2i(level, max, string, extra) \
72 do { \ 72 do { \
73 if ((level) <= (max)) \ 73 if ((level) <= (max)) \
74 gnutls_log_function2i (level, "(Emacs) " string, extra); \ 74 message ("gnutls.c: [%d] %s %d", level, string, extra); \
75 } while (false) 75 } while (false)
76 76
77extern ptrdiff_t 77extern ptrdiff_t
diff --git a/src/gtkutil.c b/src/gtkutil.c
index e791e6ac317..88e6d30bd9a 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -1829,7 +1829,8 @@ xg_get_file_with_chooser (struct frame *f,
1829{ 1829{
1830 char msgbuf[1024]; 1830 char msgbuf[1024];
1831 1831
1832 GtkWidget *filewin, *wtoggle, *wbox, *wmessage IF_LINT (= NULL); 1832 GtkWidget *filewin, *wtoggle, *wbox;
1833 GtkWidget *wmessage UNINIT;
1833 GtkWindow *gwin = GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)); 1834 GtkWindow *gwin = GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f));
1834 GtkFileChooserAction action = (mustmatch_p ? 1835 GtkFileChooserAction action = (mustmatch_p ?
1835 GTK_FILE_CHOOSER_ACTION_OPEN : 1836 GTK_FILE_CHOOSER_ACTION_OPEN :
diff --git a/src/image.c b/src/image.c
index 0991f579579..1770de7e8ff 100644
--- a/src/image.c
+++ b/src/image.c
@@ -56,6 +56,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
56#include TERM_HEADER 56#include TERM_HEADER
57#endif /* HAVE_WINDOW_SYSTEM */ 57#endif /* HAVE_WINDOW_SYSTEM */
58 58
59/* Work around GCC bug 54561. */
60#if GNUC_PREREQ (4, 3, 0)
61# pragma GCC diagnostic ignored "-Wclobbered"
62#endif
63
59#ifdef HAVE_X_WINDOWS 64#ifdef HAVE_X_WINDOWS
60typedef struct x_bitmap_record Bitmap_Record; 65typedef struct x_bitmap_record Bitmap_Record;
61#define GET_PIXEL(ximg, x, y) XGetPixel (ximg, x, y) 66#define GET_PIXEL(ximg, x, y) XGetPixel (ximg, x, y)
@@ -80,7 +85,6 @@ typedef struct w32_bitmap_record Bitmap_Record;
80#define PIX_MASK_DRAW 1 85#define PIX_MASK_DRAW 1
81 86
82#define x_defined_color w32_defined_color 87#define x_defined_color w32_defined_color
83#define DefaultDepthOfScreen(screen) (one_w32_display_info.n_cbits)
84 88
85#endif /* HAVE_NTGUI */ 89#endif /* HAVE_NTGUI */
86 90
@@ -223,6 +227,7 @@ x_create_bitmap_from_data (struct frame *f, char *bits, unsigned int width, unsi
223#endif /* HAVE_X_WINDOWS */ 227#endif /* HAVE_X_WINDOWS */
224 228
225#ifdef HAVE_NTGUI 229#ifdef HAVE_NTGUI
230 Lisp_Object frame UNINIT; /* The value is not used. */
226 Pixmap bitmap; 231 Pixmap bitmap;
227 bitmap = CreateBitmap (width, height, 232 bitmap = CreateBitmap (width, height,
228 FRAME_DISPLAY_INFO (XFRAME (frame))->n_planes, 233 FRAME_DISPLAY_INFO (XFRAME (frame))->n_planes,
@@ -272,9 +277,9 @@ x_create_bitmap_from_file (struct frame *f, Lisp_Object file)
272{ 277{
273#ifdef HAVE_NTGUI 278#ifdef HAVE_NTGUI
274 return -1; /* W32_TODO : bitmap support */ 279 return -1; /* W32_TODO : bitmap support */
275#endif /* HAVE_NTGUI */ 280#else
276
277 Display_Info *dpyinfo = FRAME_DISPLAY_INFO (f); 281 Display_Info *dpyinfo = FRAME_DISPLAY_INFO (f);
282#endif
278 283
279#ifdef HAVE_NS 284#ifdef HAVE_NS
280 ptrdiff_t id; 285 ptrdiff_t id;
@@ -1142,7 +1147,8 @@ static RGB_PIXEL_COLOR
1142four_corners_best (XImagePtr_or_DC ximg, int *corners, 1147four_corners_best (XImagePtr_or_DC ximg, int *corners,
1143 unsigned long width, unsigned long height) 1148 unsigned long width, unsigned long height)
1144{ 1149{
1145 RGB_PIXEL_COLOR corner_pixels[4], best IF_LINT (= 0); 1150 RGB_PIXEL_COLOR corner_pixels[4];
1151 RGB_PIXEL_COLOR best UNINIT;
1146 int i, best_count; 1152 int i, best_count;
1147 1153
1148 if (corners && corners[BOT_CORNER] >= 0) 1154 if (corners && corners[BOT_CORNER] >= 0)
@@ -3158,16 +3164,18 @@ static bool xpm_load (struct frame *f, struct image *img);
3158#define XColor xpm_XColor 3164#define XColor xpm_XColor
3159#define XImage xpm_XImage 3165#define XImage xpm_XImage
3160#define Display xpm_Display 3166#define Display xpm_Display
3161#define PIXEL_ALREADY_TYPEDEFED 3167#ifdef CYGWIN
3168#include "noX/xpm.h"
3169#else /* not CYGWIN */
3162#include "X11/xpm.h" 3170#include "X11/xpm.h"
3171#endif /* not CYGWIN */
3163#undef FOR_MSW 3172#undef FOR_MSW
3164#undef XColor 3173#undef XColor
3165#undef XImage 3174#undef XImage
3166#undef Display 3175#undef Display
3167#undef PIXEL_ALREADY_TYPEDEFED 3176#else /* not HAVE_NTGUI */
3168#else
3169#include "X11/xpm.h" 3177#include "X11/xpm.h"
3170#endif /* HAVE_NTGUI */ 3178#endif /* not HAVE_NTGUI */
3171#endif /* HAVE_XPM */ 3179#endif /* HAVE_XPM */
3172 3180
3173#if defined (HAVE_XPM) || defined (HAVE_NS) 3181#if defined (HAVE_XPM) || defined (HAVE_NS)
@@ -5894,10 +5902,8 @@ struct png_load_context
5894static bool 5902static bool
5895png_load_body (struct frame *f, struct image *img, struct png_load_context *c) 5903png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
5896{ 5904{
5897 Lisp_Object specified_file; 5905 Lisp_Object specified_file, specified_data;
5898 /* IF_LINT (volatile) works around GCC bug 54561. */ 5906 FILE *fp = NULL;
5899 Lisp_Object IF_LINT (volatile) specified_data;
5900 FILE * IF_LINT (volatile) fp = NULL;
5901 int x, y; 5907 int x, y;
5902 ptrdiff_t i; 5908 ptrdiff_t i;
5903 png_struct *png_ptr; 5909 png_struct *png_ptr;
@@ -6667,9 +6673,7 @@ static bool
6667jpeg_load_body (struct frame *f, struct image *img, 6673jpeg_load_body (struct frame *f, struct image *img,
6668 struct my_jpeg_error_mgr *mgr) 6674 struct my_jpeg_error_mgr *mgr)
6669{ 6675{
6670 Lisp_Object specified_file; 6676 Lisp_Object specified_file, specified_data;
6671 /* IF_LINT (volatile) works around GCC bug 54561. */
6672 Lisp_Object IF_LINT (volatile) specified_data;
6673 FILE *volatile fp = NULL; 6677 FILE *volatile fp = NULL;
6674 JSAMPARRAY buffer; 6678 JSAMPARRAY buffer;
6675 int row_stride, x, y; 6679 int row_stride, x, y;
diff --git a/src/indent.c b/src/indent.c
index 0ef8903501d..1015259cedd 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -1162,7 +1162,7 @@ compute_motion (ptrdiff_t from, ptrdiff_t frombyte, EMACS_INT fromvpos,
1162 int prev_tab_offset; /* Previous tab offset. */ 1162 int prev_tab_offset; /* Previous tab offset. */
1163 int continuation_glyph_width; 1163 int continuation_glyph_width;
1164 struct buffer *cache_buffer = current_buffer; 1164 struct buffer *cache_buffer = current_buffer;
1165 struct region_cache *width_cache; 1165 struct region_cache *width_cache = NULL;
1166 1166
1167 struct composition_it cmp_it; 1167 struct composition_it cmp_it;
1168 1168
@@ -1170,11 +1170,14 @@ compute_motion (ptrdiff_t from, ptrdiff_t frombyte, EMACS_INT fromvpos,
1170 1170
1171 if (cache_buffer->base_buffer) 1171 if (cache_buffer->base_buffer)
1172 cache_buffer = cache_buffer->base_buffer; 1172 cache_buffer = cache_buffer->base_buffer;
1173 width_cache = width_run_cache_on_off ();
1174 if (dp == buffer_display_table ()) 1173 if (dp == buffer_display_table ())
1175 width_table = (VECTORP (BVAR (current_buffer, width_table)) 1174 {
1176 ? XVECTOR (BVAR (current_buffer, width_table))->contents 1175 width_table = (VECTORP (BVAR (current_buffer, width_table))
1177 : 0); 1176 ? XVECTOR (BVAR (current_buffer, width_table))->contents
1177 : 0);
1178 if (width_table)
1179 width_cache = width_run_cache_on_off ();
1180 }
1178 else 1181 else
1179 /* If the window has its own display table, we can't use the width 1182 /* If the window has its own display table, we can't use the width
1180 run cache, because that's based on the buffer's display table. */ 1183 run cache, because that's based on the buffer's display table. */
@@ -1995,7 +1998,7 @@ whether or not it is currently displayed in some window. */)
1995 struct text_pos pt; 1998 struct text_pos pt;
1996 struct window *w; 1999 struct window *w;
1997 Lisp_Object old_buffer; 2000 Lisp_Object old_buffer;
1998 EMACS_INT old_charpos IF_LINT (= 0), old_bytepos IF_LINT (= 0); 2001 EMACS_INT old_charpos UNINIT, old_bytepos UNINIT;
1999 Lisp_Object lcols; 2002 Lisp_Object lcols;
2000 void *itdata = NULL; 2003 void *itdata = NULL;
2001 2004
@@ -2036,8 +2039,8 @@ whether or not it is currently displayed in some window. */)
2036 bool disp_string_at_start_p = 0; 2039 bool disp_string_at_start_p = 0;
2037 ptrdiff_t nlines = XINT (lines); 2040 ptrdiff_t nlines = XINT (lines);
2038 int vpos_init = 0; 2041 int vpos_init = 0;
2039 double start_col IF_LINT (= 0); 2042 double start_col UNINIT;
2040 int start_x IF_LINT (= 0); 2043 int start_x UNINIT;
2041 int to_x = -1; 2044 int to_x = -1;
2042 2045
2043 bool start_x_given = !NILP (cur_col); 2046 bool start_x_given = !NILP (cur_col);
@@ -2178,6 +2181,7 @@ whether or not it is currently displayed in some window. */)
2178 if (nlines <= 0) 2181 if (nlines <= 0)
2179 { 2182 {
2180 it.vpos = vpos_init; 2183 it.vpos = vpos_init;
2184 it.current_y = 0;
2181 /* Do this even if LINES is 0, so that we move back to the 2185 /* Do this even if LINES is 0, so that we move back to the
2182 beginning of the current line as we ought. */ 2186 beginning of the current line as we ought. */
2183 if ((nlines < 0 && IT_CHARPOS (it) > 0) 2187 if ((nlines < 0 && IT_CHARPOS (it) > 0)
@@ -2187,6 +2191,7 @@ whether or not it is currently displayed in some window. */)
2187 else if (overshoot_handled) 2191 else if (overshoot_handled)
2188 { 2192 {
2189 it.vpos = vpos_init; 2193 it.vpos = vpos_init;
2194 it.current_y = 0;
2190 move_it_by_lines (&it, min (PTRDIFF_MAX, nlines)); 2195 move_it_by_lines (&it, min (PTRDIFF_MAX, nlines));
2191 } 2196 }
2192 else 2197 else
@@ -2200,6 +2205,7 @@ whether or not it is currently displayed in some window. */)
2200 while (IT_CHARPOS (it) <= it_start) 2205 while (IT_CHARPOS (it) <= it_start)
2201 { 2206 {
2202 it.vpos = 0; 2207 it.vpos = 0;
2208 it.current_y = 0;
2203 move_it_by_lines (&it, 1); 2209 move_it_by_lines (&it, 1);
2204 } 2210 }
2205 if (nlines > 1) 2211 if (nlines > 1)
@@ -2208,6 +2214,7 @@ whether or not it is currently displayed in some window. */)
2208 else /* it_start = ZV */ 2214 else /* it_start = ZV */
2209 { 2215 {
2210 it.vpos = 0; 2216 it.vpos = 0;
2217 it.current_y = 0;
2211 move_it_by_lines (&it, min (PTRDIFF_MAX, nlines)); 2218 move_it_by_lines (&it, min (PTRDIFF_MAX, nlines));
2212 /* We could have some display or overlay string at ZV, 2219 /* We could have some display or overlay string at ZV,
2213 in which case it.vpos will be nonzero now, while 2220 in which case it.vpos will be nonzero now, while
diff --git a/src/insdel.c b/src/insdel.c
index 4ad1074f5f7..ec7bbb3e715 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -364,6 +364,78 @@ adjust_markers_for_replace (ptrdiff_t from, ptrdiff_t from_byte,
364 check_markers (); 364 check_markers ();
365} 365}
366 366
367/* Starting at POS (BYTEPOS), find the byte position corresponding to
368 ENDPOS, which could be either before or after POS. */
369static ptrdiff_t
370count_bytes (ptrdiff_t pos, ptrdiff_t bytepos, ptrdiff_t endpos)
371{
372 eassert (BEG_BYTE <= bytepos && bytepos <= Z_BYTE
373 && BEG <= endpos && endpos <= Z);
374
375 if (pos <= endpos)
376 for ( ; pos < endpos; pos++)
377 INC_POS (bytepos);
378 else
379 for ( ; pos > endpos; pos--)
380 DEC_POS (bytepos);
381
382 return bytepos;
383}
384
385/* Adjust byte positions of markers when their character positions
386 didn't change. This is used in several places that replace text,
387 but keep the character positions of the markers unchanged -- the
388 byte positions could still change due to different numbers of bytes
389 in the new text.
390
391 FROM (FROM_BYTE) and TO (TO_BYTE) specify the region of text where
392 changes have been done. TO_Z, if non-zero, means all the markers
393 whose positions are after TO should also be adjusted. */
394void
395adjust_markers_bytepos (ptrdiff_t from, ptrdiff_t from_byte,
396 ptrdiff_t to, ptrdiff_t to_byte, int to_z)
397{
398 register struct Lisp_Marker *m;
399 ptrdiff_t beg = from, begbyte = from_byte;
400
401 adjust_suspend_auto_hscroll (from, to);
402
403 if (Z == Z_BYTE || (!to_z && to == to_byte))
404 {
405 /* Make sure each affected marker's bytepos is equal to
406 its charpos. */
407 for (m = BUF_MARKERS (current_buffer); m; m = m->next)
408 {
409 if (m->bytepos > from_byte
410 && (to_z || m->bytepos <= to_byte))
411 m->bytepos = m->charpos;
412 }
413 }
414 else
415 {
416 for (m = BUF_MARKERS (current_buffer); m; m = m->next)
417 {
418 /* Recompute each affected marker's bytepos. */
419 if (m->bytepos > from_byte
420 && (to_z || m->bytepos <= to_byte))
421 {
422 if (m->charpos < beg
423 && beg - m->charpos > m->charpos - from)
424 {
425 beg = from;
426 begbyte = from_byte;
427 }
428 m->bytepos = count_bytes (beg, begbyte, m->charpos);
429 beg = m->charpos;
430 begbyte = m->bytepos;
431 }
432 }
433 }
434
435 /* Make sure cached charpos/bytepos is invalid. */
436 clear_charpos_cache (current_buffer);
437}
438
367 439
368void 440void
369buffer_overflow (void) 441buffer_overflow (void)
@@ -1397,6 +1469,16 @@ replace_range (ptrdiff_t from, ptrdiff_t to, Lisp_Object new,
1397 if (markers) 1469 if (markers)
1398 adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del, 1470 adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del,
1399 inschars, outgoing_insbytes); 1471 inschars, outgoing_insbytes);
1472 else
1473 {
1474 /* The character positions of the markers remain intact, but we
1475 still need to update their byte positions, because the
1476 deleted and the inserted text might have multibyte sequences
1477 which make the original byte positions of the markers
1478 invalid. */
1479 adjust_markers_bytepos (from, from_byte, from + inschars,
1480 from_byte + outgoing_insbytes, 1);
1481 }
1400 1482
1401 /* Adjust the overlay center as needed. This must be done after 1483 /* Adjust the overlay center as needed. This must be done after
1402 adjusting the markers that bound the overlays. */ 1484 adjusting the markers that bound the overlays. */
@@ -1509,10 +1591,22 @@ replace_range_2 (ptrdiff_t from, ptrdiff_t from_byte,
1509 eassert (GPT <= GPT_BYTE); 1591 eassert (GPT <= GPT_BYTE);
1510 1592
1511 /* Adjust markers for the deletion and the insertion. */ 1593 /* Adjust markers for the deletion and the insertion. */
1512 if (markers 1594 if (! (nchars_del == 1 && inschars == 1 && nbytes_del == insbytes))
1513 && ! (nchars_del == 1 && inschars == 1 && nbytes_del == insbytes)) 1595 {
1514 adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del, 1596 if (markers)
1515 inschars, insbytes); 1597 adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del,
1598 inschars, insbytes);
1599 else
1600 {
1601 /* The character positions of the markers remain intact, but
1602 we still need to update their byte positions, because the
1603 deleted and the inserted text might have multibyte
1604 sequences which make the original byte positions of the
1605 markers invalid. */
1606 adjust_markers_bytepos (from, from_byte, from + inschars,
1607 from_byte + insbytes, 1);
1608 }
1609 }
1516 1610
1517 /* Adjust the overlay center as needed. This must be done after 1611 /* Adjust the overlay center as needed. This must be done after
1518 adjusting the markers that bound the overlays. */ 1612 adjusting the markers that bound the overlays. */
diff --git a/src/intervals.h b/src/intervals.h
index 6a5a4129abc..9a38d849b88 100644
--- a/src/intervals.h
+++ b/src/intervals.h
@@ -285,7 +285,7 @@ extern void set_text_properties_1 (Lisp_Object, Lisp_Object,
285Lisp_Object text_property_list (Lisp_Object, Lisp_Object, Lisp_Object, 285Lisp_Object text_property_list (Lisp_Object, Lisp_Object, Lisp_Object,
286 Lisp_Object); 286 Lisp_Object);
287void add_text_properties_from_list (Lisp_Object, Lisp_Object, Lisp_Object); 287void add_text_properties_from_list (Lisp_Object, Lisp_Object, Lisp_Object);
288Lisp_Object extend_property_ranges (Lisp_Object, Lisp_Object); 288Lisp_Object extend_property_ranges (Lisp_Object, Lisp_Object, Lisp_Object);
289Lisp_Object get_char_property_and_overlay (Lisp_Object, Lisp_Object, 289Lisp_Object get_char_property_and_overlay (Lisp_Object, Lisp_Object,
290 Lisp_Object, Lisp_Object*); 290 Lisp_Object, Lisp_Object*);
291extern int text_property_stickiness (Lisp_Object prop, Lisp_Object pos, 291extern int text_property_stickiness (Lisp_Object prop, Lisp_Object pos,
diff --git a/src/keyboard.c b/src/keyboard.c
index d2976cb7359..ed4968486c3 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -70,6 +70,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
70#include TERM_HEADER 70#include TERM_HEADER
71#endif /* HAVE_WINDOW_SYSTEM */ 71#endif /* HAVE_WINDOW_SYSTEM */
72 72
73/* Work around GCC bug 54561. */
74#if GNUC_PREREQ (4, 3, 0)
75# pragma GCC diagnostic ignored "-Wclobbered"
76#endif
77
73/* Variables for blockinput.h: */ 78/* Variables for blockinput.h: */
74 79
75/* Positive if interrupt input is blocked right now. */ 80/* Positive if interrupt input is blocked right now. */
@@ -681,9 +686,17 @@ recursive_edit_1 (void)
681 specbind (Qinhibit_redisplay, Qnil); 686 specbind (Qinhibit_redisplay, Qnil);
682 redisplaying_p = 0; 687 redisplaying_p = 0;
683 688
689 /* This variable stores buffers that have changed so that an undo
690 boundary can be added. specbind this so that changes in the
691 recursive edit will not result in undo boundaries in buffers
692 changed before we entered there recursive edit.
693 See Bug #23632.
694 */
695 specbind (Qundo_auto__undoably_changed_buffers, Qnil);
696
684 val = command_loop (); 697 val = command_loop ();
685 if (EQ (val, Qt)) 698 if (EQ (val, Qt))
686 Fsignal (Qquit, Qnil); 699 quit ();
687 /* Handle throw from read_minibuf when using minibuffer 700 /* Handle throw from read_minibuf when using minibuffer
688 while it's active but we're in another window. */ 701 while it's active but we're in another window. */
689 if (STRINGP (val)) 702 if (STRINGP (val))
@@ -2312,9 +2325,7 @@ read_char (int commandflag, Lisp_Object map,
2312 Lisp_Object prev_event, 2325 Lisp_Object prev_event,
2313 bool *used_mouse_menu, struct timespec *end_time) 2326 bool *used_mouse_menu, struct timespec *end_time)
2314{ 2327{
2315 /* IF_LINT (volatile) works around GCC bug 54561. */ 2328 Lisp_Object c;
2316 Lisp_Object IF_LINT (volatile) c;
2317
2318 ptrdiff_t jmpcount; 2329 ptrdiff_t jmpcount;
2319 sys_jmp_buf local_getcjmp; 2330 sys_jmp_buf local_getcjmp;
2320 sys_jmp_buf save_jump; 2331 sys_jmp_buf save_jump;
@@ -7570,7 +7581,7 @@ menu_item_eval_property_1 (Lisp_Object arg)
7570 /* If we got a quit from within the menu computation, 7581 /* If we got a quit from within the menu computation,
7571 quit all the way out of it. This takes care of C-] in the debugger. */ 7582 quit all the way out of it. This takes care of C-] in the debugger. */
7572 if (CONSP (arg) && EQ (XCAR (arg), Qquit)) 7583 if (CONSP (arg) && EQ (XCAR (arg), Qquit))
7573 Fsignal (Qquit, Qnil); 7584 quit ();
7574 7585
7575 return Qnil; 7586 return Qnil;
7576} 7587}
@@ -8843,7 +8854,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
8843 8854
8844 /* The length of the echo buffer when we started reading, and 8855 /* The length of the echo buffer when we started reading, and
8845 the length of this_command_keys when we started reading. */ 8856 the length of this_command_keys when we started reading. */
8846 ptrdiff_t echo_start IF_LINT (= 0); 8857 ptrdiff_t echo_start UNINIT;
8847 ptrdiff_t keys_start; 8858 ptrdiff_t keys_start;
8848 8859
8849 Lisp_Object current_binding = Qnil; 8860 Lisp_Object current_binding = Qnil;
@@ -8891,7 +8902,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
8891 While we're reading, we keep the event here. */ 8902 While we're reading, we keep the event here. */
8892 Lisp_Object delayed_switch_frame; 8903 Lisp_Object delayed_switch_frame;
8893 8904
8894 Lisp_Object original_uppercase IF_LINT (= Qnil); 8905 Lisp_Object original_uppercase UNINIT;
8895 int original_uppercase_position = -1; 8906 int original_uppercase_position = -1;
8896 8907
8897 /* Gets around Microsoft compiler limitations. */ 8908 /* Gets around Microsoft compiler limitations. */
@@ -9001,7 +9012,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9001 while those allow us to restart the entire key sequence, 9012 while those allow us to restart the entire key sequence,
9002 echo_local_start and keys_local_start allow us to throw away 9013 echo_local_start and keys_local_start allow us to throw away
9003 just one key. */ 9014 just one key. */
9004 ptrdiff_t echo_local_start IF_LINT (= 0); 9015 ptrdiff_t echo_local_start UNINIT;
9005 int keys_local_start; 9016 int keys_local_start;
9006 Lisp_Object new_binding; 9017 Lisp_Object new_binding;
9007 9018
@@ -10396,7 +10407,7 @@ handle_interrupt (bool in_signal_handler)
10396 immediate_quit = false; 10407 immediate_quit = false;
10397 pthread_sigmask (SIG_SETMASK, &empty_mask, 0); 10408 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
10398 saved = gl_state; 10409 saved = gl_state;
10399 Fsignal (Qquit, Qnil); 10410 quit ();
10400 gl_state = saved; 10411 gl_state = saved;
10401 } 10412 }
10402 else 10413 else
@@ -10982,6 +10993,8 @@ syms_of_keyboard (void)
10982 DEFSYM (Qpost_command_hook, "post-command-hook"); 10993 DEFSYM (Qpost_command_hook, "post-command-hook");
10983 10994
10984 DEFSYM (Qundo_auto__add_boundary, "undo-auto--add-boundary"); 10995 DEFSYM (Qundo_auto__add_boundary, "undo-auto--add-boundary");
10996 DEFSYM (Qundo_auto__undoably_changed_buffers,
10997 "undo-auto--undoably-changed-buffers");
10985 10998
10986 DEFSYM (Qdeferred_action_function, "deferred-action-function"); 10999 DEFSYM (Qdeferred_action_function, "deferred-action-function");
10987 DEFSYM (Qdelayed_warnings_hook, "delayed-warnings-hook"); 11000 DEFSYM (Qdelayed_warnings_hook, "delayed-warnings-hook");
diff --git a/src/keymap.c b/src/keymap.c
index 44335aded87..b27df1d0452 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -971,8 +971,18 @@ copy_keymap_1 (Lisp_Object chartable, Lisp_Object idx, Lisp_Object elt)
971 971
972DEFUN ("copy-keymap", Fcopy_keymap, Scopy_keymap, 1, 1, 0, 972DEFUN ("copy-keymap", Fcopy_keymap, Scopy_keymap, 1, 1, 0,
973 doc: /* Return a copy of the keymap KEYMAP. 973 doc: /* Return a copy of the keymap KEYMAP.
974The copy starts out with the same definitions of KEYMAP, 974
975but changing either the copy or KEYMAP does not affect the other. 975Note that this is almost never needed. If you want a keymap that's like
976another yet with a few changes, you should use map inheritance rather
977than copying. I.e. something like:
978
979 (let ((map (make-sparse-keymap)))
980 (set-keymap-parent map <theirmap>)
981 (define-key map ...)
982 ...)
983
984After performing `copy-keymap', the copy starts out with the same definitions
985of KEYMAP, but changing either the copy or KEYMAP does not affect the other.
976Any key definitions that are subkeymaps are recursively copied. 986Any key definitions that are subkeymaps are recursively copied.
977However, a key definition which is a symbol whose definition is a keymap 987However, a key definition which is a symbol whose definition is a keymap
978is not copied. */) 988is not copied. */)
diff --git a/src/lisp.h b/src/lisp.h
index 4042f4decb1..089f3977cd2 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -88,7 +88,11 @@ typedef unsigned long EMACS_UINT;
88typedef long long int EMACS_INT; 88typedef long long int EMACS_INT;
89typedef unsigned long long int EMACS_UINT; 89typedef unsigned long long int EMACS_UINT;
90# define EMACS_INT_MAX LLONG_MAX 90# define EMACS_INT_MAX LLONG_MAX
91# define pI "ll" 91# ifdef __MINGW32__
92# define pI "I64"
93# else
94# define pI "ll"
95# endif
92# else 96# else
93# error "INTPTR_MAX too large" 97# error "INTPTR_MAX too large"
94# endif 98# endif
@@ -1748,7 +1752,7 @@ struct Lisp_Subr
1748 short min_args, max_args; 1752 short min_args, max_args;
1749 const char *symbol_name; 1753 const char *symbol_name;
1750 const char *intspec; 1754 const char *intspec;
1751 const char *doc; 1755 EMACS_INT doc;
1752 }; 1756 };
1753 1757
1754enum char_table_specials 1758enum char_table_specials
@@ -3524,6 +3528,8 @@ extern void adjust_after_insert (ptrdiff_t, ptrdiff_t, ptrdiff_t,
3524 ptrdiff_t, ptrdiff_t); 3528 ptrdiff_t, ptrdiff_t);
3525extern void adjust_markers_for_delete (ptrdiff_t, ptrdiff_t, 3529extern void adjust_markers_for_delete (ptrdiff_t, ptrdiff_t,
3526 ptrdiff_t, ptrdiff_t); 3530 ptrdiff_t, ptrdiff_t);
3531extern void adjust_markers_bytepos (ptrdiff_t, ptrdiff_t,
3532 ptrdiff_t, ptrdiff_t, int);
3527extern void replace_range (ptrdiff_t, ptrdiff_t, Lisp_Object, bool, bool, bool); 3533extern void replace_range (ptrdiff_t, ptrdiff_t, Lisp_Object, bool, bool, bool);
3528extern void replace_range_2 (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, 3534extern void replace_range_2 (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t,
3529 const char *, ptrdiff_t, ptrdiff_t, bool); 3535 const char *, ptrdiff_t, ptrdiff_t, bool);
@@ -3873,7 +3879,12 @@ extern void run_hook_with_args_2 (Lisp_Object, Lisp_Object, Lisp_Object);
3873extern Lisp_Object run_hook_with_args (ptrdiff_t nargs, Lisp_Object *args, 3879extern Lisp_Object run_hook_with_args (ptrdiff_t nargs, Lisp_Object *args,
3874 Lisp_Object (*funcall) 3880 Lisp_Object (*funcall)
3875 (ptrdiff_t nargs, Lisp_Object *args)); 3881 (ptrdiff_t nargs, Lisp_Object *args));
3876extern _Noreturn void xsignal (Lisp_Object, Lisp_Object); 3882extern Lisp_Object quit (void);
3883INLINE _Noreturn void
3884xsignal (Lisp_Object error_symbol, Lisp_Object data)
3885{
3886 Fsignal (error_symbol, data);
3887}
3877extern _Noreturn void xsignal0 (Lisp_Object); 3888extern _Noreturn void xsignal0 (Lisp_Object);
3878extern _Noreturn void xsignal1 (Lisp_Object, Lisp_Object); 3889extern _Noreturn void xsignal1 (Lisp_Object, Lisp_Object);
3879extern _Noreturn void xsignal2 (Lisp_Object, Lisp_Object, Lisp_Object); 3890extern _Noreturn void xsignal2 (Lisp_Object, Lisp_Object, Lisp_Object);
@@ -4131,6 +4142,7 @@ INLINE void fixup_locale (void) {}
4131INLINE void synchronize_system_messages_locale (void) {} 4142INLINE void synchronize_system_messages_locale (void) {}
4132INLINE void synchronize_system_time_locale (void) {} 4143INLINE void synchronize_system_time_locale (void) {}
4133#endif 4144#endif
4145extern char *emacs_strerror (int);
4134extern void shut_down_emacs (int, Lisp_Object); 4146extern void shut_down_emacs (int, Lisp_Object);
4135 4147
4136/* True means don't do interactive redisplay and don't change tty modes. */ 4148/* True means don't do interactive redisplay and don't change tty modes. */
@@ -4167,8 +4179,8 @@ extern void kill_buffer_processes (Lisp_Object);
4167extern int wait_reading_process_output (intmax_t, int, int, bool, Lisp_Object, 4179extern int wait_reading_process_output (intmax_t, int, int, bool, Lisp_Object,
4168 struct Lisp_Process *, int); 4180 struct Lisp_Process *, int);
4169/* Max value for the first argument of wait_reading_process_output. */ 4181/* Max value for the first argument of wait_reading_process_output. */
4170#if __GNUC__ == 3 || (__GNUC__ == 4 && __GNUC_MINOR__ <= 5) 4182#if GNUC_PREREQ (3, 0, 0) && ! GNUC_PREREQ (4, 6, 0)
4171/* Work around a bug in GCC 3.4.2, known to be fixed in GCC 4.6.3. 4183/* Work around a bug in GCC 3.4.2, known to be fixed in GCC 4.6.0.
4172 The bug merely causes a bogus warning, but the warning is annoying. */ 4184 The bug merely causes a bogus warning, but the warning is annoying. */
4173# define WAIT_READING_MAX min (TYPE_MAXIMUM (time_t), INTMAX_MAX) 4185# define WAIT_READING_MAX min (TYPE_MAXIMUM (time_t), INTMAX_MAX)
4174#else 4186#else
@@ -4254,6 +4266,12 @@ struct tty_display_info;
4254struct terminal; 4266struct terminal;
4255 4267
4256/* Defined in sysdep.c. */ 4268/* Defined in sysdep.c. */
4269#ifdef HAVE_PERSONALITY_ADDR_NO_RANDOMIZE
4270extern bool disable_address_randomization (void);
4271#else
4272INLINE bool disable_address_randomization (void) { return false; }
4273#endif
4274extern int emacs_exec_file (char const *, char *const *, char *const *);
4257extern void init_standard_fds (void); 4275extern void init_standard_fds (void);
4258extern char *emacs_get_current_dir_name (void); 4276extern char *emacs_get_current_dir_name (void);
4259extern void stuff_char (char c); 4277extern void stuff_char (char c);
@@ -4541,8 +4559,7 @@ extern void *record_xmalloc (size_t) ATTRIBUTE_ALLOC_SIZE ((1));
4541 Build with CPPFLAGS='-DUSE_STACK_LISP_OBJECTS=0' to disable it. */ 4559 Build with CPPFLAGS='-DUSE_STACK_LISP_OBJECTS=0' to disable it. */
4542 4560
4543#if (!defined USE_STACK_LISP_OBJECTS \ 4561#if (!defined USE_STACK_LISP_OBJECTS \
4544 && defined __GNUC__ && !defined __clang__ \ 4562 && defined __GNUC__ && !defined __clang__ && ! GNUC_PREREQ (4, 3, 2))
4545 && !(4 < __GNUC__ + (3 < __GNUC_MINOR__ + (2 <= __GNUC_PATCHLEVEL__))))
4546 /* Work around GCC bugs 36584 and 35271, which were fixed in GCC 4.3.2. */ 4563 /* Work around GCC bugs 36584 and 35271, which were fixed in GCC 4.3.2. */
4547# define USE_STACK_LISP_OBJECTS false 4564# define USE_STACK_LISP_OBJECTS false
4548#endif 4565#endif
diff --git a/src/lread.c b/src/lread.c
index 98a4d69894b..ecd482793a9 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -36,7 +36,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
36#include "character.h" 36#include "character.h"
37#include "buffer.h" 37#include "buffer.h"
38#include "charset.h" 38#include "charset.h"
39#include "coding.h"
40#include <epaths.h> 39#include <epaths.h>
41#include "commands.h" 40#include "commands.h"
42#include "keyboard.h" 41#include "keyboard.h"
@@ -1040,7 +1039,7 @@ Return t if the file exists and loads successfully. */)
1040{ 1039{
1041 FILE *stream; 1040 FILE *stream;
1042 int fd; 1041 int fd;
1043 int fd_index; 1042 int fd_index UNINIT;
1044 ptrdiff_t count = SPECPDL_INDEX (); 1043 ptrdiff_t count = SPECPDL_INDEX ();
1045 Lisp_Object found, efound, hist_file_name; 1044 Lisp_Object found, efound, hist_file_name;
1046 /* True means we printed the ".el is newer" message. */ 1045 /* True means we printed the ".el is newer" message. */
@@ -1156,12 +1155,7 @@ Return t if the file exists and loads successfully. */)
1156#endif 1155#endif
1157 } 1156 }
1158 1157
1159 if (fd < 0) 1158 if (0 <= fd)
1160 {
1161 /* Pacify older GCC with --enable-gcc-warnings. */
1162 IF_LINT (fd_index = 0);
1163 }
1164 else
1165 { 1159 {
1166 fd_index = SPECPDL_INDEX (); 1160 fd_index = SPECPDL_INDEX ();
1167 record_unwind_protect_int (close_file_unwind, fd); 1161 record_unwind_protect_int (close_file_unwind, fd);
@@ -1210,7 +1204,11 @@ Return t if the file exists and loads successfully. */)
1210 specbind (Qold_style_backquotes, Qnil); 1204 specbind (Qold_style_backquotes, Qnil);
1211 record_unwind_protect (load_warn_old_style_backquotes, file); 1205 record_unwind_protect (load_warn_old_style_backquotes, file);
1212 1206
1213 if (suffix_p (found, ".elc") || (fd >= 0 && (version = safe_to_load_version (fd)) > 0)) 1207 int is_elc;
1208 if ((is_elc = suffix_p (found, ".elc")) != 0
1209 /* version = 1 means the file is empty, in which case we can
1210 treat it as not byte-compiled. */
1211 || (fd >= 0 && (version = safe_to_load_version (fd)) > 1))
1214 /* Load .elc files directly, but not when they are 1212 /* Load .elc files directly, but not when they are
1215 remote and have no handler! */ 1213 remote and have no handler! */
1216 { 1214 {
@@ -1237,7 +1235,7 @@ Return t if the file exists and loads successfully. */)
1237 /* openp already checked for newness, no point doing it again. 1235 /* openp already checked for newness, no point doing it again.
1238 FIXME would be nice to get a message when openp 1236 FIXME would be nice to get a message when openp
1239 ignores suffix order due to load_prefer_newer. */ 1237 ignores suffix order due to load_prefer_newer. */
1240 if (!load_prefer_newer) 1238 if (!load_prefer_newer && is_elc)
1241 { 1239 {
1242 result = stat (SSDATA (efound), &s1); 1240 result = stat (SSDATA (efound), &s1);
1243 if (result == 0) 1241 if (result == 0)
@@ -1466,6 +1464,8 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes,
1466 1464
1467 for (; CONSP (path); path = XCDR (path)) 1465 for (; CONSP (path); path = XCDR (path))
1468 { 1466 {
1467 ptrdiff_t baselen, prefixlen;
1468
1469 filename = Fexpand_file_name (str, XCAR (path)); 1469 filename = Fexpand_file_name (str, XCAR (path));
1470 if (!complete_filename_p (filename)) 1470 if (!complete_filename_p (filename))
1471 /* If there are non-absolute elts in PATH (eg "."). */ 1471 /* If there are non-absolute elts in PATH (eg "."). */
@@ -1487,6 +1487,14 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes,
1487 fn = SAFE_ALLOCA (fn_size); 1487 fn = SAFE_ALLOCA (fn_size);
1488 } 1488 }
1489 1489
1490 /* Copy FILENAME's data to FN but remove starting /: if any. */
1491 prefixlen = ((SCHARS (filename) > 2
1492 && SREF (filename, 0) == '/'
1493 && SREF (filename, 1) == ':')
1494 ? 2 : 0);
1495 baselen = SBYTES (filename) - prefixlen;
1496 memcpy (fn, SDATA (filename) + prefixlen, baselen);
1497
1490 /* Loop over suffixes. */ 1498 /* Loop over suffixes. */
1491 for (tail = NILP (suffixes) ? list1 (empty_unibyte_string) : suffixes; 1499 for (tail = NILP (suffixes) ? list1 (empty_unibyte_string) : suffixes;
1492 CONSP (tail); tail = XCDR (tail)) 1500 CONSP (tail); tail = XCDR (tail))
@@ -1495,16 +1503,10 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes,
1495 ptrdiff_t fnlen, lsuffix = SBYTES (suffix); 1503 ptrdiff_t fnlen, lsuffix = SBYTES (suffix);
1496 Lisp_Object handler; 1504 Lisp_Object handler;
1497 1505
1498 /* Concatenate path element/specified name with the suffix. 1506 /* Make complete filename by appending SUFFIX. */
1499 If the directory starts with /:, remove that. */ 1507 memcpy (fn + baselen, SDATA (suffix), lsuffix + 1);
1500 int prefixlen = ((SCHARS (filename) > 2 1508 fnlen = baselen + lsuffix;
1501 && SREF (filename, 0) == '/' 1509
1502 && SREF (filename, 1) == ':')
1503 ? 2 : 0);
1504 fnlen = SBYTES (filename) - prefixlen;
1505 memcpy (fn, SDATA (filename) + prefixlen, fnlen);
1506 memcpy (fn + fnlen, SDATA (suffix), lsuffix + 1);
1507 fnlen += lsuffix;
1508 /* Check that the file exists and is not a directory. */ 1510 /* Check that the file exists and is not a directory. */
1509 /* We used to only check for handlers on non-absolute file names: 1511 /* We used to only check for handlers on non-absolute file names:
1510 if (absolute) 1512 if (absolute)
@@ -4489,18 +4491,24 @@ void
4489dir_warning (char const *use, Lisp_Object dirname) 4491dir_warning (char const *use, Lisp_Object dirname)
4490{ 4492{
4491 static char const format[] = "Warning: %s '%s': %s\n"; 4493 static char const format[] = "Warning: %s '%s': %s\n";
4492 int access_errno = errno; 4494 char *diagnostic = emacs_strerror (errno);
4493 fprintf (stderr, format, use, SSDATA (ENCODE_SYSTEM (dirname)), 4495 fprintf (stderr, format, use, SSDATA (ENCODE_SYSTEM (dirname)), diagnostic);
4494 strerror (access_errno));
4495 4496
4496 /* Don't log the warning before we've initialized!! */ 4497 /* Don't log the warning before we've initialized!! */
4497 if (initialized) 4498 if (initialized)
4498 { 4499 {
4499 char const *diagnostic = emacs_strerror (access_errno); 4500 ptrdiff_t diaglen = strlen (diagnostic);
4501 AUTO_STRING_WITH_LEN (diag, diagnostic, diaglen);
4502 if (! NILP (Vlocale_coding_system))
4503 {
4504 Lisp_Object s
4505 = code_convert_string_norecord (diag, Vlocale_coding_system, false);
4506 diagnostic = SSDATA (s);
4507 diaglen = SBYTES (s);
4508 }
4500 USE_SAFE_ALLOCA; 4509 USE_SAFE_ALLOCA;
4501 char *buffer = SAFE_ALLOCA (sizeof format - 3 * (sizeof "%s" - 1) 4510 char *buffer = SAFE_ALLOCA (sizeof format - 3 * (sizeof "%s" - 1)
4502 + strlen (use) + SBYTES (dirname) 4511 + strlen (use) + SBYTES (dirname) + diaglen);
4503 + strlen (diagnostic));
4504 ptrdiff_t message_len = esprintf (buffer, format, use, SSDATA (dirname), 4512 ptrdiff_t message_len = esprintf (buffer, format, use, SSDATA (dirname),
4505 diagnostic); 4513 diagnostic);
4506 message_dolog (buffer, message_len, 0, STRING_MULTIBYTE (dirname)); 4514 message_dolog (buffer, message_len, 0, STRING_MULTIBYTE (dirname));
diff --git a/src/macfont.m b/src/macfont.m
index 79001344769..c799100c855 100644
--- a/src/macfont.m
+++ b/src/macfont.m
@@ -2856,8 +2856,8 @@ macfont_draw (struct glyph_string *s, int from, int to, int x, int y,
2856 { 2856 {
2857 if (s->hl == DRAW_MOUSE_FACE) 2857 if (s->hl == DRAW_MOUSE_FACE)
2858 { 2858 {
2859 face = FACE_OPT_FROM_ID (s->f, 2859 face = FACE_FROM_ID_OR_NULL (s->f,
2860 MOUSE_HL_INFO (s->f)->mouse_face_face_id); 2860 MOUSE_HL_INFO (s->f)->mouse_face_face_id);
2861 if (!face) 2861 if (!face)
2862 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID); 2862 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
2863 } 2863 }
@@ -3767,6 +3767,7 @@ mac_font_shape (CTFontRef font, CFStringRef string,
3767 { 3767 {
3768 struct mac_glyph_layout *gl; 3768 struct mac_glyph_layout *gl;
3769 CGPoint position; 3769 CGPoint position;
3770 CGFloat max_x;
3770 3771
3771 if (!RIGHT_TO_LEFT_P) 3772 if (!RIGHT_TO_LEFT_P)
3772 gl = glbuf + range.location; 3773 gl = glbuf + range.location;
@@ -3788,12 +3789,13 @@ mac_font_shape (CTFontRef font, CFStringRef string,
3788 CTRunGetGlyphs (ctrun, range, &gl->glyph_id); 3789 CTRunGetGlyphs (ctrun, range, &gl->glyph_id);
3789 3790
3790 CTRunGetPositions (ctrun, range, &position); 3791 CTRunGetPositions (ctrun, range, &position);
3792 max_x = position.x + CTRunGetTypographicBounds (ctrun, range,
3793 NULL, NULL, NULL);
3794 max_x = max (max_x, total_advance);
3791 gl->advance_delta = position.x - total_advance; 3795 gl->advance_delta = position.x - total_advance;
3792 gl->baseline_delta = position.y; 3796 gl->baseline_delta = position.y;
3793 gl->advance = (gl->advance_delta 3797 gl->advance = max_x - total_advance;
3794 + CTRunGetTypographicBounds (ctrun, range, 3798 total_advance = max_x;
3795 NULL, NULL, NULL));
3796 total_advance += gl->advance;
3797 } 3799 }
3798 3800
3799 if (RIGHT_TO_LEFT_P) 3801 if (RIGHT_TO_LEFT_P)
diff --git a/src/menu.c b/src/menu.c
index e3d943e109f..90bb19a2e94 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -42,11 +42,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
42#endif /* HAVE_WINDOW_SYSTEM */ 42#endif /* HAVE_WINDOW_SYSTEM */
43 43
44#ifdef HAVE_NTGUI 44#ifdef HAVE_NTGUI
45# ifdef NTGUI_UNICODE
46# define unicode_append_menu AppendMenuW
47# else /* !NTGUI_UNICODE */
48extern AppendMenuW_Proc unicode_append_menu; 45extern AppendMenuW_Proc unicode_append_menu;
49# endif /* NTGUI_UNICODE */
50#endif /* HAVE_NTGUI */ 46#endif /* HAVE_NTGUI */
51 47
52#include "menu.h" 48#include "menu.h"
diff --git a/src/minibuf.c b/src/minibuf.c
index 75831618ea5..57eea05b0fc 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -194,7 +194,7 @@ read_minibuf_noninteractive (Lisp_Object map, Lisp_Object initial,
194 int c; 194 int c;
195 unsigned char hide_char = 0; 195 unsigned char hide_char = 0;
196 struct emacs_tty etty; 196 struct emacs_tty etty;
197 bool etty_valid IF_LINT (= false); 197 bool etty_valid UNINIT;
198 198
199 /* Check, whether we need to suppress echoing. */ 199 /* Check, whether we need to suppress echoing. */
200 if (CHARACTERP (Vread_hide_char)) 200 if (CHARACTERP (Vread_hide_char))
@@ -1686,6 +1686,8 @@ the values STRING, PREDICATE and `lambda'. */)
1686 tem = Fassoc_string (string, collection, completion_ignore_case ? Qt : Qnil); 1686 tem = Fassoc_string (string, collection, completion_ignore_case ? Qt : Qnil);
1687 if (NILP (tem)) 1687 if (NILP (tem))
1688 return Qnil; 1688 return Qnil;
1689 else if (CONSP (tem))
1690 tem = XCAR (tem);
1689 } 1691 }
1690 else if (VECTORP (collection)) 1692 else if (VECTORP (collection))
1691 { 1693 {
@@ -1838,8 +1840,8 @@ DEFUN ("assoc-string", Fassoc_string, Sassoc_string, 2, 3, 0,
1838This returns the first element of LIST whose car matches the string or 1840This returns the first element of LIST whose car matches the string or
1839symbol KEY, or nil if no match exists. When performing the 1841symbol KEY, or nil if no match exists. When performing the
1840comparison, symbols are first converted to strings, and unibyte 1842comparison, symbols are first converted to strings, and unibyte
1841strings to multibyte. If the optional arg CASE-FOLD is non-nil, case 1843strings to multibyte. If the optional arg CASE-FOLD is non-nil, both
1842is ignored. 1844KEY and the elements of LIST are upcased for comparison.
1843 1845
1844Unlike `assoc', KEY can also match an entry in LIST consisting of a 1846Unlike `assoc', KEY can also match an entry in LIST consisting of a
1845single string, rather than a cons cell whose car is a string. */) 1847single string, rather than a cons cell whose car is a string. */)
diff --git a/src/msdos.c b/src/msdos.c
index c2b19a65173..73d755ae646 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -795,8 +795,8 @@ static void
795IT_set_face (int face) 795IT_set_face (int face)
796{ 796{
797 struct frame *sf = SELECTED_FRAME (); 797 struct frame *sf = SELECTED_FRAME ();
798 struct face *fp = FACE_OPT_FROM_ID (sf, face); 798 struct face *fp = FACE_FROM_ID_OR_NULL (sf, face);
799 struct face *dfp = FACE_OPT_FROM_ID (sf, DEFAULT_FACE_ID); 799 struct face *dfp = FACE_FROM_ID_OR_NULL (sf, DEFAULT_FACE_ID);
800 unsigned long fg, bg, dflt_fg, dflt_bg; 800 unsigned long fg, bg, dflt_fg, dflt_bg;
801 struct tty_display_info *tty = FRAME_TTY (sf); 801 struct tty_display_info *tty = FRAME_TTY (sf);
802 802
@@ -1076,7 +1076,7 @@ IT_clear_screen (struct frame *f)
1076 any valid faces and will abort. Instead, use the initial screen 1076 any valid faces and will abort. Instead, use the initial screen
1077 colors; that should mimic what a Unix tty does, which simply clears 1077 colors; that should mimic what a Unix tty does, which simply clears
1078 the screen with whatever default colors are in use. */ 1078 the screen with whatever default colors are in use. */
1079 if (FACE_OPT_FROM_ID (SELECTED_FRAME (), DEFAULT_FACE_ID) == NULL) 1079 if (FACE_FROM_ID_OR_NULL (SELECTED_FRAME (), DEFAULT_FACE_ID) == NULL)
1080 ScreenAttrib = (initial_screen_colors[0] << 4) | initial_screen_colors[1]; 1080 ScreenAttrib = (initial_screen_colors[0] << 4) | initial_screen_colors[1];
1081 else 1081 else
1082 IT_set_face (0); 1082 IT_set_face (0);
diff --git a/src/nsfns.m b/src/nsfns.m
index 9bc6c1d3418..051e5091919 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -726,9 +726,9 @@ x_set_internal_border_width (struct frame *f, Lisp_Object arg, Lisp_Object oldva
726 int old_width = FRAME_INTERNAL_BORDER_WIDTH (f); 726 int old_width = FRAME_INTERNAL_BORDER_WIDTH (f);
727 727
728 CHECK_TYPE_RANGED_INTEGER (int, arg); 728 CHECK_TYPE_RANGED_INTEGER (int, arg);
729 FRAME_INTERNAL_BORDER_WIDTH (f) = XINT (arg); 729 f->internal_border_width = XINT (arg);
730 if (FRAME_INTERNAL_BORDER_WIDTH (f) < 0) 730 if (FRAME_INTERNAL_BORDER_WIDTH (f) < 0)
731 FRAME_INTERNAL_BORDER_WIDTH (f) = 0; 731 f->internal_border_width = 0;
732 732
733 if (FRAME_INTERNAL_BORDER_WIDTH (f) == old_width) 733 if (FRAME_INTERNAL_BORDER_WIDTH (f) == old_width)
734 return; 734 return;
@@ -983,8 +983,8 @@ frame_parm_handler ns_frame_parm_handlers[] =
983 x_set_icon_name, 983 x_set_icon_name,
984 x_set_icon_type, 984 x_set_icon_type,
985 x_set_internal_border_width, /* generic OK */ 985 x_set_internal_border_width, /* generic OK */
986 0, /* x_set_right_divider_width */ 986 x_set_right_divider_width,
987 0, /* x_set_bottom_divider_width */ 987 x_set_bottom_divider_width,
988 x_set_menu_bar_lines, 988 x_set_menu_bar_lines,
989 x_set_mouse_color, 989 x_set_mouse_color,
990 x_explicitly_set_name, 990 x_explicitly_set_name,
diff --git a/src/nsfont.m b/src/nsfont.m
index 7c97c6fd0ae..569a69f9fe8 100644
--- a/src/nsfont.m
+++ b/src/nsfont.m
@@ -1071,7 +1071,8 @@ nsfont_draw (struct glyph_string *s, int from, int to, int x, int y,
1071 face = s->face; 1071 face = s->face;
1072 break; 1072 break;
1073 case NS_DUMPGLYPH_MOUSEFACE: 1073 case NS_DUMPGLYPH_MOUSEFACE:
1074 face = FACE_OPT_FROM_ID (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id); 1074 face = FACE_FROM_ID_OR_NULL (s->f,
1075 MOUSE_HL_INFO (s->f)->mouse_face_face_id);
1075 if (!face) 1076 if (!face)
1076 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID); 1077 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
1077 break; 1078 break;
diff --git a/src/nsmenu.m b/src/nsmenu.m
index 7d340e8ec83..d1f4b020bb0 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -136,12 +136,6 @@ ns_update_menubar (struct frame *f, bool deep_p, EmacsMenu *submenu)
136 menu = [[EmacsMenu alloc] initWithTitle: ns_app_name]; 136 menu = [[EmacsMenu alloc] initWithTitle: ns_app_name];
137 needsSet = YES; 137 needsSet = YES;
138 } 138 }
139 else
140 { /* close up anything on there */
141 id attMenu = [menu attachedMenu];
142 if (attMenu != nil)
143 [attMenu close];
144 }
145 139
146#if NSMENUPROFILE 140#if NSMENUPROFILE
147 ftime (&tb); 141 ftime (&tb);
@@ -1426,29 +1420,19 @@ update_frame_tool_bar (struct frame *f)
1426 1420
1427 ========================================================================== */ 1421 ========================================================================== */
1428 1422
1429struct Popdown_data
1430{
1431 NSAutoreleasePool *pool;
1432 EmacsDialogPanel *dialog;
1433};
1434
1435static void 1423static void
1436pop_down_menu (void *arg) 1424pop_down_menu (void *arg)
1437{ 1425{
1438 struct Popdown_data *unwind_data = arg; 1426 EmacsDialogPanel *panel = arg;
1439 1427
1440 block_input ();
1441 if (popup_activated_flag) 1428 if (popup_activated_flag)
1442 { 1429 {
1443 EmacsDialogPanel *panel = unwind_data->dialog; 1430 block_input ();
1444 popup_activated_flag = 0; 1431 popup_activated_flag = 0;
1445 [panel close]; 1432 [panel close];
1446 [unwind_data->pool release];
1447 [[FRAME_NS_VIEW (SELECTED_FRAME ()) window] makeKeyWindow]; 1433 [[FRAME_NS_VIEW (SELECTED_FRAME ()) window] makeKeyWindow];
1434 unblock_input ();
1448 } 1435 }
1449
1450 xfree (unwind_data);
1451 unblock_input ();
1452} 1436}
1453 1437
1454 1438
@@ -1459,7 +1443,6 @@ ns_popup_dialog (struct frame *f, Lisp_Object header, Lisp_Object contents)
1459 Lisp_Object tem, title; 1443 Lisp_Object tem, title;
1460 NSPoint p; 1444 NSPoint p;
1461 BOOL isQ; 1445 BOOL isQ;
1462 NSAutoreleasePool *pool;
1463 1446
1464 NSTRACE ("ns_popup_dialog"); 1447 NSTRACE ("ns_popup_dialog");
1465 1448
@@ -1479,18 +1462,13 @@ ns_popup_dialog (struct frame *f, Lisp_Object header, Lisp_Object contents)
1479 contents = list2 (title, Fcons (build_string ("Ok"), Qt)); 1462 contents = list2 (title, Fcons (build_string ("Ok"), Qt));
1480 1463
1481 block_input (); 1464 block_input ();
1482 pool = [[NSAutoreleasePool alloc] init];
1483 dialog = [[EmacsDialogPanel alloc] initFromContents: contents 1465 dialog = [[EmacsDialogPanel alloc] initFromContents: contents
1484 isQuestion: isQ]; 1466 isQuestion: isQ];
1485 1467
1486 { 1468 {
1487 ptrdiff_t specpdl_count = SPECPDL_INDEX (); 1469 ptrdiff_t specpdl_count = SPECPDL_INDEX ();
1488 struct Popdown_data *unwind_data = xmalloc (sizeof (*unwind_data));
1489
1490 unwind_data->pool = pool;
1491 unwind_data->dialog = dialog;
1492 1470
1493 record_unwind_protect_ptr (pop_down_menu, unwind_data); 1471 record_unwind_protect_ptr (pop_down_menu, dialog);
1494 popup_activated_flag = 1; 1472 popup_activated_flag = 1;
1495 tem = [dialog runDialogAt: p]; 1473 tem = [dialog runDialogAt: p];
1496 unbind_to (specpdl_count, Qnil); /* calls pop_down_menu */ 1474 unbind_to (specpdl_count, Qnil); /* calls pop_down_menu */
@@ -1865,7 +1843,7 @@ ns_popup_dialog (struct frame *f, Lisp_Object header, Lisp_Object contents)
1865 1843
1866 if (EQ (ret, Qundefined) && window_closed) 1844 if (EQ (ret, Qundefined) && window_closed)
1867 /* Make close button pressed equivalent to C-g. */ 1845 /* Make close button pressed equivalent to C-g. */
1868 Fsignal (Qquit, Qnil); 1846 quit ();
1869 1847
1870 return ret; 1848 return ret;
1871} 1849}
diff --git a/src/nsterm.h b/src/nsterm.h
index c2285c90e62..862ff2ec646 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -1014,7 +1014,7 @@ struct x_output
1014#define FRAME_NS_TITLEBAR_HEIGHT(f) ((f)->output_data.ns->titlebar_height) 1014#define FRAME_NS_TITLEBAR_HEIGHT(f) ((f)->output_data.ns->titlebar_height)
1015#define FRAME_TOOLBAR_HEIGHT(f) ((f)->output_data.ns->toolbar_height) 1015#define FRAME_TOOLBAR_HEIGHT(f) ((f)->output_data.ns->toolbar_height)
1016 1016
1017#define FRAME_DEFAULT_FACE(f) FACE_OPT_FROM_ID (f, DEFAULT_FACE_ID) 1017#define FRAME_DEFAULT_FACE(f) FACE_FROM_ID_OR_NULL (f, DEFAULT_FACE_ID)
1018 1018
1019#define FRAME_NS_VIEW(f) ((f)->output_data.ns->view) 1019#define FRAME_NS_VIEW(f) ((f)->output_data.ns->view)
1020#define FRAME_CURSOR_COLOR(f) ((f)->output_data.ns->cursor_color) 1020#define FRAME_CURSOR_COLOR(f) ((f)->output_data.ns->cursor_color)
diff --git a/src/nsterm.m b/src/nsterm.m
index f2b0d901770..8da2ffe5b7f 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -2861,7 +2861,10 @@ ns_draw_window_cursor (struct window *w, struct glyph_row *glyph_row,
2861 { 2861 {
2862 if (cursor_width < 1) 2862 if (cursor_width < 1)
2863 cursor_width = max (FRAME_CURSOR_WIDTH (f), 1); 2863 cursor_width = max (FRAME_CURSOR_WIDTH (f), 1);
2864 w->phys_cursor_width = cursor_width; 2864
2865 /* The bar cursor should never be wider than the glyph. */
2866 if (cursor_width < w->phys_cursor_width)
2867 w->phys_cursor_width = cursor_width;
2865 } 2868 }
2866 /* If we have an HBAR, "cursor_width" MAY specify height. */ 2869 /* If we have an HBAR, "cursor_width" MAY specify height. */
2867 else if (cursor_type == HBAR_CURSOR) 2870 else if (cursor_type == HBAR_CURSOR)
@@ -2882,7 +2885,7 @@ ns_draw_window_cursor (struct window *w, struct glyph_row *glyph_row,
2882 ns_clip_to_row (w, glyph_row, TEXT_AREA, NO); /* do ns_focus(f, &r, 1); if remove */ 2885 ns_clip_to_row (w, glyph_row, TEXT_AREA, NO); /* do ns_focus(f, &r, 1); if remove */
2883 2886
2884 2887
2885 face = FACE_OPT_FROM_ID (f, phys_cursor_glyph->face_id); 2888 face = FACE_FROM_ID_OR_NULL (f, phys_cursor_glyph->face_id);
2886 if (face && NS_FACE_BACKGROUND (face) 2889 if (face && NS_FACE_BACKGROUND (face)
2887 == ns_index_color (FRAME_CURSOR_COLOR (f), f)) 2890 == ns_index_color (FRAME_CURSOR_COLOR (f), f))
2888 { 2891 {
@@ -2954,11 +2957,12 @@ ns_draw_vertical_window_border (struct window *w, int x, int y0, int y1)
2954 2957
2955 NSTRACE ("ns_draw_vertical_window_border"); 2958 NSTRACE ("ns_draw_vertical_window_border");
2956 2959
2957 face = FACE_OPT_FROM_ID (f, VERTICAL_BORDER_FACE_ID); 2960 face = FACE_FROM_ID_OR_NULL (f, VERTICAL_BORDER_FACE_ID);
2958 if (face)
2959 [ns_lookup_indexed_color(face->foreground, f) set];
2960 2961
2961 ns_focus (f, &r, 1); 2962 ns_focus (f, &r, 1);
2963 if (face)
2964 [ns_lookup_indexed_color(face->foreground, f) set];
2965
2962 NSRectFill(r); 2966 NSRectFill(r);
2963 ns_unfocus (f); 2967 ns_unfocus (f);
2964} 2968}
@@ -2976,11 +2980,12 @@ ns_draw_window_divider (struct window *w, int x0, int x1, int y0, int y1)
2976 2980
2977 NSTRACE ("ns_draw_window_divider"); 2981 NSTRACE ("ns_draw_window_divider");
2978 2982
2979 face = FACE_OPT_FROM_ID (f, WINDOW_DIVIDER_FACE_ID); 2983 face = FACE_FROM_ID_OR_NULL (f, WINDOW_DIVIDER_FACE_ID);
2980 if (face)
2981 [ns_lookup_indexed_color(face->foreground, f) set];
2982 2984
2983 ns_focus (f, &r, 1); 2985 ns_focus (f, &r, 1);
2986 if (face)
2987 [ns_lookup_indexed_color(face->foreground, f) set];
2988
2984 NSRectFill(r); 2989 NSRectFill(r);
2985 ns_unfocus (f); 2990 ns_unfocus (f);
2986} 2991}
@@ -3309,9 +3314,10 @@ ns_dumpglyphs_box_or_relief (struct glyph_string *s)
3309 3314
3310 if (s->hl == DRAW_MOUSE_FACE) 3315 if (s->hl == DRAW_MOUSE_FACE)
3311 { 3316 {
3312 face = FACE_OPT_FROM_ID (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id); 3317 face = FACE_FROM_ID_OR_NULL (s->f,
3318 MOUSE_HL_INFO (s->f)->mouse_face_face_id);
3313 if (!face) 3319 if (!face)
3314 face = FACE_OPT_FROM_ID (s->f, MOUSE_FACE_ID); 3320 face = FACE_FROM_ID_OR_NULL (s->f, MOUSE_FACE_ID);
3315 } 3321 }
3316 else 3322 else
3317 face = s->face; 3323 face = s->face;
@@ -3377,8 +3383,8 @@ ns_maybe_dumpglyphs_background (struct glyph_string *s, char force_p)
3377 if (s->hl == DRAW_MOUSE_FACE) 3383 if (s->hl == DRAW_MOUSE_FACE)
3378 { 3384 {
3379 face 3385 face
3380 = FACE_OPT_FROM_ID (s->f, 3386 = FACE_FROM_ID_OR_NULL (s->f,
3381 MOUSE_HL_INFO (s->f)->mouse_face_face_id); 3387 MOUSE_HL_INFO (s->f)->mouse_face_face_id);
3382 if (!face) 3388 if (!face)
3383 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID); 3389 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
3384 } 3390 }
@@ -3444,7 +3450,8 @@ ns_dumpglyphs_image (struct glyph_string *s, NSRect r)
3444 with its background color), we must clear just the image area. */ 3450 with its background color), we must clear just the image area. */
3445 if (s->hl == DRAW_MOUSE_FACE) 3451 if (s->hl == DRAW_MOUSE_FACE)
3446 { 3452 {
3447 face = FACE_OPT_FROM_ID (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id); 3453 face = FACE_FROM_ID_OR_NULL (s->f,
3454 MOUSE_HL_INFO (s->f)->mouse_face_face_id);
3448 if (!face) 3455 if (!face)
3449 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID); 3456 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
3450 } 3457 }
@@ -3561,8 +3568,8 @@ ns_dumpglyphs_stretch (struct glyph_string *s)
3561 3568
3562 if (s->hl == DRAW_MOUSE_FACE) 3569 if (s->hl == DRAW_MOUSE_FACE)
3563 { 3570 {
3564 face = FACE_OPT_FROM_ID (s->f, 3571 face = FACE_FROM_ID_OR_NULL (s->f,
3565 MOUSE_HL_INFO (s->f)->mouse_face_face_id); 3572 MOUSE_HL_INFO (s->f)->mouse_face_face_id);
3566 if (!face) 3573 if (!face)
3567 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID); 3574 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
3568 } 3575 }
@@ -3640,6 +3647,32 @@ ns_dumpglyphs_stretch (struct glyph_string *s)
3640 3647
3641 3648
3642static void 3649static void
3650ns_draw_glyph_string_foreground (struct glyph_string *s)
3651{
3652 int x, flags;
3653 struct font *font = s->font;
3654
3655 /* If first glyph of S has a left box line, start drawing the text
3656 of S to the right of that box line. */
3657 if (s->face && s->face->box != FACE_NO_BOX
3658 && s->first_glyph->left_box_line_p)
3659 x = s->x + eabs (s->face->box_line_width);
3660 else
3661 x = s->x;
3662
3663 flags = s->hl == DRAW_CURSOR ? NS_DUMPGLYPH_CURSOR :
3664 (s->hl == DRAW_MOUSE_FACE ? NS_DUMPGLYPH_MOUSEFACE :
3665 (s->for_overlaps ? NS_DUMPGLYPH_FOREGROUND :
3666 NS_DUMPGLYPH_NORMAL));
3667
3668 font->driver->draw
3669 (s, s->cmp_from, s->nchars, x, s->ybase,
3670 (flags == NS_DUMPGLYPH_NORMAL && !s->background_filled_p)
3671 || flags == NS_DUMPGLYPH_MOUSEFACE);
3672}
3673
3674
3675static void
3643ns_draw_composite_glyph_string_foreground (struct glyph_string *s) 3676ns_draw_composite_glyph_string_foreground (struct glyph_string *s)
3644{ 3677{
3645 int i, j, x; 3678 int i, j, x;
@@ -3737,7 +3770,7 @@ ns_draw_glyph_string (struct glyph_string *s)
3737{ 3770{
3738 /* TODO (optimize): focus for box and contents draw */ 3771 /* TODO (optimize): focus for box and contents draw */
3739 NSRect r[2]; 3772 NSRect r[2];
3740 int n, flags; 3773 int n;
3741 char box_drawn_p = 0; 3774 char box_drawn_p = 0;
3742 struct font *font = s->face->font; 3775 struct font *font = s->face->font;
3743 if (! font) font = FRAME_FONT (s->f); 3776 if (! font) font = FRAME_FONT (s->f);
@@ -3807,11 +3840,6 @@ ns_draw_glyph_string (struct glyph_string *s)
3807 ns_maybe_dumpglyphs_background 3840 ns_maybe_dumpglyphs_background
3808 (s, s->first_glyph->type == COMPOSITE_GLYPH); 3841 (s, s->first_glyph->type == COMPOSITE_GLYPH);
3809 3842
3810 flags = s->hl == DRAW_CURSOR ? NS_DUMPGLYPH_CURSOR :
3811 (s->hl == DRAW_MOUSE_FACE ? NS_DUMPGLYPH_MOUSEFACE :
3812 (s->for_overlaps ? NS_DUMPGLYPH_FOREGROUND :
3813 NS_DUMPGLYPH_NORMAL));
3814
3815 if (s->hl == DRAW_CURSOR && s->w->phys_cursor_type == FILLED_BOX_CURSOR) 3843 if (s->hl == DRAW_CURSOR && s->w->phys_cursor_type == FILLED_BOX_CURSOR)
3816 { 3844 {
3817 unsigned long tmp = NS_FACE_BACKGROUND (s->face); 3845 unsigned long tmp = NS_FACE_BACKGROUND (s->face);
@@ -3825,10 +3853,7 @@ ns_draw_glyph_string (struct glyph_string *s)
3825 if (isComposite) 3853 if (isComposite)
3826 ns_draw_composite_glyph_string_foreground (s); 3854 ns_draw_composite_glyph_string_foreground (s);
3827 else 3855 else
3828 font->driver->draw 3856 ns_draw_glyph_string_foreground (s);
3829 (s, s->cmp_from, s->nchars, s->x, s->ybase,
3830 (flags == NS_DUMPGLYPH_NORMAL && !s->background_filled_p)
3831 || flags == NS_DUMPGLYPH_MOUSEFACE);
3832 } 3857 }
3833 3858
3834 { 3859 {
@@ -4076,6 +4101,9 @@ ns_read_socket (struct terminal *terminal, struct input_event *hold_quit)
4076 4101
4077 NSTRACE_WHEN (NSTRACE_GROUP_EVENTS, "ns_read_socket"); 4102 NSTRACE_WHEN (NSTRACE_GROUP_EVENTS, "ns_read_socket");
4078 4103
4104 if (apploopnr > 0)
4105 return -1; /* Already within event loop. */
4106
4079#ifdef HAVE_NATIVE_FS 4107#ifdef HAVE_NATIVE_FS
4080 check_native_fs (); 4108 check_native_fs ();
4081#endif 4109#endif
@@ -4160,6 +4188,9 @@ ns_select (int nfds, fd_set *readfds, fd_set *writefds,
4160 4188
4161 NSTRACE_WHEN (NSTRACE_GROUP_EVENTS, "ns_select"); 4189 NSTRACE_WHEN (NSTRACE_GROUP_EVENTS, "ns_select");
4162 4190
4191 if (apploopnr > 0)
4192 return -1; /* Already within event loop. */
4193
4163#ifdef HAVE_NATIVE_FS 4194#ifdef HAVE_NATIVE_FS
4164 check_native_fs (); 4195 check_native_fs ();
4165#endif 4196#endif
@@ -6169,8 +6200,14 @@ not_in_argv (NSString *arg)
6169 +FRAME_LINE_HEIGHT (emacsframe)); 6200 +FRAME_LINE_HEIGHT (emacsframe));
6170 6201
6171 pt = [self convertPoint: pt toView: nil]; 6202 pt = [self convertPoint: pt toView: nil];
6203#if !defined (NS_IMPL_COCOA) || \
6204 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
6172 pt = [[self window] convertBaseToScreen: pt]; 6205 pt = [[self window] convertBaseToScreen: pt];
6173 rect.origin = pt; 6206 rect.origin = pt;
6207#else
6208 rect.origin = pt;
6209 rect = [[self window] convertRectToScreen: rect];
6210#endif
6174 return rect; 6211 return rect;
6175} 6212}
6176 6213
diff --git a/src/print.c b/src/print.c
index 83edbb6bfa4..5531210e1b8 100644
--- a/src/print.c
+++ b/src/print.c
@@ -203,7 +203,7 @@ print_unwind (Lisp_Object saved_text)
203static void 203static void
204printchar_to_stream (unsigned int ch, FILE *stream) 204printchar_to_stream (unsigned int ch, FILE *stream)
205{ 205{
206 Lisp_Object dv IF_LINT (= Qnil); 206 Lisp_Object dv UNINIT;
207 ptrdiff_t i = 0, n = 1; 207 ptrdiff_t i = 0, n = 1;
208 Lisp_Object coding_system = Vlocale_coding_system; 208 Lisp_Object coding_system = Vlocale_coding_system;
209 bool encode_p = false; 209 bool encode_p = false;
diff --git a/src/process.c b/src/process.c
index 9ca3e594355..bc2ac451c9d 100644
--- a/src/process.c
+++ b/src/process.c
@@ -130,10 +130,10 @@ extern int sys_select (int, fd_set *, fd_set *, fd_set *,
130 struct timespec *, void *); 130 struct timespec *, void *);
131#endif 131#endif
132 132
133/* Work around GCC 4.7.0 bug with strict overflow checking; see 133/* Work around GCC 4.3.0 bug with strict overflow checking; see
134 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52904>. 134 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52904>.
135 This bug appears to be fixed in GCC 5.1, so don't work around it there. */ 135 This bug appears to be fixed in GCC 5.1, so don't work around it there. */
136#if __GNUC__ == 4 && __GNUC_MINOR__ >= 3 136#if GNUC_PREREQ (4, 3, 0) && ! GNUC_PREREQ (5, 1, 0)
137# pragma GCC diagnostic ignored "-Wstrict-overflow" 137# pragma GCC diagnostic ignored "-Wstrict-overflow"
138#endif 138#endif
139 139
@@ -533,25 +533,37 @@ status_convert (int w)
533 return Qrun; 533 return Qrun;
534} 534}
535 535
536/* True if STATUS is that of a process attempting connection. */
537
538static bool
539connecting_status (Lisp_Object status)
540{
541 return CONSP (status) && EQ (XCAR (status), Qconnect);
542}
543
536/* Given a status-list, extract the three pieces of information 544/* Given a status-list, extract the three pieces of information
537 and store them individually through the three pointers. */ 545 and store them individually through the three pointers. */
538 546
539static void 547static void
540decode_status (Lisp_Object l, Lisp_Object *symbol, int *code, bool *coredump) 548decode_status (Lisp_Object l, Lisp_Object *symbol, Lisp_Object *code,
549 bool *coredump)
541{ 550{
542 Lisp_Object tem; 551 Lisp_Object tem;
543 552
553 if (connecting_status (l))
554 l = XCAR (l);
555
544 if (SYMBOLP (l)) 556 if (SYMBOLP (l))
545 { 557 {
546 *symbol = l; 558 *symbol = l;
547 *code = 0; 559 *code = make_number (0);
548 *coredump = 0; 560 *coredump = 0;
549 } 561 }
550 else 562 else
551 { 563 {
552 *symbol = XCAR (l); 564 *symbol = XCAR (l);
553 tem = XCDR (l); 565 tem = XCDR (l);
554 *code = XFASTINT (XCAR (tem)); 566 *code = XCAR (tem);
555 tem = XCDR (tem); 567 tem = XCDR (tem);
556 *coredump = !NILP (tem); 568 *coredump = !NILP (tem);
557 } 569 }
@@ -563,8 +575,7 @@ static Lisp_Object
563status_message (struct Lisp_Process *p) 575status_message (struct Lisp_Process *p)
564{ 576{
565 Lisp_Object status = p->status; 577 Lisp_Object status = p->status;
566 Lisp_Object symbol; 578 Lisp_Object symbol, code;
567 int code;
568 bool coredump; 579 bool coredump;
569 Lisp_Object string; 580 Lisp_Object string;
570 581
@@ -574,7 +585,7 @@ status_message (struct Lisp_Process *p)
574 { 585 {
575 char const *signame; 586 char const *signame;
576 synchronize_system_messages_locale (); 587 synchronize_system_messages_locale ();
577 signame = strsignal (code); 588 signame = strsignal (XFASTINT (code));
578 if (signame == 0) 589 if (signame == 0)
579 string = build_string ("unknown"); 590 string = build_string ("unknown");
580 else 591 else
@@ -596,20 +607,20 @@ status_message (struct Lisp_Process *p)
596 else if (EQ (symbol, Qexit)) 607 else if (EQ (symbol, Qexit))
597 { 608 {
598 if (NETCONN1_P (p)) 609 if (NETCONN1_P (p))
599 return build_string (code == 0 ? "deleted\n" : "connection broken by remote peer\n"); 610 return build_string (XFASTINT (code) == 0
600 if (code == 0) 611 ? "deleted\n"
612 : "connection broken by remote peer\n");
613 if (XFASTINT (code) == 0)
601 return build_string ("finished\n"); 614 return build_string ("finished\n");
602 AUTO_STRING (prefix, "exited abnormally with code "); 615 AUTO_STRING (prefix, "exited abnormally with code ");
603 string = Fnumber_to_string (make_number (code)); 616 string = Fnumber_to_string (code);
604 AUTO_STRING (suffix, coredump ? " (core dumped)\n" : "\n"); 617 AUTO_STRING (suffix, coredump ? " (core dumped)\n" : "\n");
605 return concat3 (prefix, string, suffix); 618 return concat3 (prefix, string, suffix);
606 } 619 }
607 else if (EQ (symbol, Qfailed)) 620 else if (EQ (symbol, Qfailed))
608 { 621 {
609 AUTO_STRING (prefix, "failed with code "); 622 AUTO_STRING (format, "failed with code %s\n");
610 string = Fnumber_to_string (make_number (code)); 623 return CALLN (Fformat, format, code);
611 AUTO_STRING (suffix, "\n");
612 return concat3 (prefix, string, suffix);
613 } 624 }
614 else 625 else
615 return Fcopy_sequence (Fsymbol_name (symbol)); 626 return Fcopy_sequence (Fsymbol_name (symbol));
@@ -3174,6 +3185,8 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos,
3174 xerrno = errno; 3185 xerrno = errno;
3175 emacs_close (s); 3186 emacs_close (s);
3176 s = -1; 3187 s = -1;
3188 if (socket_to_use < 0)
3189 break;
3177 continue; 3190 continue;
3178 } 3191 }
3179 } 3192 }
@@ -3288,9 +3301,10 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos,
3288 eassert (FD_ISSET (s, &fdset)); 3301 eassert (FD_ISSET (s, &fdset));
3289 if (getsockopt (s, SOL_SOCKET, SO_ERROR, &xerrno, &len) < 0) 3302 if (getsockopt (s, SOL_SOCKET, SO_ERROR, &xerrno, &len) < 0)
3290 report_file_error ("Failed getsockopt", Qnil); 3303 report_file_error ("Failed getsockopt", Qnil);
3291 if (xerrno) 3304 if (xerrno == 0)
3305 break;
3306 if (NILP (addrinfos))
3292 report_file_errno ("Failed connect", Qnil, xerrno); 3307 report_file_errno ("Failed connect", Qnil, xerrno);
3293 break;
3294 } 3308 }
3295#endif /* !WINDOWSNT */ 3309#endif /* !WINDOWSNT */
3296 3310
@@ -3300,6 +3314,8 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos,
3300 specpdl_ptr = specpdl + count1; 3314 specpdl_ptr = specpdl + count1;
3301 emacs_close (s); 3315 emacs_close (s);
3302 s = -1; 3316 s = -1;
3317 if (socket_to_use < 0)
3318 break;
3303 3319
3304#ifdef WINDOWSNT 3320#ifdef WINDOWSNT
3305 if (xerrno == EINTR) 3321 if (xerrno == EINTR)
@@ -3399,7 +3415,9 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos,
3399 /* We may get here if connect did succeed immediately. However, 3415 /* We may get here if connect did succeed immediately. However,
3400 in that case, we still need to signal this like a non-blocking 3416 in that case, we still need to signal this like a non-blocking
3401 connection. */ 3417 connection. */
3402 pset_status (p, Qconnect); 3418 if (! (connecting_status (p->status)
3419 && EQ (XCDR (p->status), addrinfos)))
3420 pset_status (p, Fcons (Qconnect, addrinfos));
3403 if (!FD_ISSET (inch, &connect_wait_mask)) 3421 if (!FD_ISSET (inch, &connect_wait_mask))
3404 { 3422 {
3405 FD_SET (inch, &connect_wait_mask); 3423 FD_SET (inch, &connect_wait_mask);
@@ -3960,7 +3978,7 @@ usage: (make-network-process &rest ARGS) */)
3960 if (!p->is_server && NILP (addrinfos)) 3978 if (!p->is_server && NILP (addrinfos))
3961 { 3979 {
3962 p->dns_request = dns_request; 3980 p->dns_request = dns_request;
3963 p->status = Qconnect; 3981 p->status = list1 (Qconnect);
3964 return proc; 3982 return proc;
3965 } 3983 }
3966#endif 3984#endif
@@ -4673,7 +4691,7 @@ check_for_dns (Lisp_Object proc)
4673 addrinfos = Fnreverse (addrinfos); 4691 addrinfos = Fnreverse (addrinfos);
4674 } 4692 }
4675 /* The DNS lookup failed. */ 4693 /* The DNS lookup failed. */
4676 else if (EQ (p->status, Qconnect)) 4694 else if (connecting_status (p->status))
4677 { 4695 {
4678 deactivate_process (proc); 4696 deactivate_process (proc);
4679 pset_status (p, (list2 4697 pset_status (p, (list2
@@ -4686,7 +4704,7 @@ check_for_dns (Lisp_Object proc)
4686 free_dns_request (proc); 4704 free_dns_request (proc);
4687 4705
4688 /* This process should not already be connected (or killed). */ 4706 /* This process should not already be connected (or killed). */
4689 if (!EQ (p->status, Qconnect)) 4707 if (! connecting_status (p->status))
4690 return Qnil; 4708 return Qnil;
4691 4709
4692 return addrinfos; 4710 return addrinfos;
@@ -4698,7 +4716,7 @@ static void
4698wait_for_socket_fds (Lisp_Object process, char const *name) 4716wait_for_socket_fds (Lisp_Object process, char const *name)
4699{ 4717{
4700 while (XPROCESS (process)->infd < 0 4718 while (XPROCESS (process)->infd < 0
4701 && EQ (XPROCESS (process)->status, Qconnect)) 4719 && connecting_status (XPROCESS (process)->status))
4702 { 4720 {
4703 add_to_log ("Waiting for socket from %s...", build_string (name)); 4721 add_to_log ("Waiting for socket from %s...", build_string (name));
4704 wait_reading_process_output (0, 20 * 1000 * 1000, 0, 0, Qnil, NULL, 0); 4722 wait_reading_process_output (0, 20 * 1000 * 1000, 0, 0, Qnil, NULL, 0);
@@ -4708,7 +4726,7 @@ wait_for_socket_fds (Lisp_Object process, char const *name)
4708static void 4726static void
4709wait_while_connecting (Lisp_Object process) 4727wait_while_connecting (Lisp_Object process)
4710{ 4728{
4711 while (EQ (XPROCESS (process)->status, Qconnect)) 4729 while (connecting_status (XPROCESS (process)->status))
4712 { 4730 {
4713 add_to_log ("Waiting for connection..."); 4731 add_to_log ("Waiting for connection...");
4714 wait_reading_process_output (0, 20 * 1000 * 1000, 0, 0, Qnil, NULL, 0); 4732 wait_reading_process_output (0, 20 * 1000 * 1000, 0, 0, Qnil, NULL, 0);
@@ -5010,7 +5028,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
5010 update_status (wait_proc); 5028 update_status (wait_proc);
5011 if (wait_proc 5029 if (wait_proc
5012 && ! EQ (wait_proc->status, Qrun) 5030 && ! EQ (wait_proc->status, Qrun)
5013 && ! EQ (wait_proc->status, Qconnect)) 5031 && ! connecting_status (wait_proc->status))
5014 { 5032 {
5015 bool read_some_bytes = false; 5033 bool read_some_bytes = false;
5016 5034
@@ -5255,16 +5273,22 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
5255 haven't lowered our timeout due to timers or SIGIO and 5273 haven't lowered our timeout due to timers or SIGIO and
5256 have waited a long amount of time due to repeated 5274 have waited a long amount of time due to repeated
5257 timers. */ 5275 timers. */
5276 struct timespec huge_timespec
5277 = make_timespec (TYPE_MAXIMUM (time_t), 2 * TIMESPEC_RESOLUTION);
5278 struct timespec cmp_time = huge_timespec;
5258 if (wait < TIMEOUT) 5279 if (wait < TIMEOUT)
5259 break; 5280 break;
5260 struct timespec cmp_time 5281 if (wait == TIMEOUT)
5261 = (wait == TIMEOUT 5282 cmp_time = end_time;
5262 ? end_time 5283 if (!process_skipped && got_some_output > 0
5263 : (!process_skipped && got_some_output > 0 5284 && (timeout.tv_sec > 0 || timeout.tv_nsec > 0))
5264 && (timeout.tv_sec > 0 || timeout.tv_nsec > 0)) 5285 {
5265 ? got_output_end_time 5286 if (!timespec_valid_p (got_output_end_time))
5266 : invalid_timespec ()); 5287 break;
5267 if (timespec_valid_p (cmp_time)) 5288 if (timespec_cmp (got_output_end_time, cmp_time) < 0)
5289 cmp_time = got_output_end_time;
5290 }
5291 if (timespec_cmp (cmp_time, huge_timespec) < 0)
5268 { 5292 {
5269 now = current_timespec (); 5293 now = current_timespec ();
5270 if (timespec_cmp (cmp_time, now) <= 0) 5294 if (timespec_cmp (cmp_time, now) <= 0)
@@ -5492,15 +5516,16 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
5492 5516
5493 p = XPROCESS (proc); 5517 p = XPROCESS (proc);
5494 5518
5495#ifdef GNU_LINUX 5519#ifndef WINDOWSNT
5496 /* getsockopt(,,SO_ERROR,,) is said to hang on some systems.
5497 So only use it on systems where it is known to work. */
5498 { 5520 {
5499 socklen_t xlen = sizeof (xerrno); 5521 socklen_t xlen = sizeof (xerrno);
5500 if (getsockopt (channel, SOL_SOCKET, SO_ERROR, &xerrno, &xlen)) 5522 if (getsockopt (channel, SOL_SOCKET, SO_ERROR, &xerrno, &xlen))
5501 xerrno = errno; 5523 xerrno = errno;
5502 } 5524 }
5503#else 5525#else
5526 /* On MS-Windows, getsockopt clears the error for the
5527 entire process, which may not be the right thing; see
5528 w32.c. Use getpeername instead. */
5504 { 5529 {
5505 struct sockaddr pname; 5530 struct sockaddr pname;
5506 socklen_t pnamelen = sizeof (pname); 5531 socklen_t pnamelen = sizeof (pname);
@@ -5519,9 +5544,18 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
5519#endif 5544#endif
5520 if (xerrno) 5545 if (xerrno)
5521 { 5546 {
5522 p->tick = ++process_tick; 5547 Lisp_Object addrinfos
5523 pset_status (p, list2 (Qfailed, make_number (xerrno))); 5548 = connecting_status (p->status) ? XCDR (p->status) : Qnil;
5549 if (!NILP (addrinfos))
5550 XSETCDR (p->status, XCDR (addrinfos));
5551 else
5552 {
5553 p->tick = ++process_tick;
5554 pset_status (p, list2 (Qfailed, make_number (xerrno)));
5555 }
5524 deactivate_process (proc); 5556 deactivate_process (proc);
5557 if (!NILP (addrinfos))
5558 connect_network_socket (proc, addrinfos, Qnil);
5525 } 5559 }
5526 else 5560 else
5527 { 5561 {
@@ -6998,7 +7032,7 @@ status_notify (struct Lisp_Process *deleting_process,
6998 7032
6999 /* If process is still active, read any output that remains. */ 7033 /* If process is still active, read any output that remains. */
7000 while (! EQ (p->filter, Qt) 7034 while (! EQ (p->filter, Qt)
7001 && ! EQ (p->status, Qconnect) 7035 && ! connecting_status (p->status)
7002 && ! EQ (p->status, Qlisten) 7036 && ! EQ (p->status, Qlisten)
7003 /* Network or serial process not stopped: */ 7037 /* Network or serial process not stopped: */
7004 && ! EQ (p->command, Qt) 7038 && ! EQ (p->command, Qt)
diff --git a/src/process.h b/src/process.h
index a5f690dc55f..6c227bc2266 100644
--- a/src/process.h
+++ b/src/process.h
@@ -83,7 +83,10 @@ struct Lisp_Process
83 Lisp_Object mark; 83 Lisp_Object mark;
84 84
85 /* Symbol indicating status of process. 85 /* Symbol indicating status of process.
86 This may be a symbol: run, open, or closed. 86 This may be a symbol: run, open, closed, listen, or failed.
87 Or it may be a pair (connect . ADDRINFOS) where ADDRINFOS is
88 a list of remaining (PROTOCOL . ADDRINFO) pairs to try.
89 Or it may be (failed ERR) where ERR is an integer, string or symbol.
87 Or it may be a list, whose car is stop, exit or signal 90 Or it may be a list, whose car is stop, exit or signal
88 and whose cdr is a pair (EXIT_CODE . COREDUMP_FLAG) 91 and whose cdr is a pair (EXIT_CODE . COREDUMP_FLAG)
89 or (SIGNAL_NUMBER . COREDUMP_FLAG). */ 92 or (SIGNAL_NUMBER . COREDUMP_FLAG). */
diff --git a/src/regex.c b/src/regex.c
index fc2a46fd5a3..1f2a1f086de 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -783,44 +783,6 @@ extract_number_and_incr (re_char **source)
783 and end. */ 783 and end. */
784#define CHARSET_RANGE_TABLE_END(range_table, count) \ 784#define CHARSET_RANGE_TABLE_END(range_table, count) \
785 ((range_table) + (count) * 2 * 3) 785 ((range_table) + (count) * 2 * 3)
786
787/* Test if C is in RANGE_TABLE. A flag NOT is negated if C is in.
788 COUNT is number of ranges in RANGE_TABLE. */
789#define CHARSET_LOOKUP_RANGE_TABLE_RAW(not, c, range_table, count) \
790 do \
791 { \
792 re_wchar_t range_start, range_end; \
793 re_char *rtp; \
794 re_char *range_table_end \
795 = CHARSET_RANGE_TABLE_END ((range_table), (count)); \
796 \
797 for (rtp = (range_table); rtp < range_table_end; rtp += 2 * 3) \
798 { \
799 EXTRACT_CHARACTER (range_start, rtp); \
800 EXTRACT_CHARACTER (range_end, rtp + 3); \
801 \
802 if (range_start <= (c) && (c) <= range_end) \
803 { \
804 (not) = !(not); \
805 break; \
806 } \
807 } \
808 } \
809 while (0)
810
811/* Test if C is in range table of CHARSET. The flag NOT is negated if
812 C is listed in it. */
813#define CHARSET_LOOKUP_RANGE_TABLE(not, c, charset) \
814 do \
815 { \
816 /* Number of ranges in range table. */ \
817 int count; \
818 re_char *range_table = CHARSET_RANGE_TABLE (charset); \
819 \
820 EXTRACT_NUMBER_AND_INCR (count, range_table); \
821 CHARSET_LOOKUP_RANGE_TABLE_RAW ((not), (c), range_table, count); \
822 } \
823 while (0)
824 786
825/* If DEBUG is defined, Regex prints many voluminous messages about what 787/* If DEBUG is defined, Regex prints many voluminous messages about what
826 it is doing (if the variable `debug' is nonzero). If linked with the 788 it is doing (if the variable `debug' is nonzero). If linked with the
@@ -4661,6 +4623,93 @@ skip_noops (const_re_char *p, const_re_char *pend)
4661 return p; 4623 return p;
4662} 4624}
4663 4625
4626/* Test if C matches charset op. *PP points to the charset or chraset_not
4627 opcode. When the function finishes, *PP will be advanced past that opcode.
4628 C is character to test (possibly after translations) and CORIG is original
4629 character (i.e. without any translations). UNIBYTE denotes whether c is
4630 unibyte or multibyte character. */
4631static bool
4632execute_charset (const_re_char **pp, unsigned c, unsigned corig, bool unibyte)
4633{
4634 re_char *p = *pp, *rtp = NULL;
4635 bool not = (re_opcode_t) *p == charset_not;
4636
4637 if (CHARSET_RANGE_TABLE_EXISTS_P (p))
4638 {
4639 int count;
4640 rtp = CHARSET_RANGE_TABLE (p);
4641 EXTRACT_NUMBER_AND_INCR (count, rtp);
4642 *pp = CHARSET_RANGE_TABLE_END ((rtp), (count));
4643 }
4644 else
4645 *pp += 2 + CHARSET_BITMAP_SIZE (p);
4646
4647 if (unibyte && c < (1 << BYTEWIDTH))
4648 { /* Lookup bitmap. */
4649 /* Cast to `unsigned' instead of `unsigned char' in
4650 case the bit list is a full 32 bytes long. */
4651 if (c < (unsigned) (CHARSET_BITMAP_SIZE (p) * BYTEWIDTH)
4652 && p[2 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH)))
4653 return !not;
4654 }
4655#ifdef emacs
4656 else if (rtp)
4657 {
4658 int class_bits = CHARSET_RANGE_TABLE_BITS (p);
4659 re_wchar_t range_start, range_end;
4660
4661 /* Sort tests by the most commonly used classes with some adjustment to which
4662 tests are easiest to perform. Frequencies of character class names used in
4663 Emacs sources as of 2016-07-15:
4664
4665 $ find \( -name \*.c -o -name \*.el \) -exec grep -h '\[:[a-z]*:]' {} + |
4666 sed 's/]/]\n/g' |grep -o '\[:[a-z]*:]' |sort |uniq -c |sort -nr
4667 213 [:alnum:]
4668 104 [:alpha:]
4669 62 [:space:]
4670 39 [:digit:]
4671 36 [:blank:]
4672 26 [:upper:]
4673 24 [:word:]
4674 21 [:lower:]
4675 10 [:punct:]
4676 10 [:ascii:]
4677 9 [:xdigit:]
4678 4 [:nonascii:]
4679 4 [:graph:]
4680 2 [:print:]
4681 2 [:cntrl:]
4682 1 [:ff:]
4683 */
4684
4685 if ((class_bits & BIT_MULTIBYTE) ||
4686 (class_bits & BIT_ALNUM && ISALNUM (c)) ||
4687 (class_bits & BIT_ALPHA && ISALPHA (c)) ||
4688 (class_bits & BIT_SPACE && ISSPACE (c)) ||
4689 (class_bits & BIT_WORD && ISWORD (c)) ||
4690 ((class_bits & BIT_UPPER) &&
4691 (ISUPPER (c) || (corig != c &&
4692 c == downcase (corig) && ISLOWER (c)))) ||
4693 ((class_bits & BIT_LOWER) &&
4694 (ISLOWER (c) || (corig != c &&
4695 c == upcase (corig) && ISUPPER(c)))) ||
4696 (class_bits & BIT_PUNCT && ISPUNCT (c)) ||
4697 (class_bits & BIT_GRAPH && ISGRAPH (c)) ||
4698 (class_bits & BIT_PRINT && ISPRINT (c)))
4699 return !not;
4700
4701 for (p = *pp; rtp < p; rtp += 2 * 3)
4702 {
4703 EXTRACT_CHARACTER (range_start, rtp);
4704 EXTRACT_CHARACTER (range_end, rtp + 3);
4705 if (range_start <= c && c <= range_end)
4706 return !not;
4707 }
4708 }
4709#endif /* emacs */
4710 return not;
4711}
4712
4664/* Non-zero if "p1 matches something" implies "p2 fails". */ 4713/* Non-zero if "p1 matches something" implies "p2 fails". */
4665static int 4714static int
4666mutually_exclusive_p (struct re_pattern_buffer *bufp, const_re_char *p1, 4715mutually_exclusive_p (struct re_pattern_buffer *bufp, const_re_char *p1,
@@ -4718,22 +4767,7 @@ mutually_exclusive_p (struct re_pattern_buffer *bufp, const_re_char *p1,
4718 else if ((re_opcode_t) *p1 == charset 4767 else if ((re_opcode_t) *p1 == charset
4719 || (re_opcode_t) *p1 == charset_not) 4768 || (re_opcode_t) *p1 == charset_not)
4720 { 4769 {
4721 int not = (re_opcode_t) *p1 == charset_not; 4770 if (!execute_charset (&p1, c, c, !multibyte || IS_REAL_ASCII (c)))
4722
4723 /* Test if C is listed in charset (or charset_not)
4724 at `p1'. */
4725 if (! multibyte || IS_REAL_ASCII (c))
4726 {
4727 if (c < CHARSET_BITMAP_SIZE (p1) * BYTEWIDTH
4728 && p1[2 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH)))
4729 not = !not;
4730 }
4731 else if (CHARSET_RANGE_TABLE_EXISTS_P (p1))
4732 CHARSET_LOOKUP_RANGE_TABLE (not, c, p1);
4733
4734 /* `not' is equal to 1 if c would match, which means
4735 that we can't change to pop_failure_jump. */
4736 if (!not)
4737 { 4771 {
4738 DEBUG_PRINT (" No match => fast loop.\n"); 4772 DEBUG_PRINT (" No match => fast loop.\n");
4739 return 1; 4773 return 1;
@@ -5439,32 +5473,13 @@ re_match_2_internal (struct re_pattern_buffer *bufp, const_re_char *string1,
5439 case charset_not: 5473 case charset_not:
5440 { 5474 {
5441 register unsigned int c, corig; 5475 register unsigned int c, corig;
5442 boolean not = (re_opcode_t) *(p - 1) == charset_not;
5443 int len; 5476 int len;
5444 5477
5445 /* Start of actual range_table, or end of bitmap if there is no
5446 range table. */
5447 re_char *range_table IF_LINT (= NULL);
5448
5449 /* Nonzero if there is a range table. */
5450 int range_table_exists;
5451
5452 /* Number of ranges of range table. This is not included
5453 in the initial byte-length of the command. */
5454 int count = 0;
5455
5456 /* Whether matching against a unibyte character. */ 5478 /* Whether matching against a unibyte character. */
5457 boolean unibyte_char = false; 5479 boolean unibyte_char = false;
5458 5480
5459 DEBUG_PRINT ("EXECUTING charset%s.\n", not ? "_not" : ""); 5481 DEBUG_PRINT ("EXECUTING charset%s.\n",
5460 5482 (re_opcode_t) *(p - 1) == charset_not ? "_not" : "");
5461 range_table_exists = CHARSET_RANGE_TABLE_EXISTS_P (&p[-1]);
5462
5463 if (range_table_exists)
5464 {
5465 range_table = CHARSET_RANGE_TABLE (&p[-1]); /* Past the bitmap. */
5466 EXTRACT_NUMBER_AND_INCR (count, range_table);
5467 }
5468 5483
5469 PREFETCH (); 5484 PREFETCH ();
5470 corig = c = RE_STRING_CHAR_AND_LENGTH (d, len, target_multibyte); 5485 corig = c = RE_STRING_CHAR_AND_LENGTH (d, len, target_multibyte);
@@ -5498,47 +5513,9 @@ re_match_2_internal (struct re_pattern_buffer *bufp, const_re_char *string1,
5498 unibyte_char = true; 5513 unibyte_char = true;
5499 } 5514 }
5500 5515
5501 if (unibyte_char && c < (1 << BYTEWIDTH)) 5516 p -= 1;
5502 { /* Lookup bitmap. */ 5517 if (!execute_charset (&p, c, corig, unibyte_char))
5503 /* Cast to `unsigned' instead of `unsigned char' in 5518 goto fail;
5504 case the bit list is a full 32 bytes long. */
5505 if (c < (unsigned) (CHARSET_BITMAP_SIZE (&p[-1]) * BYTEWIDTH)
5506 && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH)))
5507 not = !not;
5508 }
5509#ifdef emacs
5510 else if (range_table_exists)
5511 {
5512 int class_bits = CHARSET_RANGE_TABLE_BITS (&p[-1]);
5513
5514 if ( (class_bits & BIT_LOWER
5515 && (ISLOWER (c)
5516 || (corig != c
5517 && c == upcase (corig) && ISUPPER(c))))
5518 | (class_bits & BIT_MULTIBYTE)
5519 | (class_bits & BIT_PUNCT && ISPUNCT (c))
5520 | (class_bits & BIT_SPACE && ISSPACE (c))
5521 | (class_bits & BIT_UPPER
5522 && (ISUPPER (c)
5523 || (corig != c
5524 && c == downcase (corig) && ISLOWER (c))))
5525 | (class_bits & BIT_WORD && ISWORD (c))
5526 | (class_bits & BIT_ALPHA && ISALPHA (c))
5527 | (class_bits & BIT_ALNUM && ISALNUM (c))
5528 | (class_bits & BIT_GRAPH && ISGRAPH (c))
5529 | (class_bits & BIT_PRINT && ISPRINT (c)))
5530 not = !not;
5531 else
5532 CHARSET_LOOKUP_RANGE_TABLE_RAW (not, c, range_table, count);
5533 }
5534#endif /* emacs */
5535
5536 if (range_table_exists)
5537 p = CHARSET_RANGE_TABLE_END (range_table, count);
5538 else
5539 p += CHARSET_BITMAP_SIZE (&p[-1]) + 1;
5540
5541 if (!not) goto fail;
5542 5519
5543 d += len; 5520 d += len;
5544 } 5521 }
diff --git a/src/sound.c b/src/sound.c
index 8671d4a6885..f5f570190ca 100644
--- a/src/sound.c
+++ b/src/sound.c
@@ -310,7 +310,7 @@ sound_perror (const char *msg)
310 } 310 }
311#endif 311#endif
312 if (saved_errno != 0) 312 if (saved_errno != 0)
313 error ("%s: %s", msg, strerror (saved_errno)); 313 error ("%s: %s", msg, emacs_strerror (saved_errno));
314 else 314 else
315 error ("%s", msg); 315 error ("%s", msg);
316} 316}
diff --git a/src/syntax.c b/src/syntax.c
index 78c7de9c65b..f8d987b377c 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -1633,7 +1633,7 @@ skip_chars (bool forwardp, Lisp_Object string, Lisp_Object lim,
1633 int c; 1633 int c;
1634 char fastmap[0400]; 1634 char fastmap[0400];
1635 /* Store the ranges of non-ASCII characters. */ 1635 /* Store the ranges of non-ASCII characters. */
1636 int *char_ranges IF_LINT (= NULL); 1636 int *char_ranges UNINIT;
1637 int n_char_ranges = 0; 1637 int n_char_ranges = 0;
1638 bool negate = 0; 1638 bool negate = 0;
1639 ptrdiff_t i, i_byte; 1639 ptrdiff_t i, i_byte;
@@ -3128,8 +3128,9 @@ the prefix syntax flag (p). */)
3128 opoint = pos; 3128 opoint = pos;
3129 opoint_byte = pos_byte; 3129 opoint_byte = pos_byte;
3130 3130
3131 if (pos + 1 > beg) 3131 if (pos <= beg)
3132 DEC_BOTH (pos, pos_byte); 3132 break;
3133 DEC_BOTH (pos, pos_byte);
3133 } 3134 }
3134 3135
3135 SET_PT_BOTH (opoint, opoint_byte); 3136 SET_PT_BOTH (opoint, opoint_byte);
@@ -3771,7 +3772,7 @@ In both cases, LIMIT bounds the search. */);
3771 Vfind_word_boundary_function_table = Fmake_char_table (Qnil, Qnil); 3772 Vfind_word_boundary_function_table = Fmake_char_table (Qnil, Qnil);
3772 3773
3773 DEFVAR_BOOL ("comment-end-can-be-escaped", Vcomment_end_can_be_escaped, 3774 DEFVAR_BOOL ("comment-end-can-be-escaped", Vcomment_end_can_be_escaped,
3774 doc: /* Non-nil means an escaped ender inside a comment doesn'tend the comment. */); 3775 doc: /* Non-nil means an escaped ender inside a comment doesn't end the comment. */);
3775 Vcomment_end_can_be_escaped = 0; 3776 Vcomment_end_can_be_escaped = 0;
3776 DEFSYM (Qcomment_end_can_be_escaped, "comment-end-can-be-escaped"); 3777 DEFSYM (Qcomment_end_can_be_escaped, "comment-end-can-be-escaped");
3777 Fmake_variable_buffer_local (Qcomment_end_can_be_escaped); 3778 Fmake_variable_buffer_local (Qcomment_end_can_be_escaped);
diff --git a/src/sysdep.c b/src/sysdep.c
index a99c2080032..16541735f03 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -129,6 +129,48 @@ static const int baud_convert[] =
129 1800, 2400, 4800, 9600, 19200, 38400 129 1800, 2400, 4800, 9600, 19200, 38400
130 }; 130 };
131 131
132#ifdef HAVE_PERSONALITY_ADDR_NO_RANDOMIZE
133# include <sys/personality.h>
134
135/* Disable address randomization in the current process. Return true
136 if addresses were randomized but this has been disabled, false
137 otherwise. */
138bool
139disable_address_randomization (void)
140{
141 bool disabled = false;
142 int pers = personality (0xffffffff);
143 disabled = (! (pers & ADDR_NO_RANDOMIZE)
144 && 0 <= personality (pers | ADDR_NO_RANDOMIZE));
145 return disabled;
146}
147#endif
148
149/* Execute the program in FILE, with argument vector ARGV and environ
150 ENVP. Return an error number if unsuccessful. This is like execve
151 except it reenables ASLR in the executed program if necessary, and
152 on error it returns an error number rather than -1. */
153int
154emacs_exec_file (char const *file, char *const *argv, char *const *envp)
155{
156#ifdef HAVE_PERSONALITY_ADDR_NO_RANDOMIZE
157 int pers = getenv ("EMACS_HEAP_EXEC") ? personality (0xffffffff) : -1;
158 bool change_personality = 0 <= pers && pers & ADDR_NO_RANDOMIZE;
159 if (change_personality)
160 personality (pers & ~ADDR_NO_RANDOMIZE);
161#endif
162
163 execve (file, argv, envp);
164 int err = errno;
165
166#ifdef HAVE_PERSONALITY_ADDR_NO_RANDOMIZE
167 if (change_personality)
168 personality (pers);
169#endif
170
171 return err;
172}
173
132/* If FD is not already open, arrange for it to be open with FLAGS. */ 174/* If FD is not already open, arrange for it to be open with FLAGS. */
133static void 175static void
134force_open (int fd, int flags) 176force_open (int fd, int flags)
@@ -2498,7 +2540,7 @@ void
2498emacs_perror (char const *message) 2540emacs_perror (char const *message)
2499{ 2541{
2500 int err = errno; 2542 int err = errno;
2501 char const *error_string = strerror (err); 2543 char const *error_string = emacs_strerror (err);
2502 char const *command = (initial_argv && initial_argv[0] 2544 char const *command = (initial_argv && initial_argv[0]
2503 ? initial_argv[0] : "emacs"); 2545 ? initial_argv[0] : "emacs");
2504 /* Write it out all at once, if it's short; this is less likely to 2546 /* Write it out all at once, if it's short; this is less likely to
@@ -3865,7 +3907,7 @@ str_collate (Lisp_Object s1, Lisp_Object s2,
3865 locale_t loc = newlocale (LC_COLLATE_MASK | LC_CTYPE_MASK, 3907 locale_t loc = newlocale (LC_COLLATE_MASK | LC_CTYPE_MASK,
3866 SSDATA (locale), 0); 3908 SSDATA (locale), 0);
3867 if (!loc) 3909 if (!loc)
3868 error ("Invalid locale %s: %s", SSDATA (locale), strerror (errno)); 3910 error ("Invalid locale %s: %s", SSDATA (locale), emacs_strerror (errno));
3869 3911
3870 if (! NILP (ignore_case)) 3912 if (! NILP (ignore_case))
3871 for (int i = 1; i < 3; i++) 3913 for (int i = 1; i < 3; i++)
@@ -3896,10 +3938,10 @@ str_collate (Lisp_Object s1, Lisp_Object s2,
3896 } 3938 }
3897# ifndef HAVE_NEWLOCALE 3939# ifndef HAVE_NEWLOCALE
3898 if (err) 3940 if (err)
3899 error ("Invalid locale or string for collation: %s", strerror (err)); 3941 error ("Invalid locale or string for collation: %s", emacs_strerror (err));
3900# else 3942# else
3901 if (err) 3943 if (err)
3902 error ("Invalid string for collation: %s", strerror (err)); 3944 error ("Invalid string for collation: %s", emacs_strerror (err));
3903# endif 3945# endif
3904 3946
3905 SAFE_FREE (); 3947 SAFE_FREE ();
diff --git a/src/term.c b/src/term.c
index df583cb1502..d54ff115f9d 100644
--- a/src/term.c
+++ b/src/term.c
@@ -548,8 +548,8 @@ encode_terminal_code (struct glyph *src, int src_len,
548 { 548 {
549 if (src->type == COMPOSITE_GLYPH) 549 if (src->type == COMPOSITE_GLYPH)
550 { 550 {
551 struct composition *cmp IF_LINT (= NULL); 551 struct composition *cmp UNINIT;
552 Lisp_Object gstring IF_LINT (= Qnil); 552 Lisp_Object gstring UNINIT;
553 int i; 553 int i;
554 554
555 nbytes = buf - encode_terminal_src; 555 nbytes = buf - encode_terminal_src;
@@ -614,7 +614,7 @@ encode_terminal_code (struct glyph *src, int src_len,
614 else if (! CHAR_GLYPH_PADDING_P (*src)) 614 else if (! CHAR_GLYPH_PADDING_P (*src))
615 { 615 {
616 GLYPH g; 616 GLYPH g;
617 int c IF_LINT (= 0); 617 int c UNINIT;
618 Lisp_Object string; 618 Lisp_Object string;
619 619
620 string = Qnil; 620 string = Qnil;
@@ -1496,6 +1496,8 @@ append_glyph (struct it *it)
1496 glyph->pixel_width = 1; 1496 glyph->pixel_width = 1;
1497 glyph->u.ch = it->char_to_display; 1497 glyph->u.ch = it->char_to_display;
1498 glyph->face_id = it->face_id; 1498 glyph->face_id = it->face_id;
1499 glyph->avoid_cursor_p = it->avoid_cursor_p;
1500 glyph->multibyte_p = it->multibyte_p;
1499 glyph->padding_p = i > 0; 1501 glyph->padding_p = i > 0;
1500 glyph->charpos = CHARPOS (it->position); 1502 glyph->charpos = CHARPOS (it->position);
1501 glyph->object = it->object; 1503 glyph->object = it->object;
@@ -1692,8 +1694,10 @@ append_composite_glyph (struct it *it)
1692 glyph->slice.cmp.to = it->cmp_it.to - 1; 1694 glyph->slice.cmp.to = it->cmp_it.to - 1;
1693 } 1695 }
1694 1696
1697 glyph->avoid_cursor_p = it->avoid_cursor_p;
1698 glyph->multibyte_p = it->multibyte_p;
1695 glyph->face_id = it->face_id; 1699 glyph->face_id = it->face_id;
1696 glyph->padding_p = 0; 1700 glyph->padding_p = false;
1697 glyph->charpos = CHARPOS (it->position); 1701 glyph->charpos = CHARPOS (it->position);
1698 glyph->object = it->object; 1702 glyph->object = it->object;
1699 if (it->bidi_p) 1703 if (it->bidi_p)
@@ -1776,8 +1780,10 @@ append_glyphless_glyph (struct it *it, int face_id, const char *str)
1776 return; 1780 return;
1777 glyph->type = CHAR_GLYPH; 1781 glyph->type = CHAR_GLYPH;
1778 glyph->pixel_width = 1; 1782 glyph->pixel_width = 1;
1783 glyph->avoid_cursor_p = it->avoid_cursor_p;
1784 glyph->multibyte_p = it->multibyte_p;
1779 glyph->face_id = face_id; 1785 glyph->face_id = face_id;
1780 glyph->padding_p = 0; 1786 glyph->padding_p = false;
1781 glyph->charpos = CHARPOS (it->position); 1787 glyph->charpos = CHARPOS (it->position);
1782 glyph->object = it->object; 1788 glyph->object = it->object;
1783 if (it->bidi_p) 1789 if (it->bidi_p)
@@ -3099,7 +3105,7 @@ tty_menu_activate (tty_menu *menu, int *pane, int *selidx,
3099 struct tty_menu_state *state; 3105 struct tty_menu_state *state;
3100 int statecount, x, y, i; 3106 int statecount, x, y, i;
3101 bool leave, onepane; 3107 bool leave, onepane;
3102 int result IF_LINT (= 0); 3108 int result UNINIT;
3103 int title_faces[4]; /* Face to display the menu title. */ 3109 int title_faces[4]; /* Face to display the menu title. */
3104 int faces[4], buffers_num_deleted = 0; 3110 int faces[4], buffers_num_deleted = 0;
3105 struct frame *sf = SELECTED_FRAME (); 3111 struct frame *sf = SELECTED_FRAME ();
@@ -3753,7 +3759,7 @@ tty_menu_show (struct frame *f, int x, int y, int menuflags,
3753 /* Make "Cancel" equivalent to C-g unless FOR_CLICK (which means 3759 /* Make "Cancel" equivalent to C-g unless FOR_CLICK (which means
3754 the menu was invoked with a mouse event as POSITION). */ 3760 the menu was invoked with a mouse event as POSITION). */
3755 if (!(menuflags & MENU_FOR_CLICK)) 3761 if (!(menuflags & MENU_FOR_CLICK))
3756 Fsignal (Qquit, Qnil); 3762 quit ();
3757 break; 3763 break;
3758 } 3764 }
3759 3765
diff --git a/src/textprop.c b/src/textprop.c
index c4e49d98ebc..7af8c698736 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -2043,18 +2043,19 @@ add_text_properties_from_list (Lisp_Object object, Lisp_Object list, Lisp_Object
2043 end-points to NEW_END. */ 2043 end-points to NEW_END. */
2044 2044
2045Lisp_Object 2045Lisp_Object
2046extend_property_ranges (Lisp_Object list, Lisp_Object new_end) 2046extend_property_ranges (Lisp_Object list, Lisp_Object old_end, Lisp_Object new_end)
2047{ 2047{
2048 Lisp_Object prev = Qnil, head = list; 2048 Lisp_Object prev = Qnil, head = list;
2049 ptrdiff_t max = XINT (new_end); 2049 ptrdiff_t max = XINT (new_end);
2050 2050
2051 for (; CONSP (list); prev = list, list = XCDR (list)) 2051 for (; CONSP (list); prev = list, list = XCDR (list))
2052 { 2052 {
2053 Lisp_Object item, beg, end; 2053 Lisp_Object item, beg;
2054 ptrdiff_t end;
2054 2055
2055 item = XCAR (list); 2056 item = XCAR (list);
2056 beg = XCAR (item); 2057 beg = XCAR (item);
2057 end = XCAR (XCDR (item)); 2058 end = XINT (XCAR (XCDR (item)));
2058 2059
2059 if (XINT (beg) >= max) 2060 if (XINT (beg) >= max)
2060 { 2061 {
@@ -2065,9 +2066,16 @@ extend_property_ranges (Lisp_Object list, Lisp_Object new_end)
2065 else 2066 else
2066 XSETCDR (prev, XCDR (list)); 2067 XSETCDR (prev, XCDR (list));
2067 } 2068 }
2068 else if (XINT (end) > max) 2069 else if ((end == XINT (old_end) && end != max)
2069 /* The end-point is past the end of the new string. */ 2070 || end > max)
2070 XSETCAR (XCDR (item), new_end); 2071 {
2072 /* Either the end-point is past the end of the new string,
2073 and we need to discard the properties past the new end,
2074 or the caller is extending the property range, and we
2075 should update all end-points that are on the old end of
2076 the range to reflect that. */
2077 XSETCAR (XCDR (item), new_end);
2078 }
2071 } 2079 }
2072 2080
2073 return head; 2081 return head;
diff --git a/src/vm-limit.c b/src/vm-limit.c
index 7eeca3c8250..58e7729186c 100644
--- a/src/vm-limit.c
+++ b/src/vm-limit.c
@@ -54,10 +54,10 @@ char data_start[1] = { 1 };
54#ifdef HAVE_MALLOC_H 54#ifdef HAVE_MALLOC_H
55# include <malloc.h> 55# include <malloc.h>
56#endif 56#endif
57#ifndef __MALLOC_HOOK_VOLATILE
58# define __MALLOC_HOOK_VOLATILE volatile
59#endif
60#ifndef HAVE_MALLOC_H 57#ifndef HAVE_MALLOC_H
58# ifndef __MALLOC_HOOK_VOLATILE
59# define __MALLOC_HOOK_VOLATILE volatile
60# endif
61extern void *(*__morecore) (ptrdiff_t); 61extern void *(*__morecore) (ptrdiff_t);
62extern void (*__MALLOC_HOOK_VOLATILE __after_morecore_hook) (void); 62extern void (*__MALLOC_HOOK_VOLATILE __after_morecore_hook) (void);
63#endif 63#endif
diff --git a/src/w32console.c b/src/w32console.c
index 98343a6c4ff..c71afb6f888 100644
--- a/src/w32console.c
+++ b/src/w32console.c
@@ -611,8 +611,6 @@ w32_face_attributes (struct frame *f, int face_id)
611 WORD char_attr; 611 WORD char_attr;
612 struct face *face = FACE_FROM_ID (f, face_id); 612 struct face *face = FACE_FROM_ID (f, face_id);
613 613
614 eassert (face != NULL);
615
616 char_attr = char_attr_normal; 614 char_attr = char_attr_normal;
617 615
618 /* Reverse the default color if requested. If background and 616 /* Reverse the default color if requested. If background and
diff --git a/src/w32fns.c b/src/w32fns.c
index fa45b4781c1..584e311230e 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -186,11 +186,7 @@ MonitorFromWindow_Proc monitor_from_window_fn = NULL;
186EnumDisplayMonitors_Proc enum_display_monitors_fn = NULL; 186EnumDisplayMonitors_Proc enum_display_monitors_fn = NULL;
187GetTitleBarInfo_Proc get_title_bar_info_fn = NULL; 187GetTitleBarInfo_Proc get_title_bar_info_fn = NULL;
188 188
189#ifdef NTGUI_UNICODE
190#define unicode_append_menu AppendMenuW
191#else /* !NTGUI_UNICODE */
192extern AppendMenuW_Proc unicode_append_menu; 189extern AppendMenuW_Proc unicode_append_menu;
193#endif /* NTGUI_UNICODE */
194 190
195/* Flag to selectively ignore WM_IME_CHAR messages. */ 191/* Flag to selectively ignore WM_IME_CHAR messages. */
196static int ignore_ime_char = 0; 192static int ignore_ime_char = 0;
@@ -280,6 +276,8 @@ static struct
280} kbdhook; 276} kbdhook;
281typedef HWND (WINAPI *GetConsoleWindow_Proc) (void); 277typedef HWND (WINAPI *GetConsoleWindow_Proc) (void);
282 278
279typedef BOOL (WINAPI *IsDebuggerPresent_Proc) (void);
280
283/* stdin, from w32console.c */ 281/* stdin, from w32console.c */
284extern HANDLE keyboard_handle; 282extern HANDLE keyboard_handle;
285 283
@@ -1662,7 +1660,7 @@ x_set_internal_border_width (struct frame *f, Lisp_Object arg, Lisp_Object oldva
1662 1660
1663 if (border != FRAME_INTERNAL_BORDER_WIDTH (f)) 1661 if (border != FRAME_INTERNAL_BORDER_WIDTH (f))
1664 { 1662 {
1665 FRAME_INTERNAL_BORDER_WIDTH (f) = border; 1663 f->internal_border_width = border;
1666 1664
1667 if (FRAME_X_WINDOW (f) != 0) 1665 if (FRAME_X_WINDOW (f) != 0)
1668 { 1666 {
@@ -2182,7 +2180,7 @@ funhook (int code, WPARAM w, LPARAM l)
2182 can prevent this by setting the 2180 can prevent this by setting the
2183 w32-pass-[lr]window-to-system variable to 2181 w32-pass-[lr]window-to-system variable to
2184 NIL. */ 2182 NIL. */
2185 if (hs->vkCode == (VK_LWIN && !NILP (Vw32_pass_lwindow_to_system)) || 2183 if ((hs->vkCode == VK_LWIN && !NILP (Vw32_pass_lwindow_to_system)) ||
2186 (hs->vkCode == VK_RWIN && !NILP (Vw32_pass_rwindow_to_system))) 2184 (hs->vkCode == VK_RWIN && !NILP (Vw32_pass_rwindow_to_system)))
2187 { 2185 {
2188 /* Not prevented - Simulate the keypress to the system. */ 2186 /* Not prevented - Simulate the keypress to the system. */
@@ -2308,6 +2306,19 @@ setup_w32_kbdhook (void)
2308{ 2306{
2309 kbdhook.hook_count++; 2307 kbdhook.hook_count++;
2310 2308
2309 /* This hook gets in the way of debugging, since when Emacs stops,
2310 its input thread stops, and there's nothing to process keyboard
2311 events, whereas this hook is global, and is invoked in the
2312 context of the thread that installed it. So we don't install the
2313 hook if the process is being debugged. */
2314 if (w32_kbdhook_active)
2315 {
2316 IsDebuggerPresent_Proc is_debugger_present = (IsDebuggerPresent_Proc)
2317 GetProcAddress (GetModuleHandle ("kernel32.dll"), "IsDebuggerPresent");
2318 if (is_debugger_present && is_debugger_present ())
2319 return;
2320 }
2321
2311 /* Hooking is only available on NT architecture systems, as 2322 /* Hooking is only available on NT architecture systems, as
2312 indicated by the w32_kbdhook_active variable. */ 2323 indicated by the w32_kbdhook_active variable. */
2313 if (kbdhook.hook_count == 1 && w32_kbdhook_active) 2324 if (kbdhook.hook_count == 1 && w32_kbdhook_active)
@@ -2406,6 +2417,7 @@ hook_w32_key (int hook, int modifier, int vkey)
2406 } 2417 }
2407} 2418}
2408 2419
2420#ifdef WINDOWSNT
2409/* Check the current Win key pressed state. */ 2421/* Check the current Win key pressed state. */
2410int 2422int
2411check_w32_winkey_state (int vkey) 2423check_w32_winkey_state (int vkey)
@@ -2433,6 +2445,7 @@ check_w32_winkey_state (int vkey)
2433 } 2445 }
2434 return 0; 2446 return 0;
2435} 2447}
2448#endif /* WINDOWSNT */
2436 2449
2437/* Reset the keyboard hook state. Locking the workstation with Win-L 2450/* Reset the keyboard hook state. Locking the workstation with Win-L
2438 leaves the Win key(s) "down" from the hook's point of view - the 2451 leaves the Win key(s) "down" from the hook's point of view - the
@@ -2623,8 +2636,10 @@ modifier_set (int vkey)
2623 else 2636 else
2624 return (GetKeyState (vkey) & 0x1); 2637 return (GetKeyState (vkey) & 0x1);
2625 } 2638 }
2639#ifdef WINDOWSNT
2626 if (w32_kbdhook_active && (vkey == VK_LWIN || vkey == VK_RWIN)) 2640 if (w32_kbdhook_active && (vkey == VK_LWIN || vkey == VK_RWIN))
2627 return check_w32_winkey_state (vkey); 2641 return check_w32_winkey_state (vkey);
2642#endif
2628 2643
2629 if (!modifiers_recorded) 2644 if (!modifiers_recorded)
2630 return (GetKeyState (vkey) & 0x8000); 2645 return (GetKeyState (vkey) & 0x8000);
@@ -3382,7 +3397,7 @@ deliver_wm_chars (int do_translate, HWND hwnd, UINT msg, UINT wParam,
3382 W32Msg wmsg; 3397 W32Msg wmsg;
3383 DWORD console_modifiers = construct_console_modifiers (); 3398 DWORD console_modifiers = construct_console_modifiers ();
3384 int *b = buf, strip_ExtraMods = 1, hairy = 0; 3399 int *b = buf, strip_ExtraMods = 1, hairy = 0;
3385 char *type_CtrlAlt = NULL; 3400 const char *type_CtrlAlt = NULL;
3386 3401
3387 /* XXXX In fact, there may be another case when we need to do the same: 3402 /* XXXX In fact, there may be another case when we need to do the same:
3388 What happens if the string defined in the LIGATURES has length 3403 What happens if the string defined in the LIGATURES has length
@@ -6898,6 +6913,7 @@ Text larger than the specified size is clipped. */)
6898 ptrdiff_t count = SPECPDL_INDEX (); 6913 ptrdiff_t count = SPECPDL_INDEX ();
6899 ptrdiff_t count_1; 6914 ptrdiff_t count_1;
6900 Lisp_Object window, size; 6915 Lisp_Object window, size;
6916 AUTO_STRING (tip, " *tip*");
6901 6917
6902 specbind (Qinhibit_redisplay, Qt); 6918 specbind (Qinhibit_redisplay, Qt);
6903 6919
@@ -7043,6 +7059,7 @@ Text larger than the specified size is clipped. */)
7043 7059
7044 /* Create a frame for the tooltip, and record it in the global 7060 /* Create a frame for the tooltip, and record it in the global
7045 variable tip_frame. */ 7061 variable tip_frame. */
7062 struct frame *f; /* The value is unused. */
7046 if (NILP (tip_frame = x_create_tip_frame (FRAME_DISPLAY_INFO (f), parms))) 7063 if (NILP (tip_frame = x_create_tip_frame (FRAME_DISPLAY_INFO (f), parms)))
7047 { 7064 {
7048 /* Creating the tip frame failed. */ 7065 /* Creating the tip frame failed. */
@@ -7053,7 +7070,6 @@ Text larger than the specified size is clipped. */)
7053 7070
7054 tip_f = XFRAME (tip_frame); 7071 tip_f = XFRAME (tip_frame);
7055 window = FRAME_ROOT_WINDOW (tip_f); 7072 window = FRAME_ROOT_WINDOW (tip_f);
7056 AUTO_STRING (tip, " *tip*");
7057 set_window_buffer (window, Fget_buffer_create (tip), false, false); 7073 set_window_buffer (window, Fget_buffer_create (tip), false, false);
7058 w = XWINDOW (window); 7074 w = XWINDOW (window);
7059 w->pseudo_window_p = true; 7075 w->pseudo_window_p = true;
@@ -7288,7 +7304,9 @@ value of DIR as in previous invocations; this is standard Windows behavior. */)
7288{ 7304{
7289 /* Filter index: 1: All Files, 2: Directories only */ 7305 /* Filter index: 1: All Files, 2: Directories only */
7290 static const wchar_t filter_w[] = L"All Files (*.*)\0*.*\0Directories\0*|*\0"; 7306 static const wchar_t filter_w[] = L"All Files (*.*)\0*.*\0Directories\0*|*\0";
7307#ifndef NTGUI_UNICODE
7291 static const char filter_a[] = "All Files (*.*)\0*.*\0Directories\0*|*\0"; 7308 static const char filter_a[] = "All Files (*.*)\0*.*\0Directories\0*|*\0";
7309#endif
7292 7310
7293 Lisp_Object filename = default_filename; 7311 Lisp_Object filename = default_filename;
7294 struct frame *f = SELECTED_FRAME (); 7312 struct frame *f = SELECTED_FRAME ();
@@ -7566,7 +7584,7 @@ value of DIR as in previous invocations; this is standard Windows behavior. */)
7566 7584
7567 /* Make "Cancel" equivalent to C-g. */ 7585 /* Make "Cancel" equivalent to C-g. */
7568 if (NILP (filename)) 7586 if (NILP (filename))
7569 Fsignal (Qquit, Qnil); 7587 quit ();
7570 7588
7571 return filename; 7589 return filename;
7572} 7590}
@@ -8962,7 +8980,7 @@ w32_strerror (int error_no)
8962 --ret; 8980 --ret;
8963 buf[ret] = '\0'; 8981 buf[ret] = '\0';
8964 if (!ret) 8982 if (!ret)
8965 sprintf (buf, "w32 error %u", error_no); 8983 sprintf (buf, "w32 error %d", error_no);
8966 8984
8967 return buf; 8985 return buf;
8968} 8986}
@@ -10331,8 +10349,8 @@ emacs_abort (void)
10331 but not on Windows 7. addr2line doesn't mind a missing 10349 but not on Windows 7. addr2line doesn't mind a missing
10332 "0x", but will be confused by an extra one. */ 10350 "0x", but will be confused by an extra one. */
10333 if (except_addr) 10351 if (except_addr)
10334 sprintf (buf, "\r\nException 0x%lx at this address:\r\n%p\r\n", 10352 sprintf (buf, "\r\nException 0x%x at this address:\r\n%p\r\n",
10335 except_code, except_addr); 10353 (unsigned int) except_code, except_addr);
10336 if (stderr_fd >= 0) 10354 if (stderr_fd >= 0)
10337 { 10355 {
10338 if (except_addr) 10356 if (except_addr)
diff --git a/src/w32font.c b/src/w32font.c
index b8884a50db9..4d15cffb9f6 100644
--- a/src/w32font.c
+++ b/src/w32font.c
@@ -1747,7 +1747,7 @@ w32_to_x_charset (int fncharset, char *matching)
1747 1747
1748 default: 1748 default:
1749 /* Encode numerical value of unknown charset. */ 1749 /* Encode numerical value of unknown charset. */
1750 sprintf (buf, "*-#%u", fncharset); 1750 sprintf (buf, "*-#%d", fncharset);
1751 return buf; 1751 return buf;
1752 } 1752 }
1753 1753
@@ -1834,7 +1834,7 @@ w32_to_x_charset (int fncharset, char *matching)
1834 /* If no match, encode the numeric value. */ 1834 /* If no match, encode the numeric value. */
1835 if (!best_match) 1835 if (!best_match)
1836 { 1836 {
1837 sprintf (buf, "*-#%u", fncharset); 1837 sprintf (buf, "*-#%d", fncharset);
1838 return buf; 1838 return buf;
1839 } 1839 }
1840 1840
diff --git a/src/w32menu.c b/src/w32menu.c
index fecbf33a12b..7c66360becd 100644
--- a/src/w32menu.c
+++ b/src/w32menu.c
@@ -77,10 +77,10 @@ typedef int (WINAPI * MessageBoxW_Proc) (
77 IN UINT type); 77 IN UINT type);
78 78
79#ifdef NTGUI_UNICODE 79#ifdef NTGUI_UNICODE
80#define get_menu_item_info GetMenuItemInfoA 80GetMenuItemInfoA_Proc get_menu_item_info = GetMenuItemInfoA;
81#define set_menu_item_info SetMenuItemInfoA 81SetMenuItemInfoA_Proc set_menu_item_info = SetMenuItemInfoA;
82#define unicode_append_menu AppendMenuW 82AppendMenuW_Proc unicode_append_menu = AppendMenuW;
83#define unicode_message_box MessageBoxW 83MessageBoxW_Proc unicode_message_box = MessageBoxW;
84#else /* !NTGUI_UNICODE */ 84#else /* !NTGUI_UNICODE */
85GetMenuItemInfoA_Proc get_menu_item_info = NULL; 85GetMenuItemInfoA_Proc get_menu_item_info = NULL;
86SetMenuItemInfoA_Proc set_menu_item_info = NULL; 86SetMenuItemInfoA_Proc set_menu_item_info = NULL;
@@ -827,7 +827,7 @@ w32_menu_show (struct frame *f, int x, int y, int menuflags,
827 { 827 {
828 unblock_input (); 828 unblock_input ();
829 /* Make "Cancel" equivalent to C-g. */ 829 /* Make "Cancel" equivalent to C-g. */
830 Fsignal (Qquit, Qnil); 830 quit ();
831 } 831 }
832 832
833 unblock_input (); 833 unblock_input ();
@@ -1019,7 +1019,7 @@ w32_dialog_show (struct frame *f, Lisp_Object title,
1019 } 1019 }
1020 else 1020 else
1021 /* Make "Cancel" equivalent to C-g. */ 1021 /* Make "Cancel" equivalent to C-g. */
1022 Fsignal (Qquit, Qnil); 1022 quit ();
1023 1023
1024 return Qnil; 1024 return Qnil;
1025} 1025}
@@ -1155,7 +1155,7 @@ simple_dialog_show (struct frame *f, Lisp_Object contents, Lisp_Object header)
1155 else if (answer == IDNO) 1155 else if (answer == IDNO)
1156 lispy_answer = build_string ("No"); 1156 lispy_answer = build_string ("No");
1157 else 1157 else
1158 Fsignal (Qquit, Qnil); 1158 quit ();
1159 1159
1160 for (temp = XCDR (contents); CONSP (temp); temp = XCDR (temp)) 1160 for (temp = XCDR (contents); CONSP (temp); temp = XCDR (temp))
1161 { 1161 {
@@ -1177,8 +1177,7 @@ simple_dialog_show (struct frame *f, Lisp_Object contents, Lisp_Object header)
1177 return value; 1177 return value;
1178 } 1178 }
1179 } 1179 }
1180 Fsignal (Qquit, Qnil); 1180 return quit ();
1181 return Qnil;
1182} 1181}
1183#endif /* !HAVE_DIALOGS */ 1182#endif /* !HAVE_DIALOGS */
1184 1183
diff --git a/src/w32term.c b/src/w32term.c
index c16c8f4eecc..5a11e2a871a 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -611,7 +611,7 @@ w32_draw_vertical_window_border (struct window *w, int x, int y0, int y1)
611 r.bottom = y1; 611 r.bottom = y1;
612 612
613 hdc = get_frame_dc (f); 613 hdc = get_frame_dc (f);
614 face = FACE_OPT_FROM_ID (f, VERTICAL_BORDER_FACE_ID); 614 face = FACE_FROM_ID_OR_NULL (f, VERTICAL_BORDER_FACE_ID);
615 if (face) 615 if (face)
616 w32_fill_rect (f, hdc, face->foreground, &r); 616 w32_fill_rect (f, hdc, face->foreground, &r);
617 else 617 else
@@ -628,11 +628,11 @@ w32_draw_window_divider (struct window *w, int x0, int x1, int y0, int y1)
628{ 628{
629 struct frame *f = XFRAME (WINDOW_FRAME (w)); 629 struct frame *f = XFRAME (WINDOW_FRAME (w));
630 HDC hdc = get_frame_dc (f); 630 HDC hdc = get_frame_dc (f);
631 struct face *face = FACE_OPT_FROM_ID (f, WINDOW_DIVIDER_FACE_ID); 631 struct face *face = FACE_FROM_ID_OR_NULL (f, WINDOW_DIVIDER_FACE_ID);
632 struct face *face_first 632 struct face *face_first
633 = FACE_OPT_FROM_ID (f, WINDOW_DIVIDER_FIRST_PIXEL_FACE_ID); 633 = FACE_FROM_ID_OR_NULL (f, WINDOW_DIVIDER_FIRST_PIXEL_FACE_ID);
634 struct face *face_last 634 struct face *face_last
635 = FACE_OPT_FROM_ID (f, WINDOW_DIVIDER_LAST_PIXEL_FACE_ID); 635 = FACE_FROM_ID_OR_NULL (f, WINDOW_DIVIDER_LAST_PIXEL_FACE_ID);
636 unsigned long color = face ? face->foreground : FRAME_FOREGROUND_PIXEL (f); 636 unsigned long color = face ? face->foreground : FRAME_FOREGROUND_PIXEL (f);
637 unsigned long color_first = (face_first 637 unsigned long color_first = (face_first
638 ? face_first->foreground 638 ? face_first->foreground
@@ -991,7 +991,7 @@ x_set_mouse_face_gc (struct glyph_string *s)
991 991
992 /* What face has to be used last for the mouse face? */ 992 /* What face has to be used last for the mouse face? */
993 face_id = MOUSE_HL_INFO (s->f)->mouse_face_face_id; 993 face_id = MOUSE_HL_INFO (s->f)->mouse_face_face_id;
994 face = FACE_OPT_FROM_ID (s->f, face_id); 994 face = FACE_FROM_ID_OR_NULL (s->f, face_id);
995 if (face == NULL) 995 if (face == NULL)
996 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID); 996 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
997 997
@@ -1434,7 +1434,7 @@ x_draw_glyphless_glyph_string_foreground (struct glyph_string *s)
1434 { 1434 {
1435 sprintf ((char *) buf, "%0*X", 1435 sprintf ((char *) buf, "%0*X",
1436 glyph->u.glyphless.ch < 0x10000 ? 4 : 6, 1436 glyph->u.glyphless.ch < 0x10000 ? 4 : 6,
1437 glyph->u.glyphless.ch); 1437 (unsigned int) glyph->u.glyphless.ch);
1438 str = buf; 1438 str = buf;
1439 } 1439 }
1440 1440
@@ -4198,6 +4198,7 @@ w32_scroll_bar_handle_click (struct scroll_bar *bar, W32Msg *msg,
4198 y = si.nPos; 4198 y = si.nPos;
4199 4199
4200 bar->dragging = 0; 4200 bar->dragging = 0;
4201 struct frame *f; /* Value is not used. */
4201 FRAME_DISPLAY_INFO (f)->last_mouse_scroll_bar_pos = msg->msg.wParam; 4202 FRAME_DISPLAY_INFO (f)->last_mouse_scroll_bar_pos = msg->msg.wParam;
4202 4203
4203 switch (sb_event) 4204 switch (sb_event)
@@ -4313,6 +4314,7 @@ w32_horizontal_scroll_bar_handle_click (struct scroll_bar *bar, W32Msg *msg,
4313 y = si.nMax - si.nPage; 4314 y = si.nMax - si.nPage;
4314 4315
4315 bar->dragging = 0; 4316 bar->dragging = 0;
4317 struct frame *f; /* Value is not used. */
4316 FRAME_DISPLAY_INFO (f)->last_mouse_scroll_bar_pos = msg->msg.wParam; 4318 FRAME_DISPLAY_INFO (f)->last_mouse_scroll_bar_pos = msg->msg.wParam;
4317 4319
4318 switch (sb_event) 4320 switch (sb_event)
diff --git a/src/w32term.h b/src/w32term.h
index e134da5ea5c..320477073a5 100644
--- a/src/w32term.h
+++ b/src/w32term.h
@@ -399,7 +399,7 @@ extern struct w32_output w32term_display;
399#define FRAME_BASELINE_OFFSET(f) ((f)->output_data.w32->baseline_offset) 399#define FRAME_BASELINE_OFFSET(f) ((f)->output_data.w32->baseline_offset)
400 400
401/* This gives the w32_display_info structure for the display F is on. */ 401/* This gives the w32_display_info structure for the display F is on. */
402#define FRAME_DISPLAY_INFO(f) (&one_w32_display_info) 402#define FRAME_DISPLAY_INFO(f) ((void) (f), (&one_w32_display_info))
403 403
404/* This is the `Display *' which frame F is on. */ 404/* This is the `Display *' which frame F is on. */
405#define FRAME_X_DISPLAY(f) (0) 405#define FRAME_X_DISPLAY(f) (0)
diff --git a/src/window.c b/src/window.c
index 99a0709d627..e123b89aae3 100644
--- a/src/window.c
+++ b/src/window.c
@@ -2910,9 +2910,11 @@ window-start value is reasonable when this function is called. */)
2910{ 2910{
2911 struct window *w, *r, *s; 2911 struct window *w, *r, *s;
2912 struct frame *f; 2912 struct frame *f;
2913 Lisp_Object sibling, pwindow, swindow IF_LINT (= Qnil), delta; 2913 Lisp_Object sibling, pwindow, delta;
2914 ptrdiff_t startpos IF_LINT (= 0), startbyte IF_LINT (= 0); 2914 Lisp_Object swindow UNINIT;
2915 int top IF_LINT (= 0), new_top; 2915 ptrdiff_t startpos UNINIT, startbyte UNINIT;
2916 int top UNINIT;
2917 int new_top;
2916 bool resize_failed = false; 2918 bool resize_failed = false;
2917 2919
2918 w = decode_valid_window (window); 2920 w = decode_valid_window (window);
@@ -5649,21 +5651,14 @@ displayed_window_lines (struct window *w)
5649 bottom_y = line_bottom_y (&it); 5651 bottom_y = line_bottom_y (&it);
5650 bidi_unshelve_cache (itdata, false); 5652 bidi_unshelve_cache (itdata, false);
5651 5653
5652 /* rms: On a non-window display,
5653 the value of it.vpos at the bottom of the screen
5654 seems to be 1 larger than window_box_height (w).
5655 This kludge fixes a bug whereby (move-to-window-line -1)
5656 when ZV is on the last screen line
5657 moves to the previous screen line instead of the last one. */
5658 if (! FRAME_WINDOW_P (XFRAME (w->frame)))
5659 height++;
5660
5661 /* Add in empty lines at the bottom of the window. */ 5654 /* Add in empty lines at the bottom of the window. */
5662 if (bottom_y < height) 5655 if (bottom_y < height)
5663 { 5656 {
5664 int uy = FRAME_LINE_HEIGHT (it.f); 5657 int uy = FRAME_LINE_HEIGHT (it.f);
5665 it.vpos += (height - bottom_y + uy - 1) / uy; 5658 it.vpos += (height - bottom_y + uy - 1) / uy;
5666 } 5659 }
5660 else if (bottom_y == height)
5661 it.vpos++;
5667 5662
5668 if (old_buffer) 5663 if (old_buffer)
5669 set_buffer_internal (old_buffer); 5664 set_buffer_internal (old_buffer);
@@ -5938,7 +5933,12 @@ DEFUN ("move-to-window-line", Fmove_to_window_line, Smove_to_window_line,
5938 doc: /* Position point relative to window. 5933 doc: /* Position point relative to window.
5939ARG nil means position point at center of window. 5934ARG nil means position point at center of window.
5940Else, ARG specifies vertical position within the window; 5935Else, ARG specifies vertical position within the window;
5941zero means top of window, negative means relative to bottom of window. */) 5936zero means top of window, negative means relative to bottom
5937of window, -1 meaning the last fully visible display line
5938of the window.
5939
5940Value is the screen line of the window point moved to, counting
5941from the top of the window. */)
5942 (Lisp_Object arg) 5942 (Lisp_Object arg)
5943{ 5943{
5944 struct window *w = XWINDOW (selected_window); 5944 struct window *w = XWINDOW (selected_window);
diff --git a/src/xdisp.c b/src/xdisp.c
index d2f0d49d2b1..efd5f54fa39 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -1321,6 +1321,11 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y,
1321 if (CHARPOS (top) > ZV) 1321 if (CHARPOS (top) > ZV)
1322 SET_TEXT_POS (top, BEGV, BEGV_BYTE); 1322 SET_TEXT_POS (top, BEGV, BEGV_BYTE);
1323 1323
1324 /* If the top of the window is after CHARPOS, the latter is surely
1325 not visible. */
1326 if (charpos >= 0 && CHARPOS (top) > charpos)
1327 return visible_p;
1328
1324 /* Compute exact mode line heights. */ 1329 /* Compute exact mode line heights. */
1325 if (WINDOW_WANTS_MODELINE_P (w)) 1330 if (WINDOW_WANTS_MODELINE_P (w))
1326 w->mode_line_height 1331 w->mode_line_height
@@ -1813,7 +1818,7 @@ estimate_mode_line_height (struct frame *f, enum face_id face_id)
1813 cache and mode line face are not yet initialized. */ 1818 cache and mode line face are not yet initialized. */
1814 if (FRAME_FACE_CACHE (f)) 1819 if (FRAME_FACE_CACHE (f))
1815 { 1820 {
1816 struct face *face = FACE_OPT_FROM_ID (f, face_id); 1821 struct face *face = FACE_FROM_ID_OR_NULL (f, face_id);
1817 if (face) 1822 if (face)
1818 { 1823 {
1819 if (face->font) 1824 if (face->font)
@@ -2232,7 +2237,7 @@ get_phys_cursor_geometry (struct window *w, struct glyph_row *row,
2232 ascent = row->ascent; 2237 ascent = row->ascent;
2233 if (row->ascent < glyph->ascent) 2238 if (row->ascent < glyph->ascent)
2234 { 2239 {
2235 y =- glyph->ascent - row->ascent; 2240 y -= glyph->ascent - row->ascent;
2236 ascent = glyph->ascent; 2241 ascent = glyph->ascent;
2237 } 2242 }
2238 2243
@@ -2918,7 +2923,7 @@ init_iterator (struct it *it, struct window *w,
2918 2923
2919 /* If we have a boxed mode line, make the first character appear 2924 /* If we have a boxed mode line, make the first character appear
2920 with a left box line. */ 2925 with a left box line. */
2921 face = FACE_OPT_FROM_ID (it->f, remapped_base_face_id); 2926 face = FACE_FROM_ID_OR_NULL (it->f, remapped_base_face_id);
2922 if (face && face->box != FACE_NO_BOX) 2927 if (face && face->box != FACE_NO_BOX)
2923 it->start_of_box_run_p = true; 2928 it->start_of_box_run_p = true;
2924 } 2929 }
@@ -3877,9 +3882,9 @@ handle_face_prop (struct it *it)
3877 { 3882 {
3878 struct face *new_face = FACE_FROM_ID (it->f, new_face_id); 3883 struct face *new_face = FACE_FROM_ID (it->f, new_face_id);
3879 /* If it->face_id is -1, old_face below will be NULL, see 3884 /* If it->face_id is -1, old_face below will be NULL, see
3880 the definition of FACE_OPT_FROM_ID. This will happen if this 3885 the definition of FACE_FROM_ID_OR_NULL. This will happen
3881 is the initial call that gets the face. */ 3886 if this is the initial call that gets the face. */
3882 struct face *old_face = FACE_OPT_FROM_ID (it->f, it->face_id); 3887 struct face *old_face = FACE_FROM_ID_OR_NULL (it->f, it->face_id);
3883 3888
3884 /* If the value of face_id of the iterator is -1, we have to 3889 /* If the value of face_id of the iterator is -1, we have to
3885 look in front of IT's position and see whether there is a 3890 look in front of IT's position and see whether there is a
@@ -3888,7 +3893,7 @@ handle_face_prop (struct it *it)
3888 { 3893 {
3889 int prev_face_id = face_before_it_pos (it); 3894 int prev_face_id = face_before_it_pos (it);
3890 3895
3891 old_face = FACE_OPT_FROM_ID (it->f, prev_face_id); 3896 old_face = FACE_FROM_ID_OR_NULL (it->f, prev_face_id);
3892 } 3897 }
3893 3898
3894 /* If the new face has a box, but the old face does not, 3899 /* If the new face has a box, but the old face does not,
@@ -3988,7 +3993,7 @@ handle_face_prop (struct it *it)
3988 if (new_face_id != it->face_id) 3993 if (new_face_id != it->face_id)
3989 { 3994 {
3990 struct face *new_face = FACE_FROM_ID (it->f, new_face_id); 3995 struct face *new_face = FACE_FROM_ID (it->f, new_face_id);
3991 struct face *old_face = FACE_OPT_FROM_ID (it->f, it->face_id); 3996 struct face *old_face = FACE_FROM_ID_OR_NULL (it->f, it->face_id);
3992 3997
3993 /* If new face has a box but old face hasn't, this is the 3998 /* If new face has a box but old face hasn't, this is the
3994 start of a run of characters with box, i.e. it has a 3999 start of a run of characters with box, i.e. it has a
@@ -5017,8 +5022,6 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object,
5017 || EQ (XCAR (spec), Qright_fringe)) 5022 || EQ (XCAR (spec), Qright_fringe))
5018 && CONSP (XCDR (spec))) 5023 && CONSP (XCDR (spec)))
5019 { 5024 {
5020 int fringe_bitmap;
5021
5022 if (it) 5025 if (it)
5023 { 5026 {
5024 if (!FRAME_WINDOW_P (it->f)) 5027 if (!FRAME_WINDOW_P (it->f))
@@ -5043,8 +5046,8 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object,
5043 5046
5044#ifdef HAVE_WINDOW_SYSTEM 5047#ifdef HAVE_WINDOW_SYSTEM
5045 value = XCAR (XCDR (spec)); 5048 value = XCAR (XCDR (spec));
5046 if (!SYMBOLP (value) 5049 int fringe_bitmap = SYMBOLP (value) ? lookup_fringe_bitmap (value) : 0;
5047 || !(fringe_bitmap = lookup_fringe_bitmap (value))) 5050 if (! fringe_bitmap)
5048 /* If we return here, POSITION has been advanced 5051 /* If we return here, POSITION has been advanced
5049 across the text with this property. */ 5052 across the text with this property. */
5050 { 5053 {
@@ -6097,7 +6100,7 @@ pop_it (struct it *it)
6097 break; 6100 break;
6098 case GET_FROM_STRING: 6101 case GET_FROM_STRING:
6099 { 6102 {
6100 struct face *face = FACE_OPT_FROM_ID (it->f, it->face_id); 6103 struct face *face = FACE_FROM_ID_OR_NULL (it->f, it->face_id);
6101 6104
6102 /* Restore the face_box_p flag, since it could have been 6105 /* Restore the face_box_p flag, since it could have been
6103 overwritten by the face of the object that we just finished 6106 overwritten by the face of the object that we just finished
@@ -6778,7 +6781,8 @@ static next_element_function const get_next_element[NUM_IT_METHODS] =
6778 || ((IT)->cmp_it.stop_pos == (CHARPOS) \ 6781 || ((IT)->cmp_it.stop_pos == (CHARPOS) \
6779 && composition_reseat_it (&(IT)->cmp_it, CHARPOS, BYTEPOS, \ 6782 && composition_reseat_it (&(IT)->cmp_it, CHARPOS, BYTEPOS, \
6780 END_CHARPOS, (IT)->w, \ 6783 END_CHARPOS, (IT)->w, \
6781 FACE_OPT_FROM_ID ((IT)->f, (IT)->face_id), \ 6784 FACE_FROM_ID_OR_NULL ((IT)->f, \
6785 (IT)->face_id), \
6782 (IT)->string))) 6786 (IT)->string)))
6783 6787
6784 6788
@@ -7207,7 +7211,7 @@ get_next_display_element (struct it *it)
7207 if (it->method == GET_FROM_STRING && it->sp) 7211 if (it->method == GET_FROM_STRING && it->sp)
7208 { 7212 {
7209 int face_id = underlying_face_id (it); 7213 int face_id = underlying_face_id (it);
7210 struct face *face = FACE_OPT_FROM_ID (it->f, face_id); 7214 struct face *face = FACE_FROM_ID_OR_NULL (it->f, face_id);
7211 7215
7212 if (face) 7216 if (face)
7213 { 7217 {
@@ -7740,8 +7744,8 @@ next_element_from_display_vector (struct it *it)
7740 /* Glyphs in the display vector could have the box face, so we 7744 /* Glyphs in the display vector could have the box face, so we
7741 need to set the related flags in the iterator, as 7745 need to set the related flags in the iterator, as
7742 appropriate. */ 7746 appropriate. */
7743 this_face = FACE_OPT_FROM_ID (it->f, it->face_id); 7747 this_face = FACE_FROM_ID_OR_NULL (it->f, it->face_id);
7744 prev_face = FACE_OPT_FROM_ID (it->f, prev_face_id); 7748 prev_face = FACE_FROM_ID_OR_NULL (it->f, prev_face_id);
7745 7749
7746 /* Is this character the first character of a box-face run? */ 7750 /* Is this character the first character of a box-face run? */
7747 it->start_of_box_run_p = (this_face && this_face->box != FACE_NO_BOX 7751 it->start_of_box_run_p = (this_face && this_face->box != FACE_NO_BOX
@@ -7766,7 +7770,7 @@ next_element_from_display_vector (struct it *it)
7766 it->saved_face_id); 7770 it->saved_face_id);
7767 } 7771 }
7768 } 7772 }
7769 next_face = FACE_OPT_FROM_ID (it->f, next_face_id); 7773 next_face = FACE_FROM_ID_OR_NULL (it->f, next_face_id);
7770 it->end_of_box_run_p = (this_face && this_face->box != FACE_NO_BOX 7774 it->end_of_box_run_p = (this_face && this_face->box != FACE_NO_BOX
7771 && (!next_face 7775 && (!next_face
7772 || next_face->box == FACE_NO_BOX)); 7776 || next_face->box == FACE_NO_BOX));
@@ -8558,7 +8562,8 @@ move_it_in_display_line_to (struct it *it,
8558 void *ppos_data = NULL; 8562 void *ppos_data = NULL;
8559 bool may_wrap = false; 8563 bool may_wrap = false;
8560 enum it_method prev_method = it->method; 8564 enum it_method prev_method = it->method;
8561 ptrdiff_t closest_pos IF_LINT (= 0), prev_pos = IT_CHARPOS (*it); 8565 ptrdiff_t closest_pos UNINIT;
8566 ptrdiff_t prev_pos = IT_CHARPOS (*it);
8562 bool saw_smaller_pos = prev_pos < to_charpos; 8567 bool saw_smaller_pos = prev_pos < to_charpos;
8563 8568
8564 /* Don't produce glyphs in produce_glyphs. */ 8569 /* Don't produce glyphs in produce_glyphs. */
@@ -8609,8 +8614,7 @@ move_it_in_display_line_to (struct it *it,
8609 && it->dpvec + it->current.dpvec_index + 1 >= it->dpend))) 8614 && it->dpvec + it->current.dpvec_index + 1 >= it->dpend)))
8610 8615
8611 /* If there's a line-/wrap-prefix, handle it. */ 8616 /* If there's a line-/wrap-prefix, handle it. */
8612 if (it->hpos == 0 && it->method == GET_FROM_BUFFER 8617 if (it->hpos == 0 && it->method == GET_FROM_BUFFER)
8613 && it->current_y < it->last_visible_y)
8614 handle_line_prefix (it); 8618 handle_line_prefix (it);
8615 8619
8616 if (IT_CHARPOS (*it) < CHARPOS (this_line_min_pos)) 8620 if (IT_CHARPOS (*it) < CHARPOS (this_line_min_pos))
@@ -9037,6 +9041,11 @@ move_it_in_display_line_to (struct it *it,
9037 } 9041 }
9038 else 9042 else
9039 result = MOVE_NEWLINE_OR_CR; 9043 result = MOVE_NEWLINE_OR_CR;
9044 /* If we've processed the newline, make sure this flag is
9045 reset, as it must only be set when the newline itself is
9046 processed. */
9047 if (result == MOVE_NEWLINE_OR_CR)
9048 it->constrain_row_ascent_descent_p = false;
9040 break; 9049 break;
9041 } 9050 }
9042 9051
@@ -9975,18 +9984,21 @@ include the height of both, if present, in the return value. */)
9975 it.last_visible_x = max_x; 9984 it.last_visible_x = max_x;
9976 /* Actually, we never want move_it_to stop at to_x. But to make 9985 /* Actually, we never want move_it_to stop at to_x. But to make
9977 sure that move_it_in_display_line_to always moves far enough, 9986 sure that move_it_in_display_line_to always moves far enough,
9978 we set it to INT_MAX and specify MOVE_TO_X. Also bound width 9987 we set it to INT_MAX and specify MOVE_TO_X. */
9979 value by X-LIMIT. */ 9988 x = move_it_to (&it, end, INT_MAX, max_y, -1,
9980 x = min (move_it_to (&it, end, INT_MAX, max_y, -1, 9989 MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y);
9981 MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y), 9990 /* Don't return more than X-LIMIT. */
9982 max_x); 9991 if (x > max_x)
9992 x = max_x;
9983 } 9993 }
9984 9994
9985 /* Subtract height of header-line which was counted automatically by 9995 /* Subtract height of header-line which was counted automatically by
9986 start_display. */ 9996 start_display. */
9987 y = min (it.current_y + it.max_ascent + it.max_descent 9997 y = it.current_y + it.max_ascent + it.max_descent
9988 - WINDOW_HEADER_LINE_HEIGHT (w), 9998 - WINDOW_HEADER_LINE_HEIGHT (w);
9989 max_y); 9999 /* Don't return more than Y-LIMIT. */
10000 if (y > max_y)
10001 y = max_y;
9990 10002
9991 if (EQ (mode_and_header_line, Qheader_line) 10003 if (EQ (mode_and_header_line, Qheader_line)
9992 || EQ (mode_and_header_line, Qt)) 10004 || EQ (mode_and_header_line, Qt))
@@ -15505,12 +15517,14 @@ try_scrolling (Lisp_Object window, bool just_this_one_p,
15505 15517
15506 The new window start will be computed, based on W's width, starting 15518 The new window start will be computed, based on W's width, starting
15507 from the start of the continued line. It is the start of the 15519 from the start of the continued line. It is the start of the
15508 screen line with the minimum distance from the old start W->start. */ 15520 screen line with the minimum distance from the old start W->start,
15521 which is still before point (otherwise point will definitely not
15522 be visible in the window). */
15509 15523
15510static bool 15524static bool
15511compute_window_start_on_continuation_line (struct window *w) 15525compute_window_start_on_continuation_line (struct window *w)
15512{ 15526{
15513 struct text_pos pos, start_pos; 15527 struct text_pos pos, start_pos, pos_before_pt;
15514 bool window_start_changed_p = false; 15528 bool window_start_changed_p = false;
15515 15529
15516 SET_TEXT_POS_FROM_MARKER (start_pos, w->start); 15530 SET_TEXT_POS_FROM_MARKER (start_pos, w->start);
@@ -15538,10 +15552,14 @@ compute_window_start_on_continuation_line (struct window *w)
15538 reseat_at_previous_visible_line_start (&it); 15552 reseat_at_previous_visible_line_start (&it);
15539 15553
15540 /* If the line start is "too far" away from the window start, 15554 /* If the line start is "too far" away from the window start,
15541 say it takes too much time to compute a new window start. */ 15555 say it takes too much time to compute a new window start.
15542 if (CHARPOS (start_pos) - IT_CHARPOS (it) 15556 Also, give up if the line start is after point, as in that
15543 /* PXW: Do we need upper bounds here? */ 15557 case point will not be visible with any window start we
15544 < WINDOW_TOTAL_LINES (w) * WINDOW_TOTAL_COLS (w)) 15558 compute. */
15559 if (IT_CHARPOS (it) <= PT
15560 || (CHARPOS (start_pos) - IT_CHARPOS (it)
15561 /* PXW: Do we need upper bounds here? */
15562 < WINDOW_TOTAL_LINES (w) * WINDOW_TOTAL_COLS (w)))
15545 { 15563 {
15546 int min_distance, distance; 15564 int min_distance, distance;
15547 15565
@@ -15551,12 +15569,14 @@ compute_window_start_on_continuation_line (struct window *w)
15551 decreased, the new window start will be < the old start. 15569 decreased, the new window start will be < the old start.
15552 So, we're looking for the display line start with the 15570 So, we're looking for the display line start with the
15553 minimum distance from the old window start. */ 15571 minimum distance from the old window start. */
15554 pos = it.current.pos; 15572 pos_before_pt = pos = it.current.pos;
15555 min_distance = INFINITY; 15573 min_distance = INFINITY;
15556 while ((distance = eabs (CHARPOS (start_pos) - IT_CHARPOS (it))), 15574 while ((distance = eabs (CHARPOS (start_pos) - IT_CHARPOS (it))),
15557 distance < min_distance) 15575 distance < min_distance)
15558 { 15576 {
15559 min_distance = distance; 15577 min_distance = distance;
15578 if (CHARPOS (pos) <= PT)
15579 pos_before_pt = pos;
15560 pos = it.current.pos; 15580 pos = it.current.pos;
15561 if (it.line_wrap == WORD_WRAP) 15581 if (it.line_wrap == WORD_WRAP)
15562 { 15582 {
@@ -15579,6 +15599,13 @@ compute_window_start_on_continuation_line (struct window *w)
15579 move_it_by_lines (&it, 1); 15599 move_it_by_lines (&it, 1);
15580 } 15600 }
15581 15601
15602 /* It makes very little sense to make the new window start
15603 after point, as point won't be visible. If that's what
15604 the loop above finds, fall back on the candidate before
15605 or at point that is closest to the old window start. */
15606 if (CHARPOS (pos) > PT)
15607 pos = pos_before_pt;
15608
15582 /* Set the window start there. */ 15609 /* Set the window start there. */
15583 SET_MARKER_FROM_TEXT_POS (w->start, pos); 15610 SET_MARKER_FROM_TEXT_POS (w->start, pos);
15584 window_start_changed_p = true; 15611 window_start_changed_p = true;
@@ -19508,7 +19535,6 @@ append_space_for_newline (struct it *it, bool default_face_p)
19508 struct text_pos saved_pos; 19535 struct text_pos saved_pos;
19509 Lisp_Object saved_object; 19536 Lisp_Object saved_object;
19510 struct face *face; 19537 struct face *face;
19511 struct glyph *g;
19512 19538
19513 saved_object = it->object; 19539 saved_object = it->object;
19514 saved_pos = it->position; 19540 saved_pos = it->position;
@@ -19544,7 +19570,7 @@ append_space_for_newline (struct it *it, bool default_face_p)
19544 /* Make sure this space glyph has the right ascent and 19570 /* Make sure this space glyph has the right ascent and
19545 descent values, or else cursor at end of line will look 19571 descent values, or else cursor at end of line will look
19546 funny, and height of empty lines will be incorrect. */ 19572 funny, and height of empty lines will be incorrect. */
19547 g = it->glyph_row->glyphs[TEXT_AREA] + n; 19573 struct glyph *g = it->glyph_row->glyphs[TEXT_AREA] + n;
19548 struct font *font = face->font ? face->font : FRAME_FONT (it->f); 19574 struct font *font = face->font ? face->font : FRAME_FONT (it->f);
19549 if (n == 0) 19575 if (n == 0)
19550 { 19576 {
@@ -19669,14 +19695,15 @@ extend_face_to_end_of_line (struct it *it)
19669 return; 19695 return;
19670 19696
19671 /* The default face, possibly remapped. */ 19697 /* The default face, possibly remapped. */
19672 default_face = FACE_OPT_FROM_ID (f, lookup_basic_face (f, DEFAULT_FACE_ID)); 19698 default_face = FACE_FROM_ID_OR_NULL (f,
19699 lookup_basic_face (f, DEFAULT_FACE_ID));
19673 19700
19674 /* Face extension extends the background and box of IT->face_id 19701 /* Face extension extends the background and box of IT->face_id
19675 to the end of the line. If the background equals the background 19702 to the end of the line. If the background equals the background
19676 of the frame, we don't have to do anything. */ 19703 of the frame, we don't have to do anything. */
19677 face = FACE_OPT_FROM_ID (f, (it->face_before_selective_p 19704 face = FACE_FROM_ID (f, (it->face_before_selective_p
19678 ? it->saved_face_id 19705 ? it->saved_face_id
19679 : it->face_id)); 19706 : it->face_id));
19680 19707
19681 if (FRAME_WINDOW_P (f) 19708 if (FRAME_WINDOW_P (f)
19682 && MATRIX_ROW_DISPLAYS_TEXT_P (it->glyph_row) 19709 && MATRIX_ROW_DISPLAYS_TEXT_P (it->glyph_row)
@@ -20416,16 +20443,16 @@ display_line (struct it *it)
20416 struct it wrap_it; 20443 struct it wrap_it;
20417 void *wrap_data = NULL; 20444 void *wrap_data = NULL;
20418 bool may_wrap = false; 20445 bool may_wrap = false;
20419 int wrap_x IF_LINT (= 0); 20446 int wrap_x UNINIT;
20420 int wrap_row_used = -1; 20447 int wrap_row_used = -1;
20421 int wrap_row_ascent IF_LINT (= 0), wrap_row_height IF_LINT (= 0); 20448 int wrap_row_ascent UNINIT, wrap_row_height UNINIT;
20422 int wrap_row_phys_ascent IF_LINT (= 0), wrap_row_phys_height IF_LINT (= 0); 20449 int wrap_row_phys_ascent UNINIT, wrap_row_phys_height UNINIT;
20423 int wrap_row_extra_line_spacing IF_LINT (= 0); 20450 int wrap_row_extra_line_spacing UNINIT;
20424 ptrdiff_t wrap_row_min_pos IF_LINT (= 0), wrap_row_min_bpos IF_LINT (= 0); 20451 ptrdiff_t wrap_row_min_pos UNINIT, wrap_row_min_bpos UNINIT;
20425 ptrdiff_t wrap_row_max_pos IF_LINT (= 0), wrap_row_max_bpos IF_LINT (= 0); 20452 ptrdiff_t wrap_row_max_pos UNINIT, wrap_row_max_bpos UNINIT;
20426 int cvpos; 20453 int cvpos;
20427 ptrdiff_t min_pos = ZV + 1, max_pos = 0; 20454 ptrdiff_t min_pos = ZV + 1, max_pos = 0;
20428 ptrdiff_t min_bpos IF_LINT (= 0), max_bpos IF_LINT (= 0); 20455 ptrdiff_t min_bpos UNINIT, max_bpos UNINIT;
20429 bool pending_handle_line_prefix = false; 20456 bool pending_handle_line_prefix = false;
20430 20457
20431 /* We always start displaying at hpos zero even if hscrolled. */ 20458 /* We always start displaying at hpos zero even if hscrolled. */
@@ -21842,7 +21869,6 @@ Value is the new character position of point. */)
21842 } 21869 }
21843 21870
21844 /* Move to the target X coordinate. */ 21871 /* Move to the target X coordinate. */
21845#ifdef HAVE_WINDOW_SYSTEM
21846 /* On GUI frames, as we don't know the X coordinate of the 21872 /* On GUI frames, as we don't know the X coordinate of the
21847 character to the left of point, moving point to the left 21873 character to the left of point, moving point to the left
21848 requires walking, one grapheme cluster at a time, until we 21874 requires walking, one grapheme cluster at a time, until we
@@ -21899,9 +21925,7 @@ Value is the new character position of point. */)
21899 new_pos.bytepos = CHAR_TO_BYTE (new_pos.charpos); 21925 new_pos.bytepos = CHAR_TO_BYTE (new_pos.charpos);
21900 it.current.pos = new_pos; 21926 it.current.pos = new_pos;
21901 } 21927 }
21902 else 21928 else if (it.current_x != target_x)
21903#endif
21904 if (it.current_x != target_x)
21905 move_it_in_display_line_to (&it, ZV, target_x, MOVE_TO_POS | MOVE_TO_X); 21929 move_it_in_display_line_to (&it, ZV, target_x, MOVE_TO_POS | MOVE_TO_X);
21906 21930
21907 /* If we ended up in a display string that covers point, move to 21931 /* If we ended up in a display string that covers point, move to
@@ -24781,7 +24805,7 @@ fill_gstring_glyph_string (struct glyph_string *s, int face_id,
24781 s->cmp_id = glyph->u.cmp.id; 24805 s->cmp_id = glyph->u.cmp.id;
24782 s->cmp_from = glyph->slice.cmp.from; 24806 s->cmp_from = glyph->slice.cmp.from;
24783 s->cmp_to = glyph->slice.cmp.to + 1; 24807 s->cmp_to = glyph->slice.cmp.to + 1;
24784 s->face = FACE_OPT_FROM_ID (s->f, face_id); 24808 s->face = FACE_FROM_ID (s->f, face_id);
24785 lgstring = composition_gstring_from_id (s->cmp_id); 24809 lgstring = composition_gstring_from_id (s->cmp_id);
24786 s->font = XFONT_OBJECT (LGSTRING_FONT (lgstring)); 24810 s->font = XFONT_OBJECT (LGSTRING_FONT (lgstring));
24787 glyph++; 24811 glyph++;
@@ -25374,7 +25398,7 @@ compute_overhangs_and_x (struct glyph_string *s, int x, bool backward_p)
25374#define BUILD_COMPOSITE_GLYPH_STRING(START, END, HEAD, TAIL, HL, X, LAST_X) \ 25398#define BUILD_COMPOSITE_GLYPH_STRING(START, END, HEAD, TAIL, HL, X, LAST_X) \
25375 do { \ 25399 do { \
25376 int face_id = (row)->glyphs[area][START].face_id; \ 25400 int face_id = (row)->glyphs[area][START].face_id; \
25377 struct face *base_face = FACE_OPT_FROM_ID (f, face_id); \ 25401 struct face *base_face = FACE_FROM_ID (f, face_id); \
25378 ptrdiff_t cmp_id = (row)->glyphs[area][START].u.cmp.id; \ 25402 ptrdiff_t cmp_id = (row)->glyphs[area][START].u.cmp.id; \
25379 struct composition *cmp = composition_table[cmp_id]; \ 25403 struct composition *cmp = composition_table[cmp_id]; \
25380 XChar2b *char2b; \ 25404 XChar2b *char2b; \
@@ -25595,7 +25619,7 @@ draw_glyphs (struct window *w, int x, struct glyph_row *row,
25595 { 25619 {
25596 struct glyph_string *h, *t; 25620 struct glyph_string *h, *t;
25597 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); 25621 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
25598 int mouse_beg_col IF_LINT (= 0), mouse_end_col IF_LINT (= 0); 25622 int mouse_beg_col UNINIT, mouse_end_col UNINIT;
25599 bool check_mouse_face = false; 25623 bool check_mouse_face = false;
25600 int dummy_x = 0; 25624 int dummy_x = 0;
25601 25625
@@ -26691,12 +26715,8 @@ calc_line_height_property (struct it *it, Lisp_Object val, struct font *font,
26691 struct face *face; 26715 struct face *face;
26692 26716
26693 face_id = lookup_named_face (it->f, face_name, false); 26717 face_id = lookup_named_face (it->f, face_name, false);
26694 if (face_id < 0) 26718 face = FACE_FROM_ID_OR_NULL (it->f, face_id);
26695 return make_number (-1); 26719 if (face == NULL || ((font = face->font) == NULL))
26696
26697 face = FACE_FROM_ID (it->f, face_id);
26698 font = face->font;
26699 if (font == NULL)
26700 return make_number (-1); 26720 return make_number (-1);
26701 boff = font->baseline_offset; 26721 boff = font->baseline_offset;
26702 if (font->vertical_centering) 26722 if (font->vertical_centering)
@@ -27349,8 +27369,8 @@ x_produce_glyphs (struct it *it)
27349 27369
27350 eassume (0 < glyph_len); /* See Bug#8512. */ 27370 eassume (0 < glyph_len); /* See Bug#8512. */
27351 do 27371 do
27352 c = COMPOSITION_GLYPH (cmp, --glyph_len); 27372 c = COMPOSITION_GLYPH (cmp, glyph_len - 1);
27353 while (c == '\t' && 0 < glyph_len); 27373 while (c == '\t' && 0 < --glyph_len);
27354 27374
27355 bool right_padded = glyph_len < cmp->glyph_len; 27375 bool right_padded = glyph_len < cmp->glyph_len;
27356 for (i = 0; i < glyph_len; i++) 27376 for (i = 0; i < glyph_len; i++)
@@ -28680,12 +28700,12 @@ show_mouse_face (Mouse_HLInfo *hlinfo, enum draw_glyphs_face draw)
28680 } 28700 }
28681 } 28701 }
28682 28702
28683#ifdef HAVE_WINDOW_SYSTEM
28684 /* When we've written over the cursor, arrange for it to 28703 /* When we've written over the cursor, arrange for it to
28685 be displayed again. */ 28704 be displayed again. */
28686 if (FRAME_WINDOW_P (f) 28705 if (FRAME_WINDOW_P (f)
28687 && phys_cursor_on_p && !w->phys_cursor_on_p) 28706 && phys_cursor_on_p && !w->phys_cursor_on_p)
28688 { 28707 {
28708#ifdef HAVE_WINDOW_SYSTEM
28689 int hpos = w->phys_cursor.hpos; 28709 int hpos = w->phys_cursor.hpos;
28690 28710
28691 /* When the window is hscrolled, cursor hpos can legitimately be 28711 /* When the window is hscrolled, cursor hpos can legitimately be
@@ -28700,8 +28720,8 @@ show_mouse_face (Mouse_HLInfo *hlinfo, enum draw_glyphs_face draw)
28700 display_and_set_cursor (w, true, hpos, w->phys_cursor.vpos, 28720 display_and_set_cursor (w, true, hpos, w->phys_cursor.vpos,
28701 w->phys_cursor.x, w->phys_cursor.y); 28721 w->phys_cursor.x, w->phys_cursor.y);
28702 unblock_input (); 28722 unblock_input ();
28703 }
28704#endif /* HAVE_WINDOW_SYSTEM */ 28723#endif /* HAVE_WINDOW_SYSTEM */
28724 }
28705 } 28725 }
28706 28726
28707#ifdef HAVE_WINDOW_SYSTEM 28727#ifdef HAVE_WINDOW_SYSTEM
@@ -29641,12 +29661,17 @@ Returns the alist element for the first matching AREA in MAP. */)
29641 clip_to_bounds (INT_MIN, XINT (x), INT_MAX), 29661 clip_to_bounds (INT_MIN, XINT (x), INT_MAX),
29642 clip_to_bounds (INT_MIN, XINT (y), INT_MAX)); 29662 clip_to_bounds (INT_MIN, XINT (y), INT_MAX));
29643} 29663}
29664#endif /* HAVE_WINDOW_SYSTEM */
29644 29665
29645 29666
29646/* Display frame CURSOR, optionally using shape defined by POINTER. */ 29667/* Display frame CURSOR, optionally using shape defined by POINTER. */
29647static void 29668static void
29648define_frame_cursor1 (struct frame *f, Cursor cursor, Lisp_Object pointer) 29669define_frame_cursor1 (struct frame *f, Cursor cursor, Lisp_Object pointer)
29649{ 29670{
29671#ifdef HAVE_WINDOW_SYSTEM
29672 if (!FRAME_WINDOW_P (f))
29673 return;
29674
29650 /* Do not change cursor shape while dragging mouse. */ 29675 /* Do not change cursor shape while dragging mouse. */
29651 if (EQ (do_mouse_tracking, Qdragging)) 29676 if (EQ (do_mouse_tracking, Qdragging))
29652 return; 29677 return;
@@ -29663,10 +29688,10 @@ define_frame_cursor1 (struct frame *f, Cursor cursor, Lisp_Object pointer)
29663 cursor = FRAME_X_OUTPUT (f)->horizontal_drag_cursor; 29688 cursor = FRAME_X_OUTPUT (f)->horizontal_drag_cursor;
29664 else if (EQ (pointer, intern ("nhdrag"))) 29689 else if (EQ (pointer, intern ("nhdrag")))
29665 cursor = FRAME_X_OUTPUT (f)->vertical_drag_cursor; 29690 cursor = FRAME_X_OUTPUT (f)->vertical_drag_cursor;
29666#ifdef HAVE_X_WINDOWS 29691# ifdef HAVE_X_WINDOWS
29667 else if (EQ (pointer, intern ("vdrag"))) 29692 else if (EQ (pointer, intern ("vdrag")))
29668 cursor = FRAME_DISPLAY_INFO (f)->vertical_scroll_bar_cursor; 29693 cursor = FRAME_DISPLAY_INFO (f)->vertical_scroll_bar_cursor;
29669#endif 29694# endif
29670 else if (EQ (pointer, intern ("hourglass"))) 29695 else if (EQ (pointer, intern ("hourglass")))
29671 cursor = FRAME_X_OUTPUT (f)->hourglass_cursor; 29696 cursor = FRAME_X_OUTPUT (f)->hourglass_cursor;
29672 else if (EQ (pointer, Qmodeline)) 29697 else if (EQ (pointer, Qmodeline))
@@ -29677,10 +29702,9 @@ define_frame_cursor1 (struct frame *f, Cursor cursor, Lisp_Object pointer)
29677 29702
29678 if (cursor != No_Cursor) 29703 if (cursor != No_Cursor)
29679 FRAME_RIF (f)->define_frame_cursor (f, cursor); 29704 FRAME_RIF (f)->define_frame_cursor (f, cursor);
29705#endif
29680} 29706}
29681 29707
29682#endif /* HAVE_WINDOW_SYSTEM */
29683
29684/* Take proper action when mouse has moved to the mode or header line 29708/* Take proper action when mouse has moved to the mode or header line
29685 or marginal area AREA of window W, x-position X and y-position Y. 29709 or marginal area AREA of window W, x-position X and y-position Y.
29686 X is relative to the start of the text display area of W, so the 29710 X is relative to the start of the text display area of W, so the
@@ -29702,12 +29726,11 @@ note_mode_line_or_margin_highlight (Lisp_Object window, int x, int y,
29702 int dx, dy, width, height; 29726 int dx, dy, width, height;
29703 ptrdiff_t charpos; 29727 ptrdiff_t charpos;
29704 Lisp_Object string, object = Qnil; 29728 Lisp_Object string, object = Qnil;
29705 Lisp_Object pos IF_LINT (= Qnil), help; 29729 Lisp_Object pos UNINIT;
29706
29707 Lisp_Object mouse_face; 29730 Lisp_Object mouse_face;
29708 int original_x_pixel = x; 29731 int original_x_pixel = x;
29709 struct glyph * glyph = NULL, * row_start_glyph = NULL; 29732 struct glyph * glyph = NULL, * row_start_glyph = NULL;
29710 struct glyph_row *row IF_LINT (= 0); 29733 struct glyph_row *row UNINIT;
29711 29734
29712 if (area == ON_MODE_LINE || area == ON_HEADER_LINE) 29735 if (area == ON_MODE_LINE || area == ON_HEADER_LINE)
29713 { 29736 {
@@ -29747,7 +29770,7 @@ note_mode_line_or_margin_highlight (Lisp_Object window, int x, int y,
29747 &object, &dx, &dy, &width, &height); 29770 &object, &dx, &dy, &width, &height);
29748 } 29771 }
29749 29772
29750 help = Qnil; 29773 Lisp_Object help = Qnil;
29751 29774
29752#ifdef HAVE_WINDOW_SYSTEM 29775#ifdef HAVE_WINDOW_SYSTEM
29753 if (IMAGEP (object)) 29776 if (IMAGEP (object))
@@ -29995,10 +30018,7 @@ note_mode_line_or_margin_highlight (Lisp_Object window, int x, int y,
29995 if ((area == ON_MODE_LINE || area == ON_HEADER_LINE) && !mouse_face_shown) 30018 if ((area == ON_MODE_LINE || area == ON_HEADER_LINE) && !mouse_face_shown)
29996 clear_mouse_face (hlinfo); 30019 clear_mouse_face (hlinfo);
29997 30020
29998#ifdef HAVE_WINDOW_SYSTEM 30021 define_frame_cursor1 (f, cursor, pointer);
29999 if (FRAME_WINDOW_P (f))
30000 define_frame_cursor1 (f, cursor, pointer);
30001#endif
30002} 30022}
30003 30023
30004 30024
@@ -30203,15 +30223,15 @@ note_mouse_highlight (struct frame *f, int x, int y)
30203 { 30223 {
30204 if (clear_mouse_face (hlinfo)) 30224 if (clear_mouse_face (hlinfo))
30205 cursor = No_Cursor; 30225 cursor = No_Cursor;
30206#ifdef HAVE_WINDOW_SYSTEM
30207 if (FRAME_WINDOW_P (f) && NILP (pointer)) 30226 if (FRAME_WINDOW_P (f) && NILP (pointer))
30208 { 30227 {
30228#ifdef HAVE_WINDOW_SYSTEM
30209 if (area != TEXT_AREA) 30229 if (area != TEXT_AREA)
30210 cursor = FRAME_X_OUTPUT (f)->nontext_cursor; 30230 cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
30211 else 30231 else
30212 pointer = Vvoid_text_area_pointer; 30232 pointer = Vvoid_text_area_pointer;
30213 }
30214#endif 30233#endif
30234 }
30215 goto set_cursor; 30235 goto set_cursor;
30216 } 30236 }
30217 30237
@@ -30322,8 +30342,8 @@ note_mouse_highlight (struct frame *f, int x, int y)
30322 { 30342 {
30323 /* The mouse-highlighting, if any, comes from an overlay 30343 /* The mouse-highlighting, if any, comes from an overlay
30324 or text property in the buffer. */ 30344 or text property in the buffer. */
30325 Lisp_Object buffer IF_LINT (= Qnil); 30345 Lisp_Object buffer UNINIT;
30326 Lisp_Object disp_string IF_LINT (= Qnil); 30346 Lisp_Object disp_string UNINIT;
30327 30347
30328 if (STRINGP (object)) 30348 if (STRINGP (object))
30329 { 30349 {
@@ -30523,15 +30543,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
30523 } 30543 }
30524 30544
30525 set_cursor: 30545 set_cursor:
30526 30546 define_frame_cursor1 (f, cursor, pointer);
30527#ifdef HAVE_WINDOW_SYSTEM
30528 if (FRAME_WINDOW_P (f))
30529 define_frame_cursor1 (f, cursor, pointer);
30530#else
30531 /* This is here to prevent a compiler error, about "label at end of
30532 compound statement". */
30533 return;
30534#endif
30535} 30547}
30536 30548
30537 30549
diff --git a/src/xfaces.c b/src/xfaces.c
index de73c010d54..0a1315d6f0d 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -1552,9 +1552,7 @@ the WIDTH times as wide as FACE on FRAME. */)
1552 /* This is of limited utility since it works with character 1552 /* This is of limited utility since it works with character
1553 widths. Keep it for compatibility. --gerd. */ 1553 widths. Keep it for compatibility. --gerd. */
1554 int face_id = lookup_named_face (f, face, false); 1554 int face_id = lookup_named_face (f, face, false);
1555 struct face *width_face = (face_id < 0 1555 struct face *width_face = FACE_FROM_ID_OR_NULL (f, face_id);
1556 ? NULL
1557 : FACE_FROM_ID (f, face_id));
1558 1556
1559 if (width_face && width_face->font) 1557 if (width_face && width_face->font)
1560 { 1558 {
@@ -3694,7 +3692,7 @@ Default face attributes override any local face attributes. */)
3694 if (EQ (face, Qdefault)) 3692 if (EQ (face, Qdefault))
3695 { 3693 {
3696 struct face_cache *c = FRAME_FACE_CACHE (f); 3694 struct face_cache *c = FRAME_FACE_CACHE (f);
3697 struct face *newface, *oldface = FACE_OPT_FROM_ID (f, DEFAULT_FACE_ID); 3695 struct face *newface, *oldface = FACE_FROM_ID_OR_NULL (f, DEFAULT_FACE_ID);
3698 Lisp_Object attrs[LFACE_VECTOR_SIZE]; 3696 Lisp_Object attrs[LFACE_VECTOR_SIZE];
3699 3697
3700 /* This can be NULL (e.g., in batch mode). */ 3698 /* This can be NULL (e.g., in batch mode). */
@@ -3777,7 +3775,7 @@ return the font name used for CHARACTER. */)
3777 { 3775 {
3778 struct frame *f = decode_live_frame (frame); 3776 struct frame *f = decode_live_frame (frame);
3779 int face_id = lookup_named_face (f, face, true); 3777 int face_id = lookup_named_face (f, face, true);
3780 struct face *fface = FACE_OPT_FROM_ID (f, face_id); 3778 struct face *fface = FACE_FROM_ID_OR_NULL (f, face_id);
3781 3779
3782 if (! fface) 3780 if (! fface)
3783 return Qnil; 3781 return Qnil;
@@ -3786,9 +3784,9 @@ return the font name used for CHARACTER. */)
3786 { 3784 {
3787 CHECK_CHARACTER (character); 3785 CHECK_CHARACTER (character);
3788 face_id = FACE_FOR_CHAR (f, fface, XINT (character), -1, Qnil); 3786 face_id = FACE_FOR_CHAR (f, fface, XINT (character), -1, Qnil);
3789 fface = FACE_FROM_ID (f, face_id); 3787 fface = FACE_FROM_ID_OR_NULL (f, face_id);
3790 } 3788 }
3791 return (fface->font 3789 return ((fface && fface->font)
3792 ? fface->font->props[FONT_NAME_INDEX] 3790 ? fface->font->props[FONT_NAME_INDEX]
3793 : Qnil); 3791 : Qnil);
3794#else /* !HAVE_WINDOW_SYSTEM */ 3792#else /* !HAVE_WINDOW_SYSTEM */
@@ -4376,7 +4374,7 @@ lookup_face (struct frame *f, Lisp_Object *attr)
4376 face = realize_face (cache, attr, -1); 4374 face = realize_face (cache, attr, -1);
4377 4375
4378#ifdef GLYPH_DEBUG 4376#ifdef GLYPH_DEBUG
4379 eassert (face == FACE_FROM_ID (f, face->id)); 4377 eassert (face == FACE_FROM_ID_OR_NULL (f, face->id));
4380#endif /* GLYPH_DEBUG */ 4378#endif /* GLYPH_DEBUG */
4381 4379
4382 return face->id; 4380 return face->id;
@@ -4429,7 +4427,7 @@ lookup_named_face (struct frame *f, Lisp_Object symbol, bool signal_p)
4429{ 4427{
4430 Lisp_Object attrs[LFACE_VECTOR_SIZE]; 4428 Lisp_Object attrs[LFACE_VECTOR_SIZE];
4431 Lisp_Object symbol_attrs[LFACE_VECTOR_SIZE]; 4429 Lisp_Object symbol_attrs[LFACE_VECTOR_SIZE];
4432 struct face *default_face = FACE_OPT_FROM_ID (f, DEFAULT_FACE_ID); 4430 struct face *default_face = FACE_FROM_ID_OR_NULL (f, DEFAULT_FACE_ID);
4433 4431
4434 if (default_face == NULL) 4432 if (default_face == NULL)
4435 { 4433 {
@@ -4596,11 +4594,12 @@ lookup_derived_face (struct frame *f, Lisp_Object symbol, int face_id,
4596{ 4594{
4597 Lisp_Object attrs[LFACE_VECTOR_SIZE]; 4595 Lisp_Object attrs[LFACE_VECTOR_SIZE];
4598 Lisp_Object symbol_attrs[LFACE_VECTOR_SIZE]; 4596 Lisp_Object symbol_attrs[LFACE_VECTOR_SIZE];
4599 struct face *default_face = FACE_FROM_ID (f, face_id); 4597 struct face *default_face;
4600 4598
4601 if (!get_lface_attributes (f, symbol, symbol_attrs, signal_p, 0)) 4599 if (!get_lface_attributes (f, symbol, symbol_attrs, signal_p, 0))
4602 return -1; 4600 return -1;
4603 4601
4602 default_face = FACE_FROM_ID (f, face_id);
4604 memcpy (attrs, default_face->lface, sizeof attrs); 4603 memcpy (attrs, default_face->lface, sizeof attrs);
4605 merge_face_vectors (f, symbol_attrs, attrs, 0); 4604 merge_face_vectors (f, symbol_attrs, attrs, 0);
4606 return lookup_face (f, attrs); 4605 return lookup_face (f, attrs);
@@ -4701,7 +4700,7 @@ x_supports_face_attributes_p (struct frame *f,
4701 merge_face_vectors (f, attrs, merged_attrs, 0); 4700 merge_face_vectors (f, attrs, merged_attrs, 0);
4702 4701
4703 face_id = lookup_face (f, merged_attrs); 4702 face_id = lookup_face (f, merged_attrs);
4704 face = FACE_OPT_FROM_ID (f, face_id); 4703 face = FACE_FROM_ID_OR_NULL (f, face_id);
4705 4704
4706 if (! face) 4705 if (! face)
4707 error ("Cannot make face"); 4706 error ("Cannot make face");
@@ -4971,7 +4970,7 @@ face for italic. */)
4971 attrs[i] = Qunspecified; 4970 attrs[i] = Qunspecified;
4972 merge_face_ref (f, attributes, attrs, true, 0); 4971 merge_face_ref (f, attributes, attrs, true, 0);
4973 4972
4974 def_face = FACE_OPT_FROM_ID (f, DEFAULT_FACE_ID); 4973 def_face = FACE_FROM_ID_OR_NULL (f, DEFAULT_FACE_ID);
4975 if (def_face == NULL) 4974 if (def_face == NULL)
4976 { 4975 {
4977 if (! realize_basic_faces (f)) 4976 if (! realize_basic_faces (f))
@@ -5198,7 +5197,6 @@ realize_default_face (struct frame *f)
5198 struct face_cache *c = FRAME_FACE_CACHE (f); 5197 struct face_cache *c = FRAME_FACE_CACHE (f);
5199 Lisp_Object lface; 5198 Lisp_Object lface;
5200 Lisp_Object attrs[LFACE_VECTOR_SIZE]; 5199 Lisp_Object attrs[LFACE_VECTOR_SIZE];
5201 struct face *face;
5202 5200
5203 /* If the `default' face is not yet known, create it. */ 5201 /* If the `default' face is not yet known, create it. */
5204 lface = lface_from_face_name (f, Qdefault, false); 5202 lface = lface_from_face_name (f, Qdefault, false);
@@ -5288,10 +5286,11 @@ realize_default_face (struct frame *f)
5288 eassert (lface_fully_specified_p (XVECTOR (lface)->contents)); 5286 eassert (lface_fully_specified_p (XVECTOR (lface)->contents));
5289 check_lface (lface); 5287 check_lface (lface);
5290 memcpy (attrs, XVECTOR (lface)->contents, sizeof attrs); 5288 memcpy (attrs, XVECTOR (lface)->contents, sizeof attrs);
5291 face = realize_face (c, attrs, DEFAULT_FACE_ID); 5289 struct face *face = realize_face (c, attrs, DEFAULT_FACE_ID);
5292 5290
5293#ifdef HAVE_WINDOW_SYSTEM 5291#ifndef HAVE_WINDOW_SYSTEM
5294#ifdef HAVE_X_WINDOWS 5292 (void) face;
5293#else
5295 if (FRAME_X_P (f) && face->font != FRAME_FONT (f)) 5294 if (FRAME_X_P (f) && face->font != FRAME_FONT (f))
5296 { 5295 {
5297 /* This can happen when making a frame on a display that does 5296 /* This can happen when making a frame on a display that does
@@ -5305,8 +5304,7 @@ realize_default_face (struct frame *f)
5305 font. */ 5304 font. */
5306 x_set_font (f, LFACE_FONT (lface), Qnil); 5305 x_set_font (f, LFACE_FONT (lface), Qnil);
5307 } 5306 }
5308#endif /* HAVE_X_WINDOWS */ 5307#endif
5309#endif /* HAVE_WINDOW_SYSTEM */
5310 return true; 5308 return true;
5311} 5309}
5312 5310
@@ -5446,7 +5444,7 @@ realize_x_face (struct face_cache *cache, Lisp_Object attrs[LFACE_VECTOR_SIZE])
5446 5444
5447 /* Determine the font to use. Most of the time, the font will be 5445 /* Determine the font to use. Most of the time, the font will be
5448 the same as the font of the default face, so try that first. */ 5446 the same as the font of the default face, so try that first. */
5449 default_face = FACE_OPT_FROM_ID (f, DEFAULT_FACE_ID); 5447 default_face = FACE_FROM_ID_OR_NULL (f, DEFAULT_FACE_ID);
5450 if (default_face 5448 if (default_face
5451 && lface_same_font_attributes_p (default_face->lface, attrs)) 5449 && lface_same_font_attributes_p (default_face->lface, attrs))
5452 { 5450 {
@@ -6094,7 +6092,7 @@ face_at_string_position (struct window *w, Lisp_Object string,
6094 if we don't have fonts, so we can stop here if not working 6092 if we don't have fonts, so we can stop here if not working
6095 on a window-system frame. */ 6093 on a window-system frame. */
6096 || !FRAME_WINDOW_P (f) 6094 || !FRAME_WINDOW_P (f)
6097 || FACE_SUITABLE_FOR_ASCII_CHAR_P (base_face, 0))) 6095 || FACE_SUITABLE_FOR_ASCII_CHAR_P (base_face)))
6098 return base_face->id; 6096 return base_face->id;
6099 6097
6100 /* Begin with attributes from the base face. */ 6098 /* Begin with attributes from the base face. */
@@ -6132,7 +6130,7 @@ merge_faces (struct frame *f, Lisp_Object face_name, int face_id,
6132 Lisp_Object attrs[LFACE_VECTOR_SIZE]; 6130 Lisp_Object attrs[LFACE_VECTOR_SIZE];
6133 struct face *base_face; 6131 struct face *base_face;
6134 6132
6135 base_face = FACE_OPT_FROM_ID (f, base_face_id); 6133 base_face = FACE_FROM_ID_OR_NULL (f, base_face_id);
6136 if (!base_face) 6134 if (!base_face)
6137 return base_face_id; 6135 return base_face_id;
6138 6136
@@ -6160,7 +6158,7 @@ merge_faces (struct frame *f, Lisp_Object face_name, int face_id,
6160 struct face *face; 6158 struct face *face;
6161 if (face_id < 0) 6159 if (face_id < 0)
6162 return base_face_id; 6160 return base_face_id;
6163 face = FACE_OPT_FROM_ID (f, face_id); 6161 face = FACE_FROM_ID_OR_NULL (f, face_id);
6164 if (!face) 6162 if (!face)
6165 return base_face_id; 6163 return base_face_id;
6166 merge_face_vectors (f, face->lface, attrs, 0); 6164 merge_face_vectors (f, face->lface, attrs, 0);
@@ -6280,7 +6278,7 @@ DEFUN ("dump-face", Fdump_face, Sdump_face, 0, 1, 0, doc: /* */)
6280 { 6278 {
6281 struct face *face; 6279 struct face *face;
6282 CHECK_NUMBER (n); 6280 CHECK_NUMBER (n);
6283 face = FACE_OPT_FROM_ID (SELECTED_FRAME (), XINT (n)); 6281 face = FACE_FROM_ID_OR_NULL (SELECTED_FRAME (), XINT (n));
6284 if (face == NULL) 6282 if (face == NULL)
6285 error ("Not a valid face"); 6283 error ("Not a valid face");
6286 dump_realized_face (face); 6284 dump_realized_face (face);
@@ -6494,8 +6492,8 @@ REPLACEMENT is a face specification, i.e. one of the following:
6494 (3) a list in which each element has the form of (1) or (2). 6492 (3) a list in which each element has the form of (1) or (2).
6495 6493
6496List values for REPLACEMENT are merged to form the final face 6494List values for REPLACEMENT are merged to form the final face
6497specification, with earlier entries taking precedence, in the same as 6495specification, with earlier entries taking precedence, in the same way
6498as in the `face' text property. 6496as with the `face' text property.
6499 6497
6500Face-name remapping cycles are suppressed; recursive references use 6498Face-name remapping cycles are suppressed; recursive references use
6501the underlying face instead of the remapped face. So a remapping of 6499the underlying face instead of the remapped face. So a remapping of
diff --git a/src/xfns.c b/src/xfns.c
index 9ff77738c11..c44997b3d6f 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -91,11 +91,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
91#include "../lwlib/xlwmenu.h" 91#include "../lwlib/xlwmenu.h"
92#endif 92#endif
93 93
94#if !defined (NO_EDITRES)
95#define HACK_EDITRES
96extern void _XEditResCheckMessages (Widget, XtPointer, XEvent *, Boolean *);
97#endif /* not defined NO_EDITRES */
98
99/* Unique id counter for widgets created by the Lucid Widget Library. */ 94/* Unique id counter for widgets created by the Lucid Widget Library. */
100 95
101extern LWLIB_ID widget_id_tick; 96extern LWLIB_ID widget_id_tick;
@@ -1434,7 +1429,7 @@ x_set_internal_border_width (struct frame *f, Lisp_Object arg, Lisp_Object oldva
1434 1429
1435 if (border != FRAME_INTERNAL_BORDER_WIDTH (f)) 1430 if (border != FRAME_INTERNAL_BORDER_WIDTH (f))
1436 { 1431 {
1437 FRAME_INTERNAL_BORDER_WIDTH (f) = border; 1432 f->internal_border_width = border;
1438 1433
1439#ifdef USE_X_TOOLKIT 1434#ifdef USE_X_TOOLKIT
1440 if (FRAME_X_OUTPUT (f)->edit_widget) 1435 if (FRAME_X_OUTPUT (f)->edit_widget)
@@ -2662,7 +2657,7 @@ x_window (struct frame *f, long window_prompting)
2662 2657
2663 hack_wm_protocols (f, shell_widget); 2658 hack_wm_protocols (f, shell_widget);
2664 2659
2665#ifdef HACK_EDITRES 2660#ifdef X_TOOLKIT_EDITRES
2666 XtAddEventHandler (shell_widget, 0, True, _XEditResCheckMessages, 0); 2661 XtAddEventHandler (shell_widget, 0, True, _XEditResCheckMessages, 0);
2667#endif 2662#endif
2668 2663
@@ -4286,7 +4281,7 @@ x_get_monitor_attributes_xrandr (struct x_display_info *dpyinfo)
4286 n_monitors = resources->noutput; 4281 n_monitors = resources->noutput;
4287 monitors = xzalloc (n_monitors * sizeof *monitors); 4282 monitors = xzalloc (n_monitors * sizeof *monitors);
4288 4283
4289#ifdef RANDR13_LIBRARY 4284#if RANDR13_LIBRARY
4290 if (randr13_avail) 4285 if (randr13_avail)
4291 pxid = XRRGetOutputPrimary (dpy, dpyinfo->root_window); 4286 pxid = XRRGetOutputPrimary (dpy, dpyinfo->root_window);
4292#endif 4287#endif
@@ -4295,8 +4290,8 @@ x_get_monitor_attributes_xrandr (struct x_display_info *dpyinfo)
4295 { 4290 {
4296 XRROutputInfo *info = XRRGetOutputInfo (dpy, resources, 4291 XRROutputInfo *info = XRRGetOutputInfo (dpy, resources,
4297 resources->outputs[i]); 4292 resources->outputs[i]);
4298 Connection conn = info ? info->connection : RR_Disconnected; 4293 if (!info)
4299 RRCrtc id = info ? info->crtc : None; 4294 continue;
4300 4295
4301 if (strcmp (info->name, "default") == 0) 4296 if (strcmp (info->name, "default") == 0)
4302 { 4297 {
@@ -4307,9 +4302,9 @@ x_get_monitor_attributes_xrandr (struct x_display_info *dpyinfo)
4307 return Qnil; 4302 return Qnil;
4308 } 4303 }
4309 4304
4310 if (conn != RR_Disconnected && id != None) 4305 if (info->connection != RR_Disconnected && info->crtc != None)
4311 { 4306 {
4312 XRRCrtcInfo *crtc = XRRGetCrtcInfo (dpy, resources, id); 4307 XRRCrtcInfo *crtc = XRRGetCrtcInfo (dpy, resources, info->crtc);
4313 struct MonitorInfo *mi = &monitors[i]; 4308 struct MonitorInfo *mi = &monitors[i];
4314 XRectangle workarea_r; 4309 XRectangle workarea_r;
4315 4310
@@ -6351,7 +6346,7 @@ value of DIR as in previous invocations; this is standard Windows behavior. */)
6351 6346
6352 /* Make "Cancel" equivalent to C-g. */ 6347 /* Make "Cancel" equivalent to C-g. */
6353 if (NILP (file)) 6348 if (NILP (file))
6354 Fsignal (Qquit, Qnil); 6349 quit ();
6355 6350
6356 decoded_file = DECODE_FILE (file); 6351 decoded_file = DECODE_FILE (file);
6357 6352
@@ -6423,7 +6418,7 @@ value of DIR as in previous invocations; this is standard Windows behavior. */)
6423 6418
6424 /* Make "Cancel" equivalent to C-g. */ 6419 /* Make "Cancel" equivalent to C-g. */
6425 if (NILP (file)) 6420 if (NILP (file))
6426 Fsignal (Qquit, Qnil); 6421 quit ();
6427 6422
6428 decoded_file = DECODE_FILE (file); 6423 decoded_file = DECODE_FILE (file);
6429 6424
@@ -6474,7 +6469,7 @@ nil, it defaults to the selected frame. */)
6474 unblock_input (); 6469 unblock_input ();
6475 6470
6476 if (NILP (font)) 6471 if (NILP (font))
6477 Fsignal (Qquit, Qnil); 6472 quit ();
6478 6473
6479 return unbind_to (count, font); 6474 return unbind_to (count, font);
6480} 6475}
diff --git a/src/xfont.c b/src/xfont.c
index 0ef64bef10e..8fbe94c01ab 100644
--- a/src/xfont.c
+++ b/src/xfont.c
@@ -635,7 +635,7 @@ xfont_list_family (struct frame *f)
635 char **names; 635 char **names;
636 int num_fonts, i; 636 int num_fonts, i;
637 Lisp_Object list; 637 Lisp_Object list;
638 char *last_family IF_LINT (= 0); 638 char *last_family UNINIT;
639 int last_len; 639 int last_len;
640 640
641 block_input (); 641 block_input ();
diff --git a/src/xmenu.c b/src/xmenu.c
index 9e1a817946a..9ab7bdf971f 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -1649,7 +1649,7 @@ x_menu_show (struct frame *f, int x, int y, int menuflags,
1649 { 1649 {
1650 unblock_input (); 1650 unblock_input ();
1651 /* Make "Cancel" equivalent to C-g. */ 1651 /* Make "Cancel" equivalent to C-g. */
1652 Fsignal (Qquit, Qnil); 1652 quit ();
1653 } 1653 }
1654 1654
1655 unblock_input (); 1655 unblock_input ();
@@ -1913,7 +1913,7 @@ x_dialog_show (struct frame *f, Lisp_Object title,
1913 } 1913 }
1914 else 1914 else
1915 /* Make "Cancel" equivalent to C-g. */ 1915 /* Make "Cancel" equivalent to C-g. */
1916 Fsignal (Qquit, Qnil); 1916 quit ();
1917 1917
1918 return Qnil; 1918 return Qnil;
1919} 1919}
@@ -2304,7 +2304,7 @@ x_menu_show (struct frame *f, int x, int y, int menuflags,
2304 if (!(menuflags & MENU_FOR_CLICK)) 2304 if (!(menuflags & MENU_FOR_CLICK))
2305 { 2305 {
2306 unblock_input (); 2306 unblock_input ();
2307 Fsignal (Qquit, Qnil); 2307 quit ();
2308 } 2308 }
2309 break; 2309 break;
2310 } 2310 }
diff --git a/src/xterm.c b/src/xterm.c
index 9fb19a16f60..cd1d712f39a 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -95,10 +95,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
95#endif 95#endif
96 96
97#ifdef USE_X_TOOLKIT 97#ifdef USE_X_TOOLKIT
98#if !defined (NO_EDITRES)
99#define HACK_EDITRES
100extern void _XEditResCheckMessages (Widget, XtPointer, XEvent *, Boolean *);
101#endif /* not NO_EDITRES */
102 98
103/* Include toolkit specific headers for the scroll bar widget. */ 99/* Include toolkit specific headers for the scroll bar widget. */
104 100
@@ -1062,7 +1058,7 @@ x_draw_vertical_window_border (struct window *w, int x, int y0, int y1)
1062 struct frame *f = XFRAME (WINDOW_FRAME (w)); 1058 struct frame *f = XFRAME (WINDOW_FRAME (w));
1063 struct face *face; 1059 struct face *face;
1064 1060
1065 face = FACE_OPT_FROM_ID (f, VERTICAL_BORDER_FACE_ID); 1061 face = FACE_FROM_ID_OR_NULL (f, VERTICAL_BORDER_FACE_ID);
1066 if (face) 1062 if (face)
1067 XSetForeground (FRAME_X_DISPLAY (f), f->output_data.x->normal_gc, 1063 XSetForeground (FRAME_X_DISPLAY (f), f->output_data.x->normal_gc,
1068 face->foreground); 1064 face->foreground);
@@ -1081,11 +1077,11 @@ static void
1081x_draw_window_divider (struct window *w, int x0, int x1, int y0, int y1) 1077x_draw_window_divider (struct window *w, int x0, int x1, int y0, int y1)
1082{ 1078{
1083 struct frame *f = XFRAME (WINDOW_FRAME (w)); 1079 struct frame *f = XFRAME (WINDOW_FRAME (w));
1084 struct face *face = FACE_OPT_FROM_ID (f, WINDOW_DIVIDER_FACE_ID); 1080 struct face *face = FACE_FROM_ID_OR_NULL (f, WINDOW_DIVIDER_FACE_ID);
1085 struct face *face_first 1081 struct face *face_first
1086 = FACE_OPT_FROM_ID (f, WINDOW_DIVIDER_FIRST_PIXEL_FACE_ID); 1082 = FACE_FROM_ID_OR_NULL (f, WINDOW_DIVIDER_FIRST_PIXEL_FACE_ID);
1087 struct face *face_last 1083 struct face *face_last
1088 = FACE_OPT_FROM_ID (f, WINDOW_DIVIDER_LAST_PIXEL_FACE_ID); 1084 = FACE_FROM_ID_OR_NULL (f, WINDOW_DIVIDER_LAST_PIXEL_FACE_ID);
1089 unsigned long color = face ? face->foreground : FRAME_FOREGROUND_PIXEL (f); 1085 unsigned long color = face ? face->foreground : FRAME_FOREGROUND_PIXEL (f);
1090 unsigned long color_first = (face_first 1086 unsigned long color_first = (face_first
1091 ? face_first->foreground 1087 ? face_first->foreground
@@ -1507,7 +1503,7 @@ x_set_mouse_face_gc (struct glyph_string *s)
1507 1503
1508 /* What face has to be used last for the mouse face? */ 1504 /* What face has to be used last for the mouse face? */
1509 face_id = MOUSE_HL_INFO (s->f)->mouse_face_face_id; 1505 face_id = MOUSE_HL_INFO (s->f)->mouse_face_face_id;
1510 face = FACE_OPT_FROM_ID (s->f, face_id); 1506 face = FACE_FROM_ID_OR_NULL (s->f, face_id);
1511 if (face == NULL) 1507 if (face == NULL)
1512 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID); 1508 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
1513 1509
@@ -7610,7 +7606,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
7610 goto done; 7606 goto done;
7611 } 7607 }
7612 7608
7613#ifdef HACK_EDITRES 7609#ifdef X_TOOLKIT_EDITRES
7614 if (event->xclient.message_type == dpyinfo->Xatom_editres) 7610 if (event->xclient.message_type == dpyinfo->Xatom_editres)
7615 { 7611 {
7616 f = any; 7612 f = any;
@@ -7619,7 +7615,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
7619 NULL, (XEvent *) event, NULL); 7615 NULL, (XEvent *) event, NULL);
7620 goto done; 7616 goto done;
7621 } 7617 }
7622#endif /* HACK_EDITRES */ 7618#endif /* X_TOOLKIT_EDITRES */
7623 7619
7624 if (event->xclient.message_type == dpyinfo->Xatom_DONE 7620 if (event->xclient.message_type == dpyinfo->Xatom_DONE
7625 || event->xclient.message_type == dpyinfo->Xatom_PAGE) 7621 || event->xclient.message_type == dpyinfo->Xatom_PAGE)
diff --git a/src/xterm.h b/src/xterm.h
index 8e1fc788bc1..675a48443dc 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -38,6 +38,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
38#include <X11/CoreP.h> /* foul, but we need this to use our own 38#include <X11/CoreP.h> /* foul, but we need this to use our own
39 window inside a widget instead of one 39 window inside a widget instead of one
40 that Xt creates... */ 40 that Xt creates... */
41#ifdef X_TOOLKIT_EDITRES
42#include <X11/Xmu/Editres.h>
43#endif
44
41typedef Widget xt_or_gtk_widget; 45typedef Widget xt_or_gtk_widget;
42#endif 46#endif
43 47
diff --git a/src/xwidget.c b/src/xwidget.c
index 82449f7a215..f5f4da0d369 100644
--- a/src/xwidget.c
+++ b/src/xwidget.c
@@ -21,87 +21,13 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21 21
22#include "xwidget.h" 22#include "xwidget.h"
23 23
24#include <signal.h>
25
26#include <stdio.h>
27#include <setjmp.h>
28#ifdef HAVE_X_WINDOWS
29
30#include "lisp.h" 24#include "lisp.h"
31#include "blockinput.h" 25#include "blockinput.h"
32#include "syssignal.h"
33
34#include "xterm.h"
35#include <X11/cursorfont.h>
36
37#ifndef makedev
38# include <sys/types.h>
39#endif
40
41#ifdef BSD_SYSTEM
42# include <sys/ioctl.h>
43#endif
44
45#include "systime.h"
46
47#ifndef INCLUDED_FCNTL
48# include <fcntl.h>
49#endif
50#include <ctype.h>
51#include <errno.h>
52#include <setjmp.h>
53#include <sys/stat.h>
54
55#include "charset.h"
56#include "character.h"
57#include "coding.h"
58#include "ccl.h"
59#include "frame.h" 26#include "frame.h"
60#include "dispextern.h"
61#include "fontset.h"
62#include "termhooks.h"
63#include "termopts.h"
64#include "termchar.h"
65#include "disptab.h"
66#include "buffer.h"
67#include "window.h"
68#include "keyboard.h" 27#include "keyboard.h"
69#include "intervals.h"
70#include "process.h"
71#include "atimer.h"
72#include "keymap.h"
73
74
75#ifdef USE_X_TOOLKIT
76#include <X11/Shell.h>
77#endif
78#include <X11/extensions/Xcomposite.h>
79#include <X11/extensions/Xrender.h>
80#include <cairo.h>
81#ifdef HAVE_SYS_TIME_H
82#include <sys/time.h>
83#endif
84#ifdef HAVE_UNISTD_H
85#include <unistd.h>
86#endif
87
88#include "gtkutil.h" 28#include "gtkutil.h"
89#include "font.h"
90#endif /* HAVE_X_WINDOWS */
91
92#include <gtk/gtk.h>
93#include <gdk/gdk.h>
94
95#include <gtk/gtkx.h>
96
97#include "emacsgtkfixed.h"
98
99#include <wchar.h>
100 29
101#include <webkit/webkitwebview.h> 30#include <webkit/webkitwebview.h>
102#include <webkit/webkitwebplugindatabase.h>
103#include <webkit/webkitwebplugin.h>
104#include <webkit/webkitglobals.h>
105#include <webkit/webkitwebnavigationaction.h> 31#include <webkit/webkitwebnavigationaction.h>
106#include <webkit/webkitdownload.h> 32#include <webkit/webkitdownload.h>
107#include <webkit/webkitwebpolicydecision.h> 33#include <webkit/webkitwebpolicydecision.h>
@@ -565,12 +491,16 @@ x_draw_xwidget_glyph_string (struct glyph_string *s)
565 xwidget on screen. Moving and clipping is done here. Also view 491 xwidget on screen. Moving and clipping is done here. Also view
566 initialization. */ 492 initialization. */
567 struct xwidget *xww = s->xwidget; 493 struct xwidget *xww = s->xwidget;
568 struct xwidget_view *xv = xwidget_view_lookup (xww, s->w); 494 struct xwidget_view *xv;
569 int clip_right; 495 int clip_right;
570 int clip_bottom; 496 int clip_bottom;
571 int clip_top; 497 int clip_top;
572 int clip_left; 498 int clip_left;
573 499
500 /* FIXME: The result of this call is discarded.
501 What if the lookup fails? */
502 xwidget_view_lookup (xww, s->w);
503
574 int x = s->x; 504 int x = s->x;
575 int y = s->y + (s->height / 2) - (xww->height / 2); 505 int y = s->y + (s->height / 2) - (xww->height / 2);
576 506
@@ -1145,7 +1075,13 @@ xwidget_end_redisplay (struct window *w, struct glyph_matrix *matrix)
1145 { 1075 {
1146 /* The only call to xwidget_end_redisplay is in dispnew. 1076 /* The only call to xwidget_end_redisplay is in dispnew.
1147 xwidget_end_redisplay (w->current_matrix); */ 1077 xwidget_end_redisplay (w->current_matrix); */
1148 xwidget_touch (xwidget_view_lookup (glyph->u.xwidget, w)); 1078 struct xwidget_view *xv
1079 = xwidget_view_lookup (glyph->u.xwidget, w);
1080 /* FIXME: Is it safe to assume xwidget_view_lookup
1081 always succeeds here? If so, this comment can be removed.
1082 If not, the code probably needs fixing. */
1083 eassume (xv);
1084 xwidget_touch (xv);
1149 } 1085 }
1150 } 1086 }
1151 } 1087 }