aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJan D2015-04-26 13:55:01 +0200
committerJan D2015-04-26 13:55:01 +0200
commitf92ac2e82ed199d6f25d2a59508e08addb1150ac (patch)
treed7d7756e3dbce10d8f73c27815d815499f78c2bd /src
parent5a094119ce79723108abd90a1fcc33721e964823 (diff)
parenta40869789fc5502e3d4e393b7c31d78cb7f29aa1 (diff)
downloademacs-f92ac2e82ed199d6f25d2a59508e08addb1150ac.tar.gz
emacs-f92ac2e82ed199d6f25d2a59508e08addb1150ac.zip
Merge branch 'master' into cairo
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog.13 (renamed from src/ChangeLog)27
-rw-r--r--src/callproc.c4
-rw-r--r--src/ccl.c2
-rw-r--r--src/character.c43
-rw-r--r--src/character.h2
-rw-r--r--src/cmds.c60
-rw-r--r--src/dbusbind.c4
-rw-r--r--src/editfns.c10
-rw-r--r--src/eval.c12
-rw-r--r--src/fileio.c34
-rw-r--r--src/gnutls.c12
-rw-r--r--src/gtkutil.c6
-rw-r--r--src/image.c9
-rw-r--r--src/insdel.c2
-rw-r--r--src/keyboard.c3
-rw-r--r--src/lisp.h2
-rw-r--r--src/lread.c9
-rw-r--r--src/print.c557
-rw-r--r--src/process.c406
-rw-r--r--src/process.h3
-rw-r--r--src/regex.c19
-rw-r--r--src/term.c8
-rw-r--r--src/textprop.c171
-rw-r--r--src/tparam.c8
-rw-r--r--src/undo.c8
-rw-r--r--src/w32.c20
-rw-r--r--src/w32.h1
-rw-r--r--src/w32fns.c27
-rw-r--r--src/w32proc.c35
-rw-r--r--src/widget.c23
-rw-r--r--src/window.c636
-rw-r--r--src/window.h20
-rw-r--r--src/xdisp.c13
-rw-r--r--src/xfaces.c2
-rw-r--r--src/xselect.c28
-rw-r--r--src/xterm.c6
36 files changed, 1304 insertions, 928 deletions
diff --git a/src/ChangeLog b/src/ChangeLog.13
index 78070072438..8057b6e75d6 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog.13
@@ -31,6 +31,12 @@
31 (tiff_load): Create cairo image surface if USE_CAIRO. 31 (tiff_load): Create cairo image surface if USE_CAIRO.
32 (gif_load): Ditto. 32 (gif_load): Ditto.
33 33
342015-04-06 Koichi Arakawa <arakawa@pp.iij4u.or.jp> (tiny change)
35
36 * w32proc.c (w32_executable_type): Look for the DLL name in the
37 correct section. This avoids segfaults with some executables.
38 (Bug#20264)
39
342015-04-05 Jan Djärv <jan.h.d@swipnet.se> 402015-04-05 Jan Djärv <jan.h.d@swipnet.se>
35 41
36 * image.c: #undef COLOR_TABLE_SUPPORT when USE_CAIRO. 42 * image.c: #undef COLOR_TABLE_SUPPORT when USE_CAIRO.
@@ -40,6 +46,15 @@
40 46
41 * dispextern.h (struct image): add cr_data2 if cairo. 47 * dispextern.h (struct image): add cr_data2 if cairo.
42 48
492015-04-04 Jan Djärv <jan.h.d@swipnet.se>
50
51 * xselect.c (x_reply_selection_request)
52 (receive_incremental_selection): Call set_property_change_object
53 inside block_input.
54 (wait_for_property_change): Move set property_change_reply(_object)
55 outside of this function (Bug#16737).
56 (set_property_change_object): New function.
57
432015-04-03 Jan Djärv <jan.h.d@swipnet.se> 582015-04-03 Jan Djärv <jan.h.d@swipnet.se>
44 59
45 * image.c (prepare_image_for_display): Don't load if USE_CAIRO. 60 * image.c (prepare_image_for_display): Don't load if USE_CAIRO.
@@ -160,7 +175,7 @@
160 Fix minor ldexp issues 175 Fix minor ldexp issues
161 * floatfns.c (Fldexp): Require 2 args. Avoid undefined behavior 176 * floatfns.c (Fldexp): Require 2 args. Avoid undefined behavior
162 if the exponent is out of 'int' range. Improve documentation. 177 if the exponent is out of 'int' range. Improve documentation.
163 Fixes: bug#20185 178 (Bug#20185)
164 179
1652015-03-24 Daniel Colascione <dancol@dancol.org> 1802015-03-24 Daniel Colascione <dancol@dancol.org>
166 181
@@ -251,7 +266,7 @@
251 266
252 Work around x86 glibc backtrace bug 267 Work around x86 glibc backtrace bug
253 * sysdep.c (emacs_backtrace): Don't dump core on x86. 268 * sysdep.c (emacs_backtrace): Don't dump core on x86.
254 Fixes: bug#19959 269 (Bug#19959)
255 270
2562015-03-05 Eli Zaretskii <eliz@gnu.org> 2712015-03-05 Eli Zaretskii <eliz@gnu.org>
257 272
@@ -1300,7 +1315,7 @@
1300 to unused args. 1315 to unused args.
1301 * lisp.h (CALLMANY, CALLN): New macros. 1316 * lisp.h (CALLMANY, CALLN): New macros.
1302 * sound.c (Fplay_sound_internal): Coalesce duplicate code. 1317 * sound.c (Fplay_sound_internal): Coalesce duplicate code.
1303 Fixes: bug#19634 1318 (Bug#19634)
1304 1319
1305 Use gnustep-config if available 1320 Use gnustep-config if available
1306 * emacs.c [NS_IMPL_GNUSTEP]: Don't include <GNUstepBase/GSConfig.h>. 1321 * emacs.c [NS_IMPL_GNUSTEP]: Don't include <GNUstepBase/GSConfig.h>.
@@ -1324,7 +1339,7 @@
1324 1339
1325 Don't downcase system diagnostics' first letters 1340 Don't downcase system diagnostics' first letters
1326 * fileio.c (report_file_errno): Don't downcase, and simplify. 1341 * fileio.c (report_file_errno): Don't downcase, and simplify.
1327 Fixes: bug#19642 1342 (Bug#19642)
1328 1343
1329 Isolate NIL_IS_ZERO-assuming code better 1344 Isolate NIL_IS_ZERO-assuming code better
1330 Suggested by Stefan Monnier in: 1345 Suggested by Stefan Monnier in:
@@ -1369,7 +1384,7 @@
1369 1384
1370 Correct an old fix for GTK font selection 1385 Correct an old fix for GTK font selection
1371 * gtkutil.c (xg_get_font): Fix off-by-2 typo. 1386 * gtkutil.c (xg_get_font): Fix off-by-2 typo.
1372 Fixes: bug#3228 1387 (Bug#3228)
1373 1388
1374 Fix minor bugs with printing null bytes 1389 Fix minor bugs with printing null bytes
1375 * minibuf.c (read_minibuf_noninteractive): 1390 * minibuf.c (read_minibuf_noninteractive):
@@ -2358,7 +2373,7 @@
2358 * fileio.c (Finsert_file_contents): Compute same_at_end character 2373 * fileio.c (Finsert_file_contents): Compute same_at_end character
2359 position using the old buffer size, not the new one, since 2374 position using the old buffer size, not the new one, since
2360 restore_window_points wants the old size. 2375 restore_window_points wants the old size.
2361 Fixes: debbugs:19161 2376 (Bug#19161)
2362 2377
23632014-12-14 Alan Mackenzie <acm@muc.de> 23782014-12-14 Alan Mackenzie <acm@muc.de>
2364 2379
diff --git a/src/callproc.c b/src/callproc.c
index e1fe8ed95df..12c81439fe4 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -1595,12 +1595,12 @@ init_callproc (void)
1595#ifdef HAVE_NS 1595#ifdef HAVE_NS
1596 const char *path_exec = ns_exec_path (); 1596 const char *path_exec = ns_exec_path ();
1597#endif 1597#endif
1598 /* Running uninstalled, so default to tem rather than PATH_EXEC. */
1598 Vexec_path = decode_env_path ("EMACSPATH", 1599 Vexec_path = decode_env_path ("EMACSPATH",
1599#ifdef HAVE_NS 1600#ifdef HAVE_NS
1600 path_exec ? path_exec : 1601 path_exec ? path_exec :
1601#endif 1602#endif
1602 PATH_EXEC, 0); 1603 SSDATA (tem), 0);
1603 Vexec_path = Fcons (tem, Vexec_path);
1604 Vexec_path = nconc2 (decode_env_path ("PATH", "", 0), Vexec_path); 1604 Vexec_path = nconc2 (decode_env_path ("PATH", "", 0), Vexec_path);
1605 } 1605 }
1606 1606
diff --git a/src/ccl.c b/src/ccl.c
index 053544c8274..88307a30aa6 100644
--- a/src/ccl.c
+++ b/src/ccl.c
@@ -1713,7 +1713,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
1713 case CCL_STAT_INVALID_CMD: 1713 case CCL_STAT_INVALID_CMD:
1714 msglen = sprintf (msg, 1714 msglen = sprintf (msg,
1715 "\nCCL: Invalid command %x (ccl_code = %x) at %d.", 1715 "\nCCL: Invalid command %x (ccl_code = %x) at %d.",
1716 code & 0x1F, code, this_ic); 1716 code & 0x1Fu, code + 0u, this_ic);
1717#ifdef CCL_DEBUG 1717#ifdef CCL_DEBUG
1718 { 1718 {
1719 int i = ccl_backtrace_idx - 1; 1719 int i = ccl_backtrace_idx - 1;
diff --git a/src/character.c b/src/character.c
index ad78f512f43..f51d97125e0 100644
--- a/src/character.c
+++ b/src/character.c
@@ -841,7 +841,7 @@ string_escape_byte8 (Lisp_Object string)
841 { 841 {
842 c = STRING_CHAR_ADVANCE (src); 842 c = STRING_CHAR_ADVANCE (src);
843 c = CHAR_TO_BYTE8 (c); 843 c = CHAR_TO_BYTE8 (c);
844 dst += sprintf ((char *) dst, "\\%03o", c); 844 dst += sprintf ((char *) dst, "\\%03o", c + 0u);
845 } 845 }
846 else 846 else
847 while (len--) *dst++ = *src++; 847 while (len--) *dst++ = *src++;
@@ -851,7 +851,7 @@ string_escape_byte8 (Lisp_Object string)
851 { 851 {
852 c = *src++; 852 c = *src++;
853 if (c >= 0x80) 853 if (c >= 0x80)
854 dst += sprintf ((char *) dst, "\\%03o", c); 854 dst += sprintf ((char *) dst, "\\%03o", c + 0u);
855 else 855 else
856 *dst++ = c; 856 *dst++ = c;
857 } 857 }
@@ -984,8 +984,7 @@ character is not ASCII nor 8-bit character, an error is signaled. */)
984 984
985#ifdef emacs 985#ifdef emacs
986 986
987/* Return 'true' if C is an alphabetic character as defined by its 987/* Return true if C is an alphabetic character. */
988 Unicode properties. */
989bool 988bool
990alphabeticp (int c) 989alphabeticp (int c)
991{ 990{
@@ -1008,8 +1007,7 @@ alphabeticp (int c)
1008 || gen_cat == UNICODE_CATEGORY_Nl); 1007 || gen_cat == UNICODE_CATEGORY_Nl);
1009} 1008}
1010 1009
1011/* Return 'true' if C is an decimal-number character as defined by its 1010/* Return true if C is a decimal-number character. */
1012 Unicode properties. */
1013bool 1011bool
1014decimalnump (int c) 1012decimalnump (int c)
1015{ 1013{
@@ -1022,6 +1020,39 @@ decimalnump (int c)
1022 return gen_cat == UNICODE_CATEGORY_Nd; 1020 return gen_cat == UNICODE_CATEGORY_Nd;
1023} 1021}
1024 1022
1023/* Return true if C is a graphic character. */
1024bool
1025graphicp (int c)
1026{
1027 Lisp_Object category = CHAR_TABLE_REF (Vunicode_category_table, c);
1028 if (! INTEGERP (category))
1029 return false;
1030 EMACS_INT gen_cat = XINT (category);
1031
1032 /* See UTS #18. */
1033 return (!(gen_cat == UNICODE_CATEGORY_Zs /* space separator */
1034 || gen_cat == UNICODE_CATEGORY_Zl /* line separator */
1035 || gen_cat == UNICODE_CATEGORY_Zp /* paragraph separator */
1036 || gen_cat == UNICODE_CATEGORY_Cc /* control */
1037 || gen_cat == UNICODE_CATEGORY_Cs /* surrogate */
1038 || gen_cat == UNICODE_CATEGORY_Cn)); /* unassigned */
1039}
1040
1041/* Return true if C is a printable character. */
1042bool
1043printablep (int c)
1044{
1045 Lisp_Object category = CHAR_TABLE_REF (Vunicode_category_table, c);
1046 if (! INTEGERP (category))
1047 return false;
1048 EMACS_INT gen_cat = XINT (category);
1049
1050 /* See UTS #18. */
1051 return (!(gen_cat == UNICODE_CATEGORY_Cc /* control */
1052 || gen_cat == UNICODE_CATEGORY_Cs /* surrogate */
1053 || gen_cat == UNICODE_CATEGORY_Cn)); /* unassigned */
1054}
1055
1025void 1056void
1026syms_of_character (void) 1057syms_of_character (void)
1027{ 1058{
diff --git a/src/character.h b/src/character.h
index 7d902952db6..859d717a0ba 100644
--- a/src/character.h
+++ b/src/character.h
@@ -662,6 +662,8 @@ extern Lisp_Object string_escape_byte8 (Lisp_Object);
662 662
663extern bool alphabeticp (int); 663extern bool alphabeticp (int);
664extern bool decimalnump (int); 664extern bool decimalnump (int);
665extern bool graphicp (int);
666extern bool printablep (int);
665 667
666/* Return a translation table of id number ID. */ 668/* Return a translation table of id number ID. */
667#define GET_TRANSLATION_TABLE(id) \ 669#define GET_TRANSLATION_TABLE(id) \
diff --git a/src/cmds.c b/src/cmds.c
index 270fc39cabc..168ce8355ed 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -213,6 +213,36 @@ to t. */)
213 return Qnil; 213 return Qnil;
214} 214}
215 215
216static int nonundocount;
217
218static void
219remove_excessive_undo_boundaries (void)
220{
221 bool remove_boundary = true;
222
223 if (!EQ (Vthis_command, KVAR (current_kboard, Vlast_command)))
224 nonundocount = 0;
225
226 if (NILP (Vexecuting_kbd_macro))
227 {
228 if (nonundocount <= 0 || nonundocount >= 20)
229 {
230 remove_boundary = false;
231 nonundocount = 0;
232 }
233 nonundocount++;
234 }
235
236 if (remove_boundary
237 && CONSP (BVAR (current_buffer, undo_list))
238 && NILP (XCAR (BVAR (current_buffer, undo_list)))
239 /* Only remove auto-added boundaries, not boundaries
240 added by explicit calls to undo-boundary. */
241 && EQ (BVAR (current_buffer, undo_list), last_undo_boundary))
242 /* Remove the undo_boundary that was just pushed. */
243 bset_undo_list (current_buffer, XCDR (BVAR (current_buffer, undo_list)));
244}
245
216DEFUN ("delete-char", Fdelete_char, Sdelete_char, 1, 2, "p\nP", 246DEFUN ("delete-char", Fdelete_char, Sdelete_char, 1, 2, "p\nP",
217 doc: /* Delete the following N characters (previous if N is negative). 247 doc: /* Delete the following N characters (previous if N is negative).
218Optional second arg KILLFLAG non-nil means kill instead (save in kill ring). 248Optional second arg KILLFLAG non-nil means kill instead (save in kill ring).
@@ -227,6 +257,9 @@ because it respects values of `delete-active-region' and `overwrite-mode'. */)
227 257
228 CHECK_NUMBER (n); 258 CHECK_NUMBER (n);
229 259
260 if (abs (XINT (n)) < 2)
261 remove_excessive_undo_boundaries ();
262
230 pos = PT + XINT (n); 263 pos = PT + XINT (n);
231 if (NILP (killflag)) 264 if (NILP (killflag))
232 { 265 {
@@ -252,8 +285,6 @@ because it respects values of `delete-active-region' and `overwrite-mode'. */)
252 return Qnil; 285 return Qnil;
253} 286}
254 287
255static int nonundocount;
256
257/* Note that there's code in command_loop_1 which typically avoids 288/* Note that there's code in command_loop_1 which typically avoids
258 calling this. */ 289 calling this. */
259DEFUN ("self-insert-command", Fself_insert_command, Sself_insert_command, 1, 1, "p", 290DEFUN ("self-insert-command", Fself_insert_command, Sself_insert_command, 1, 1, "p",
@@ -267,34 +298,13 @@ After insertion, the value of `auto-fill-function' is called if the
267At the end, it runs `post-self-insert-hook'. */) 298At the end, it runs `post-self-insert-hook'. */)
268 (Lisp_Object n) 299 (Lisp_Object n)
269{ 300{
270 bool remove_boundary = 1;
271 CHECK_NUMBER (n); 301 CHECK_NUMBER (n);
272 302
273 if (XFASTINT (n) < 0) 303 if (XFASTINT (n) < 0)
274 error ("Negative repetition argument %"pI"d", XFASTINT (n)); 304 error ("Negative repetition argument %"pI"d", XFASTINT (n));
275 305
276 if (!EQ (Vthis_command, KVAR (current_kboard, Vlast_command))) 306 if (XFASTINT (n) < 2)
277 nonundocount = 0; 307 remove_excessive_undo_boundaries ();
278
279 if (NILP (Vexecuting_kbd_macro)
280 && !EQ (minibuf_window, selected_window))
281 {
282 if (nonundocount <= 0 || nonundocount >= 20)
283 {
284 remove_boundary = 0;
285 nonundocount = 0;
286 }
287 nonundocount++;
288 }
289
290 if (remove_boundary
291 && CONSP (BVAR (current_buffer, undo_list))
292 && NILP (XCAR (BVAR (current_buffer, undo_list)))
293 /* Only remove auto-added boundaries, not boundaries
294 added be explicit calls to undo-boundary. */
295 && EQ (BVAR (current_buffer, undo_list), last_undo_boundary))
296 /* Remove the undo_boundary that was just pushed. */
297 bset_undo_list (current_buffer, XCDR (BVAR (current_buffer, undo_list)));
298 308
299 /* Barf if the key that invoked this was not a character. */ 309 /* Barf if the key that invoked this was not a character. */
300 if (!CHARACTERP (last_command_event)) 310 if (!CHARACTERP (last_command_event))
diff --git a/src/dbusbind.c b/src/dbusbind.c
index 54e92cce16e..fa26f9e4168 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -874,7 +874,7 @@ xd_retrieve_arg (int dtype, DBusMessageIter *iter)
874 uprintmax_t pval; 874 uprintmax_t pval;
875 dbus_message_iter_get_basic (iter, &val); 875 dbus_message_iter_get_basic (iter, &val);
876 pval = val; 876 pval = val;
877 XD_DEBUG_MESSAGE ("%c %"pMd, dtype, pval); 877 XD_DEBUG_MESSAGE ("%c %"pMu, dtype, pval);
878 return make_fixnum_or_float (val); 878 return make_fixnum_or_float (val);
879 } 879 }
880 880
@@ -990,7 +990,7 @@ xd_add_watch (DBusWatch *watch, void *data)
990 unsigned int flags = dbus_watch_get_flags (watch); 990 unsigned int flags = dbus_watch_get_flags (watch);
991 int fd = xd_find_watch_fd (watch); 991 int fd = xd_find_watch_fd (watch);
992 992
993 XD_DEBUG_MESSAGE ("fd %d, write %d, enabled %d", 993 XD_DEBUG_MESSAGE ("fd %d, write %u, enabled %u",
994 fd, flags & DBUS_WATCH_WRITABLE, 994 fd, flags & DBUS_WATCH_WRITABLE,
995 dbus_watch_get_enabled (watch)); 995 dbus_watch_get_enabled (watch));
996 996
diff --git a/src/editfns.c b/src/editfns.c
index 7d3e4620029..dead48c1a62 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -2728,7 +2728,15 @@ DEFUN ("insert-buffer-substring", Finsert_buffer_substring, Sinsert_buffer_subst
2728 doc: /* Insert before point a substring of the contents of BUFFER. 2728 doc: /* Insert before point a substring of the contents of BUFFER.
2729BUFFER may be a buffer or a buffer name. 2729BUFFER may be a buffer or a buffer name.
2730Arguments START and END are character positions specifying the substring. 2730Arguments START and END are character positions specifying the substring.
2731They default to the values of (point-min) and (point-max) in BUFFER. */) 2731They default to the values of (point-min) and (point-max) in BUFFER.
2732
2733Point and before-insertion markers move forward to end up after the
2734inserted text.
2735Any other markers at the point of insertion remain before the text.
2736
2737If the current buffer is multibyte and BUFFER is unibyte, or vice
2738versa, strings are converted from unibyte to multibyte or vice versa
2739using `string-make-multibyte' or `string-make-unibyte', which see. */)
2732 (Lisp_Object buffer, Lisp_Object start, Lisp_Object end) 2740 (Lisp_Object buffer, Lisp_Object start, Lisp_Object end)
2733{ 2741{
2734 register EMACS_INT b, e, temp; 2742 register EMACS_INT b, e, temp;
diff --git a/src/eval.c b/src/eval.c
index e828da9288f..490226149ff 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -210,7 +210,7 @@ init_eval_once (void)
210 specpdl = specpdl_ptr = pdlvec + 1; 210 specpdl = specpdl_ptr = pdlvec + 1;
211 /* Don't forget to update docs (lispref node "Local Variables"). */ 211 /* Don't forget to update docs (lispref node "Local Variables"). */
212 max_specpdl_size = 1300; /* 1000 is not enough for CEDET's c-by.el. */ 212 max_specpdl_size = 1300; /* 1000 is not enough for CEDET's c-by.el. */
213 max_lisp_eval_depth = 600; 213 max_lisp_eval_depth = 800;
214 214
215 Vrun_hooks = Qnil; 215 Vrun_hooks = Qnil;
216} 216}
@@ -3305,27 +3305,27 @@ Output stream used is value of `standard-output'. */)
3305 3305
3306 while (backtrace_p (pdl)) 3306 while (backtrace_p (pdl))
3307 { 3307 {
3308 write_string (backtrace_debug_on_exit (pdl) ? "* " : " ", 2); 3308 write_string (backtrace_debug_on_exit (pdl) ? "* " : " ");
3309 if (backtrace_nargs (pdl) == UNEVALLED) 3309 if (backtrace_nargs (pdl) == UNEVALLED)
3310 { 3310 {
3311 Fprin1 (Fcons (backtrace_function (pdl), *backtrace_args (pdl)), 3311 Fprin1 (Fcons (backtrace_function (pdl), *backtrace_args (pdl)),
3312 Qnil); 3312 Qnil);
3313 write_string ("\n", -1); 3313 write_string ("\n");
3314 } 3314 }
3315 else 3315 else
3316 { 3316 {
3317 tem = backtrace_function (pdl); 3317 tem = backtrace_function (pdl);
3318 Fprin1 (tem, Qnil); /* This can QUIT. */ 3318 Fprin1 (tem, Qnil); /* This can QUIT. */
3319 write_string ("(", -1); 3319 write_string ("(");
3320 { 3320 {
3321 ptrdiff_t i; 3321 ptrdiff_t i;
3322 for (i = 0; i < backtrace_nargs (pdl); i++) 3322 for (i = 0; i < backtrace_nargs (pdl); i++)
3323 { 3323 {
3324 if (i) write_string (" ", -1); 3324 if (i) write_string (" ");
3325 Fprin1 (backtrace_args (pdl)[i], Qnil); 3325 Fprin1 (backtrace_args (pdl)[i], Qnil);
3326 } 3326 }
3327 } 3327 }
3328 write_string (")\n", -1); 3328 write_string (")\n");
3329 } 3329 }
3330 pdl = backtrace_next (pdl); 3330 pdl = backtrace_next (pdl);
3331 } 3331 }
diff --git a/src/fileio.c b/src/fileio.c
index d4e12cbe277..796f08d3c58 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -2344,62 +2344,62 @@ This is what happens in interactive use with M-x. */)
2344 2344
2345DEFUN ("make-symbolic-link", Fmake_symbolic_link, Smake_symbolic_link, 2, 3, 2345DEFUN ("make-symbolic-link", Fmake_symbolic_link, Smake_symbolic_link, 2, 3,
2346 "FMake symbolic link to file: \nGMake symbolic link to file %s: \np", 2346 "FMake symbolic link to file: \nGMake symbolic link to file %s: \np",
2347 doc: /* Make a symbolic link to FILENAME, named LINKNAME. 2347 doc: /* Make a symbolic link to TARGET, named LINKNAME.
2348Both args must be strings. 2348Both args must be strings.
2349Signals a `file-already-exists' error if a file LINKNAME already exists 2349Signals a `file-already-exists' error if a file LINKNAME already exists
2350unless optional third argument OK-IF-ALREADY-EXISTS is non-nil. 2350unless optional third argument OK-IF-ALREADY-EXISTS is non-nil.
2351A number as third arg means request confirmation if LINKNAME already exists. 2351A number as third arg means request confirmation if LINKNAME already exists.
2352This happens for interactive use with M-x. */) 2352This happens for interactive use with M-x. */)
2353 (Lisp_Object filename, Lisp_Object linkname, Lisp_Object ok_if_already_exists) 2353 (Lisp_Object target, Lisp_Object linkname, Lisp_Object ok_if_already_exists)
2354{ 2354{
2355 Lisp_Object handler; 2355 Lisp_Object handler;
2356 Lisp_Object encoded_filename, encoded_linkname; 2356 Lisp_Object encoded_target, encoded_linkname;
2357 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 2357 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
2358 2358
2359 GCPRO4 (filename, linkname, encoded_filename, encoded_linkname); 2359 GCPRO4 (target, linkname, encoded_target, encoded_linkname);
2360 encoded_filename = encoded_linkname = Qnil; 2360 encoded_target = encoded_linkname = Qnil;
2361 CHECK_STRING (filename); 2361 CHECK_STRING (target);
2362 CHECK_STRING (linkname); 2362 CHECK_STRING (linkname);
2363 /* If the link target has a ~, we must expand it to get 2363 /* If the link target has a ~, we must expand it to get
2364 a truly valid file name. Otherwise, do not expand; 2364 a truly valid file name. Otherwise, do not expand;
2365 we want to permit links to relative file names. */ 2365 we want to permit links to relative file names. */
2366 if (SREF (filename, 0) == '~') 2366 if (SREF (target, 0) == '~')
2367 filename = Fexpand_file_name (filename, Qnil); 2367 target = Fexpand_file_name (target, Qnil);
2368 2368
2369 if (!NILP (Ffile_directory_p (linkname))) 2369 if (!NILP (Ffile_directory_p (linkname)))
2370 linkname = Fexpand_file_name (Ffile_name_nondirectory (filename), linkname); 2370 linkname = Fexpand_file_name (Ffile_name_nondirectory (target), linkname);
2371 else 2371 else
2372 linkname = Fexpand_file_name (linkname, Qnil); 2372 linkname = Fexpand_file_name (linkname, Qnil);
2373 2373
2374 /* If the file name has special constructs in it, 2374 /* If the file name has special constructs in it,
2375 call the corresponding file handler. */ 2375 call the corresponding file handler. */
2376 handler = Ffind_file_name_handler (filename, Qmake_symbolic_link); 2376 handler = Ffind_file_name_handler (target, Qmake_symbolic_link);
2377 if (!NILP (handler)) 2377 if (!NILP (handler))
2378 RETURN_UNGCPRO (call4 (handler, Qmake_symbolic_link, filename, 2378 RETURN_UNGCPRO (call4 (handler, Qmake_symbolic_link, target,
2379 linkname, ok_if_already_exists)); 2379 linkname, ok_if_already_exists));
2380 2380
2381 /* If the new link name has special constructs in it, 2381 /* If the new link name has special constructs in it,
2382 call the corresponding file handler. */ 2382 call the corresponding file handler. */
2383 handler = Ffind_file_name_handler (linkname, Qmake_symbolic_link); 2383 handler = Ffind_file_name_handler (linkname, Qmake_symbolic_link);
2384 if (!NILP (handler)) 2384 if (!NILP (handler))
2385 RETURN_UNGCPRO (call4 (handler, Qmake_symbolic_link, filename, 2385 RETURN_UNGCPRO (call4 (handler, Qmake_symbolic_link, target,
2386 linkname, ok_if_already_exists)); 2386 linkname, ok_if_already_exists));
2387 2387
2388 encoded_filename = ENCODE_FILE (filename); 2388 encoded_target = ENCODE_FILE (target);
2389 encoded_linkname = ENCODE_FILE (linkname); 2389 encoded_linkname = ENCODE_FILE (linkname);
2390 2390
2391 if (NILP (ok_if_already_exists) 2391 if (NILP (ok_if_already_exists)
2392 || INTEGERP (ok_if_already_exists)) 2392 || INTEGERP (ok_if_already_exists))
2393 barf_or_query_if_file_exists (linkname, false, "make it a link", 2393 barf_or_query_if_file_exists (linkname, false, "make it a link",
2394 INTEGERP (ok_if_already_exists), false); 2394 INTEGERP (ok_if_already_exists), false);
2395 if (symlink (SSDATA (encoded_filename), SSDATA (encoded_linkname)) < 0) 2395 if (symlink (SSDATA (encoded_target), SSDATA (encoded_linkname)) < 0)
2396 { 2396 {
2397 /* If we didn't complain already, silently delete existing file. */ 2397 /* If we didn't complain already, silently delete existing file. */
2398 int symlink_errno; 2398 int symlink_errno;
2399 if (errno == EEXIST) 2399 if (errno == EEXIST)
2400 { 2400 {
2401 unlink (SSDATA (encoded_linkname)); 2401 unlink (SSDATA (encoded_linkname));
2402 if (symlink (SSDATA (encoded_filename), SSDATA (encoded_linkname)) 2402 if (symlink (SSDATA (encoded_target), SSDATA (encoded_linkname))
2403 >= 0) 2403 >= 0)
2404 { 2404 {
2405 UNGCPRO; 2405 UNGCPRO;
@@ -2414,7 +2414,7 @@ This happens for interactive use with M-x. */)
2414 } 2414 }
2415 2415
2416 symlink_errno = errno; 2416 symlink_errno = errno;
2417 report_file_errno ("Making symbolic link", list2 (filename, linkname), 2417 report_file_errno ("Making symbolic link", list2 (target, linkname),
2418 symlink_errno); 2418 symlink_errno);
2419 } 2419 }
2420 UNGCPRO; 2420 UNGCPRO;
@@ -4165,7 +4165,7 @@ by calling `format-decode', which see. */)
4165 Vdeactivate_mark = old_Vdeactivate_mark; 4165 Vdeactivate_mark = old_Vdeactivate_mark;
4166 } 4166 }
4167 else 4167 else
4168 Vdeactivate_mark = Qt; 4168 Fset (Qdeactivate_mark, Qt);
4169 4169
4170 emacs_close (fd); 4170 emacs_close (fd);
4171 clear_unwind_protect (fd_index); 4171 clear_unwind_protect (fd_index);
diff --git a/src/gnutls.c b/src/gnutls.c
index 35f0eb48bc1..9b8ae2bd1a8 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -1512,7 +1512,7 @@ one trustfile (usually a CA bundle). */)
1512 || !NILP (Fmember (QCgnutls_bootprop_trustfiles, verify_error))) 1512 || !NILP (Fmember (QCgnutls_bootprop_trustfiles, verify_error)))
1513 { 1513 {
1514 emacs_gnutls_deinit (proc); 1514 emacs_gnutls_deinit (proc);
1515 error ("Certificate validation failed %s, verification code %d", 1515 error ("Certificate validation failed %s, verification code %u",
1516 c_hostname, peer_verification); 1516 c_hostname, peer_verification);
1517 } 1517 }
1518 else 1518 else
@@ -1645,6 +1645,16 @@ DEFUN ("gnutls-available-p", Fgnutls_available_p, Sgnutls_available_p, 0, 0, 0,
1645void 1645void
1646syms_of_gnutls (void) 1646syms_of_gnutls (void)
1647{ 1647{
1648 DEFSYM (Qlibgnutls_version, "libgnutls-version");
1649 Fset (Qlibgnutls_version,
1650#ifdef HAVE_GNUTLS
1651 make_number (GNUTLS_VERSION_MAJOR * 10000
1652 + GNUTLS_VERSION_MINOR * 100
1653 + GNUTLS_VERSION_PATCH)
1654#else
1655 make_number (-1)
1656#endif
1657 );
1648#ifdef HAVE_GNUTLS 1658#ifdef HAVE_GNUTLS
1649 gnutls_global_initialized = 0; 1659 gnutls_global_initialized = 0;
1650 1660
diff --git a/src/gtkutil.c b/src/gtkutil.c
index c41bb4645a5..d7340ba797e 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -579,9 +579,9 @@ xg_check_special_colors (struct frame *f,
579 gtk_style_context_get_background_color (gsty, state, &col); 579 gtk_style_context_get_background_color (gsty, state, &col);
580 580
581 sprintf (buf, "rgb:%04x/%04x/%04x", 581 sprintf (buf, "rgb:%04x/%04x/%04x",
582 (int)(col.red * 65535), 582 (unsigned) (col.red * 65535),
583 (int)(col.green * 65535), 583 (unsigned) (col.green * 65535),
584 (int)(col.blue * 65535)); 584 (unsigned) (col.blue * 65535));
585 success_p = (XParseColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), 585 success_p = (XParseColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f),
586 buf, color) 586 buf, color)
587 != 0); 587 != 0);
diff --git a/src/image.c b/src/image.c
index 78de0ba884e..ffbed747590 100644
--- a/src/image.c
+++ b/src/image.c
@@ -5063,7 +5063,8 @@ x_build_heuristic_mask (struct frame *f, struct image *img, Lisp_Object how)
5063 if (i == 3 && NILP (how)) 5063 if (i == 3 && NILP (how))
5064 { 5064 {
5065 char color_name[30]; 5065 char color_name[30];
5066 sprintf (color_name, "#%04x%04x%04x", rgb[0], rgb[1], rgb[2]); 5066 sprintf (color_name, "#%04x%04x%04x",
5067 rgb[0] + 0u, rgb[1] + 0u, rgb[2] + 0u);
5067 bg = ( 5068 bg = (
5068#ifdef HAVE_NTGUI 5069#ifdef HAVE_NTGUI
5069 0x00ffffff & /* Filter out palette info. */ 5070 0x00ffffff & /* Filter out palette info. */
@@ -5896,6 +5897,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
5896 /* Find out what file to load. */ 5897 /* Find out what file to load. */
5897 specified_file = image_spec_value (img->spec, QCfile, NULL); 5898 specified_file = image_spec_value (img->spec, QCfile, NULL);
5898 specified_data = image_spec_value (img->spec, QCdata, NULL); 5899 specified_data = image_spec_value (img->spec, QCdata, NULL);
5900 IF_LINT (Lisp_Object volatile specified_data_volatile = specified_data);
5899 5901
5900 if (NILP (specified_data)) 5902 if (NILP (specified_data))
5901 { 5903 {
@@ -5992,6 +5994,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
5992 5994
5993 /* Silence a bogus diagnostic; see GCC bug 54561. */ 5995 /* Silence a bogus diagnostic; see GCC bug 54561. */
5994 IF_LINT (fp = c->fp); 5996 IF_LINT (fp = c->fp);
5997 IF_LINT (specified_data = specified_data_volatile);
5995 5998
5996 /* Read image info. */ 5999 /* Read image info. */
5997 if (!NILP (specified_data)) 6000 if (!NILP (specified_data))
@@ -6658,6 +6661,7 @@ jpeg_load_body (struct frame *f, struct image *img,
6658 /* Open the JPEG file. */ 6661 /* Open the JPEG file. */
6659 specified_file = image_spec_value (img->spec, QCfile, NULL); 6662 specified_file = image_spec_value (img->spec, QCfile, NULL);
6660 specified_data = image_spec_value (img->spec, QCdata, NULL); 6663 specified_data = image_spec_value (img->spec, QCdata, NULL);
6664 IF_LINT (Lisp_Object volatile specified_data_volatile = specified_data);
6661 6665
6662 if (NILP (specified_data)) 6666 if (NILP (specified_data))
6663 { 6667 {
@@ -6720,6 +6724,9 @@ jpeg_load_body (struct frame *f, struct image *img,
6720 return 0; 6724 return 0;
6721 } 6725 }
6722 6726
6727 /* Silence a bogus diagnostic; see GCC bug 54561. */
6728 IF_LINT (specified_data = specified_data_volatile);
6729
6723 /* Create the JPEG decompression object. Let it read from fp. 6730 /* Create the JPEG decompression object. Let it read from fp.
6724 Read the JPEG image header. */ 6731 Read the JPEG image header. */
6725 jpeg_CreateDecompress (&mgr->cinfo, JPEG_LIB_VERSION, sizeof *&mgr->cinfo); 6732 jpeg_CreateDecompress (&mgr->cinfo, JPEG_LIB_VERSION, sizeof *&mgr->cinfo);
diff --git a/src/insdel.c b/src/insdel.c
index 80650be25ae..22c2bcccb82 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -1846,7 +1846,7 @@ prepare_to_modify_buffer_1 (ptrdiff_t start, ptrdiff_t end,
1846 = call1 (Fsymbol_value (Qregion_extract_function), Qnil); 1846 = call1 (Fsymbol_value (Qregion_extract_function), Qnil);
1847 1847
1848 signal_before_change (start, end, preserve_ptr); 1848 signal_before_change (start, end, preserve_ptr);
1849 Vdeactivate_mark = Qt; 1849 Fset (Qdeactivate_mark, Qt);
1850} 1850}
1851 1851
1852/* Like above, but called when we know that the buffer text 1852/* Like above, but called when we know that the buffer text
diff --git a/src/keyboard.c b/src/keyboard.c
index 2d047da5511..bd79f901970 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -2192,7 +2192,7 @@ read_event_from_main_queue (struct timespec *end_time,
2192 save_getcjmp (save_jump); 2192 save_getcjmp (save_jump);
2193 restore_getcjmp (local_getcjmp); 2193 restore_getcjmp (local_getcjmp);
2194 if (!end_time) 2194 if (!end_time)
2195 timer_start_idle (); 2195 timer_start_idle ();
2196 c = kbd_buffer_get_event (&kb, used_mouse_menu, end_time); 2196 c = kbd_buffer_get_event (&kb, used_mouse_menu, end_time);
2197 restore_getcjmp (save_jump); 2197 restore_getcjmp (save_jump);
2198 2198
@@ -11492,6 +11492,7 @@ for that character after that prefix key. */);
11492 doc: /* Form to evaluate when Emacs starts up. 11492 doc: /* Form to evaluate when Emacs starts up.
11493Useful to set before you dump a modified Emacs. */); 11493Useful to set before you dump a modified Emacs. */);
11494 Vtop_level = Qnil; 11494 Vtop_level = Qnil;
11495 XSYMBOL (Qtop_level)->declared_special = false;
11495 11496
11496 DEFVAR_KBOARD ("keyboard-translate-table", Vkeyboard_translate_table, 11497 DEFVAR_KBOARD ("keyboard-translate-table", Vkeyboard_translate_table,
11497 doc: /* Translate table for local keyboard input, or nil. 11498 doc: /* Translate table for local keyboard input, or nil.
diff --git a/src/lisp.h b/src/lisp.h
index b730619726b..55c4c662c06 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3923,7 +3923,7 @@ extern Lisp_Object Vprin1_to_string_buffer;
3923extern void debug_print (Lisp_Object) EXTERNALLY_VISIBLE; 3923extern void debug_print (Lisp_Object) EXTERNALLY_VISIBLE;
3924extern void temp_output_buffer_setup (const char *); 3924extern void temp_output_buffer_setup (const char *);
3925extern int print_level; 3925extern int print_level;
3926extern void write_string (const char *, int); 3926extern void write_string (const char *);
3927extern void print_error_message (Lisp_Object, Lisp_Object, const char *, 3927extern void print_error_message (Lisp_Object, Lisp_Object, const char *,
3928 Lisp_Object); 3928 Lisp_Object);
3929extern Lisp_Object internal_with_output_to_temp_buffer 3929extern Lisp_Object internal_with_output_to_temp_buffer
diff --git a/src/lread.c b/src/lread.c
index 050e43e2d08..a84450a4364 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -3024,7 +3024,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
3024 3024
3025 ch = read_escape (readcharfun, 1); 3025 ch = read_escape (readcharfun, 1);
3026 3026
3027 /* CH is -1 if \ newline has just been seen. */ 3027 /* CH is -1 if \ newline or \ space has just been seen. */
3028 if (ch == -1) 3028 if (ch == -1)
3029 { 3029 {
3030 if (p == read_buffer) 3030 if (p == read_buffer)
@@ -3778,8 +3778,11 @@ intern_1 (const char *str, ptrdiff_t len)
3778 Lisp_Object obarray = check_obarray (Vobarray); 3778 Lisp_Object obarray = check_obarray (Vobarray);
3779 Lisp_Object tem = oblookup (obarray, str, len, len); 3779 Lisp_Object tem = oblookup (obarray, str, len, len);
3780 3780
3781 return SYMBOLP (tem) ? tem : intern_driver (make_string (str, len), 3781 return (SYMBOLP (tem) ? tem
3782 obarray, tem); 3782 /* The above `oblookup' was done on the basis of nchars==nbytes, so
3783 the string has to be unibyte. */
3784 : intern_driver (make_unibyte_string (str, len),
3785 obarray, tem));
3783} 3786}
3784 3787
3785Lisp_Object 3788Lisp_Object
diff --git a/src/print.c b/src/print.c
index 838d03666d4..206466ce68f 100644
--- a/src/print.c
+++ b/src/print.c
@@ -37,6 +37,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
37#include "termhooks.h" /* For struct terminal. */ 37#include "termhooks.h" /* For struct terminal. */
38#include "font.h" 38#include "font.h"
39 39
40#include <c-ctype.h>
40#include <float.h> 41#include <float.h>
41#include <ftoastr.h> 42#include <ftoastr.h>
42 43
@@ -83,12 +84,11 @@ bool print_output_debug_flag EXTERNALLY_VISIBLE = 1;
83 84
84/* Lisp functions to do output using a stream 85/* Lisp functions to do output using a stream
85 must have the stream in a variable called printcharfun 86 must have the stream in a variable called printcharfun
86 and must start with PRINTPREPARE, end with PRINTFINISH, 87 and must start with PRINTPREPARE, end with PRINTFINISH.
87 and use PRINTDECLARE to declare common variables. 88 Use printchar to output one character,
88 Use PRINTCHAR to output one character,
89 or call strout to output a block of characters. */ 89 or call strout to output a block of characters. */
90 90
91#define PRINTDECLARE \ 91#define PRINTPREPARE \
92 struct buffer *old = current_buffer; \ 92 struct buffer *old = current_buffer; \
93 ptrdiff_t old_point = -1, start_point = -1; \ 93 ptrdiff_t old_point = -1, start_point = -1; \
94 ptrdiff_t old_point_byte = -1, start_point_byte = -1; \ 94 ptrdiff_t old_point_byte = -1, start_point_byte = -1; \
@@ -96,10 +96,7 @@ bool print_output_debug_flag EXTERNALLY_VISIBLE = 1;
96 bool free_print_buffer = 0; \ 96 bool free_print_buffer = 0; \
97 bool multibyte \ 97 bool multibyte \
98 = !NILP (BVAR (current_buffer, enable_multibyte_characters)); \ 98 = !NILP (BVAR (current_buffer, enable_multibyte_characters)); \
99 Lisp_Object original 99 Lisp_Object original = printcharfun; \
100
101#define PRINTPREPARE \
102 original = printcharfun; \
103 if (NILP (printcharfun)) printcharfun = Qt; \ 100 if (NILP (printcharfun)) printcharfun = Qt; \
104 if (BUFFERP (printcharfun)) \ 101 if (BUFFERP (printcharfun)) \
105 { \ 102 { \
@@ -189,8 +186,6 @@ bool print_output_debug_flag EXTERNALLY_VISIBLE = 1;
189 ? PT_BYTE - start_point_byte : 0)); \ 186 ? PT_BYTE - start_point_byte : 0)); \
190 set_buffer_internal (old); 187 set_buffer_internal (old);
191 188
192#define PRINTCHAR(ch) printchar (ch, printcharfun)
193
194/* This is used to restore the saved contents of print_buffer 189/* This is used to restore the saved contents of print_buffer
195 when there is a recursive call to print. */ 190 when there is a recursive call to print. */
196 191
@@ -248,8 +243,7 @@ printchar (unsigned int ch, Lisp_Object fun)
248 243
249 244
250/* Output SIZE characters, SIZE_BYTE bytes from string PTR using 245/* Output SIZE characters, SIZE_BYTE bytes from string PTR using
251 method PRINTCHARFUN. If SIZE < 0, use the string length of PTR for 246 method PRINTCHARFUN. PRINTCHARFUN nil means output to
252 both SIZE and SIZE_BYTE. PRINTCHARFUN nil means output to
253 print_buffer. PRINTCHARFUN t means output to the echo area or to 247 print_buffer. PRINTCHARFUN t means output to the echo area or to
254 stdout if non-interactive. If neither nil nor t, call Lisp 248 stdout if non-interactive. If neither nil nor t, call Lisp
255 function PRINTCHARFUN for each character printed. MULTIBYTE 249 function PRINTCHARFUN for each character printed. MULTIBYTE
@@ -262,9 +256,6 @@ static void
262strout (const char *ptr, ptrdiff_t size, ptrdiff_t size_byte, 256strout (const char *ptr, ptrdiff_t size, ptrdiff_t size_byte,
263 Lisp_Object printcharfun) 257 Lisp_Object printcharfun)
264{ 258{
265 if (size < 0)
266 size_byte = size = strlen (ptr);
267
268 if (NILP (printcharfun)) 259 if (NILP (printcharfun))
269 { 260 {
270 ptrdiff_t incr = size_byte - (print_buffer_size - print_buffer_pos_byte); 261 ptrdiff_t incr = size_byte - (print_buffer_size - print_buffer_pos_byte);
@@ -317,7 +308,7 @@ strout (const char *ptr, ptrdiff_t size, ptrdiff_t size_byte,
317 while (i < size_byte) 308 while (i < size_byte)
318 { 309 {
319 int ch = ptr[i++]; 310 int ch = ptr[i++];
320 PRINTCHAR (ch); 311 printchar (ch, printcharfun);
321 } 312 }
322 } 313 }
323 else 314 else
@@ -330,7 +321,7 @@ strout (const char *ptr, ptrdiff_t size, ptrdiff_t size_byte,
330 int len; 321 int len;
331 int ch = STRING_CHAR_AND_LENGTH ((const unsigned char *) ptr + i, 322 int ch = STRING_CHAR_AND_LENGTH ((const unsigned char *) ptr + i,
332 len); 323 len);
333 PRINTCHAR (ch); 324 printchar (ch, printcharfun);
334 i += len; 325 i += len;
335 } 326 }
336 } 327 }
@@ -407,7 +398,7 @@ print_string (Lisp_Object string, Lisp_Object printcharfun)
407 GCPRO1 (string); 398 GCPRO1 (string);
408 if (size == size_byte) 399 if (size == size_byte)
409 for (i = 0; i < size; i++) 400 for (i = 0; i < size; i++)
410 PRINTCHAR (SREF (string, i)); 401 printchar (SREF (string, i), printcharfun);
411 else 402 else
412 for (i = 0; i < size_byte; ) 403 for (i = 0; i < size_byte; )
413 { 404 {
@@ -415,7 +406,7 @@ print_string (Lisp_Object string, Lisp_Object printcharfun)
415 corresponding character code before handing it to PRINTCHAR. */ 406 corresponding character code before handing it to PRINTCHAR. */
416 int len; 407 int len;
417 int ch = STRING_CHAR_AND_LENGTH (SDATA (string) + i, len); 408 int ch = STRING_CHAR_AND_LENGTH (SDATA (string) + i, len);
418 PRINTCHAR (ch); 409 printchar (ch, printcharfun);
419 i += len; 410 i += len;
420 } 411 }
421 UNGCPRO; 412 UNGCPRO;
@@ -427,46 +418,45 @@ DEFUN ("write-char", Fwrite_char, Swrite_char, 1, 2, 0,
427PRINTCHARFUN defaults to the value of `standard-output' (which see). */) 418PRINTCHARFUN defaults to the value of `standard-output' (which see). */)
428 (Lisp_Object character, Lisp_Object printcharfun) 419 (Lisp_Object character, Lisp_Object printcharfun)
429{ 420{
430 PRINTDECLARE;
431
432 if (NILP (printcharfun)) 421 if (NILP (printcharfun))
433 printcharfun = Vstandard_output; 422 printcharfun = Vstandard_output;
434 CHECK_NUMBER (character); 423 CHECK_NUMBER (character);
435 PRINTPREPARE; 424 PRINTPREPARE;
436 PRINTCHAR (XINT (character)); 425 printchar (XINT (character), printcharfun);
437 PRINTFINISH; 426 PRINTFINISH;
438 return character; 427 return character;
439} 428}
440 429
441/* Used from outside of print.c to print a block of SIZE 430/* Print the contents of a unibyte C string STRING using PRINTCHARFUN.
442 single-byte chars at DATA on the default output stream. 431 The caller should arrange to put this inside PRINTPREPARE and PRINTFINISH.
443 Do not use this on the contents of a Lisp string. */ 432 Do not use this on the contents of a Lisp string. */
444 433
445void 434static void
446write_string (const char *data, int size) 435print_c_string (char const *string, Lisp_Object printcharfun)
447{ 436{
448 PRINTDECLARE; 437 ptrdiff_t len = strlen (string);
449 Lisp_Object printcharfun; 438 strout (string, len, len, printcharfun);
439}
450 440
451 printcharfun = Vstandard_output; 441/* Print unibyte C string at DATA on a specified stream PRINTCHARFUN.
442 Do not use this on the contents of a Lisp string. */
452 443
444static void
445write_string_1 (const char *data, Lisp_Object printcharfun)
446{
453 PRINTPREPARE; 447 PRINTPREPARE;
454 strout (data, size, size, printcharfun); 448 print_c_string (data, printcharfun);
455 PRINTFINISH; 449 PRINTFINISH;
456} 450}
457 451
458/* Used to print a block of SIZE single-byte chars at DATA on a 452/* Used from outside of print.c to print a C unibyte
459 specified stream PRINTCHARFUN. 453 string at DATA on the default output stream.
460 Do not use this on the contents of a Lisp string. */ 454 Do not use this on the contents of a Lisp string. */
461 455
462static void 456void
463write_string_1 (const char *data, int size, Lisp_Object printcharfun) 457write_string (const char *data)
464{ 458{
465 PRINTDECLARE; 459 write_string_1 (data, Vstandard_output);
466
467 PRINTPREPARE;
468 strout (data, size, size, printcharfun);
469 PRINTFINISH;
470} 460}
471 461
472 462
@@ -515,9 +505,8 @@ beginning of a line. Value is non-nil if a newline is printed.
515If PRINTCHARFUN is omitted or nil, the value of `standard-output' is used. */) 505If PRINTCHARFUN is omitted or nil, the value of `standard-output' is used. */)
516 (Lisp_Object printcharfun, Lisp_Object ensure) 506 (Lisp_Object printcharfun, Lisp_Object ensure)
517{ 507{
518 Lisp_Object val = Qnil; 508 Lisp_Object val;
519 509
520 PRINTDECLARE;
521 if (NILP (printcharfun)) 510 if (NILP (printcharfun))
522 printcharfun = Vstandard_output; 511 printcharfun = Vstandard_output;
523 PRINTPREPARE; 512 PRINTPREPARE;
@@ -529,10 +518,11 @@ If PRINTCHARFUN is omitted or nil, the value of `standard-output' is used. */)
529 signal_error ("Unsupported function argument", printcharfun); 518 signal_error ("Unsupported function argument", printcharfun);
530 else if (noninteractive && !NILP (printcharfun)) 519 else if (noninteractive && !NILP (printcharfun))
531 val = printchar_stdout_last == 10 ? Qnil : Qt; 520 val = printchar_stdout_last == 10 ? Qnil : Qt;
532 else if (NILP (Fbolp ())) 521 else
533 val = Qt; 522 val = NILP (Fbolp ()) ? Qt : Qnil;
534 523
535 if (!NILP (val)) PRINTCHAR ('\n'); 524 if (!NILP (val))
525 printchar ('\n', printcharfun);
536 PRINTFINISH; 526 PRINTFINISH;
537 return val; 527 return val;
538} 528}
@@ -562,8 +552,6 @@ If PRINTCHARFUN is omitted, the value of `standard-output' (which see)
562is used instead. */) 552is used instead. */)
563 (Lisp_Object object, Lisp_Object printcharfun) 553 (Lisp_Object object, Lisp_Object printcharfun)
564{ 554{
565 PRINTDECLARE;
566
567 if (NILP (printcharfun)) 555 if (NILP (printcharfun))
568 printcharfun = Vstandard_output; 556 printcharfun = Vstandard_output;
569 PRINTPREPARE; 557 PRINTPREPARE;
@@ -588,32 +576,24 @@ a list, a buffer, a window, a frame, etc.
588A printed representation of an object is text which describes that object. */) 576A printed representation of an object is text which describes that object. */)
589 (Lisp_Object object, Lisp_Object noescape) 577 (Lisp_Object object, Lisp_Object noescape)
590{ 578{
591 Lisp_Object printcharfun;
592 bool prev_abort_on_gc;
593 Lisp_Object save_deactivate_mark;
594 ptrdiff_t count = SPECPDL_INDEX (); 579 ptrdiff_t count = SPECPDL_INDEX ();
595 struct buffer *previous;
596 580
597 specbind (Qinhibit_modification_hooks, Qt); 581 specbind (Qinhibit_modification_hooks, Qt);
598 582
599 { 583 /* Save and restore this: we are altering a buffer
600 PRINTDECLARE; 584 but we don't want to deactivate the mark just for that.
601 585 No need for specbind, since errors deactivate the mark. */
602 /* Save and restore this--we are altering a buffer 586 Lisp_Object save_deactivate_mark = Vdeactivate_mark;
603 but we don't want to deactivate the mark just for that. 587 bool prev_abort_on_gc = abort_on_gc;
604 No need for specbind, since errors deactivate the mark. */ 588 abort_on_gc = true;
605 save_deactivate_mark = Vdeactivate_mark;
606 prev_abort_on_gc = abort_on_gc;
607 abort_on_gc = 1;
608
609 printcharfun = Vprin1_to_string_buffer;
610 PRINTPREPARE;
611 print (object, printcharfun, NILP (noescape));
612 /* Make Vprin1_to_string_buffer be the default buffer after PRINTFINISH */
613 PRINTFINISH;
614 }
615 589
616 previous = current_buffer; 590 Lisp_Object printcharfun = Vprin1_to_string_buffer;
591 PRINTPREPARE;
592 print (object, printcharfun, NILP (noescape));
593 /* Make Vprin1_to_string_buffer be the default buffer after PRINTFINISH */
594 PRINTFINISH;
595
596 struct buffer *previous = current_buffer;
617 set_buffer_internal (XBUFFER (Vprin1_to_string_buffer)); 597 set_buffer_internal (XBUFFER (Vprin1_to_string_buffer));
618 object = Fbuffer_string (); 598 object = Fbuffer_string ();
619 if (SBYTES (object) == SCHARS (object)) 599 if (SBYTES (object) == SCHARS (object))
@@ -655,8 +635,6 @@ If PRINTCHARFUN is omitted, the value of `standard-output' (which see)
655is used instead. */) 635is used instead. */)
656 (Lisp_Object object, Lisp_Object printcharfun) 636 (Lisp_Object object, Lisp_Object printcharfun)
657{ 637{
658 PRINTDECLARE;
659
660 if (NILP (printcharfun)) 638 if (NILP (printcharfun))
661 printcharfun = Vstandard_output; 639 printcharfun = Vstandard_output;
662 PRINTPREPARE; 640 PRINTPREPARE;
@@ -690,16 +668,15 @@ If PRINTCHARFUN is omitted, the value of `standard-output' (which see)
690is used instead. */) 668is used instead. */)
691 (Lisp_Object object, Lisp_Object printcharfun) 669 (Lisp_Object object, Lisp_Object printcharfun)
692{ 670{
693 PRINTDECLARE;
694 struct gcpro gcpro1; 671 struct gcpro gcpro1;
695 672
696 if (NILP (printcharfun)) 673 if (NILP (printcharfun))
697 printcharfun = Vstandard_output; 674 printcharfun = Vstandard_output;
698 GCPRO1 (object); 675 GCPRO1 (object);
699 PRINTPREPARE; 676 PRINTPREPARE;
700 PRINTCHAR ('\n'); 677 printchar ('\n', printcharfun);
701 print (object, printcharfun, 1); 678 print (object, printcharfun, 1);
702 PRINTCHAR ('\n'); 679 printchar ('\n', printcharfun);
703 PRINTFINISH; 680 PRINTFINISH;
704 UNGCPRO; 681 UNGCPRO;
705 return object; 682 return object;
@@ -817,9 +794,12 @@ safe_debug_print (Lisp_Object arg)
817 if (valid > 0) 794 if (valid > 0)
818 debug_print (arg); 795 debug_print (arg);
819 else 796 else
820 fprintf (stderr, "#<%s_LISP_OBJECT 0x%08"pI"x>\r\n", 797 {
821 !valid ? "INVALID" : "SOME", 798 EMACS_UINT n = XLI (arg);
822 XLI (arg)); 799 fprintf (stderr, "#<%s_LISP_OBJECT 0x%08"pI"x>\r\n",
800 !valid ? "INVALID" : "SOME",
801 n);
802 }
823} 803}
824 804
825 805
@@ -869,7 +849,7 @@ print_error_message (Lisp_Object data, Lisp_Object stream, const char *context,
869 struct gcpro gcpro1; 849 struct gcpro gcpro1;
870 850
871 if (context != 0) 851 if (context != 0)
872 write_string_1 (context, -1, stream); 852 write_string_1 (context, stream);
873 853
874 /* If we know from where the error was signaled, show it in 854 /* If we know from where the error was signaled, show it in
875 *Messages*. */ 855 *Messages*. */
@@ -916,7 +896,7 @@ print_error_message (Lisp_Object data, Lisp_Object stream, const char *context,
916 const char *sep = ": "; 896 const char *sep = ": ";
917 897
918 if (!STRINGP (errmsg)) 898 if (!STRINGP (errmsg))
919 write_string_1 ("peculiar error", -1, stream); 899 write_string_1 ("peculiar error", stream);
920 else if (SCHARS (errmsg)) 900 else if (SCHARS (errmsg))
921 Fprinc (errmsg, stream); 901 Fprinc (errmsg, stream);
922 else 902 else
@@ -927,7 +907,7 @@ print_error_message (Lisp_Object data, Lisp_Object stream, const char *context,
927 Lisp_Object obj; 907 Lisp_Object obj;
928 908
929 if (sep) 909 if (sep)
930 write_string_1 (sep, 2, stream); 910 write_string_1 (sep, stream);
931 obj = XCAR (tail); 911 obj = XCAR (tail);
932 if (!NILP (file_error) 912 if (!NILP (file_error)
933 || EQ (errname, Qend_of_file) || EQ (errname, Quser_error)) 913 || EQ (errname, Qend_of_file) || EQ (errname, Quser_error))
@@ -1409,9 +1389,9 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1409 register ptrdiff_t i, i_byte; 1389 register ptrdiff_t i, i_byte;
1410 struct gcpro gcpro1; 1390 struct gcpro gcpro1;
1411 ptrdiff_t size_byte; 1391 ptrdiff_t size_byte;
1412 /* 1 means we must ensure that the next character we output 1392 /* True means we must ensure that the next character we output
1413 cannot be taken as part of a hex character escape. */ 1393 cannot be taken as part of a hex character escape. */
1414 bool need_nonhex = 0; 1394 bool need_nonhex = false;
1415 bool multibyte = STRING_MULTIBYTE (obj); 1395 bool multibyte = STRING_MULTIBYTE (obj);
1416 1396
1417 GCPRO1 (obj); 1397 GCPRO1 (obj);
@@ -1420,93 +1400,70 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1420 obj = print_prune_string_charset (obj); 1400 obj = print_prune_string_charset (obj);
1421 1401
1422 if (string_intervals (obj)) 1402 if (string_intervals (obj))
1423 { 1403 print_c_string ("#(", printcharfun);
1424 PRINTCHAR ('#');
1425 PRINTCHAR ('(');
1426 }
1427 1404
1428 PRINTCHAR ('\"'); 1405 printchar ('\"', printcharfun);
1429 size_byte = SBYTES (obj); 1406 size_byte = SBYTES (obj);
1430 1407
1431 for (i = 0, i_byte = 0; i_byte < size_byte;) 1408 for (i = 0, i_byte = 0; i_byte < size_byte;)
1432 { 1409 {
1433 /* Here, we must convert each multi-byte form to the 1410 /* Here, we must convert each multi-byte form to the
1434 corresponding character code before handing it to PRINTCHAR. */ 1411 corresponding character code before handing it to printchar. */
1435 int c; 1412 int c;
1436 1413
1437 FETCH_STRING_CHAR_ADVANCE (c, obj, i, i_byte); 1414 FETCH_STRING_CHAR_ADVANCE (c, obj, i, i_byte);
1438 1415
1439 QUIT; 1416 QUIT;
1440 1417
1441 if (c == '\n' && print_escape_newlines) 1418 if (multibyte
1442 { 1419 ? (CHAR_BYTE8_P (c) && (c = CHAR_TO_BYTE8 (c), true))
1443 PRINTCHAR ('\\'); 1420 : (SINGLE_BYTE_CHAR_P (c) && ! ASCII_CHAR_P (c)
1444 PRINTCHAR ('n'); 1421 && print_escape_nonascii))
1445 }
1446 else if (c == '\f' && print_escape_newlines)
1447 { 1422 {
1448 PRINTCHAR ('\\'); 1423 /* When printing a raw 8-bit byte in a multibyte buffer, or
1449 PRINTCHAR ('f'); 1424 (when requested) a non-ASCII character in a unibyte buffer,
1450 }
1451 else if (multibyte
1452 && (CHAR_BYTE8_P (c)
1453 || (! ASCII_CHAR_P (c) && print_escape_multibyte)))
1454 {
1455 /* When multibyte is disabled,
1456 print multibyte string chars using hex escapes.
1457 For a char code that could be in a unibyte string,
1458 when found in a multibyte string, always use a hex escape
1459 so it reads back as multibyte. */
1460 char outbuf[50];
1461 int len;
1462
1463 if (CHAR_BYTE8_P (c))
1464 len = sprintf (outbuf, "\\%03o", CHAR_TO_BYTE8 (c));
1465 else
1466 {
1467 len = sprintf (outbuf, "\\x%04x", c);
1468 need_nonhex = 1;
1469 }
1470 strout (outbuf, len, len, printcharfun);
1471 }
1472 else if (! multibyte
1473 && SINGLE_BYTE_CHAR_P (c) && ! ASCII_CHAR_P (c)
1474 && print_escape_nonascii)
1475 {
1476 /* When printing in a multibyte buffer
1477 or when explicitly requested,
1478 print single-byte non-ASCII string chars 1425 print single-byte non-ASCII string chars
1479 using octal escapes. */ 1426 using octal escapes. */
1480 char outbuf[5]; 1427 char outbuf[5];
1481 int len = sprintf (outbuf, "\\%03o", c); 1428 int len = sprintf (outbuf, "\\%03o", c + 0u);
1482 strout (outbuf, len, len, printcharfun); 1429 strout (outbuf, len, len, printcharfun);
1430 need_nonhex = false;
1431 }
1432 else if (multibyte
1433 && ! ASCII_CHAR_P (c) && print_escape_multibyte)
1434 {
1435 /* When requested, print multibyte chars using hex escapes. */
1436 char outbuf[sizeof "\\x" + INT_STRLEN_BOUND (c)];
1437 int len = sprintf (outbuf, "\\x%04x", c + 0u);
1438 strout (outbuf, len, len, printcharfun);
1439 need_nonhex = true;
1483 } 1440 }
1484 else 1441 else
1485 { 1442 {
1486 /* If we just had a hex escape, and this character 1443 /* If we just had a hex escape, and this character
1487 could be taken as part of it, 1444 could be taken as part of it,
1488 output `\ ' to prevent that. */ 1445 output `\ ' to prevent that. */
1489 if (need_nonhex) 1446 if (need_nonhex && c_isxdigit (c))
1490 { 1447 print_c_string ("\\ ", printcharfun);
1491 need_nonhex = 0; 1448
1492 if ((c >= 'a' && c <= 'f') 1449 if (c == '\n' && print_escape_newlines
1493 || (c >= 'A' && c <= 'F') 1450 ? (c = 'n', true)
1494 || (c >= '0' && c <= '9')) 1451 : c == '\f' && print_escape_newlines
1495 strout ("\\ ", -1, -1, printcharfun); 1452 ? (c = 'f', true)
1496 } 1453 : c == '\"' || c == '\\')
1497 1454 printchar ('\\', printcharfun);
1498 if (c == '\"' || c == '\\') 1455
1499 PRINTCHAR ('\\'); 1456 printchar (c, printcharfun);
1500 PRINTCHAR (c); 1457 need_nonhex = false;
1501 } 1458 }
1502 } 1459 }
1503 PRINTCHAR ('\"'); 1460 printchar ('\"', printcharfun);
1504 1461
1505 if (string_intervals (obj)) 1462 if (string_intervals (obj))
1506 { 1463 {
1507 traverse_intervals (string_intervals (obj), 1464 traverse_intervals (string_intervals (obj),
1508 0, print_interval, printcharfun); 1465 0, print_interval, printcharfun);
1509 PRINTCHAR (')'); 1466 printchar (')', printcharfun);
1510 } 1467 }
1511 1468
1512 UNGCPRO; 1469 UNGCPRO;
@@ -1550,14 +1507,10 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1550 size_byte = SBYTES (name); 1507 size_byte = SBYTES (name);
1551 1508
1552 if (! NILP (Vprint_gensym) && !SYMBOL_INTERNED_P (obj)) 1509 if (! NILP (Vprint_gensym) && !SYMBOL_INTERNED_P (obj))
1553 { 1510 print_c_string ("#:", printcharfun);
1554 PRINTCHAR ('#');
1555 PRINTCHAR (':');
1556 }
1557 else if (size_byte == 0) 1511 else if (size_byte == 0)
1558 { 1512 {
1559 PRINTCHAR ('#'); 1513 print_c_string ("##", printcharfun);
1560 PRINTCHAR ('#');
1561 break; 1514 break;
1562 } 1515 }
1563 1516
@@ -1575,9 +1528,12 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1575 || c == ',' || c == '.' || c == '`' 1528 || c == ',' || c == '.' || c == '`'
1576 || c == '[' || c == ']' || c == '?' || c <= 040 1529 || c == '[' || c == ']' || c == '?' || c <= 040
1577 || confusing) 1530 || confusing)
1578 PRINTCHAR ('\\'), confusing = 0; 1531 {
1532 printchar ('\\', printcharfun);
1533 confusing = false;
1534 }
1579 } 1535 }
1580 PRINTCHAR (c); 1536 printchar (c, printcharfun);
1581 } 1537 }
1582 } 1538 }
1583 break; 1539 break;
@@ -1586,18 +1542,17 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1586 /* If deeper than spec'd depth, print placeholder. */ 1542 /* If deeper than spec'd depth, print placeholder. */
1587 if (INTEGERP (Vprint_level) 1543 if (INTEGERP (Vprint_level)
1588 && print_depth > XINT (Vprint_level)) 1544 && print_depth > XINT (Vprint_level))
1589 strout ("...", -1, -1, printcharfun); 1545 print_c_string ("...", printcharfun);
1590 else if (print_quoted && CONSP (XCDR (obj)) && NILP (XCDR (XCDR (obj))) 1546 else if (print_quoted && CONSP (XCDR (obj)) && NILP (XCDR (XCDR (obj)))
1591 && (EQ (XCAR (obj), Qquote))) 1547 && (EQ (XCAR (obj), Qquote)))
1592 { 1548 {
1593 PRINTCHAR ('\''); 1549 printchar ('\'', printcharfun);
1594 print_object (XCAR (XCDR (obj)), printcharfun, escapeflag); 1550 print_object (XCAR (XCDR (obj)), printcharfun, escapeflag);
1595 } 1551 }
1596 else if (print_quoted && CONSP (XCDR (obj)) && NILP (XCDR (XCDR (obj))) 1552 else if (print_quoted && CONSP (XCDR (obj)) && NILP (XCDR (XCDR (obj)))
1597 && (EQ (XCAR (obj), Qfunction))) 1553 && (EQ (XCAR (obj), Qfunction)))
1598 { 1554 {
1599 PRINTCHAR ('#'); 1555 print_c_string ("#'", printcharfun);
1600 PRINTCHAR ('\'');
1601 print_object (XCAR (XCDR (obj)), printcharfun, escapeflag); 1556 print_object (XCAR (XCDR (obj)), printcharfun, escapeflag);
1602 } 1557 }
1603 else if (print_quoted && CONSP (XCDR (obj)) && NILP (XCDR (XCDR (obj))) 1558 else if (print_quoted && CONSP (XCDR (obj)) && NILP (XCDR (XCDR (obj)))
@@ -1622,75 +1577,71 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1622 } 1577 }
1623 else 1578 else
1624 { 1579 {
1625 PRINTCHAR ('('); 1580 printchar ('(', printcharfun);
1626 1581
1627 { 1582 Lisp_Object halftail = obj;
1628 printmax_t i, print_length;
1629 Lisp_Object halftail = obj;
1630 1583
1631 /* Negative values of print-length are invalid in CL. 1584 /* Negative values of print-length are invalid in CL.
1632 Treat them like nil, as CMUCL does. */ 1585 Treat them like nil, as CMUCL does. */
1633 if (NATNUMP (Vprint_length)) 1586 printmax_t print_length = (NATNUMP (Vprint_length)
1634 print_length = XFASTINT (Vprint_length); 1587 ? XFASTINT (Vprint_length)
1635 else 1588 : TYPE_MAXIMUM (printmax_t));
1636 print_length = TYPE_MAXIMUM (printmax_t);
1637 1589
1638 i = 0; 1590 printmax_t i = 0;
1639 while (CONSP (obj)) 1591 while (CONSP (obj))
1640 { 1592 {
1641 /* Detect circular list. */ 1593 /* Detect circular list. */
1642 if (NILP (Vprint_circle)) 1594 if (NILP (Vprint_circle))
1643 { 1595 {
1644 /* Simple but incomplete way. */ 1596 /* Simple but incomplete way. */
1645 if (i != 0 && EQ (obj, halftail)) 1597 if (i != 0 && EQ (obj, halftail))
1646 { 1598 {
1647 int len = sprintf (buf, " . #%"pMd, i / 2); 1599 int len = sprintf (buf, " . #%"pMd, i / 2);
1648 strout (buf, len, len, printcharfun); 1600 strout (buf, len, len, printcharfun);
1649 goto end_of_list; 1601 goto end_of_list;
1650 } 1602 }
1651 } 1603 }
1652 else 1604 else
1653 { 1605 {
1654 /* With the print-circle feature. */ 1606 /* With the print-circle feature. */
1655 if (i != 0) 1607 if (i != 0)
1656 { 1608 {
1657 Lisp_Object num = Fgethash (obj, Vprint_number_table, Qnil); 1609 Lisp_Object num = Fgethash (obj, Vprint_number_table, Qnil);
1658 if (INTEGERP (num)) 1610 if (INTEGERP (num))
1659 { 1611 {
1660 strout (" . ", 3, 3, printcharfun); 1612 print_c_string (" . ", printcharfun);
1661 print_object (obj, printcharfun, escapeflag); 1613 print_object (obj, printcharfun, escapeflag);
1662 goto end_of_list; 1614 goto end_of_list;
1663 } 1615 }
1664 } 1616 }
1665 } 1617 }
1666 1618
1667 if (i) 1619 if (i)
1668 PRINTCHAR (' '); 1620 printchar (' ', printcharfun);
1669 1621
1670 if (print_length <= i) 1622 if (print_length <= i)
1671 { 1623 {
1672 strout ("...", 3, 3, printcharfun); 1624 print_c_string ("...", printcharfun);
1673 goto end_of_list; 1625 goto end_of_list;
1674 } 1626 }
1675 1627
1676 i++; 1628 i++;
1677 print_object (XCAR (obj), printcharfun, escapeflag); 1629 print_object (XCAR (obj), printcharfun, escapeflag);
1678 1630
1679 obj = XCDR (obj); 1631 obj = XCDR (obj);
1680 if (!(i & 1)) 1632 if (!(i & 1))
1681 halftail = XCDR (halftail); 1633 halftail = XCDR (halftail);
1682 }
1683 } 1634 }
1684 1635
1685 /* OBJ non-nil here means it's the end of a dotted list. */ 1636 /* OBJ non-nil here means it's the end of a dotted list. */
1686 if (!NILP (obj)) 1637 if (!NILP (obj))
1687 { 1638 {
1688 strout (" . ", 3, 3, printcharfun); 1639 print_c_string (" . ", printcharfun);
1689 print_object (obj, printcharfun, escapeflag); 1640 print_object (obj, printcharfun, escapeflag);
1690 } 1641 }
1691 1642
1692 end_of_list: 1643 end_of_list:
1693 PRINTCHAR (')'); 1644 printchar (')', printcharfun);
1694 } 1645 }
1695 break; 1646 break;
1696 1647
@@ -1699,9 +1650,9 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1699 { 1650 {
1700 if (escapeflag) 1651 if (escapeflag)
1701 { 1652 {
1702 strout ("#<process ", -1, -1, printcharfun); 1653 print_c_string ("#<process ", printcharfun);
1703 print_string (XPROCESS (obj)->name, printcharfun); 1654 print_string (XPROCESS (obj)->name, printcharfun);
1704 PRINTCHAR ('>'); 1655 printchar ('>', printcharfun);
1705 } 1656 }
1706 else 1657 else
1707 print_string (XPROCESS (obj)->name, printcharfun); 1658 print_string (XPROCESS (obj)->name, printcharfun);
@@ -1709,7 +1660,6 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1709 else if (BOOL_VECTOR_P (obj)) 1660 else if (BOOL_VECTOR_P (obj))
1710 { 1661 {
1711 ptrdiff_t i; 1662 ptrdiff_t i;
1712 int len;
1713 unsigned char c; 1663 unsigned char c;
1714 struct gcpro gcpro1; 1664 struct gcpro gcpro1;
1715 EMACS_INT size = bool_vector_size (obj); 1665 EMACS_INT size = bool_vector_size (obj);
@@ -1717,11 +1667,8 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1717 ptrdiff_t real_size_in_chars = size_in_chars; 1667 ptrdiff_t real_size_in_chars = size_in_chars;
1718 GCPRO1 (obj); 1668 GCPRO1 (obj);
1719 1669
1720 PRINTCHAR ('#'); 1670 int len = sprintf (buf, "#&%"pI"d\"", size);
1721 PRINTCHAR ('&');
1722 len = sprintf (buf, "%"pI"d", size);
1723 strout (buf, len, len, printcharfun); 1671 strout (buf, len, len, printcharfun);
1724 PRINTCHAR ('\"');
1725 1672
1726 /* Don't print more characters than the specified maximum. 1673 /* Don't print more characters than the specified maximum.
1727 Negative values of print-length are invalid. Treat them 1674 Negative values of print-length are invalid. Treat them
@@ -1735,70 +1682,59 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1735 QUIT; 1682 QUIT;
1736 c = bool_vector_uchar_data (obj)[i]; 1683 c = bool_vector_uchar_data (obj)[i];
1737 if (c == '\n' && print_escape_newlines) 1684 if (c == '\n' && print_escape_newlines)
1738 { 1685 print_c_string ("\\n", printcharfun);
1739 PRINTCHAR ('\\');
1740 PRINTCHAR ('n');
1741 }
1742 else if (c == '\f' && print_escape_newlines) 1686 else if (c == '\f' && print_escape_newlines)
1743 { 1687 print_c_string ("\\f", printcharfun);
1744 PRINTCHAR ('\\');
1745 PRINTCHAR ('f');
1746 }
1747 else if (c > '\177') 1688 else if (c > '\177')
1748 { 1689 {
1749 /* Use octal escapes to avoid encoding issues. */ 1690 /* Use octal escapes to avoid encoding issues. */
1750 PRINTCHAR ('\\'); 1691 len = sprintf (buf, "\\%o", c);
1751 PRINTCHAR ('0' + ((c >> 6) & 3)); 1692 strout (buf, len, len, printcharfun);
1752 PRINTCHAR ('0' + ((c >> 3) & 7));
1753 PRINTCHAR ('0' + (c & 7));
1754 } 1693 }
1755 else 1694 else
1756 { 1695 {
1757 if (c == '\"' || c == '\\') 1696 if (c == '\"' || c == '\\')
1758 PRINTCHAR ('\\'); 1697 printchar ('\\', printcharfun);
1759 PRINTCHAR (c); 1698 printchar (c, printcharfun);
1760 } 1699 }
1761 } 1700 }
1762 1701
1763 if (size_in_chars < real_size_in_chars) 1702 if (size_in_chars < real_size_in_chars)
1764 strout (" ...", 4, 4, printcharfun); 1703 print_c_string (" ...", printcharfun);
1765 PRINTCHAR ('\"'); 1704 printchar ('\"', printcharfun);
1766 1705
1767 UNGCPRO; 1706 UNGCPRO;
1768 } 1707 }
1769 else if (SUBRP (obj)) 1708 else if (SUBRP (obj))
1770 { 1709 {
1771 strout ("#<subr ", -1, -1, printcharfun); 1710 print_c_string ("#<subr ", printcharfun);
1772 strout (XSUBR (obj)->symbol_name, -1, -1, printcharfun); 1711 print_c_string (XSUBR (obj)->symbol_name, printcharfun);
1773 PRINTCHAR ('>'); 1712 printchar ('>', printcharfun);
1774 } 1713 }
1775 else if (WINDOWP (obj)) 1714 else if (WINDOWP (obj))
1776 { 1715 {
1777 int len; 1716 int len = sprintf (buf, "#<window %"pI"d",
1778 strout ("#<window ", -1, -1, printcharfun); 1717 XWINDOW (obj)->sequence_number);
1779 len = sprintf (buf, "%d", XWINDOW (obj)->sequence_number);
1780 strout (buf, len, len, printcharfun); 1718 strout (buf, len, len, printcharfun);
1781 if (BUFFERP (XWINDOW (obj)->contents)) 1719 if (BUFFERP (XWINDOW (obj)->contents))
1782 { 1720 {
1783 strout (" on ", -1, -1, printcharfun); 1721 print_c_string (" on ", printcharfun);
1784 print_string (BVAR (XBUFFER (XWINDOW (obj)->contents), name), 1722 print_string (BVAR (XBUFFER (XWINDOW (obj)->contents), name),
1785 printcharfun); 1723 printcharfun);
1786 } 1724 }
1787 PRINTCHAR ('>'); 1725 printchar ('>', printcharfun);
1788 } 1726 }
1789 else if (TERMINALP (obj)) 1727 else if (TERMINALP (obj))
1790 { 1728 {
1791 int len;
1792 struct terminal *t = XTERMINAL (obj); 1729 struct terminal *t = XTERMINAL (obj);
1793 strout ("#<terminal ", -1, -1, printcharfun); 1730 int len = sprintf (buf, "#<terminal %d", t->id);
1794 len = sprintf (buf, "%d", t->id);
1795 strout (buf, len, len, printcharfun); 1731 strout (buf, len, len, printcharfun);
1796 if (t->name) 1732 if (t->name)
1797 { 1733 {
1798 strout (" on ", -1, -1, printcharfun); 1734 print_c_string (" on ", printcharfun);
1799 strout (t->name, -1, -1, printcharfun); 1735 print_c_string (t->name, printcharfun);
1800 } 1736 }
1801 PRINTCHAR ('>'); 1737 printchar ('>', printcharfun);
1802 } 1738 }
1803 else if (HASH_TABLE_P (obj)) 1739 else if (HASH_TABLE_P (obj))
1804 { 1740 {
@@ -1808,16 +1744,14 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1808 int len; 1744 int len;
1809#if 0 1745#if 0
1810 void *ptr = h; 1746 void *ptr = h;
1811 strout ("#<hash-table", -1, -1, printcharfun); 1747 print_c_string ("#<hash-table", printcharfun);
1812 if (SYMBOLP (h->test)) 1748 if (SYMBOLP (h->test))
1813 { 1749 {
1814 PRINTCHAR (' '); 1750 print_c_string (" '", printcharfun);
1815 PRINTCHAR ('\''); 1751 print_c_string (SSDATA (SYMBOL_NAME (h->test)), printcharfun);
1816 strout (SDATA (SYMBOL_NAME (h->test)), -1, -1, printcharfun); 1752 printchar (' ', printcharfun);
1817 PRINTCHAR (' '); 1753 print_c_string (SSDATA (SYMBOL_NAME (h->weak)), printcharfun);
1818 strout (SDATA (SYMBOL_NAME (h->weak)), -1, -1, printcharfun); 1754 len = sprintf (buf, " %"pD"d/%"pD"d", h->count, ASIZE (h->next));
1819 PRINTCHAR (' ');
1820 len = sprintf (buf, "%"pD"d/%"pD"d", h->count, ASIZE (h->next));
1821 strout (buf, len, len, printcharfun); 1755 strout (buf, len, len, printcharfun);
1822 } 1756 }
1823 len = sprintf (buf, " %p>", ptr); 1757 len = sprintf (buf, " %p>", ptr);
@@ -1831,29 +1765,29 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1831 1765
1832 if (!NILP (h->test.name)) 1766 if (!NILP (h->test.name))
1833 { 1767 {
1834 strout (" test ", -1, -1, printcharfun); 1768 print_c_string (" test ", printcharfun);
1835 print_object (h->test.name, printcharfun, escapeflag); 1769 print_object (h->test.name, printcharfun, escapeflag);
1836 } 1770 }
1837 1771
1838 if (!NILP (h->weak)) 1772 if (!NILP (h->weak))
1839 { 1773 {
1840 strout (" weakness ", -1, -1, printcharfun); 1774 print_c_string (" weakness ", printcharfun);
1841 print_object (h->weak, printcharfun, escapeflag); 1775 print_object (h->weak, printcharfun, escapeflag);
1842 } 1776 }
1843 1777
1844 if (!NILP (h->rehash_size)) 1778 if (!NILP (h->rehash_size))
1845 { 1779 {
1846 strout (" rehash-size ", -1, -1, printcharfun); 1780 print_c_string (" rehash-size ", printcharfun);
1847 print_object (h->rehash_size, printcharfun, escapeflag); 1781 print_object (h->rehash_size, printcharfun, escapeflag);
1848 } 1782 }
1849 1783
1850 if (!NILP (h->rehash_threshold)) 1784 if (!NILP (h->rehash_threshold))
1851 { 1785 {
1852 strout (" rehash-threshold ", -1, -1, printcharfun); 1786 print_c_string (" rehash-threshold ", printcharfun);
1853 print_object (h->rehash_threshold, printcharfun, escapeflag); 1787 print_object (h->rehash_threshold, printcharfun, escapeflag);
1854 } 1788 }
1855 1789
1856 strout (" data ", -1, -1, printcharfun); 1790 print_c_string (" data ", printcharfun);
1857 1791
1858 /* Print the data here as a plist. */ 1792 /* Print the data here as a plist. */
1859 real_size = HASH_TABLE_SIZE (h); 1793 real_size = HASH_TABLE_SIZE (h);
@@ -1864,49 +1798,47 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1864 && XFASTINT (Vprint_length) < size) 1798 && XFASTINT (Vprint_length) < size)
1865 size = XFASTINT (Vprint_length); 1799 size = XFASTINT (Vprint_length);
1866 1800
1867 PRINTCHAR ('('); 1801 printchar ('(', printcharfun);
1868 for (i = 0; i < size; i++) 1802 for (i = 0; i < size; i++)
1869 if (!NILP (HASH_HASH (h, i))) 1803 if (!NILP (HASH_HASH (h, i)))
1870 { 1804 {
1871 if (i) PRINTCHAR (' '); 1805 if (i) printchar (' ', printcharfun);
1872 print_object (HASH_KEY (h, i), printcharfun, escapeflag); 1806 print_object (HASH_KEY (h, i), printcharfun, escapeflag);
1873 PRINTCHAR (' '); 1807 printchar (' ', printcharfun);
1874 print_object (HASH_VALUE (h, i), printcharfun, escapeflag); 1808 print_object (HASH_VALUE (h, i), printcharfun, escapeflag);
1875 } 1809 }
1876 1810
1877 if (size < real_size) 1811 if (size < real_size)
1878 strout (" ...", 4, 4, printcharfun); 1812 print_c_string (" ...", printcharfun);
1879 1813
1880 PRINTCHAR (')'); 1814 print_c_string ("))", printcharfun);
1881 PRINTCHAR (')');
1882 1815
1883 } 1816 }
1884 else if (BUFFERP (obj)) 1817 else if (BUFFERP (obj))
1885 { 1818 {
1886 if (!BUFFER_LIVE_P (XBUFFER (obj))) 1819 if (!BUFFER_LIVE_P (XBUFFER (obj)))
1887 strout ("#<killed buffer>", -1, -1, printcharfun); 1820 print_c_string ("#<killed buffer>", printcharfun);
1888 else if (escapeflag) 1821 else if (escapeflag)
1889 { 1822 {
1890 strout ("#<buffer ", -1, -1, printcharfun); 1823 print_c_string ("#<buffer ", printcharfun);
1891 print_string (BVAR (XBUFFER (obj), name), printcharfun); 1824 print_string (BVAR (XBUFFER (obj), name), printcharfun);
1892 PRINTCHAR ('>'); 1825 printchar ('>', printcharfun);
1893 } 1826 }
1894 else 1827 else
1895 print_string (BVAR (XBUFFER (obj), name), printcharfun); 1828 print_string (BVAR (XBUFFER (obj), name), printcharfun);
1896 } 1829 }
1897 else if (WINDOW_CONFIGURATIONP (obj)) 1830 else if (WINDOW_CONFIGURATIONP (obj))
1898 { 1831 print_c_string ("#<window-configuration>", printcharfun);
1899 strout ("#<window-configuration>", -1, -1, printcharfun);
1900 }
1901 else if (FRAMEP (obj)) 1832 else if (FRAMEP (obj))
1902 { 1833 {
1903 int len; 1834 int len;
1904 void *ptr = XFRAME (obj); 1835 void *ptr = XFRAME (obj);
1905 Lisp_Object frame_name = XFRAME (obj)->name; 1836 Lisp_Object frame_name = XFRAME (obj)->name;
1906 1837
1907 strout ((FRAME_LIVE_P (XFRAME (obj)) 1838 print_c_string ((FRAME_LIVE_P (XFRAME (obj))
1908 ? "#<frame " : "#<dead frame "), 1839 ? "#<frame "
1909 -1, -1, printcharfun); 1840 : "#<dead frame "),
1841 printcharfun);
1910 if (!STRINGP (frame_name)) 1842 if (!STRINGP (frame_name))
1911 { 1843 {
1912 /* A frame could be too young and have no name yet; 1844 /* A frame could be too young and have no name yet;
@@ -1927,12 +1859,12 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1927 if (! FONT_OBJECT_P (obj)) 1859 if (! FONT_OBJECT_P (obj))
1928 { 1860 {
1929 if (FONT_SPEC_P (obj)) 1861 if (FONT_SPEC_P (obj))
1930 strout ("#<font-spec", -1, -1, printcharfun); 1862 print_c_string ("#<font-spec", printcharfun);
1931 else 1863 else
1932 strout ("#<font-entity", -1, -1, printcharfun); 1864 print_c_string ("#<font-entity", printcharfun);
1933 for (i = 0; i < FONT_SPEC_MAX; i++) 1865 for (i = 0; i < FONT_SPEC_MAX; i++)
1934 { 1866 {
1935 PRINTCHAR (' '); 1867 printchar (' ', printcharfun);
1936 if (i < FONT_WEIGHT_INDEX || i > FONT_WIDTH_INDEX) 1868 if (i < FONT_WEIGHT_INDEX || i > FONT_WIDTH_INDEX)
1937 print_object (AREF (obj, i), printcharfun, escapeflag); 1869 print_object (AREF (obj, i), printcharfun, escapeflag);
1938 else 1870 else
@@ -1942,18 +1874,18 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1942 } 1874 }
1943 else 1875 else
1944 { 1876 {
1945 strout ("#<font-object ", -1, -1, printcharfun); 1877 print_c_string ("#<font-object ", printcharfun);
1946 print_object (AREF (obj, FONT_NAME_INDEX), printcharfun, 1878 print_object (AREF (obj, FONT_NAME_INDEX), printcharfun,
1947 escapeflag); 1879 escapeflag);
1948 } 1880 }
1949 PRINTCHAR ('>'); 1881 printchar ('>', printcharfun);
1950 } 1882 }
1951 else 1883 else
1952 { 1884 {
1953 ptrdiff_t size = ASIZE (obj); 1885 ptrdiff_t size = ASIZE (obj);
1954 if (COMPILEDP (obj)) 1886 if (COMPILEDP (obj))
1955 { 1887 {
1956 PRINTCHAR ('#'); 1888 printchar ('#', printcharfun);
1957 size &= PSEUDOVECTOR_SIZE_MASK; 1889 size &= PSEUDOVECTOR_SIZE_MASK;
1958 } 1890 }
1959 if (CHAR_TABLE_P (obj) || SUB_CHAR_TABLE_P (obj)) 1891 if (CHAR_TABLE_P (obj) || SUB_CHAR_TABLE_P (obj))
@@ -1967,20 +1899,19 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1967 results in slow redisplay. */ 1899 results in slow redisplay. */
1968 if (SUB_CHAR_TABLE_P (obj) 1900 if (SUB_CHAR_TABLE_P (obj)
1969 && XSUB_CHAR_TABLE (obj)->depth == 3) 1901 && XSUB_CHAR_TABLE (obj)->depth == 3)
1970 PRINTCHAR ('\n'); 1902 printchar ('\n', printcharfun);
1971 PRINTCHAR ('#'); 1903 print_c_string ("#^", printcharfun);
1972 PRINTCHAR ('^');
1973 if (SUB_CHAR_TABLE_P (obj)) 1904 if (SUB_CHAR_TABLE_P (obj))
1974 PRINTCHAR ('^'); 1905 printchar ('^', printcharfun);
1975 size &= PSEUDOVECTOR_SIZE_MASK; 1906 size &= PSEUDOVECTOR_SIZE_MASK;
1976 } 1907 }
1977 if (size & PSEUDOVECTOR_FLAG) 1908 if (size & PSEUDOVECTOR_FLAG)
1978 goto badtype; 1909 goto badtype;
1979 1910
1980 PRINTCHAR ('['); 1911 printchar ('[', printcharfun);
1981 { 1912 {
1982 int i, idx = SUB_CHAR_TABLE_P (obj) ? SUB_CHAR_TABLE_OFFSET : 0; 1913 int i, idx = SUB_CHAR_TABLE_P (obj) ? SUB_CHAR_TABLE_OFFSET : 0;
1983 register Lisp_Object tem; 1914 Lisp_Object tem;
1984 ptrdiff_t real_size = size; 1915 ptrdiff_t real_size = size;
1985 1916
1986 /* For a sub char-table, print heading non-Lisp data first. */ 1917 /* For a sub char-table, print heading non-Lisp data first. */
@@ -1998,14 +1929,14 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1998 1929
1999 for (i = idx; i < size; i++) 1930 for (i = idx; i < size; i++)
2000 { 1931 {
2001 if (i) PRINTCHAR (' '); 1932 if (i) printchar (' ', printcharfun);
2002 tem = AREF (obj, i); 1933 tem = AREF (obj, i);
2003 print_object (tem, printcharfun, escapeflag); 1934 print_object (tem, printcharfun, escapeflag);
2004 } 1935 }
2005 if (size < real_size) 1936 if (size < real_size)
2006 strout (" ...", 4, 4, printcharfun); 1937 print_c_string (" ...", printcharfun);
2007 } 1938 }
2008 PRINTCHAR (']'); 1939 printchar (']', printcharfun);
2009 } 1940 }
2010 break; 1941 break;
2011 1942
@@ -2013,26 +1944,25 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
2013 switch (XMISCTYPE (obj)) 1944 switch (XMISCTYPE (obj))
2014 { 1945 {
2015 case Lisp_Misc_Marker: 1946 case Lisp_Misc_Marker:
2016 strout ("#<marker ", -1, -1, printcharfun); 1947 print_c_string ("#<marker ", printcharfun);
2017 /* Do you think this is necessary? */ 1948 /* Do you think this is necessary? */
2018 if (XMARKER (obj)->insertion_type != 0) 1949 if (XMARKER (obj)->insertion_type != 0)
2019 strout ("(moves after insertion) ", -1, -1, printcharfun); 1950 print_c_string ("(moves after insertion) ", printcharfun);
2020 if (! XMARKER (obj)->buffer) 1951 if (! XMARKER (obj)->buffer)
2021 strout ("in no buffer", -1, -1, printcharfun); 1952 print_c_string ("in no buffer", printcharfun);
2022 else 1953 else
2023 { 1954 {
2024 int len = sprintf (buf, "at %"pD"d", marker_position (obj)); 1955 int len = sprintf (buf, "at %"pD"d in ", marker_position (obj));
2025 strout (buf, len, len, printcharfun); 1956 strout (buf, len, len, printcharfun);
2026 strout (" in ", -1, -1, printcharfun);
2027 print_string (BVAR (XMARKER (obj)->buffer, name), printcharfun); 1957 print_string (BVAR (XMARKER (obj)->buffer, name), printcharfun);
2028 } 1958 }
2029 PRINTCHAR ('>'); 1959 printchar ('>', printcharfun);
2030 break; 1960 break;
2031 1961
2032 case Lisp_Misc_Overlay: 1962 case Lisp_Misc_Overlay:
2033 strout ("#<overlay ", -1, -1, printcharfun); 1963 print_c_string ("#<overlay ", printcharfun);
2034 if (! XMARKER (OVERLAY_START (obj))->buffer) 1964 if (! XMARKER (OVERLAY_START (obj))->buffer)
2035 strout ("in no buffer", -1, -1, printcharfun); 1965 print_c_string ("in no buffer", printcharfun);
2036 else 1966 else
2037 { 1967 {
2038 int len = sprintf (buf, "from %"pD"d to %"pD"d in ", 1968 int len = sprintf (buf, "from %"pD"d to %"pD"d in ",
@@ -2042,21 +1972,21 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
2042 print_string (BVAR (XMARKER (OVERLAY_START (obj))->buffer, name), 1972 print_string (BVAR (XMARKER (OVERLAY_START (obj))->buffer, name),
2043 printcharfun); 1973 printcharfun);
2044 } 1974 }
2045 PRINTCHAR ('>'); 1975 printchar ('>', printcharfun);
2046 break; 1976 break;
2047 1977
2048 case Lisp_Misc_Finalizer: 1978 case Lisp_Misc_Finalizer:
2049 strout ("#<finalizer", -1, -1, printcharfun); 1979 print_c_string ("#<finalizer", printcharfun);
2050 if (NILP (XFINALIZER (obj)->function)) 1980 if (NILP (XFINALIZER (obj)->function))
2051 strout (" used", -1, -1, printcharfun); 1981 print_c_string (" used", printcharfun);
2052 strout (">", -1, -1, printcharfun); 1982 printchar ('>', printcharfun);
2053 break; 1983 break;
2054 1984
2055 /* Remaining cases shouldn't happen in normal usage, but let's 1985 /* Remaining cases shouldn't happen in normal usage, but let's
2056 print them anyway for the benefit of the debugger. */ 1986 print them anyway for the benefit of the debugger. */
2057 1987
2058 case Lisp_Misc_Free: 1988 case Lisp_Misc_Free:
2059 strout ("#<misc free cell>", -1, -1, printcharfun); 1989 print_c_string ("#<misc free cell>", printcharfun);
2060 break; 1990 break;
2061 1991
2062 case Lisp_Misc_Save_Value: 1992 case Lisp_Misc_Save_Value:
@@ -2064,7 +1994,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
2064 int i; 1994 int i;
2065 struct Lisp_Save_Value *v = XSAVE_VALUE (obj); 1995 struct Lisp_Save_Value *v = XSAVE_VALUE (obj);
2066 1996
2067 strout ("#<save-value ", -1, -1, printcharfun); 1997 print_c_string ("#<save-value ", printcharfun);
2068 1998
2069 if (v->save_type == SAVE_TYPE_MEMORY) 1999 if (v->save_type == SAVE_TYPE_MEMORY)
2070 { 2000 {
@@ -2087,17 +2017,15 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
2087 Lisp_Object maybe = area[i]; 2017 Lisp_Object maybe = area[i];
2088 int valid = valid_lisp_object_p (maybe); 2018 int valid = valid_lisp_object_p (maybe);
2089 2019
2020 printchar (' ', printcharfun);
2090 if (0 < valid) 2021 if (0 < valid)
2091 { 2022 print_object (maybe, printcharfun, escapeflag);
2092 PRINTCHAR (' ');
2093 print_object (maybe, printcharfun, escapeflag);
2094 }
2095 else 2023 else
2096 strout (valid ? " <some>" : " <invalid>", 2024 print_c_string (valid < 0 ? "<some>" : "<invalid>",
2097 -1, -1, printcharfun); 2025 printcharfun);
2098 } 2026 }
2099 if (i == limit && i < amount) 2027 if (i == limit && i < amount)
2100 strout (" ...", 4, 4, printcharfun); 2028 print_c_string (" ...", printcharfun);
2101 2029
2102#else /* not GC_MARK_STACK */ 2030#else /* not GC_MARK_STACK */
2103 2031
@@ -2116,7 +2044,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
2116 for (index = 0; index < SAVE_VALUE_SLOTS; index++) 2044 for (index = 0; index < SAVE_VALUE_SLOTS; index++)
2117 { 2045 {
2118 if (index) 2046 if (index)
2119 PRINTCHAR (' '); 2047 printchar (' ', printcharfun);
2120 2048
2121 switch (save_type (v, index)) 2049 switch (save_type (v, index))
2122 { 2050 {
@@ -2152,7 +2080,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
2152 strout (buf, i, i, printcharfun); 2080 strout (buf, i, i, printcharfun);
2153 } 2081 }
2154 } 2082 }
2155 PRINTCHAR ('>'); 2083 printchar ('>', printcharfun);
2156 } 2084 }
2157 break; 2085 break;
2158 2086
@@ -2167,16 +2095,17 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
2167 int len; 2095 int len;
2168 /* We're in trouble if this happens! 2096 /* We're in trouble if this happens!
2169 Probably should just emacs_abort (). */ 2097 Probably should just emacs_abort (). */
2170 strout ("#<EMACS BUG: INVALID DATATYPE ", -1, -1, printcharfun); 2098 print_c_string ("#<EMACS BUG: INVALID DATATYPE ", printcharfun);
2171 if (MISCP (obj)) 2099 if (MISCP (obj))
2172 len = sprintf (buf, "(MISC 0x%04x)", (int) XMISCTYPE (obj)); 2100 len = sprintf (buf, "(MISC 0x%04x)", (unsigned) XMISCTYPE (obj));
2173 else if (VECTORLIKEP (obj)) 2101 else if (VECTORLIKEP (obj))
2174 len = sprintf (buf, "(PVEC 0x%08"pD"x)", ASIZE (obj)); 2102 len = sprintf (buf, "(PVEC 0x%08zx)", (size_t) ASIZE (obj));
2175 else 2103 else
2176 len = sprintf (buf, "(0x%02x)", (int) XTYPE (obj)); 2104 len = sprintf (buf, "(0x%02x)", (unsigned) XTYPE (obj));
2177 strout (buf, len, len, printcharfun); 2105 strout (buf, len, len, printcharfun);
2178 strout (" Save your buffers immediately and please report this bug>", 2106 print_c_string ((" Save your buffers immediately"
2179 -1, -1, printcharfun); 2107 " and please report this bug>"),
2108 printcharfun);
2180 } 2109 }
2181 } 2110 }
2182 2111
@@ -2192,12 +2121,12 @@ print_interval (INTERVAL interval, Lisp_Object printcharfun)
2192{ 2121{
2193 if (NILP (interval->plist)) 2122 if (NILP (interval->plist))
2194 return; 2123 return;
2195 PRINTCHAR (' '); 2124 printchar (' ', printcharfun);
2196 print_object (make_number (interval->position), printcharfun, 1); 2125 print_object (make_number (interval->position), printcharfun, 1);
2197 PRINTCHAR (' '); 2126 printchar (' ', printcharfun);
2198 print_object (make_number (interval->position + LENGTH (interval)), 2127 print_object (make_number (interval->position + LENGTH (interval)),
2199 printcharfun, 1); 2128 printcharfun, 1);
2200 PRINTCHAR (' '); 2129 printchar (' ', printcharfun);
2201 print_object (interval->plist, printcharfun, 1); 2130 print_object (interval->plist, printcharfun, 1);
2202} 2131}
2203 2132
diff --git a/src/process.c b/src/process.c
index 2800fa58340..3e04cb76387 100644
--- a/src/process.c
+++ b/src/process.c
@@ -189,6 +189,8 @@ process_socket (int domain, int type, int protocol)
189#define NETCONN1_P(p) (EQ (p->type, Qnetwork)) 189#define NETCONN1_P(p) (EQ (p->type, Qnetwork))
190#define SERIALCONN_P(p) (EQ (XPROCESS (p)->type, Qserial)) 190#define SERIALCONN_P(p) (EQ (XPROCESS (p)->type, Qserial))
191#define SERIALCONN1_P(p) (EQ (p->type, Qserial)) 191#define SERIALCONN1_P(p) (EQ (p->type, Qserial))
192#define PIPECONN_P(p) (EQ (XPROCESS (p)->type, Qpipe))
193#define PIPECONN1_P(p) (EQ (p->type, Qpipe))
192 194
193/* Number of events of change of status of a process. */ 195/* Number of events of change of status of a process. */
194static EMACS_INT process_tick; 196static EMACS_INT process_tick;
@@ -411,6 +413,11 @@ pset_write_queue (struct Lisp_Process *p, Lisp_Object val)
411{ 413{
412 p->write_queue = val; 414 p->write_queue = val;
413} 415}
416static void
417pset_stderrproc (struct Lisp_Process *p, Lisp_Object val)
418{
419 p->stderrproc = val;
420}
414 421
415 422
416static Lisp_Object 423static Lisp_Object
@@ -837,7 +844,7 @@ nil, indicating the current buffer's process. */)
837 p = XPROCESS (process); 844 p = XPROCESS (process);
838 845
839 p->raw_status_new = 0; 846 p->raw_status_new = 0;
840 if (NETCONN1_P (p) || SERIALCONN1_P (p)) 847 if (NETCONN1_P (p) || SERIALCONN1_P (p) || PIPECONN1_P (p))
841 { 848 {
842 pset_status (p, list2 (Qexit, make_number (0))); 849 pset_status (p, list2 (Qexit, make_number (0)));
843 p->tick = ++process_tick; 850 p->tick = ++process_tick;
@@ -903,7 +910,7 @@ nil, indicating the current buffer's process. */)
903 status = p->status; 910 status = p->status;
904 if (CONSP (status)) 911 if (CONSP (status))
905 status = XCAR (status); 912 status = XCAR (status);
906 if (NETCONN1_P (p) || SERIALCONN1_P (p)) 913 if (NETCONN1_P (p) || SERIALCONN1_P (p) || PIPECONN1_P (p))
907 { 914 {
908 if (EQ (status, Qexit)) 915 if (EQ (status, Qexit))
909 status = Qclosed; 916 status = Qclosed;
@@ -987,7 +994,7 @@ Return BUFFER. */)
987 CHECK_BUFFER (buffer); 994 CHECK_BUFFER (buffer);
988 p = XPROCESS (process); 995 p = XPROCESS (process);
989 pset_buffer (p, buffer); 996 pset_buffer (p, buffer);
990 if (NETCONN1_P (p) || SERIALCONN1_P (p)) 997 if (NETCONN1_P (p) || SERIALCONN1_P (p) || PIPECONN1_P (p))
991 pset_childp (p, Fplist_put (p->childp, QCbuffer, buffer)); 998 pset_childp (p, Fplist_put (p->childp, QCbuffer, buffer));
992 setup_process_coding_systems (process); 999 setup_process_coding_systems (process);
993 return buffer; 1000 return buffer;
@@ -1063,7 +1070,7 @@ The string argument is normally a multibyte string, except:
1063 } 1070 }
1064 1071
1065 pset_filter (p, filter); 1072 pset_filter (p, filter);
1066 if (NETCONN1_P (p) || SERIALCONN1_P (p)) 1073 if (NETCONN1_P (p) || SERIALCONN1_P (p) || PIPECONN1_P (p))
1067 pset_childp (p, Fplist_put (p->childp, QCfilter, filter)); 1074 pset_childp (p, Fplist_put (p->childp, QCfilter, filter));
1068 setup_process_coding_systems (process); 1075 setup_process_coding_systems (process);
1069 return filter; 1076 return filter;
@@ -1095,7 +1102,7 @@ It gets two arguments: the process, and a string describing the change. */)
1095 sentinel = Qinternal_default_process_sentinel; 1102 sentinel = Qinternal_default_process_sentinel;
1096 1103
1097 pset_sentinel (p, sentinel); 1104 pset_sentinel (p, sentinel);
1098 if (NETCONN1_P (p) || SERIALCONN1_P (p)) 1105 if (NETCONN1_P (p) || SERIALCONN1_P (p) || PIPECONN1_P (p))
1099 pset_childp (p, Fplist_put (p->childp, QCsentinel, sentinel)); 1106 pset_childp (p, Fplist_put (p->childp, QCsentinel, sentinel));
1100 return sentinel; 1107 return sentinel;
1101} 1108}
@@ -1204,7 +1211,8 @@ list of keywords. */)
1204 Fprocess_datagram_address (process)); 1211 Fprocess_datagram_address (process));
1205#endif 1212#endif
1206 1213
1207 if ((!NETCONN_P (process) && !SERIALCONN_P (process)) || EQ (key, Qt)) 1214 if ((!NETCONN_P (process) && !SERIALCONN_P (process) && !PIPECONN_P (process))
1215 || EQ (key, Qt))
1208 return contact; 1216 return contact;
1209 if (NILP (key) && NETCONN_P (process)) 1217 if (NILP (key) && NETCONN_P (process))
1210 return list2 (Fplist_get (contact, QChost), 1218 return list2 (Fplist_get (contact, QChost),
@@ -1212,6 +1220,11 @@ list of keywords. */)
1212 if (NILP (key) && SERIALCONN_P (process)) 1220 if (NILP (key) && SERIALCONN_P (process))
1213 return list2 (Fplist_get (contact, QCport), 1221 return list2 (Fplist_get (contact, QCport),
1214 Fplist_get (contact, QCspeed)); 1222 Fplist_get (contact, QCspeed));
1223 /* FIXME: Return a meaningful value (e.g., the child end of the pipe)
1224 if the pipe process is useful for purposes other than receiving
1225 stderr. */
1226 if (NILP (key) && PIPECONN_P (process))
1227 return Qt;
1215 return Fplist_get (contact, key); 1228 return Fplist_get (contact, key);
1216} 1229}
1217 1230
@@ -1386,10 +1399,15 @@ to use a pty, or nil to use the default specified through
1386 1399
1387:sentinel SENTINEL -- Install SENTINEL as the process sentinel. 1400:sentinel SENTINEL -- Install SENTINEL as the process sentinel.
1388 1401
1402:stderr STDERR -- STDERR is either a buffer or a pipe process attached
1403to the standard error of subprocess. Specifying this implies
1404`:connection-type' is set to `pipe'.
1405
1389usage: (make-process &rest ARGS) */) 1406usage: (make-process &rest ARGS) */)
1390 (ptrdiff_t nargs, Lisp_Object *args) 1407 (ptrdiff_t nargs, Lisp_Object *args)
1391{ 1408{
1392 Lisp_Object buffer, name, command, program, proc, contact, current_dir, tem; 1409 Lisp_Object buffer, name, command, program, proc, contact, current_dir, tem;
1410 Lisp_Object xstderr, stderrproc;
1393 ptrdiff_t count = SPECPDL_INDEX (); 1411 ptrdiff_t count = SPECPDL_INDEX ();
1394 struct gcpro gcpro1; 1412 struct gcpro gcpro1;
1395 USE_SAFE_ALLOCA; 1413 USE_SAFE_ALLOCA;
@@ -1433,6 +1451,27 @@ usage: (make-process &rest ARGS) */)
1433 if (!NILP (program)) 1451 if (!NILP (program))
1434 CHECK_STRING (program); 1452 CHECK_STRING (program);
1435 1453
1454 stderrproc = Qnil;
1455 xstderr = Fplist_get (contact, QCstderr);
1456 if (PROCESSP (xstderr))
1457 {
1458 if (!PIPECONN_P (xstderr))
1459 error ("Process is not a pipe process");
1460 stderrproc = xstderr;
1461 }
1462 else if (!NILP (xstderr))
1463 {
1464 struct gcpro gcpro1, gcpro2;
1465 CHECK_STRING (program);
1466 GCPRO2 (buffer, current_dir);
1467 stderrproc = CALLN (Fmake_pipe_process,
1468 QCname,
1469 concat2 (name, build_string (" stderr")),
1470 QCbuffer,
1471 Fget_buffer_create (xstderr));
1472 UNGCPRO;
1473 }
1474
1436 proc = make_process (name); 1475 proc = make_process (name);
1437 /* If an error occurs and we can't start the process, we want to 1476 /* If an error occurs and we can't start the process, we want to
1438 remove it from the process list. This means that each error 1477 remove it from the process list. This means that each error
@@ -1444,8 +1483,8 @@ usage: (make-process &rest ARGS) */)
1444 pset_plist (XPROCESS (proc), Qnil); 1483 pset_plist (XPROCESS (proc), Qnil);
1445 pset_type (XPROCESS (proc), Qreal); 1484 pset_type (XPROCESS (proc), Qreal);
1446 pset_buffer (XPROCESS (proc), buffer); 1485 pset_buffer (XPROCESS (proc), buffer);
1447 pset_sentinel (XPROCESS (proc), Qinternal_default_process_sentinel); 1486 pset_sentinel (XPROCESS (proc), Fplist_get (contact, QCsentinel));
1448 pset_filter (XPROCESS (proc), Qinternal_default_process_filter); 1487 pset_filter (XPROCESS (proc), Fplist_get (contact, QCfilter));
1449 pset_command (XPROCESS (proc), Fcopy_sequence (command)); 1488 pset_command (XPROCESS (proc), Fcopy_sequence (command));
1450 1489
1451 if (tem = Fplist_get (contact, QCnoquery), !NILP (tem)) 1490 if (tem = Fplist_get (contact, QCnoquery), !NILP (tem))
@@ -1463,6 +1502,13 @@ usage: (make-process &rest ARGS) */)
1463 else 1502 else
1464 report_file_error ("Unknown connection type", tem); 1503 report_file_error ("Unknown connection type", tem);
1465 1504
1505 if (!NILP (stderrproc))
1506 {
1507 pset_stderrproc (XPROCESS (proc), stderrproc);
1508
1509 XPROCESS (proc)->pty_flag = false;
1510 }
1511
1466#ifdef HAVE_GNUTLS 1512#ifdef HAVE_GNUTLS
1467 /* AKA GNUTLS_INITSTAGE(proc). */ 1513 /* AKA GNUTLS_INITSTAGE(proc). */
1468 XPROCESS (proc)->gnutls_initstage = GNUTLS_STAGE_EMPTY; 1514 XPROCESS (proc)->gnutls_initstage = GNUTLS_STAGE_EMPTY;
@@ -1708,7 +1754,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1708 int inchannel, outchannel; 1754 int inchannel, outchannel;
1709 pid_t pid; 1755 pid_t pid;
1710 int vfork_errno; 1756 int vfork_errno;
1711 int forkin, forkout; 1757 int forkin, forkout, forkerr = -1;
1712 bool pty_flag = 0; 1758 bool pty_flag = 0;
1713 char pty_name[PTY_NAME_SIZE]; 1759 char pty_name[PTY_NAME_SIZE];
1714 Lisp_Object lisp_pty_name = Qnil; 1760 Lisp_Object lisp_pty_name = Qnil;
@@ -1746,6 +1792,17 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1746 outchannel = p->open_fd[WRITE_TO_SUBPROCESS]; 1792 outchannel = p->open_fd[WRITE_TO_SUBPROCESS];
1747 inchannel = p->open_fd[READ_FROM_SUBPROCESS]; 1793 inchannel = p->open_fd[READ_FROM_SUBPROCESS];
1748 forkout = p->open_fd[SUBPROCESS_STDOUT]; 1794 forkout = p->open_fd[SUBPROCESS_STDOUT];
1795
1796 if (!NILP (p->stderrproc))
1797 {
1798 struct Lisp_Process *pp = XPROCESS (p->stderrproc);
1799
1800 forkerr = pp->open_fd[SUBPROCESS_STDOUT];
1801
1802 /* Close unnecessary file descriptors. */
1803 close_process_fd (&pp->open_fd[WRITE_TO_SUBPROCESS]);
1804 close_process_fd (&pp->open_fd[SUBPROCESS_STDIN]);
1805 }
1749 } 1806 }
1750 1807
1751#ifndef WINDOWSNT 1808#ifndef WINDOWSNT
@@ -1792,6 +1849,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1792 char **volatile new_argv_volatile = new_argv; 1849 char **volatile new_argv_volatile = new_argv;
1793 int volatile forkin_volatile = forkin; 1850 int volatile forkin_volatile = forkin;
1794 int volatile forkout_volatile = forkout; 1851 int volatile forkout_volatile = forkout;
1852 int volatile forkerr_volatile = forkerr;
1795 struct Lisp_Process *p_volatile = p; 1853 struct Lisp_Process *p_volatile = p;
1796 1854
1797 pid = vfork (); 1855 pid = vfork ();
@@ -1801,6 +1859,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1801 new_argv = new_argv_volatile; 1859 new_argv = new_argv_volatile;
1802 forkin = forkin_volatile; 1860 forkin = forkin_volatile;
1803 forkout = forkout_volatile; 1861 forkout = forkout_volatile;
1862 forkerr = forkerr_volatile;
1804 p = p_volatile; 1863 p = p_volatile;
1805 1864
1806 pty_flag = p->pty_flag; 1865 pty_flag = p->pty_flag;
@@ -1811,6 +1870,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1811 { 1870 {
1812 int xforkin = forkin; 1871 int xforkin = forkin;
1813 int xforkout = forkout; 1872 int xforkout = forkout;
1873 int xforkerr = forkerr;
1814 1874
1815 /* Make the pty be the controlling terminal of the process. */ 1875 /* Make the pty be the controlling terminal of the process. */
1816#ifdef HAVE_PTYS 1876#ifdef HAVE_PTYS
@@ -1910,10 +1970,13 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1910 1970
1911 if (pty_flag) 1971 if (pty_flag)
1912 child_setup_tty (xforkout); 1972 child_setup_tty (xforkout);
1973
1974 if (xforkerr < 0)
1975 xforkerr = xforkout;
1913#ifdef WINDOWSNT 1976#ifdef WINDOWSNT
1914 pid = child_setup (xforkin, xforkout, xforkout, new_argv, 1, current_dir); 1977 pid = child_setup (xforkin, xforkout, xforkerr, new_argv, 1, current_dir);
1915#else /* not WINDOWSNT */ 1978#else /* not WINDOWSNT */
1916 child_setup (xforkin, xforkout, xforkout, new_argv, 1, current_dir); 1979 child_setup (xforkin, xforkout, xforkerr, new_argv, 1, current_dir);
1917#endif /* not WINDOWSNT */ 1980#endif /* not WINDOWSNT */
1918 } 1981 }
1919 1982
@@ -1958,6 +2021,11 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1958 close_process_fd (&p->open_fd[READ_FROM_EXEC_MONITOR]); 2021 close_process_fd (&p->open_fd[READ_FROM_EXEC_MONITOR]);
1959 } 2022 }
1960#endif 2023#endif
2024 if (!NILP (p->stderrproc))
2025 {
2026 struct Lisp_Process *pp = XPROCESS (p->stderrproc);
2027 close_process_fd (&pp->open_fd[SUBPROCESS_STDOUT]);
2028 }
1961 } 2029 }
1962} 2030}
1963 2031
@@ -2016,6 +2084,187 @@ create_pty (Lisp_Object process)
2016 p->pid = -2; 2084 p->pid = -2;
2017} 2085}
2018 2086
2087DEFUN ("make-pipe-process", Fmake_pipe_process, Smake_pipe_process,
2088 0, MANY, 0,
2089 doc: /* Create and return a bidirectional pipe process.
2090
2091In Emacs, pipes are represented by process objects, so input and
2092output work as for subprocesses, and `delete-process' closes a pipe.
2093However, a pipe process has no process id, it cannot be signaled,
2094and the status codes are different from normal processes.
2095
2096Arguments are specified as keyword/argument pairs. The following
2097arguments are defined:
2098
2099:name NAME -- NAME is the name of the process. It is modified if necessary to make it unique.
2100
2101:buffer BUFFER -- BUFFER is the buffer (or buffer-name) to associate
2102with the process. Process output goes at the end of that buffer,
2103unless you specify an output stream or filter function to handle the
2104output. If BUFFER is not given, the value of NAME is used.
2105
2106:coding CODING -- If CODING is a symbol, it specifies the coding
2107system used for both reading and writing for this process. If CODING
2108is a cons (DECODING . ENCODING), DECODING is used for reading, and
2109ENCODING is used for writing.
2110
2111:noquery BOOL -- When exiting Emacs, query the user if BOOL is nil and
2112the process is running. If BOOL is not given, query before exiting.
2113
2114:stop BOOL -- Start process in the `stopped' state if BOOL non-nil.
2115In the stopped state, a pipe process does not accept incoming data,
2116but you can send outgoing data. The stopped state is cleared by
2117`continue-process' and set by `stop-process'.
2118
2119:filter FILTER -- Install FILTER as the process filter.
2120
2121:sentinel SENTINEL -- Install SENTINEL as the process sentinel.
2122
2123usage: (make-pipe-process &rest ARGS) */)
2124 (ptrdiff_t nargs, Lisp_Object *args)
2125{
2126 Lisp_Object proc, contact;
2127 struct Lisp_Process *p;
2128 struct gcpro gcpro1;
2129 Lisp_Object name, buffer;
2130 Lisp_Object tem;
2131 ptrdiff_t specpdl_count;
2132 int inchannel, outchannel;
2133
2134 if (nargs == 0)
2135 return Qnil;
2136
2137 contact = Flist (nargs, args);
2138 GCPRO1 (contact);
2139
2140 name = Fplist_get (contact, QCname);
2141 CHECK_STRING (name);
2142 proc = make_process (name);
2143 specpdl_count = SPECPDL_INDEX ();
2144 record_unwind_protect (remove_process, proc);
2145 p = XPROCESS (proc);
2146
2147 if (emacs_pipe (p->open_fd + SUBPROCESS_STDIN) != 0
2148 || emacs_pipe (p->open_fd + READ_FROM_SUBPROCESS) != 0)
2149 report_file_error ("Creating pipe", Qnil);
2150 outchannel = p->open_fd[WRITE_TO_SUBPROCESS];
2151 inchannel = p->open_fd[READ_FROM_SUBPROCESS];
2152
2153 fcntl (inchannel, F_SETFL, O_NONBLOCK);
2154 fcntl (outchannel, F_SETFL, O_NONBLOCK);
2155
2156#ifdef WINDOWSNT
2157 register_aux_fd (inchannel);
2158#endif
2159
2160 /* Record this as an active process, with its channels. */
2161 chan_process[inchannel] = proc;
2162 p->infd = inchannel;
2163 p->outfd = outchannel;
2164
2165 if (inchannel > max_process_desc)
2166 max_process_desc = inchannel;
2167
2168 buffer = Fplist_get (contact, QCbuffer);
2169 if (NILP (buffer))
2170 buffer = name;
2171 buffer = Fget_buffer_create (buffer);
2172 pset_buffer (p, buffer);
2173
2174 pset_childp (p, contact);
2175 pset_plist (p, Fcopy_sequence (Fplist_get (contact, QCplist)));
2176 pset_type (p, Qpipe);
2177 pset_sentinel (p, Fplist_get (contact, QCsentinel));
2178 pset_filter (p, Fplist_get (contact, QCfilter));
2179 pset_log (p, Qnil);
2180 if (tem = Fplist_get (contact, QCnoquery), !NILP (tem))
2181 p->kill_without_query = 1;
2182 if (tem = Fplist_get (contact, QCstop), !NILP (tem))
2183 pset_command (p, Qt);
2184 eassert (! p->pty_flag);
2185
2186 if (!EQ (p->command, Qt))
2187 {
2188 FD_SET (inchannel, &input_wait_mask);
2189 FD_SET (inchannel, &non_keyboard_wait_mask);
2190 }
2191#ifdef ADAPTIVE_READ_BUFFERING
2192 p->adaptive_read_buffering
2193 = (NILP (Vprocess_adaptive_read_buffering) ? 0
2194 : EQ (Vprocess_adaptive_read_buffering, Qt) ? 1 : 2);
2195#endif
2196
2197 /* Make the process marker point into the process buffer (if any). */
2198 if (BUFFERP (buffer))
2199 set_marker_both (p->mark, buffer,
2200 BUF_ZV (XBUFFER (buffer)),
2201 BUF_ZV_BYTE (XBUFFER (buffer)));
2202
2203 {
2204 /* Setup coding systems for communicating with the network stream. */
2205
2206 /* Qt denotes we have not yet called Ffind_operation_coding_system. */
2207 Lisp_Object coding_systems = Qt;
2208 Lisp_Object val;
2209
2210 tem = Fplist_get (contact, QCcoding);
2211 val = Qnil;
2212 if (!NILP (tem))
2213 {
2214 val = tem;
2215 if (CONSP (val))
2216 val = XCAR (val);
2217 }
2218 else if (!NILP (Vcoding_system_for_read))
2219 val = Vcoding_system_for_read;
2220 else if ((!NILP (buffer) && NILP (BVAR (XBUFFER (buffer), enable_multibyte_characters)))
2221 || (NILP (buffer) && NILP (BVAR (&buffer_defaults, enable_multibyte_characters))))
2222 /* We dare not decode end-of-line format by setting VAL to
2223 Qraw_text, because the existing Emacs Lisp libraries
2224 assume that they receive bare code including a sequence of
2225 CR LF. */
2226 val = Qnil;
2227 else
2228 {
2229 if (CONSP (coding_systems))
2230 val = XCAR (coding_systems);
2231 else if (CONSP (Vdefault_process_coding_system))
2232 val = XCAR (Vdefault_process_coding_system);
2233 else
2234 val = Qnil;
2235 }
2236 pset_decode_coding_system (p, val);
2237
2238 if (!NILP (tem))
2239 {
2240 val = tem;
2241 if (CONSP (val))
2242 val = XCDR (val);
2243 }
2244 else if (!NILP (Vcoding_system_for_write))
2245 val = Vcoding_system_for_write;
2246 else if (NILP (BVAR (current_buffer, enable_multibyte_characters)))
2247 val = Qnil;
2248 else
2249 {
2250 if (CONSP (coding_systems))
2251 val = XCDR (coding_systems);
2252 else if (CONSP (Vdefault_process_coding_system))
2253 val = XCDR (Vdefault_process_coding_system);
2254 else
2255 val = Qnil;
2256 }
2257 pset_encode_coding_system (p, val);
2258 }
2259 /* This may signal an error. */
2260 setup_process_coding_systems (proc);
2261
2262 specpdl_ptr = specpdl + specpdl_count;
2263
2264 UNGCPRO;
2265 return proc;
2266}
2267
2019 2268
2020/* Convert an internal struct sockaddr to a lisp object (vector or string). 2269/* Convert an internal struct sockaddr to a lisp object (vector or string).
2021 The address family of sa is not included in the result. */ 2270 The address family of sa is not included in the result. */
@@ -4536,37 +4785,41 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4536 if (wait_proc && wait_proc->raw_status_new) 4785 if (wait_proc && wait_proc->raw_status_new)
4537 update_status (wait_proc); 4786 update_status (wait_proc);
4538 if (wait_proc 4787 if (wait_proc
4539 && wait_proc->infd >= 0
4540 && ! EQ (wait_proc->status, Qrun) 4788 && ! EQ (wait_proc->status, Qrun)
4541 && ! EQ (wait_proc->status, Qconnect)) 4789 && ! EQ (wait_proc->status, Qconnect))
4542 { 4790 {
4543 bool read_some_bytes = false; 4791 bool read_some_bytes = false;
4544 4792
4545 clear_waiting_for_input (); 4793 clear_waiting_for_input ();
4546 XSETPROCESS (proc, wait_proc);
4547 4794
4548 /* Read data from the process, until we exhaust it. */ 4795 /* If data can be read from the process, do so until exhausted. */
4549 while (true) 4796 if (wait_proc->infd >= 0)
4550 { 4797 {
4551 int nread = read_process_output (proc, wait_proc->infd); 4798 XSETPROCESS (proc, wait_proc);
4552 if (nread < 0) 4799
4800 while (true)
4553 { 4801 {
4554 if (errno == EIO || errno == EAGAIN) 4802 int nread = read_process_output (proc, wait_proc->infd);
4555 break; 4803 if (nread < 0)
4804 {
4805 if (errno == EIO || errno == EAGAIN)
4806 break;
4556#ifdef EWOULDBLOCK 4807#ifdef EWOULDBLOCK
4557 if (errno == EWOULDBLOCK) 4808 if (errno == EWOULDBLOCK)
4558 break; 4809 break;
4559#endif 4810#endif
4560 } 4811 }
4561 else 4812 else
4562 { 4813 {
4563 if (got_some_input < nread) 4814 if (got_some_input < nread)
4564 got_some_input = nread; 4815 got_some_input = nread;
4565 if (nread == 0) 4816 if (nread == 0)
4566 break; 4817 break;
4567 read_some_bytes = true; 4818 read_some_bytes = true;
4819 }
4568 } 4820 }
4569 } 4821 }
4822
4570 if (read_some_bytes && do_display) 4823 if (read_some_bytes && do_display)
4571 redisplay_preserve_echo_area (10); 4824 redisplay_preserve_echo_area (10);
4572 4825
@@ -4884,7 +5137,8 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4884 available now and a closed pipe. 5137 available now and a closed pipe.
4885 With luck, a closed pipe will be accompanied by 5138 With luck, a closed pipe will be accompanied by
4886 subprocess termination and SIGCHLD. */ 5139 subprocess termination and SIGCHLD. */
4887 else if (nread == 0 && !NETCONN_P (proc) && !SERIALCONN_P (proc)) 5140 else if (nread == 0 && !NETCONN_P (proc) && !SERIALCONN_P (proc)
5141 && !PIPECONN_P (proc))
4888 ; 5142 ;
4889#endif 5143#endif
4890#ifdef HAVE_PTYS 5144#ifdef HAVE_PTYS
@@ -4916,8 +5170,18 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4916#endif /* HAVE_PTYS */ 5170#endif /* HAVE_PTYS */
4917 /* If we can detect process termination, don't consider the 5171 /* If we can detect process termination, don't consider the
4918 process gone just because its pipe is closed. */ 5172 process gone just because its pipe is closed. */
4919 else if (nread == 0 && !NETCONN_P (proc) && !SERIALCONN_P (proc)) 5173 else if (nread == 0 && !NETCONN_P (proc) && !SERIALCONN_P (proc)
5174 && !PIPECONN_P (proc))
4920 ; 5175 ;
5176 else if (nread == 0 && PIPECONN_P (proc))
5177 {
5178 /* Preserve status of processes already terminated. */
5179 XPROCESS (proc)->tick = ++process_tick;
5180 deactivate_process (proc);
5181 if (EQ (XPROCESS (proc)->status, Qrun))
5182 pset_status (XPROCESS (proc),
5183 list2 (Qexit, make_number (0)));
5184 }
4921 else 5185 else
4922 { 5186 {
4923 /* Preserve status of processes already terminated. */ 5187 /* Preserve status of processes already terminated. */
@@ -5954,7 +6218,8 @@ If PROCESS is a network or serial process, inhibit handling of incoming
5954traffic. */) 6218traffic. */)
5955 (Lisp_Object process, Lisp_Object current_group) 6219 (Lisp_Object process, Lisp_Object current_group)
5956{ 6220{
5957 if (PROCESSP (process) && (NETCONN_P (process) || SERIALCONN_P (process))) 6221 if (PROCESSP (process) && (NETCONN_P (process) || SERIALCONN_P (process)
6222 || PIPECONN_P (process)))
5958 { 6223 {
5959 struct Lisp_Process *p; 6224 struct Lisp_Process *p;
5960 6225
@@ -5983,7 +6248,8 @@ If PROCESS is a network or serial process, resume handling of incoming
5983traffic. */) 6248traffic. */)
5984 (Lisp_Object process, Lisp_Object current_group) 6249 (Lisp_Object process, Lisp_Object current_group)
5985{ 6250{
5986 if (PROCESSP (process) && (NETCONN_P (process) || SERIALCONN_P (process))) 6251 if (PROCESSP (process) && (NETCONN_P (process) || SERIALCONN_P (process)
6252 || PIPECONN_P (process)))
5987 { 6253 {
5988 struct Lisp_Process *p; 6254 struct Lisp_Process *p;
5989 6255
@@ -7030,7 +7296,7 @@ kill_buffer_processes (Lisp_Object buffer)
7030 FOR_EACH_PROCESS (tail, proc) 7296 FOR_EACH_PROCESS (tail, proc)
7031 if (NILP (buffer) || EQ (XPROCESS (proc)->buffer, buffer)) 7297 if (NILP (buffer) || EQ (XPROCESS (proc)->buffer, buffer))
7032 { 7298 {
7033 if (NETCONN_P (proc) || SERIALCONN_P (proc)) 7299 if (NETCONN_P (proc) || SERIALCONN_P (proc) || PIPECONN_P (proc))
7034 Fdelete_process (proc); 7300 Fdelete_process (proc);
7035 else if (XPROCESS (proc)->infd >= 0) 7301 else if (XPROCESS (proc)->infd >= 0)
7036 process_send_signal (proc, SIGHUP, Qnil, 1); 7302 process_send_signal (proc, SIGHUP, Qnil, 1);
@@ -7236,40 +7502,6 @@ init_process_emacs (void)
7236 memset (datagram_address, 0, sizeof datagram_address); 7502 memset (datagram_address, 0, sizeof datagram_address);
7237#endif 7503#endif
7238 7504
7239 {
7240 Lisp_Object subfeatures = Qnil;
7241 const struct socket_options *sopt;
7242
7243#define ADD_SUBFEATURE(key, val) \
7244 subfeatures = pure_cons (pure_cons (key, pure_cons (val, Qnil)), subfeatures)
7245
7246#ifdef NON_BLOCKING_CONNECT
7247 ADD_SUBFEATURE (QCnowait, Qt);
7248#endif
7249#ifdef DATAGRAM_SOCKETS
7250 ADD_SUBFEATURE (QCtype, Qdatagram);
7251#endif
7252#ifdef HAVE_SEQPACKET
7253 ADD_SUBFEATURE (QCtype, Qseqpacket);
7254#endif
7255#ifdef HAVE_LOCAL_SOCKETS
7256 ADD_SUBFEATURE (QCfamily, Qlocal);
7257#endif
7258 ADD_SUBFEATURE (QCfamily, Qipv4);
7259#ifdef AF_INET6
7260 ADD_SUBFEATURE (QCfamily, Qipv6);
7261#endif
7262#ifdef HAVE_GETSOCKNAME
7263 ADD_SUBFEATURE (QCservice, Qt);
7264#endif
7265 ADD_SUBFEATURE (QCserver, Qt);
7266
7267 for (sopt = socket_options; sopt->name; sopt++)
7268 subfeatures = pure_cons (intern_c_string (sopt->name), subfeatures);
7269
7270 Fprovide (intern_c_string ("make-network-process"), subfeatures);
7271 }
7272
7273#if defined (DARWIN_OS) 7505#if defined (DARWIN_OS)
7274 /* PTYs are broken on Darwin < 6, but are sometimes useful for interactive 7506 /* PTYs are broken on Darwin < 6, but are sometimes useful for interactive
7275 processes. As such, we only change the default value. */ 7507 processes. As such, we only change the default value. */
@@ -7330,6 +7562,7 @@ syms_of_process (void)
7330 DEFSYM (Qreal, "real"); 7562 DEFSYM (Qreal, "real");
7331 DEFSYM (Qnetwork, "network"); 7563 DEFSYM (Qnetwork, "network");
7332 DEFSYM (Qserial, "serial"); 7564 DEFSYM (Qserial, "serial");
7565 DEFSYM (Qpipe, "pipe");
7333 DEFSYM (QCbuffer, ":buffer"); 7566 DEFSYM (QCbuffer, ":buffer");
7334 DEFSYM (QChost, ":host"); 7567 DEFSYM (QChost, ":host");
7335 DEFSYM (QCservice, ":service"); 7568 DEFSYM (QCservice, ":service");
@@ -7346,6 +7579,7 @@ syms_of_process (void)
7346 DEFSYM (QCplist, ":plist"); 7579 DEFSYM (QCplist, ":plist");
7347 DEFSYM (QCcommand, ":command"); 7580 DEFSYM (QCcommand, ":command");
7348 DEFSYM (QCconnection_type, ":connection-type"); 7581 DEFSYM (QCconnection_type, ":connection-type");
7582 DEFSYM (QCstderr, ":stderr");
7349 DEFSYM (Qpty, "pty"); 7583 DEFSYM (Qpty, "pty");
7350 DEFSYM (Qpipe, "pipe"); 7584 DEFSYM (Qpipe, "pipe");
7351 7585
@@ -7451,6 +7685,7 @@ The variable takes effect when `start-process' is called. */);
7451 defsubr (&Sset_process_plist); 7685 defsubr (&Sset_process_plist);
7452 defsubr (&Sprocess_list); 7686 defsubr (&Sprocess_list);
7453 defsubr (&Smake_process); 7687 defsubr (&Smake_process);
7688 defsubr (&Smake_pipe_process);
7454 defsubr (&Sserial_process_configure); 7689 defsubr (&Sserial_process_configure);
7455 defsubr (&Smake_serial_process); 7690 defsubr (&Smake_serial_process);
7456 defsubr (&Sset_network_process_option); 7691 defsubr (&Sset_network_process_option);
@@ -7488,4 +7723,39 @@ The variable takes effect when `start-process' is called. */);
7488 defsubr (&Sprocess_inherit_coding_system_flag); 7723 defsubr (&Sprocess_inherit_coding_system_flag);
7489 defsubr (&Slist_system_processes); 7724 defsubr (&Slist_system_processes);
7490 defsubr (&Sprocess_attributes); 7725 defsubr (&Sprocess_attributes);
7726
7727 {
7728 Lisp_Object subfeatures = Qnil;
7729 const struct socket_options *sopt;
7730
7731#define ADD_SUBFEATURE(key, val) \
7732 subfeatures = pure_cons (pure_cons (key, pure_cons (val, Qnil)), subfeatures)
7733
7734#ifdef NON_BLOCKING_CONNECT
7735 ADD_SUBFEATURE (QCnowait, Qt);
7736#endif
7737#ifdef DATAGRAM_SOCKETS
7738 ADD_SUBFEATURE (QCtype, Qdatagram);
7739#endif
7740#ifdef HAVE_SEQPACKET
7741 ADD_SUBFEATURE (QCtype, Qseqpacket);
7742#endif
7743#ifdef HAVE_LOCAL_SOCKETS
7744 ADD_SUBFEATURE (QCfamily, Qlocal);
7745#endif
7746 ADD_SUBFEATURE (QCfamily, Qipv4);
7747#ifdef AF_INET6
7748 ADD_SUBFEATURE (QCfamily, Qipv6);
7749#endif
7750#ifdef HAVE_GETSOCKNAME
7751 ADD_SUBFEATURE (QCservice, Qt);
7752#endif
7753 ADD_SUBFEATURE (QCserver, Qt);
7754
7755 for (sopt = socket_options; sopt->name; sopt++)
7756 subfeatures = pure_cons (intern_c_string (sopt->name), subfeatures);
7757
7758 Fprovide (intern_c_string ("make-network-process"), subfeatures);
7759 }
7760
7491} 7761}
diff --git a/src/process.h b/src/process.h
index 36979dcac9e..e889055dc23 100644
--- a/src/process.h
+++ b/src/process.h
@@ -105,6 +105,9 @@ struct Lisp_Process
105 Lisp_Object gnutls_cred_type; 105 Lisp_Object gnutls_cred_type;
106#endif 106#endif
107 107
108 /* Pipe process attached to the standard error of this process. */
109 Lisp_Object stderrproc;
110
108 /* After this point, there are no Lisp_Objects any more. */ 111 /* After this point, there are no Lisp_Objects any more. */
109 /* alloc.c assumes that `pid' is the first such non-Lisp slot. */ 112 /* alloc.c assumes that `pid' is the first such non-Lisp slot. */
110 113
diff --git a/src/regex.c b/src/regex.c
index 1afc5037594..38c5e350541 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -313,12 +313,12 @@ enum syntaxcode { Swhitespace = 0, Sword = 1, Ssymbol = 2 };
313/* The rest must handle multibyte characters. */ 313/* The rest must handle multibyte characters. */
314 314
315# define ISGRAPH(c) (SINGLE_BYTE_CHAR_P (c) \ 315# define ISGRAPH(c) (SINGLE_BYTE_CHAR_P (c) \
316 ? (c) > ' ' && !((c) >= 0177 && (c) <= 0237) \ 316 ? (c) > ' ' && !((c) >= 0177 && (c) <= 0240) \
317 : 1) 317 : graphicp (c))
318 318
319# define ISPRINT(c) (SINGLE_BYTE_CHAR_P (c) \ 319# define ISPRINT(c) (SINGLE_BYTE_CHAR_P (c) \
320 ? (c) >= ' ' && !((c) >= 0177 && (c) <= 0237) \ 320 ? (c) >= ' ' && !((c) >= 0177 && (c) <= 0237) \
321 : 1) 321 : printablep (c))
322 322
323# define ISALNUM(c) (IS_REAL_ASCII (c) \ 323# define ISALNUM(c) (IS_REAL_ASCII (c) \
324 ? (((c) >= 'a' && (c) <= 'z') \ 324 ? (((c) >= 'a' && (c) <= 'z') \
@@ -1865,7 +1865,8 @@ struct range_table_work_area
1865#define RANGE_TABLE_WORK_ELT(work_area, i) ((work_area).table[i]) 1865#define RANGE_TABLE_WORK_ELT(work_area, i) ((work_area).table[i])
1866 1866
1867/* Bits used to implement the multibyte-part of the various character classes 1867/* Bits used to implement the multibyte-part of the various character classes
1868 such as [:alnum:] in a charset's range table. */ 1868 such as [:alnum:] in a charset's range table. The code currently assumes
1869 that only the low 16 bits are used. */
1869#define BIT_WORD 0x1 1870#define BIT_WORD 0x1
1870#define BIT_LOWER 0x2 1871#define BIT_LOWER 0x2
1871#define BIT_PUNCT 0x4 1872#define BIT_PUNCT 0x4
@@ -1874,6 +1875,8 @@ struct range_table_work_area
1874#define BIT_MULTIBYTE 0x20 1875#define BIT_MULTIBYTE 0x20
1875#define BIT_ALPHA 0x40 1876#define BIT_ALPHA 0x40
1876#define BIT_ALNUM 0x80 1877#define BIT_ALNUM 0x80
1878#define BIT_GRAPH 0x100
1879#define BIT_PRINT 0x200
1877 1880
1878 1881
1879/* Set the bit for character C in a list. */ 1882/* Set the bit for character C in a list. */
@@ -2072,7 +2075,7 @@ re_wctype_to_bit (re_wctype_t cc)
2072{ 2075{
2073 switch (cc) 2076 switch (cc)
2074 { 2077 {
2075 case RECC_NONASCII: case RECC_PRINT: case RECC_GRAPH: 2078 case RECC_NONASCII:
2076 case RECC_MULTIBYTE: return BIT_MULTIBYTE; 2079 case RECC_MULTIBYTE: return BIT_MULTIBYTE;
2077 case RECC_ALPHA: return BIT_ALPHA; 2080 case RECC_ALPHA: return BIT_ALPHA;
2078 case RECC_ALNUM: return BIT_ALNUM; 2081 case RECC_ALNUM: return BIT_ALNUM;
@@ -2081,6 +2084,8 @@ re_wctype_to_bit (re_wctype_t cc)
2081 case RECC_UPPER: return BIT_UPPER; 2084 case RECC_UPPER: return BIT_UPPER;
2082 case RECC_PUNCT: return BIT_PUNCT; 2085 case RECC_PUNCT: return BIT_PUNCT;
2083 case RECC_SPACE: return BIT_SPACE; 2086 case RECC_SPACE: return BIT_SPACE;
2087 case RECC_GRAPH: return BIT_GRAPH;
2088 case RECC_PRINT: return BIT_PRINT;
2084 case RECC_ASCII: case RECC_DIGIT: case RECC_XDIGIT: case RECC_CNTRL: 2089 case RECC_ASCII: case RECC_DIGIT: case RECC_XDIGIT: case RECC_CNTRL:
2085 case RECC_BLANK: case RECC_UNIBYTE: case RECC_ERROR: return 0; 2090 case RECC_BLANK: case RECC_UNIBYTE: case RECC_ERROR: return 0;
2086 default: 2091 default:
@@ -5519,7 +5524,9 @@ re_match_2_internal (struct re_pattern_buffer *bufp, const_re_char *string1,
5519 | (class_bits & BIT_UPPER && ISUPPER (c)) 5524 | (class_bits & BIT_UPPER && ISUPPER (c))
5520 | (class_bits & BIT_WORD && ISWORD (c)) 5525 | (class_bits & BIT_WORD && ISWORD (c))
5521 | (class_bits & BIT_ALPHA && ISALPHA (c)) 5526 | (class_bits & BIT_ALPHA && ISALPHA (c))
5522 | (class_bits & BIT_ALNUM && ISALNUM (c))) 5527 | (class_bits & BIT_ALNUM && ISALNUM (c))
5528 | (class_bits & BIT_GRAPH && ISGRAPH (c))
5529 | (class_bits & BIT_PRINT && ISPRINT (c)))
5523 not = !not; 5530 not = !not;
5524 else 5531 else
5525 CHARSET_LOOKUP_RANGE_TABLE_RAW (not, c, range_table, count); 5532 CHARSET_LOOKUP_RANGE_TABLE_RAW (not, c, range_table, count);
diff --git a/src/term.c b/src/term.c
index 15d33b4e3ee..d2a9c3d1f30 100644
--- a/src/term.c
+++ b/src/term.c
@@ -1862,9 +1862,11 @@ produce_glyphless_glyph (struct it *it, Lisp_Object acronym)
1862 else 1862 else
1863 { 1863 {
1864 eassert (it->glyphless_method == GLYPHLESS_DISPLAY_HEX_CODE); 1864 eassert (it->glyphless_method == GLYPHLESS_DISPLAY_HEX_CODE);
1865 len = (it->c < 0x10000 ? sprintf (buf, "\\u%04X", it->c) 1865 len = sprintf (buf,
1866 : it->c <= MAX_UNICODE_CHAR ? sprintf (buf, "\\U%06X", it->c) 1866 (it->c < 0x10000 ? "\\u%04X"
1867 : sprintf (buf, "\\x%06X", it->c)); 1867 : it->c <= MAX_UNICODE_CHAR ? "\\U%06X"
1868 : "\\x%06X"),
1869 it->c + 0u);
1868 } 1870 }
1869 str = buf; 1871 str = buf;
1870 } 1872 }
diff --git a/src/textprop.c b/src/textprop.c
index 740b96227cf..0a591d0e05f 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -52,8 +52,8 @@ enum property_set_type
52 TEXT_PROPERTY_APPEND 52 TEXT_PROPERTY_APPEND
53}; 53};
54 54
55/* If o1 is a cons whose cdr is a cons, return non-zero and set o2 to 55/* If o1 is a cons whose cdr is a cons, return true and set o2 to
56 the o1's cdr. Otherwise, return zero. This is handy for 56 the o1's cdr. Otherwise, return false. This is handy for
57 traversing plists. */ 57 traversing plists. */
58#define PLIST_ELT_P(o1, o2) (CONSP (o1) && ((o2)=XCDR (o1), CONSP (o2))) 58#define PLIST_ELT_P(o1, o2) (CONSP (o1) && ((o2)=XCDR (o1), CONSP (o2)))
59 59
@@ -123,13 +123,12 @@ CHECK_STRING_OR_BUFFER (Lisp_Object x)
123 Fprevious_property_change which call this function with BEGIN == END. 123 Fprevious_property_change which call this function with BEGIN == END.
124 Handle this case specially. 124 Handle this case specially.
125 125
126 If FORCE is soft (0), it's OK to return NULL. Otherwise, 126 If FORCE is soft (false), it's OK to return NULL. Otherwise,
127 create an interval tree for OBJECT if one doesn't exist, provided 127 create an interval tree for OBJECT if one doesn't exist, provided
128 the object actually contains text. In the current design, if there 128 the object actually contains text. In the current design, if there
129 is no text, there can be no text properties. */ 129 is no text, there can be no text properties. */
130 130
131#define soft 0 131enum { soft = false, hard = true };
132#define hard 1
133 132
134INTERVAL 133INTERVAL
135validate_interval_range (Lisp_Object object, Lisp_Object *begin, 134validate_interval_range (Lisp_Object object, Lisp_Object *begin,
@@ -206,15 +205,17 @@ validate_plist (Lisp_Object list)
206 205
207 if (CONSP (list)) 206 if (CONSP (list))
208 { 207 {
209 bool odd_length = 0; 208 Lisp_Object tail = list;
210 Lisp_Object tail; 209 do
211 for (tail = list; CONSP (tail); tail = XCDR (tail))
212 { 210 {
213 odd_length ^= 1; 211 tail = XCDR (tail);
212 if (! CONSP (tail))
213 error ("Odd length text property list");
214 tail = XCDR (tail);
214 QUIT; 215 QUIT;
215 } 216 }
216 if (odd_length) 217 while (CONSP (tail));
217 error ("Odd length text property list"); 218
218 return list; 219 return list;
219 } 220 }
220 221
@@ -233,27 +234,27 @@ interval_has_all_properties (Lisp_Object plist, INTERVAL i)
233 for (tail1 = plist; CONSP (tail1); tail1 = Fcdr (XCDR (tail1))) 234 for (tail1 = plist; CONSP (tail1); tail1 = Fcdr (XCDR (tail1)))
234 { 235 {
235 Lisp_Object sym1 = XCAR (tail1); 236 Lisp_Object sym1 = XCAR (tail1);
236 bool found = 0; 237 bool found = false;
237 238
238 /* Go through I's plist, looking for sym1 */ 239 /* Go through I's plist, looking for sym1 */
239 for (tail2 = i->plist; CONSP (tail2); tail2 = Fcdr (XCDR (tail2))) 240 for (tail2 = i->plist; CONSP (tail2); tail2 = Fcdr (XCDR (tail2)))
240 if (EQ (sym1, XCAR (tail2))) 241 if (EQ (sym1, XCAR (tail2)))
241 { 242 {
242 /* Found the same property on both lists. If the 243 /* Found the same property on both lists. If the
243 values are unequal, return zero. */ 244 values are unequal, return false. */
244 if (! EQ (Fcar (XCDR (tail1)), Fcar (XCDR (tail2)))) 245 if (! EQ (Fcar (XCDR (tail1)), Fcar (XCDR (tail2))))
245 return 0; 246 return false;
246 247
247 /* Property has same value on both lists; go to next one. */ 248 /* Property has same value on both lists; go to next one. */
248 found = 1; 249 found = true;
249 break; 250 break;
250 } 251 }
251 252
252 if (! found) 253 if (! found)
253 return 0; 254 return false;
254 } 255 }
255 256
256 return 1; 257 return true;
257} 258}
258 259
259/* Return true if the plist of interval I has any of the 260/* Return true if the plist of interval I has any of the
@@ -272,13 +273,13 @@ interval_has_some_properties (Lisp_Object plist, INTERVAL i)
272 /* Go through i's plist, looking for tail1 */ 273 /* Go through i's plist, looking for tail1 */
273 for (tail2 = i->plist; CONSP (tail2); tail2 = Fcdr (XCDR (tail2))) 274 for (tail2 = i->plist; CONSP (tail2); tail2 = Fcdr (XCDR (tail2)))
274 if (EQ (sym, XCAR (tail2))) 275 if (EQ (sym, XCAR (tail2)))
275 return 1; 276 return true;
276 } 277 }
277 278
278 return 0; 279 return false;
279} 280}
280 281
281/* Return nonzero if the plist of interval I has any of the 282/* Return true if the plist of interval I has any of the
282 property names in LIST, regardless of their values. */ 283 property names in LIST, regardless of their values. */
283 284
284static bool 285static bool
@@ -294,10 +295,10 @@ interval_has_some_properties_list (Lisp_Object list, INTERVAL i)
294 /* Go through i's plist, looking for tail1 */ 295 /* Go through i's plist, looking for tail1 */
295 for (tail2 = i->plist; CONSP (tail2); tail2 = XCDR (XCDR (tail2))) 296 for (tail2 = i->plist; CONSP (tail2); tail2 = XCDR (XCDR (tail2)))
296 if (EQ (sym, XCAR (tail2))) 297 if (EQ (sym, XCAR (tail2)))
297 return 1; 298 return true;
298 } 299 }
299 300
300 return 0; 301 return false;
301} 302}
302 303
303/* Changing the plists of individual intervals. */ 304/* Changing the plists of individual intervals. */
@@ -373,7 +374,7 @@ add_properties (Lisp_Object plist, INTERVAL i, Lisp_Object object,
373 enum property_set_type set_type) 374 enum property_set_type set_type)
374{ 375{
375 Lisp_Object tail1, tail2, sym1, val1; 376 Lisp_Object tail1, tail2, sym1, val1;
376 bool changed = 0; 377 bool changed = false;
377 struct gcpro gcpro1, gcpro2, gcpro3; 378 struct gcpro gcpro1, gcpro2, gcpro3;
378 379
379 tail1 = plist; 380 tail1 = plist;
@@ -387,7 +388,7 @@ add_properties (Lisp_Object plist, INTERVAL i, Lisp_Object object,
387 /* Go through each element of PLIST. */ 388 /* Go through each element of PLIST. */
388 for (tail1 = plist; CONSP (tail1); tail1 = Fcdr (XCDR (tail1))) 389 for (tail1 = plist; CONSP (tail1); tail1 = Fcdr (XCDR (tail1)))
389 { 390 {
390 bool found = 0; 391 bool found = false;
391 sym1 = XCAR (tail1); 392 sym1 = XCAR (tail1);
392 val1 = Fcar (XCDR (tail1)); 393 val1 = Fcar (XCDR (tail1));
393 394
@@ -401,7 +402,7 @@ add_properties (Lisp_Object plist, INTERVAL i, Lisp_Object object,
401 402
402 this_cdr = XCDR (tail2); 403 this_cdr = XCDR (tail2);
403 /* Found the property. Now check its value. */ 404 /* Found the property. Now check its value. */
404 found = 1; 405 found = true;
405 406
406 /* The properties have the same value on both lists. 407 /* The properties have the same value on both lists.
407 Continue to the next property. */ 408 Continue to the next property. */
@@ -438,7 +439,7 @@ add_properties (Lisp_Object plist, INTERVAL i, Lisp_Object object,
438 Fsetcar (this_cdr, list2 (Fcar (this_cdr), val1)); 439 Fsetcar (this_cdr, list2 (Fcar (this_cdr), val1));
439 } 440 }
440 } 441 }
441 changed = 1; 442 changed = true;
442 break; 443 break;
443 } 444 }
444 445
@@ -451,7 +452,7 @@ add_properties (Lisp_Object plist, INTERVAL i, Lisp_Object object,
451 sym1, Qnil, object); 452 sym1, Qnil, object);
452 } 453 }
453 set_interval_plist (i, Fcons (sym1, Fcons (val1, i->plist))); 454 set_interval_plist (i, Fcons (sym1, Fcons (val1, i->plist)));
454 changed = 1; 455 changed = true;
455 } 456 }
456 } 457 }
457 458
@@ -468,23 +469,18 @@ add_properties (Lisp_Object plist, INTERVAL i, Lisp_Object object,
468static bool 469static bool
469remove_properties (Lisp_Object plist, Lisp_Object list, INTERVAL i, Lisp_Object object) 470remove_properties (Lisp_Object plist, Lisp_Object list, INTERVAL i, Lisp_Object object)
470{ 471{
471 Lisp_Object tail1, tail2, sym, current_plist; 472 bool changed = false;
472 bool changed = 0;
473 473
474 /* True means tail1 is a plist, otherwise it is a list. */ 474 /* True means tail1 is a plist, otherwise it is a list. */
475 bool use_plist; 475 bool use_plist = ! NILP (plist);
476 Lisp_Object tail1 = use_plist ? plist : list;
476 477
477 current_plist = i->plist; 478 Lisp_Object current_plist = i->plist;
478
479 if (! NILP (plist))
480 tail1 = plist, use_plist = 1;
481 else
482 tail1 = list, use_plist = 0;
483 479
484 /* Go through each element of LIST or PLIST. */ 480 /* Go through each element of LIST or PLIST. */
485 while (CONSP (tail1)) 481 while (CONSP (tail1))
486 { 482 {
487 sym = XCAR (tail1); 483 Lisp_Object sym = XCAR (tail1);
488 484
489 /* First, remove the symbol if it's at the head of the list */ 485 /* First, remove the symbol if it's at the head of the list */
490 while (CONSP (current_plist) && EQ (sym, XCAR (current_plist))) 486 while (CONSP (current_plist) && EQ (sym, XCAR (current_plist)))
@@ -495,15 +491,14 @@ remove_properties (Lisp_Object plist, Lisp_Object list, INTERVAL i, Lisp_Object
495 object); 491 object);
496 492
497 current_plist = XCDR (XCDR (current_plist)); 493 current_plist = XCDR (XCDR (current_plist));
498 changed = 1; 494 changed = true;
499 } 495 }
500 496
501 /* Go through I's plist, looking for SYM. */ 497 /* Go through I's plist, looking for SYM. */
502 tail2 = current_plist; 498 Lisp_Object tail2 = current_plist;
503 while (! NILP (tail2)) 499 while (! NILP (tail2))
504 { 500 {
505 register Lisp_Object this; 501 Lisp_Object this = XCDR (XCDR (tail2));
506 this = XCDR (XCDR (tail2));
507 if (CONSP (this) && EQ (sym, XCAR (this))) 502 if (CONSP (this) && EQ (sym, XCAR (this)))
508 { 503 {
509 if (BUFFERP (object)) 504 if (BUFFERP (object))
@@ -511,7 +506,7 @@ remove_properties (Lisp_Object plist, Lisp_Object list, INTERVAL i, Lisp_Object
511 sym, XCAR (XCDR (this)), object); 506 sym, XCAR (XCDR (this)), object);
512 507
513 Fsetcdr (XCDR (tail2), XCDR (XCDR (this))); 508 Fsetcdr (XCDR (tail2), XCDR (XCDR (this)));
514 changed = 1; 509 changed = true;
515 } 510 }
516 tail2 = this; 511 tail2 = this;
517 } 512 }
@@ -643,7 +638,7 @@ get_char_property_and_overlay (Lisp_Object position, register Lisp_Object prop,
643 set_buffer_temp (XBUFFER (object)); 638 set_buffer_temp (XBUFFER (object));
644 639
645 USE_SAFE_ALLOCA; 640 USE_SAFE_ALLOCA;
646 GET_OVERLAYS_AT (XINT (position), overlay_vec, noverlays, NULL, 0); 641 GET_OVERLAYS_AT (XINT (position), overlay_vec, noverlays, NULL, false);
647 noverlays = sort_overlays (overlay_vec, noverlays, w); 642 noverlays = sort_overlays (overlay_vec, noverlays, w);
648 643
649 set_buffer_temp (obuf); 644 set_buffer_temp (obuf);
@@ -716,11 +711,12 @@ DEFUN ("next-char-property-change", Fnext_char_property_change,
716This scans characters forward in the current buffer from POSITION till 711This scans characters forward in the current buffer from POSITION till
717it finds a change in some text property, or the beginning or end of an 712it finds a change in some text property, or the beginning or end of an
718overlay, and returns the position of that. 713overlay, and returns the position of that.
719If none is found up to (point-max), the function returns (point-max). 714If none is found, and LIMIT is nil or omitted, the function
715returns (point-max).
720 716
721If the optional second argument LIMIT is non-nil, don't search 717If the optional second argument LIMIT is non-nil, the function doesn't
722past position LIMIT; return LIMIT if nothing is found before LIMIT. 718search past position LIMIT, and returns LIMIT if nothing is found
723LIMIT is a no-op if it is greater than (point-max). */) 719before LIMIT. LIMIT is a no-op if it is greater than (point-max). */)
724 (Lisp_Object position, Lisp_Object limit) 720 (Lisp_Object position, Lisp_Object limit)
725{ 721{
726 Lisp_Object temp; 722 Lisp_Object temp;
@@ -741,11 +737,12 @@ DEFUN ("previous-char-property-change", Fprevious_char_property_change,
741Scans characters backward in the current buffer from POSITION till it 737Scans characters backward in the current buffer from POSITION till it
742finds a change in some text property, or the beginning or end of an 738finds a change in some text property, or the beginning or end of an
743overlay, and returns the position of that. 739overlay, and returns the position of that.
744If none is found since (point-min), the function returns (point-min). 740If none is found, and LIMIT is nil or omitted, the function
741returns (point-min).
745 742
746If the optional second argument LIMIT is non-nil, don't search 743If the optional second argument LIMIT is non-nil, the function doesn't
747past position LIMIT; return LIMIT if nothing is found before LIMIT. 744search before position LIMIT, and returns LIMIT if nothing is found
748LIMIT is a no-op if it is less than (point-min). */) 745before LIMIT. LIMIT is a no-op if it is less than (point-min). */)
749 (Lisp_Object position, Lisp_Object limit) 746 (Lisp_Object position, Lisp_Object limit)
750{ 747{
751 Lisp_Object temp; 748 Lisp_Object temp;
@@ -770,14 +767,15 @@ If the optional third argument OBJECT is a buffer (or nil, which means
770the current buffer), POSITION is a buffer position (integer or marker). 767the current buffer), POSITION is a buffer position (integer or marker).
771If OBJECT is a string, POSITION is a 0-based index into it. 768If OBJECT is a string, POSITION is a 0-based index into it.
772 769
773In a string, scan runs to the end of the string. 770In a string, scan runs to the end of the string, unless LIMIT is non-nil.
774In a buffer, it runs to (point-max), and the value cannot exceed that. 771In a buffer, if LIMIT is nil or omitted, it runs to (point-max), and the
772value cannot exceed that.
773If the optional fourth argument LIMIT is non-nil, don't search
774past position LIMIT; return LIMIT if nothing is found before LIMIT.
775 775
776The property values are compared with `eq'. 776The property values are compared with `eq'.
777If the property is constant all the way to the end of OBJECT, return the 777If the property is constant all the way to the end of OBJECT, return the
778last valid position in OBJECT. 778last valid position in OBJECT. */)
779If the optional fourth argument LIMIT is non-nil, don't search
780past position LIMIT; return LIMIT if nothing is found before LIMIT. */)
781 (Lisp_Object position, Lisp_Object prop, Lisp_Object object, Lisp_Object limit) 779 (Lisp_Object position, Lisp_Object prop, Lisp_Object object, Lisp_Object limit)
782{ 780{
783 if (STRINGP (object)) 781 if (STRINGP (object))
@@ -824,7 +822,7 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT. */)
824 XSETFASTINT (position, ZV); 822 XSETFASTINT (position, ZV);
825 } 823 }
826 else 824 else
827 while (1) 825 while (true)
828 { 826 {
829 position = Fnext_char_property_change (position, limit); 827 position = Fnext_char_property_change (position, limit);
830 if (XFASTINT (position) >= XFASTINT (limit)) 828 if (XFASTINT (position) >= XFASTINT (limit))
@@ -854,14 +852,15 @@ If the optional third argument OBJECT is a buffer (or nil, which means
854the current buffer), POSITION is a buffer position (integer or marker). 852the current buffer), POSITION is a buffer position (integer or marker).
855If OBJECT is a string, POSITION is a 0-based index into it. 853If OBJECT is a string, POSITION is a 0-based index into it.
856 854
857In a string, scan runs to the start of the string. 855In a string, scan runs to the start of the string, unless LIMIT is non-nil.
858In a buffer, it runs to (point-min), and the value cannot be less than that. 856In a buffer, if LIMIT is nil or omitted, it runs to (point-min), and the
857value cannot be less than that.
858If the optional fourth argument LIMIT is non-nil, don't search back past
859position LIMIT; return LIMIT if nothing is found before reaching LIMIT.
859 860
860The property values are compared with `eq'. 861The property values are compared with `eq'.
861If the property is constant all the way to the start of OBJECT, return the 862If the property is constant all the way to the start of OBJECT, return the
862first valid position in OBJECT. 863first valid position in OBJECT. */)
863If the optional fourth argument LIMIT is non-nil, don't search back past
864position LIMIT; return LIMIT if nothing is found before reaching LIMIT. */)
865 (Lisp_Object position, Lisp_Object prop, Lisp_Object object, Lisp_Object limit) 864 (Lisp_Object position, Lisp_Object prop, Lisp_Object object, Lisp_Object limit)
866{ 865{
867 if (STRINGP (object)) 866 if (STRINGP (object))
@@ -910,7 +909,7 @@ position LIMIT; return LIMIT if nothing is found before reaching LIMIT. */)
910 = Fget_char_property (make_number (XFASTINT (position) - 1), 909 = Fget_char_property (make_number (XFASTINT (position) - 1),
911 prop, object); 910 prop, object);
912 911
913 while (1) 912 while (true)
914 { 913 {
915 position = Fprevious_char_property_change (position, limit); 914 position = Fprevious_char_property_change (position, limit);
916 915
@@ -945,8 +944,9 @@ a change in some text property, then returns the position of the change.
945If the optional second argument OBJECT is a buffer (or nil, which means 944If the optional second argument OBJECT is a buffer (or nil, which means
946the current buffer), POSITION is a buffer position (integer or marker). 945the current buffer), POSITION is a buffer position (integer or marker).
947If OBJECT is a string, POSITION is a 0-based index into it. 946If OBJECT is a string, POSITION is a 0-based index into it.
948Return nil if the property is constant all the way to the end of OBJECT. 947Return nil if LIMIT is nil or omitted, and the property is constant all
949If the value is non-nil, it is a position greater than POSITION, never equal. 948the way to the end of OBJECT; if the value is non-nil, it is a position
949greater than POSITION, never equal.
950 950
951If the optional third argument LIMIT is non-nil, don't search 951If the optional third argument LIMIT is non-nil, don't search
952past position LIMIT; return LIMIT if nothing is found before LIMIT. */) 952past position LIMIT; return LIMIT if nothing is found before LIMIT. */)
@@ -1010,8 +1010,9 @@ If the optional third argument OBJECT is a buffer (or nil, which means
1010the current buffer), POSITION is a buffer position (integer or marker). 1010the current buffer), POSITION is a buffer position (integer or marker).
1011If OBJECT is a string, POSITION is a 0-based index into it. 1011If OBJECT is a string, POSITION is a 0-based index into it.
1012The property values are compared with `eq'. 1012The property values are compared with `eq'.
1013Return nil if the property is constant all the way to the end of OBJECT. 1013Return nil if LIMIT is nil or omitted, and the property is constant all
1014If the value is non-nil, it is a position greater than POSITION, never equal. 1014the way to the end of OBJECT; if the value is non-nil, it is a position
1015greater than POSITION, never equal.
1015 1016
1016If the optional fourth argument LIMIT is non-nil, don't search 1017If the optional fourth argument LIMIT is non-nil, don't search
1017past position LIMIT; return LIMIT if nothing is found before LIMIT. */) 1018past position LIMIT; return LIMIT if nothing is found before LIMIT. */)
@@ -1057,8 +1058,9 @@ a change in some text property, then returns the position of the change.
1057If the optional second argument OBJECT is a buffer (or nil, which means 1058If the optional second argument OBJECT is a buffer (or nil, which means
1058the current buffer), POSITION is a buffer position (integer or marker). 1059the current buffer), POSITION is a buffer position (integer or marker).
1059If OBJECT is a string, POSITION is a 0-based index into it. 1060If OBJECT is a string, POSITION is a 0-based index into it.
1060Return nil if the property is constant all the way to the start of OBJECT. 1061Return nil if LIMIT is nil or omitted, and the property is constant all
1061If the value is non-nil, it is a position less than POSITION, never equal. 1062the way to the start of OBJECT; if the value is non-nil, it is a position
1063less than POSITION, never equal.
1062 1064
1063If the optional third argument LIMIT is non-nil, don't search 1065If the optional third argument LIMIT is non-nil, don't search
1064back past position LIMIT; return LIMIT if nothing is found until LIMIT. */) 1066back past position LIMIT; return LIMIT if nothing is found until LIMIT. */)
@@ -1105,8 +1107,9 @@ If the optional third argument OBJECT is a buffer (or nil, which means
1105the current buffer), POSITION is a buffer position (integer or marker). 1107the current buffer), POSITION is a buffer position (integer or marker).
1106If OBJECT is a string, POSITION is a 0-based index into it. 1108If OBJECT is a string, POSITION is a 0-based index into it.
1107The property values are compared with `eq'. 1109The property values are compared with `eq'.
1108Return nil if the property is constant all the way to the start of OBJECT. 1110Return nil if LIMIT is nil or omitted, and the property is constant all
1109If the value is non-nil, it is a position less than POSITION, never equal. 1111the way to the start of OBJECT; if the value is non-nil, it is a position
1112less than POSITION, never equal.
1110 1113
1111If the optional fourth argument LIMIT is non-nil, don't search 1114If the optional fourth argument LIMIT is non-nil, don't search
1112back past position LIMIT; return LIMIT if nothing is found until LIMIT. */) 1115back past position LIMIT; return LIMIT if nothing is found until LIMIT. */)
@@ -1156,9 +1159,9 @@ add_text_properties_1 (Lisp_Object start, Lisp_Object end,
1156 enum property_set_type set_type) { 1159 enum property_set_type set_type) {
1157 INTERVAL i, unchanged; 1160 INTERVAL i, unchanged;
1158 ptrdiff_t s, len; 1161 ptrdiff_t s, len;
1159 bool modified = 0; 1162 bool modified = false;
1160 struct gcpro gcpro1; 1163 struct gcpro gcpro1;
1161 bool first_time = 1; 1164 bool first_time = true;
1162 1165
1163 properties = validate_plist (properties); 1166 properties = validate_plist (properties);
1164 if (NILP (properties)) 1167 if (NILP (properties))
@@ -1218,7 +1221,7 @@ add_text_properties_1 (Lisp_Object start, Lisp_Object end,
1218 if (TOTAL_LENGTH (i) != prev_total_length 1221 if (TOTAL_LENGTH (i) != prev_total_length
1219 || i->position != prev_pos) 1222 || i->position != prev_pos)
1220 { 1223 {
1221 first_time = 0; 1224 first_time = false;
1222 goto retry; 1225 goto retry;
1223 } 1226 }
1224 } 1227 }
@@ -1521,8 +1524,8 @@ Use `set-text-properties' if you want to remove all text properties. */)
1521{ 1524{
1522 INTERVAL i, unchanged; 1525 INTERVAL i, unchanged;
1523 ptrdiff_t s, len; 1526 ptrdiff_t s, len;
1524 bool modified = 0; 1527 bool modified = false;
1525 bool first_time = 1; 1528 bool first_time = true;
1526 1529
1527 if (NILP (object)) 1530 if (NILP (object))
1528 XSETBUFFER (object, current_buffer); 1531 XSETBUFFER (object, current_buffer);
@@ -1574,7 +1577,7 @@ Use `set-text-properties' if you want to remove all text properties. */)
1574 if (TOTAL_LENGTH (i) != prev_total_length 1577 if (TOTAL_LENGTH (i) != prev_total_length
1575 || i->position != prev_pos) 1578 || i->position != prev_pos)
1576 { 1579 {
1577 first_time = 0; 1580 first_time = false;
1578 goto retry; 1581 goto retry;
1579 } 1582 }
1580 } 1583 }
@@ -1633,7 +1636,7 @@ Return t if any property was actually removed, nil otherwise. */)
1633{ 1636{
1634 INTERVAL i, unchanged; 1637 INTERVAL i, unchanged;
1635 ptrdiff_t s, len; 1638 ptrdiff_t s, len;
1636 bool modified = 0; 1639 bool modified = false;
1637 Lisp_Object properties; 1640 Lisp_Object properties;
1638 properties = list_of_properties; 1641 properties = list_of_properties;
1639 1642
@@ -1672,11 +1675,11 @@ Return t if any property was actually removed, nil otherwise. */)
1672 } 1675 }
1673 1676
1674 /* We are at the beginning of an interval, with len to scan. 1677 /* We are at the beginning of an interval, with len to scan.
1675 The flag `modified' records if changes have been made. 1678 The flag MODIFIED records if changes have been made.
1676 When object is a buffer, we must call modify_text_properties 1679 When object is a buffer, we must call modify_text_properties
1677 before changes are made and signal_after_change when we are done. 1680 before changes are made and signal_after_change when we are done.
1678 We call modify_text_properties before calling remove_properties if modified == 0, 1681 Call modify_text_properties before calling remove_properties if !MODIFIED,
1679 and we call signal_after_change before returning if modified != 0. */ 1682 and call signal_after_change before returning if MODIFIED. */
1680 for (;;) 1683 for (;;)
1681 { 1684 {
1682 eassert (i != 0); 1685 eassert (i != 0);
@@ -1725,7 +1728,7 @@ Return t if any property was actually removed, nil otherwise. */)
1725 if (!modified && BUFFERP (object)) 1728 if (!modified && BUFFERP (object))
1726 modify_text_properties (object, start, end); 1729 modify_text_properties (object, start, end);
1727 remove_properties (Qnil, properties, i, object); 1730 remove_properties (Qnil, properties, i, object);
1728 modified = 1; 1731 modified = true;
1729 } 1732 }
1730 len -= LENGTH (i); 1733 len -= LENGTH (i);
1731 i = next_interval (i); 1734 i = next_interval (i);
@@ -1902,7 +1905,7 @@ copy_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object src,
1902 Lisp_Object stuff; 1905 Lisp_Object stuff;
1903 Lisp_Object plist; 1906 Lisp_Object plist;
1904 ptrdiff_t s, e, e2, p, len; 1907 ptrdiff_t s, e, e2, p, len;
1905 bool modified = 0; 1908 bool modified = false;
1906 struct gcpro gcpro1, gcpro2; 1909 struct gcpro gcpro1, gcpro2;
1907 1910
1908 i = validate_interval_range (src, &start, &end, soft); 1911 i = validate_interval_range (src, &start, &end, soft);
@@ -1969,7 +1972,7 @@ copy_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object src,
1969 res = Fadd_text_properties (Fcar (res), Fcar (Fcdr (res)), 1972 res = Fadd_text_properties (Fcar (res), Fcar (Fcdr (res)),
1970 Fcar (Fcdr (Fcdr (res))), dest); 1973 Fcar (Fcdr (Fcdr (res))), dest);
1971 if (! NILP (res)) 1974 if (! NILP (res))
1972 modified = 1; 1975 modified = true;
1973 stuff = Fcdr (stuff); 1976 stuff = Fcdr (stuff);
1974 } 1977 }
1975 1978
diff --git a/src/tparam.c b/src/tparam.c
index 538f26c83b6..02047db2095 100644
--- a/src/tparam.c
+++ b/src/tparam.c
@@ -79,14 +79,14 @@ tparam1 (const char *string, char *outstring, int len,
79 register int tem; 79 register int tem;
80 int *old_argp = argp; /* can move */ 80 int *old_argp = argp; /* can move */
81 int *fixed_argp = argp; /* never moves */ 81 int *fixed_argp = argp; /* never moves */
82 bool explicit_param_p = 0; /* set by %p */ 82 bool explicit_param_p = false; /* set by %p */
83 ptrdiff_t doleft = 0; 83 ptrdiff_t doleft = 0;
84 ptrdiff_t doup = 0; 84 ptrdiff_t doup = 0;
85 ptrdiff_t append_len = 0; 85 ptrdiff_t append_len = 0;
86 86
87 outend = outstring + len; 87 outend = outstring + len;
88 88
89 while (1) 89 while (true)
90 { 90 {
91 /* If the buffer might be too short, make it bigger. */ 91 /* If the buffer might be too short, make it bigger. */
92 while (outend - op - append_len <= 5) 92 while (outend - op - append_len <= 5)
@@ -115,7 +115,7 @@ tparam1 (const char *string, char *outstring, int len,
115 { 115 {
116 c = *p++; 116 c = *p++;
117 if (explicit_param_p) 117 if (explicit_param_p)
118 explicit_param_p = 0; 118 explicit_param_p = false;
119 else 119 else
120 tem = *argp; 120 tem = *argp;
121 switch (c) 121 switch (c)
@@ -142,7 +142,7 @@ tparam1 (const char *string, char *outstring, int len,
142 break; 142 break;
143 case 'p': /* %pN means use param N for next subst. */ 143 case 'p': /* %pN means use param N for next subst. */
144 tem = fixed_argp[(*p++) - '1']; 144 tem = fixed_argp[(*p++) - '1'];
145 explicit_param_p = 1; 145 explicit_param_p = true;
146 break; 146 break;
147 case 'C': 147 case 'C':
148 /* For c-100: print quotient of value by 96, if nonzero, 148 /* For c-100: print quotient of value by 96, if nonzero,
diff --git a/src/undo.c b/src/undo.c
index 948dcf9ec1a..750bc8afff2 100644
--- a/src/undo.c
+++ b/src/undo.c
@@ -212,7 +212,7 @@ record_delete (ptrdiff_t beg, Lisp_Object string, bool record_markers)
212void 212void
213record_change (ptrdiff_t beg, ptrdiff_t length) 213record_change (ptrdiff_t beg, ptrdiff_t length)
214{ 214{
215 record_delete (beg, make_buffer_string (beg, beg + length, 1), false); 215 record_delete (beg, make_buffer_string (beg, beg + length, true), false);
216 record_insert (beg, length); 216 record_insert (beg, length);
217} 217}
218 218
@@ -250,7 +250,7 @@ record_property_change (ptrdiff_t beg, ptrdiff_t length,
250{ 250{
251 Lisp_Object lbeg, lend, entry; 251 Lisp_Object lbeg, lend, entry;
252 struct buffer *obuf = current_buffer, *buf = XBUFFER (buffer); 252 struct buffer *obuf = current_buffer, *buf = XBUFFER (buffer);
253 bool boundary = 0; 253 bool boundary = false;
254 254
255 if (EQ (BVAR (buf, undo_list), Qt)) 255 if (EQ (BVAR (buf, undo_list), Qt))
256 return; 256 return;
@@ -260,7 +260,7 @@ record_property_change (ptrdiff_t beg, ptrdiff_t length,
260 pending_boundary = Fcons (Qnil, Qnil); 260 pending_boundary = Fcons (Qnil, Qnil);
261 261
262 if (buf != last_undo_buffer) 262 if (buf != last_undo_buffer)
263 boundary = 1; 263 boundary = true;
264 last_undo_buffer = buf; 264 last_undo_buffer = buf;
265 265
266 /* Switch temporarily to the buffer that was changed. */ 266 /* Switch temporarily to the buffer that was changed. */
@@ -519,5 +519,5 @@ so it must make sure not to do a lot of consing. */);
519 519
520 DEFVAR_BOOL ("undo-inhibit-record-point", undo_inhibit_record_point, 520 DEFVAR_BOOL ("undo-inhibit-record-point", undo_inhibit_record_point,
521 doc: /* Non-nil means do not record `point' in `buffer-undo-list'. */); 521 doc: /* Non-nil means do not record `point' in `buffer-undo-list'. */);
522 undo_inhibit_record_point = 0; 522 undo_inhibit_record_point = false;
523} 523}
diff --git a/src/w32.c b/src/w32.c
index 6f16704909c..8721ed919fc 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -9473,6 +9473,26 @@ serial_configure (struct Lisp_Process *p, Lisp_Object contact)
9473 pset_childp (p, childp2); 9473 pset_childp (p, childp2);
9474} 9474}
9475 9475
9476/* For make-pipe-process */
9477void
9478register_aux_fd (int infd)
9479{
9480 child_process *cp;
9481
9482 cp = new_child ();
9483 if (!cp)
9484 error ("Could not create child process");
9485 cp->fd = infd;
9486 cp->status = STATUS_READ_ACKNOWLEDGED;
9487
9488 if (fd_info[ infd ].cp != NULL)
9489 {
9490 error ("fd_info[fd = %d] is already in use", infd);
9491 }
9492 fd_info[ infd ].cp = cp;
9493 fd_info[ infd ].hnd = (HANDLE) _get_osfhandle (infd);
9494}
9495
9476#ifdef HAVE_GNUTLS 9496#ifdef HAVE_GNUTLS
9477 9497
9478ssize_t 9498ssize_t
diff --git a/src/w32.h b/src/w32.h
index 9b3521d077f..e62b93c8e2b 100644
--- a/src/w32.h
+++ b/src/w32.h
@@ -202,6 +202,7 @@ extern int random (void);
202extern int fchmod (int, mode_t); 202extern int fchmod (int, mode_t);
203extern int sys_rename_replace (char const *, char const *, BOOL); 203extern int sys_rename_replace (char const *, char const *, BOOL);
204extern int pipe2 (int *, int); 204extern int pipe2 (int *, int);
205extern void register_aux_fd (int);
205 206
206extern void set_process_dir (char *); 207extern void set_process_dir (char *);
207extern int sys_spawnve (int, char *, char **, char **); 208extern int sys_spawnve (int, char *, char **, char **);
diff --git a/src/w32fns.c b/src/w32fns.c
index 6abb433fd2f..b9d7bd4d75b 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -29,6 +29,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
29#include <fcntl.h> 29#include <fcntl.h>
30#include <unistd.h> 30#include <unistd.h>
31 31
32#include <c-ctype.h>
33
32#include "lisp.h" 34#include "lisp.h"
33#include "w32term.h" 35#include "w32term.h"
34#include "frame.h" 36#include "frame.h"
@@ -7038,7 +7040,28 @@ a ShowWindow flag:
7038 7040
7039#else /* !CYGWIN */ 7041#else /* !CYGWIN */
7040 7042
7041 current_dir = ENCODE_FILE (current_dir); 7043 const char file_url_str[] = "file:///";
7044 const int file_url_len = sizeof (file_url_str) - 1;
7045 if (strncmp (SSDATA (document), file_url_str, file_url_len) == 0)
7046 {
7047 /* Passing "file:///" URLs to ShellExecute causes shlwapi.dll to
7048 start a thread in some rare system configurations, for
7049 unknown reasons. That thread is started in the context of
7050 the Emacs process, but out of control of our code, and seems
7051 to never exit afterwards. Each such thread reserves 8MB of
7052 stack space (because that's the value recorded in the Emacs
7053 executable at link time: Emacs needs a large stack). So a
7054 large enough number of invocations of w32-shell-execute can
7055 potentially cause the Emacs process to run out of available
7056 address space, which is nasty. To work around this, we
7057 convert such URLs to local file names, which seems to prevent
7058 those threads from starting. See bug #20220. */
7059 char *p = SSDATA (document) + file_url_len;
7060
7061 if (c_isalpha (*p) && p[1] == ':' && IS_DIRECTORY_SEP (p[2]))
7062 document = Fsubstring_no_properties (document,
7063 make_number (file_url_len), Qnil);
7064 }
7042 /* We have a situation here. If DOCUMENT is a relative file name, 7065 /* We have a situation here. If DOCUMENT is a relative file name,
7043 but its name includes leading directories, i.e. it lives not in 7066 but its name includes leading directories, i.e. it lives not in
7044 CURRENT_DIR, but in its subdirectory, then ShellExecute below 7067 CURRENT_DIR, but in its subdirectory, then ShellExecute below
@@ -7071,6 +7094,8 @@ a ShowWindow flag:
7071 else 7094 else
7072 document = ENCODE_FILE (document); 7095 document = ENCODE_FILE (document);
7073 UNGCPRO; 7096 UNGCPRO;
7097
7098 current_dir = ENCODE_FILE (current_dir);
7074 if (use_unicode) 7099 if (use_unicode)
7075 { 7100 {
7076 wchar_t document_w[MAX_PATH], current_dir_w[MAX_PATH]; 7101 wchar_t document_w[MAX_PATH], current_dir_w[MAX_PATH];
diff --git a/src/w32proc.c b/src/w32proc.c
index 7d982f831e2..1f633d834c2 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -806,7 +806,7 @@ alarm (int seconds)
806 etc. 806 etc.
807 807
808 Both these arrays reference each other: there's a member of 808 Both these arrays reference each other: there's a member of
809 child_process structure that records the file corresponding 809 child_process structure that records the corresponding file
810 descriptor, and there's a member of filedesc structure that holds a 810 descriptor, and there's a member of filedesc structure that holds a
811 pointer to the corresponding child_process. 811 pointer to the corresponding child_process.
812 812
@@ -817,13 +817,13 @@ alarm (int seconds)
817 thread" that will watch the output of the subprocess/stream and its 817 thread" that will watch the output of the subprocess/stream and its
818 status. (If no vacant slot can be found, new_child returns a 818 status. (If no vacant slot can be found, new_child returns a
819 failure indication to its caller, and the higher-level Emacs 819 failure indication to its caller, and the higher-level Emacs
820 primitive will then fail with EMFILE or EAGAIN.) 820 primitive that called it will then fail with EMFILE or EAGAIN.)
821 821
822 The reader thread started by new_child communicates with the main 822 The reader thread started by new_child communicates with the main
823 (a.k.a. "Lisp") thread via two event objects and a status, all of 823 (a.k.a. "Lisp") thread via two event objects and a status, all of
824 them recorded by the members of the child_process structure in 824 them recorded by the members of the child_process structure in
825 child_procs[]. The event objects serve as semaphores between the 825 child_procs[]. The event objects serve as semaphores between the
826 reader thread and the 'select' emulation in sys_select, as follows: 826 reader thread and the 'pselect' emulation in sys_select, as follows:
827 827
828 . Initially, the reader thread is waiting for the char_consumed 828 . Initially, the reader thread is waiting for the char_consumed
829 event to become signaled by sys_select, which is an indication 829 event to become signaled by sys_select, which is an indication
@@ -841,8 +841,8 @@ alarm (int seconds)
841 841
842 When the subprocess exits or the network/serial stream is closed, 842 When the subprocess exits or the network/serial stream is closed,
843 the reader thread sets the status accordingly and exits. It also 843 the reader thread sets the status accordingly and exits. It also
844 exits when the main thread sets the ststus to STATUS_READ_ERROR 844 exits when the main thread sets the status to STATUS_READ_ERROR
845 and/or the char_avail and char_consumed event handles are NULL; 845 and/or the char_avail and char_consumed event handles become NULL;
846 this is how delete_child, called by Emacs when a subprocess or a 846 this is how delete_child, called by Emacs when a subprocess or a
847 stream is terminated, terminates the reader thread as part of 847 stream is terminated, terminates the reader thread as part of
848 deleting the child_process object. 848 deleting the child_process object.
@@ -863,8 +863,8 @@ alarm (int seconds)
863 863
864 If file descriptor zero (stdin) doesn't have its bit set in the 864 If file descriptor zero (stdin) doesn't have its bit set in the
865 'rfds' argument to sys_select, the function always watches for 865 'rfds' argument to sys_select, the function always watches for
866 keyboard interrupts, to be able to return when the user presses 866 keyboard interrupts, to be able to interrupt the wait and return
867 C-g. 867 when the user presses C-g.
868 868
869 Having collected the handles to watch, sys_select calls 869 Having collected the handles to watch, sys_select calls
870 WaitForMultipleObjects to wait for any one of them to become 870 WaitForMultipleObjects to wait for any one of them to become
@@ -1613,24 +1613,25 @@ w32_executable_type (char * filename,
1613#endif 1613#endif
1614 if (data_dir) 1614 if (data_dir)
1615 { 1615 {
1616 /* Look for cygwin.dll in DLL import list. */ 1616 /* Look for Cygwin DLL in the DLL import list. */
1617 IMAGE_DATA_DIRECTORY import_dir = 1617 IMAGE_DATA_DIRECTORY import_dir =
1618 data_dir[IMAGE_DIRECTORY_ENTRY_IMPORT]; 1618 data_dir[IMAGE_DIRECTORY_ENTRY_IMPORT];
1619 IMAGE_IMPORT_DESCRIPTOR * imports; 1619 IMAGE_IMPORT_DESCRIPTOR * imports =
1620 IMAGE_SECTION_HEADER * section; 1620 RVA_TO_PTR (import_dir.VirtualAddress,
1621 1621 rva_to_section (import_dir.VirtualAddress,
1622 section = rva_to_section (import_dir.VirtualAddress, nt_header); 1622 nt_header),
1623 imports = RVA_TO_PTR (import_dir.VirtualAddress, section, 1623 executable);
1624 executable);
1625 1624
1626 for ( ; imports->Name; imports++) 1625 for ( ; imports->Name; imports++)
1627 { 1626 {
1627 IMAGE_SECTION_HEADER * section =
1628 rva_to_section (imports->Name, nt_header);
1628 char * dllname = RVA_TO_PTR (imports->Name, section, 1629 char * dllname = RVA_TO_PTR (imports->Name, section,
1629 executable); 1630 executable);
1630 1631
1631 /* The exact name of the cygwin dll has changed with 1632 /* The exact name of the Cygwin DLL has changed with
1632 various releases, but hopefully this will be reasonably 1633 various releases, but hopefully this will be
1633 future proof. */ 1634 reasonably future-proof. */
1634 if (strncmp (dllname, "cygwin", 6) == 0) 1635 if (strncmp (dllname, "cygwin", 6) == 0)
1635 { 1636 {
1636 *is_cygnus_app = TRUE; 1637 *is_cygnus_app = TRUE;
diff --git a/src/widget.c b/src/widget.c
index acf559f313b..0986ba61dbf 100644
--- a/src/widget.c
+++ b/src/widget.c
@@ -61,10 +61,7 @@ static void EmacsFrameResize (Widget widget);
61static XtGeometryResult EmacsFrameQueryGeometry (Widget widget, XtWidgetGeometry *request, XtWidgetGeometry *result); 61static XtGeometryResult EmacsFrameQueryGeometry (Widget widget, XtWidgetGeometry *request, XtWidgetGeometry *result);
62 62
63 63
64#undef XtOffset 64#define offset(field) offsetof (EmacsFrameRec, emacs_frame.field)
65#define XtOffset(p_type,field) \
66 ((Cardinal) (((char *) (&(((p_type)0)->field))) - ((char *)0)))
67#define offset(field) XtOffset (EmacsFrame, emacs_frame.field)
68 65
69static XtResource resources[] = { 66static XtResource resources[] = {
70 {XtNgeometry, XtCGeometry, XtRString, sizeof (String), 67 {XtNgeometry, XtCGeometry, XtRString, sizeof (String),
@@ -271,8 +268,8 @@ set_frame_size (EmacsFrame ew)
271 */ 268 */
272 269
273 /* Hairily merged geometry */ 270 /* Hairily merged geometry */
274 unsigned int w = FRAME_COLS (ew->emacs_frame.frame); 271 int w = FRAME_COLS (ew->emacs_frame.frame);
275 unsigned int h = FRAME_LINES (ew->emacs_frame.frame); 272 int h = FRAME_LINES (ew->emacs_frame.frame);
276 273
277 Widget wmshell = get_wm_shell ((Widget) ew); 274 Widget wmshell = get_wm_shell ((Widget) ew);
278 /* Each Emacs shell is now independent and top-level. */ 275 /* Each Emacs shell is now independent and top-level. */
@@ -437,7 +434,7 @@ set_frame_size (EmacsFrame ew)
437static void 434static void
438update_wm_hints (EmacsFrame ew) 435update_wm_hints (EmacsFrame ew)
439{ 436{
440 Widget wmshell = get_wm_shell ((Widget)ew); 437 Widget wmshell = get_wm_shell ((Widget) ew);
441 int cw; 438 int cw;
442 int ch; 439 int ch;
443 Dimension rounded_width; 440 Dimension rounded_width;
@@ -480,7 +477,7 @@ update_wm_hints (EmacsFrame ew)
480void 477void
481widget_update_wm_size_hints (Widget widget) 478widget_update_wm_size_hints (Widget widget)
482{ 479{
483 EmacsFrame ew = (EmacsFrame)widget; 480 EmacsFrame ew = (EmacsFrame) widget;
484 update_wm_hints (ew); 481 update_wm_hints (ew);
485} 482}
486 483
@@ -519,7 +516,7 @@ update_from_various_frame_slots (EmacsFrame ew)
519static void 516static void
520EmacsFrameInitialize (Widget request, Widget new, ArgList dum1, Cardinal *dum2) 517EmacsFrameInitialize (Widget request, Widget new, ArgList dum1, Cardinal *dum2)
521{ 518{
522 EmacsFrame ew = (EmacsFrame)new; 519 EmacsFrame ew = (EmacsFrame) new;
523 520
524 if (!ew->emacs_frame.frame) 521 if (!ew->emacs_frame.frame)
525 { 522 {
@@ -545,7 +542,7 @@ resize_cb (Widget widget,
545static void 542static void
546EmacsFrameRealize (Widget widget, XtValueMask *mask, XSetWindowAttributes *attrs) 543EmacsFrameRealize (Widget widget, XtValueMask *mask, XSetWindowAttributes *attrs)
547{ 544{
548 EmacsFrame ew = (EmacsFrame)widget; 545 EmacsFrame ew = (EmacsFrame) widget;
549 546
550 /* This used to contain SubstructureRedirectMask, but this turns out 547 /* This used to contain SubstructureRedirectMask, but this turns out
551 to be a problem with XIM on Solaris, and events from that mask 548 to be a problem with XIM on Solaris, and events from that mask
@@ -554,7 +551,7 @@ EmacsFrameRealize (Widget widget, XtValueMask *mask, XSetWindowAttributes *attrs
554 | PropertyChangeMask 551 | PropertyChangeMask
555 | SubstructureNotifyMask); 552 | SubstructureNotifyMask);
556 *mask |= CWEventMask; 553 *mask |= CWEventMask;
557 XtCreateWindow (widget, InputOutput, (Visual *)CopyFromParent, *mask, 554 XtCreateWindow (widget, InputOutput, (Visual *) CopyFromParent, *mask,
558 attrs); 555 attrs);
559 /* Some ConfigureNotify events does not end up in EmacsFrameResize so 556 /* Some ConfigureNotify events does not end up in EmacsFrameResize so
560 make sure we get them all. Seen with xfcwm4 for example. */ 557 make sure we get them all. Seen with xfcwm4 for example. */
@@ -571,7 +568,7 @@ EmacsFrameDestroy (Widget widget)
571static void 568static void
572EmacsFrameResize (Widget widget) 569EmacsFrameResize (Widget widget)
573{ 570{
574 EmacsFrame ew = (EmacsFrame)widget; 571 EmacsFrame ew = (EmacsFrame) widget;
575 struct frame *f = ew->emacs_frame.frame; 572 struct frame *f = ew->emacs_frame.frame;
576 int width, height; 573 int width, height;
577 574
@@ -592,7 +589,7 @@ EmacsFrameResize (Widget widget)
592static XtGeometryResult 589static XtGeometryResult
593EmacsFrameQueryGeometry (Widget widget, XtWidgetGeometry *request, XtWidgetGeometry *result) 590EmacsFrameQueryGeometry (Widget widget, XtWidgetGeometry *request, XtWidgetGeometry *result)
594{ 591{
595 EmacsFrame ew = (EmacsFrame)widget; 592 EmacsFrame ew = (EmacsFrame) widget;
596 593
597 int mask = request->request_mode; 594 int mask = request->request_mode;
598 Dimension ok_width, ok_height; 595 Dimension ok_width, ok_height;
diff --git a/src/window.c b/src/window.c
index d59616d0545..0fcf82d43f4 100644
--- a/src/window.c
+++ b/src/window.c
@@ -45,28 +45,19 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
45#include "msdos.h" 45#include "msdos.h"
46#endif 46#endif
47 47
48static int displayed_window_lines (struct window *); 48static ptrdiff_t count_windows (struct window *);
49static int count_windows (struct window *); 49static ptrdiff_t get_leaf_windows (struct window *, struct window **,
50static int get_leaf_windows (struct window *, struct window **, int); 50 ptrdiff_t);
51static void window_scroll (Lisp_Object, EMACS_INT, bool, int); 51static void window_scroll_pixel_based (Lisp_Object, int, bool, bool);
52static void window_scroll_pixel_based (Lisp_Object, int, bool, int); 52static void window_scroll_line_based (Lisp_Object, int, bool, bool);
53static void window_scroll_line_based (Lisp_Object, int, bool, int);
54static int add_window_to_list (struct window *, void *);
55static Lisp_Object next_window (Lisp_Object, Lisp_Object,
56 Lisp_Object, int);
57static void decode_next_window_args (Lisp_Object *, Lisp_Object *,
58 Lisp_Object *);
59static void foreach_window (struct frame *, 53static void foreach_window (struct frame *,
60 int (* fn) (struct window *, void *), 54 bool (* fn) (struct window *, void *),
61 void *); 55 void *);
62static int foreach_window_1 (struct window *, 56static bool foreach_window_1 (struct window *,
63 int (* fn) (struct window *, void *), 57 bool (* fn) (struct window *, void *),
64 void *); 58 void *);
65static Lisp_Object window_list_1 (Lisp_Object, Lisp_Object, Lisp_Object); 59static bool window_resize_check (struct window *, bool);
66static int window_resize_check (struct window *, bool);
67static void window_resize_apply (struct window *, bool); 60static void window_resize_apply (struct window *, bool);
68static void window_resize_apply_total (struct window *, bool);
69static Lisp_Object select_window (Lisp_Object, Lisp_Object, int);
70static void select_window_1 (Lisp_Object, bool); 61static void select_window_1 (Lisp_Object, bool);
71 62
72static struct window *set_window_fringes (struct window *, Lisp_Object, 63static struct window *set_window_fringes (struct window *, Lisp_Object,
@@ -74,7 +65,8 @@ static struct window *set_window_fringes (struct window *, Lisp_Object,
74static struct window *set_window_margins (struct window *, Lisp_Object, 65static struct window *set_window_margins (struct window *, Lisp_Object,
75 Lisp_Object); 66 Lisp_Object);
76static struct window *set_window_scroll_bars (struct window *, Lisp_Object, 67static struct window *set_window_scroll_bars (struct window *, Lisp_Object,
77 Lisp_Object, Lisp_Object, Lisp_Object); 68 Lisp_Object, Lisp_Object,
69 Lisp_Object);
78static void apply_window_adjustment (struct window *); 70static void apply_window_adjustment (struct window *);
79 71
80/* This is the window in which the terminal's cursor should 72/* This is the window in which the terminal's cursor should
@@ -102,7 +94,7 @@ Lisp_Object minibuf_window;
102Lisp_Object minibuf_selected_window; 94Lisp_Object minibuf_selected_window;
103 95
104/* Incremented for each window created. */ 96/* Incremented for each window created. */
105static int sequence_number; 97static EMACS_INT sequence_number;
106 98
107/* Used by the function window_scroll_pixel_based. */ 99/* Used by the function window_scroll_pixel_based. */
108static int window_scroll_pixel_based_preserve_x; 100static int window_scroll_pixel_based_preserve_x;
@@ -216,7 +208,7 @@ wset_combination (struct window *w, bool horflag, Lisp_Object val)
216 w->horizontal = horflag; 208 w->horizontal = horflag;
217} 209}
218 210
219/* Nonzero if leaf window W doesn't reflect the actual state 211/* True if leaf window W doesn't reflect the actual state
220 of displayed buffer due to its text or overlays change. */ 212 of displayed buffer due to its text or overlays change. */
221 213
222bool 214bool
@@ -279,7 +271,7 @@ adjust_window_count (struct window *w, int arg)
279 b->window_count += arg; 271 b->window_count += arg;
280 eassert (b->window_count >= 0); 272 eassert (b->window_count >= 0);
281 /* These should be recalculated by redisplay code. */ 273 /* These should be recalculated by redisplay code. */
282 w->window_end_valid = 0; 274 w->window_end_valid = false;
283 w->base_line_pos = 0; 275 w->base_line_pos = 0;
284 } 276 }
285} 277}
@@ -460,17 +452,18 @@ selected windows appears and to which many commands apply. */)
460 return selected_window; 452 return selected_window;
461} 453}
462 454
463int window_select_count; 455EMACS_INT window_select_count;
464 456
465/* If select_window is called with inhibit_point_swap non-zero it will 457/* If select_window is called with inhibit_point_swap true it will
466 not store point of the old selected window's buffer back into that 458 not store point of the old selected window's buffer back into that
467 window's pointm slot. This is needed by Fset_window_configuration to 459 window's pointm slot. This is needed by Fset_window_configuration to
468 avoid that the display routine is called with selected_window set to 460 avoid that the display routine is called with selected_window set to
469 Qnil causing a subsequent crash. */ 461 Qnil causing a subsequent crash. */
470static Lisp_Object 462static Lisp_Object
471select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap) 463select_window (Lisp_Object window, Lisp_Object norecord,
464 bool inhibit_point_swap)
472{ 465{
473 register struct window *w; 466 struct window *w;
474 struct frame *sf; 467 struct frame *sf;
475 468
476 CHECK_LIVE_WINDOW (window); 469 CHECK_LIVE_WINDOW (window);
@@ -577,9 +570,9 @@ time a window gets selected put it on `buffer-list-update-hook'.
577 570
578Also note that the main editor command loop sets the current buffer to 571Also note that the main editor command loop sets the current buffer to
579the buffer of the selected window before each command. */) 572the buffer of the selected window before each command. */)
580 (register Lisp_Object window, Lisp_Object norecord) 573 (Lisp_Object window, Lisp_Object norecord)
581{ 574{
582 return select_window (window, norecord, 0); 575 return select_window (window, norecord, false);
583} 576}
584 577
585DEFUN ("window-buffer", Fwindow_buffer, Swindow_buffer, 0, 1, 0, 578DEFUN ("window-buffer", Fwindow_buffer, Swindow_buffer, 0, 1, 0,
@@ -930,11 +923,10 @@ window_body_width (struct window *w, bool pixelwise)
930 - WINDOW_RIGHT_DIVIDER_WIDTH (w) 923 - WINDOW_RIGHT_DIVIDER_WIDTH (w)
931 - (WINDOW_HAS_VERTICAL_SCROLL_BAR (w) 924 - (WINDOW_HAS_VERTICAL_SCROLL_BAR (w)
932 ? WINDOW_SCROLL_BAR_AREA_WIDTH (w) 925 ? WINDOW_SCROLL_BAR_AREA_WIDTH (w)
933 : ((!FRAME_WINDOW_P (f) 926 : (/* A vertical bar is either 1 or 0. */
934 && !WINDOW_RIGHTMOST_P (w) 927 !FRAME_WINDOW_P (f)
935 && !WINDOW_RIGHT_DIVIDER_WIDTH (w)) 928 && !WINDOW_RIGHTMOST_P (w)
936 /* A vertical bar is either 1 or 0. */ 929 && !WINDOW_RIGHT_DIVIDER_WIDTH (w)))
937 ? 1 : 0))
938 - WINDOW_MARGINS_WIDTH (w) 930 - WINDOW_MARGINS_WIDTH (w)
939 - (FRAME_WINDOW_P (f) 931 - (FRAME_WINDOW_P (f)
940 ? WINDOW_FRINGES_WIDTH (w) 932 ? WINDOW_FRINGES_WIDTH (w)
@@ -961,7 +953,7 @@ visible, that line is not counted. */)
961 (Lisp_Object window, Lisp_Object pixelwise) 953 (Lisp_Object window, Lisp_Object pixelwise)
962{ 954{
963 return make_number (window_body_height (decode_live_window (window), 955 return make_number (window_body_height (decode_live_window (window),
964 NILP (pixelwise) ? 0 : 1)); 956 !NILP (pixelwise)));
965} 957}
966 958
967DEFUN ("window-body-width", Fwindow_body_width, Swindow_body_width, 0, 2, 0, 959DEFUN ("window-body-width", Fwindow_body_width, Swindow_body_width, 0, 2, 0,
@@ -981,7 +973,7 @@ continuation glyph. */)
981 (Lisp_Object window, Lisp_Object pixelwise) 973 (Lisp_Object window, Lisp_Object pixelwise)
982{ 974{
983 return make_number (window_body_width (decode_live_window (window), 975 return make_number (window_body_width (decode_live_window (window),
984 NILP (pixelwise) ? 0 : 1)); 976 !NILP (pixelwise)));
985} 977}
986 978
987DEFUN ("window-mode-line-height", Fwindow_mode_line_height, 979DEFUN ("window-mode-line-height", Fwindow_mode_line_height,
@@ -1062,10 +1054,10 @@ set_window_hscroll (struct window *w, EMACS_INT hscroll)
1062 1054
1063 /* Prevent redisplay shortcuts when changing the hscroll. */ 1055 /* Prevent redisplay shortcuts when changing the hscroll. */
1064 if (w->hscroll != new_hscroll) 1056 if (w->hscroll != new_hscroll)
1065 XBUFFER (w->contents)->prevent_redisplay_optimizations_p = 1; 1057 XBUFFER (w->contents)->prevent_redisplay_optimizations_p = true;
1066 1058
1067 w->hscroll = new_hscroll; 1059 w->hscroll = new_hscroll;
1068 w->suspend_auto_hscroll = 1; 1060 w->suspend_auto_hscroll = true;
1069 1061
1070 return make_number (new_hscroll); 1062 return make_number (new_hscroll);
1071} 1063}
@@ -1583,7 +1575,7 @@ If they are in the windows's left or right marginal areas, `left-margin'\n\
1583 Check if window W contains coordinates *CW->x and *CW->y. If it 1575 Check if window W contains coordinates *CW->x and *CW->y. If it
1584 does, return W in *CW->window, as Lisp_Object, and return in 1576 does, return W in *CW->window, as Lisp_Object, and return in
1585 *CW->part the part of the window under coordinates *X,*Y. Return 1577 *CW->part the part of the window under coordinates *X,*Y. Return
1586 zero from this function to stop iterating over windows. */ 1578 false from this function to stop iterating over windows. */
1587 1579
1588struct check_window_data 1580struct check_window_data
1589{ 1581{
@@ -1592,22 +1584,19 @@ struct check_window_data
1592 enum window_part *part; 1584 enum window_part *part;
1593}; 1585};
1594 1586
1595static int 1587static bool
1596check_window_containing (struct window *w, void *user_data) 1588check_window_containing (struct window *w, void *user_data)
1597{ 1589{
1598 struct check_window_data *cw = user_data; 1590 struct check_window_data *cw = user_data;
1599 enum window_part found; 1591 enum window_part found = coordinates_in_window (w, cw->x, cw->y);
1600 int continue_p = 1; 1592 if (found == ON_NOTHING)
1601 1593 return true;
1602 found = coordinates_in_window (w, cw->x, cw->y); 1594 else
1603 if (found != ON_NOTHING)
1604 { 1595 {
1605 *cw->part = found; 1596 *cw->part = found;
1606 XSETWINDOW (*cw->window, w); 1597 XSETWINDOW (*cw->window, w);
1607 continue_p = 0; 1598 return false;
1608 } 1599 }
1609
1610 return continue_p;
1611} 1600}
1612 1601
1613 1602
@@ -1618,7 +1607,7 @@ check_window_containing (struct window *w, void *user_data)
1618 set *PART to the id of that element. 1607 set *PART to the id of that element.
1619 1608
1620 If there is no window under X, Y return nil and leave *PART 1609 If there is no window under X, Y return nil and leave *PART
1621 unmodified. TOOL_BAR_P non-zero means detect tool-bar windows. 1610 unmodified. TOOL_BAR_P means detect tool-bar windows.
1622 1611
1623 This function was previously implemented with a loop cycling over 1612 This function was previously implemented with a loop cycling over
1624 windows with Fnext_window, and starting with the frame's selected 1613 windows with Fnext_window, and starting with the frame's selected
@@ -1680,7 +1669,7 @@ column 0. */)
1680 + FRAME_INTERNAL_BORDER_WIDTH (f)), 1669 + FRAME_INTERNAL_BORDER_WIDTH (f)),
1681 (FRAME_PIXEL_Y_FROM_CANON_Y (f, y) 1670 (FRAME_PIXEL_Y_FROM_CANON_Y (f, y)
1682 + FRAME_INTERNAL_BORDER_WIDTH (f)), 1671 + FRAME_INTERNAL_BORDER_WIDTH (f)),
1683 0, 0); 1672 0, false);
1684} 1673}
1685 1674
1686DEFUN ("window-point", Fwindow_point, Swindow_point, 0, 1, 0, 1675DEFUN ("window-point", Fwindow_point, Swindow_point, 0, 1, 0,
@@ -1787,7 +1776,7 @@ if it isn't already recorded. */)
1787 if (it.current_y < it.last_visible_y) 1776 if (it.current_y < it.last_visible_y)
1788 move_it_past_eol (&it); 1777 move_it_past_eol (&it);
1789 value = make_number (IT_CHARPOS (it)); 1778 value = make_number (IT_CHARPOS (it));
1790 bidi_unshelve_cache (itdata, 0); 1779 bidi_unshelve_cache (itdata, false);
1791 1780
1792 if (old_buffer) 1781 if (old_buffer)
1793 set_buffer_internal (old_buffer); 1782 set_buffer_internal (old_buffer);
@@ -1845,12 +1834,12 @@ overriding motion of point in order to display at this exact start. */)
1845 1834
1846 set_marker_restricted (w->start, pos, w->contents); 1835 set_marker_restricted (w->start, pos, w->contents);
1847 /* This is not right, but much easier than doing what is right. */ 1836 /* This is not right, but much easier than doing what is right. */
1848 w->start_at_line_beg = 0; 1837 w->start_at_line_beg = false;
1849 if (NILP (noforce)) 1838 if (NILP (noforce))
1850 w->force_start = 1; 1839 w->force_start = true;
1851 w->update_mode_line = 1; 1840 w->update_mode_line = true;
1852 /* Bug#15957. */ 1841 /* Bug#15957. */
1853 w->window_end_valid = 0; 1842 w->window_end_valid = false;
1854 wset_redisplay (w); 1843 wset_redisplay (w);
1855 1844
1856 return pos; 1845 return pos;
@@ -1878,12 +1867,13 @@ POS, ROWH is the visible height of that row, and VPOS is the row number
1878\(zero-based). */) 1867\(zero-based). */)
1879 (Lisp_Object pos, Lisp_Object window, Lisp_Object partially) 1868 (Lisp_Object pos, Lisp_Object window, Lisp_Object partially)
1880{ 1869{
1881 register struct window *w; 1870 struct window *w;
1882 register EMACS_INT posint; 1871 EMACS_INT posint;
1883 register struct buffer *buf; 1872 struct buffer *buf;
1884 struct text_pos top; 1873 struct text_pos top;
1885 Lisp_Object in_window = Qnil; 1874 Lisp_Object in_window = Qnil;
1886 int rtop, rbot, rowh, vpos, fully_p = 1; 1875 int rtop, rbot, rowh, vpos;
1876 bool fully_p = true;
1887 int x, y; 1877 int x, y;
1888 1878
1889 w = decode_live_window (window); 1879 w = decode_live_window (window);
@@ -1908,9 +1898,12 @@ POS, ROWH is the visible height of that row, and VPOS is the row number
1908 || (posint >= CHARPOS (top) && posint <= BUF_ZV (buf))) 1898 || (posint >= CHARPOS (top) && posint <= BUF_ZV (buf)))
1909 && CHARPOS (top) >= BUF_BEGV (buf) 1899 && CHARPOS (top) >= BUF_BEGV (buf)
1910 && CHARPOS (top) <= BUF_ZV (buf) 1900 && CHARPOS (top) <= BUF_ZV (buf)
1911 && pos_visible_p (w, posint, &x, &y, &rtop, &rbot, &rowh, &vpos) 1901 && pos_visible_p (w, posint, &x, &y, &rtop, &rbot, &rowh, &vpos))
1912 && (fully_p = !rtop && !rbot, (!NILP (partially) || fully_p))) 1902 {
1913 in_window = Qt; 1903 fully_p = !rtop && !rbot;
1904 if (!NILP (partially) || fully_p)
1905 in_window = Qt;
1906 }
1914 1907
1915 if (!NILP (in_window) && !NILP (partially)) 1908 if (!NILP (in_window) && !NILP (partially))
1916 { 1909 {
@@ -2215,7 +2208,7 @@ unshow_buffer (register struct window *w)
2215 2208
2216 eassert (b == XMARKER (w->pointm)->buffer); 2209 eassert (b == XMARKER (w->pointm)->buffer);
2217 2210
2218#if 0 2211#if false
2219 if (w == XWINDOW (selected_window) 2212 if (w == XWINDOW (selected_window)
2220 || ! EQ (buf, XWINDOW (selected_window)->contents)) 2213 || ! EQ (buf, XWINDOW (selected_window)->contents))
2221 /* Do this except when the selected window's buffer 2214 /* Do this except when the selected window's buffer
@@ -2254,14 +2247,14 @@ unshow_buffer (register struct window *w)
2254 bset_last_selected_window (b, Qnil); 2247 bset_last_selected_window (b, Qnil);
2255} 2248}
2256 2249
2257/* Put NEW into the window structure in place of OLD. SETFLAG zero 2250/* Put NEW into the window structure in place of OLD. SETFLAG false
2258 means change window structure only. Otherwise store geometry and 2251 means change window structure only. Otherwise store geometry and
2259 other settings as well. */ 2252 other settings as well. */
2260static void 2253static void
2261replace_window (Lisp_Object old, Lisp_Object new, int setflag) 2254replace_window (Lisp_Object old, Lisp_Object new, bool setflag)
2262{ 2255{
2263 register Lisp_Object tem; 2256 Lisp_Object tem;
2264 register struct window *o = XWINDOW (old), *n = XWINDOW (new); 2257 struct window *o = XWINDOW (old), *n = XWINDOW (new);
2265 2258
2266 /* If OLD is its frame's root window, then NEW is the new 2259 /* If OLD is its frame's root window, then NEW is the new
2267 root window for that frame. */ 2260 root window for that frame. */
@@ -2291,11 +2284,11 @@ replace_window (Lisp_Object old, Lisp_Object new, int setflag)
2291 n->phys_cursor_type = NO_CURSOR; 2284 n->phys_cursor_type = NO_CURSOR;
2292 n->phys_cursor_width = -1; 2285 n->phys_cursor_width = -1;
2293#endif 2286#endif
2294 n->must_be_updated_p = 0; 2287 n->must_be_updated_p = false;
2295 n->pseudo_window_p = 0; 2288 n->pseudo_window_p = false;
2296 n->window_end_vpos = 0; 2289 n->window_end_vpos = 0;
2297 n->window_end_pos = 0; 2290 n->window_end_pos = 0;
2298 n->window_end_valid = 0; 2291 n->window_end_valid = false;
2299 } 2292 }
2300 2293
2301 tem = o->next; 2294 tem = o->next;
@@ -2380,7 +2373,7 @@ recombine_windows (Lisp_Object window)
2380 } 2373 }
2381 2374
2382 /* WINDOW can be deleted now. */ 2375 /* WINDOW can be deleted now. */
2383 wset_combination (w, 0, Qnil); 2376 wset_combination (w, false, Qnil);
2384 } 2377 }
2385 } 2378 }
2386} 2379}
@@ -2401,14 +2394,14 @@ delete_deletable_window (Lisp_Object window)
2401 pointer. This is a callback function for foreach_window, used in 2394 pointer. This is a callback function for foreach_window, used in
2402 the window_list function. */ 2395 the window_list function. */
2403 2396
2404static int 2397static bool
2405add_window_to_list (struct window *w, void *user_data) 2398add_window_to_list (struct window *w, void *user_data)
2406{ 2399{
2407 Lisp_Object *list = user_data; 2400 Lisp_Object *list = user_data;
2408 Lisp_Object window; 2401 Lisp_Object window;
2409 XSETWINDOW (window, w); 2402 XSETWINDOW (window, w);
2410 *list = Fcons (window, *list); 2403 *list = Fcons (window, *list);
2411 return 1; 2404 return true;
2412} 2405}
2413 2406
2414 2407
@@ -2441,7 +2434,7 @@ window_list (void)
2441} 2434}
2442 2435
2443 2436
2444/* Value is non-zero if WINDOW satisfies the constraints given by 2437/* Value is true if WINDOW satisfies the constraints given by
2445 OWINDOW, MINIBUF and ALL_FRAMES. 2438 OWINDOW, MINIBUF and ALL_FRAMES.
2446 2439
2447 MINIBUF t means WINDOW may be minibuffer windows. 2440 MINIBUF t means WINDOW may be minibuffer windows.
@@ -2463,20 +2456,20 @@ candidate_window_p (Lisp_Object window, Lisp_Object owindow,
2463{ 2456{
2464 struct window *w = XWINDOW (window); 2457 struct window *w = XWINDOW (window);
2465 struct frame *f = XFRAME (w->frame); 2458 struct frame *f = XFRAME (w->frame);
2466 bool candidate_p = 1; 2459 bool candidate_p = true;
2467 2460
2468 if (!BUFFERP (w->contents)) 2461 if (!BUFFERP (w->contents))
2469 candidate_p = 0; 2462 candidate_p = false;
2470 else if (MINI_WINDOW_P (w) 2463 else if (MINI_WINDOW_P (w)
2471 && (EQ (minibuf, Qlambda) 2464 && (EQ (minibuf, Qlambda)
2472 || (WINDOWP (minibuf) && !EQ (minibuf, window)))) 2465 || (WINDOWP (minibuf) && !EQ (minibuf, window))))
2473 { 2466 {
2474 /* If MINIBUF is `lambda' don't consider any mini-windows. 2467 /* If MINIBUF is `lambda' don't consider any mini-windows.
2475 If it is a window, consider only that one. */ 2468 If it is a window, consider only that one. */
2476 candidate_p = 0; 2469 candidate_p = false;
2477 } 2470 }
2478 else if (EQ (all_frames, Qt)) 2471 else if (EQ (all_frames, Qt))
2479 candidate_p = 1; 2472 candidate_p = true;
2480 else if (NILP (all_frames)) 2473 else if (NILP (all_frames))
2481 { 2474 {
2482 eassert (WINDOWP (owindow)); 2475 eassert (WINDOWP (owindow));
@@ -2556,12 +2549,13 @@ decode_next_window_args (Lisp_Object *window, Lisp_Object *minibuf, Lisp_Object
2556 2549
2557 2550
2558/* Return the next or previous window of WINDOW in cyclic ordering 2551/* Return the next or previous window of WINDOW in cyclic ordering
2559 of windows. NEXT_P non-zero means return the next window. See the 2552 of windows. NEXT_P means return the next window. See the
2560 documentation string of next-window for the meaning of MINIBUF and 2553 documentation string of next-window for the meaning of MINIBUF and
2561 ALL_FRAMES. */ 2554 ALL_FRAMES. */
2562 2555
2563static Lisp_Object 2556static Lisp_Object
2564next_window (Lisp_Object window, Lisp_Object minibuf, Lisp_Object all_frames, int next_p) 2557next_window (Lisp_Object window, Lisp_Object minibuf, Lisp_Object all_frames,
2558 bool next_p)
2565{ 2559{
2566 decode_next_window_args (&window, &minibuf, &all_frames); 2560 decode_next_window_args (&window, &minibuf, &all_frames);
2567 2561
@@ -2659,7 +2653,7 @@ windows, eventually ending up back at the window you started with.
2659`previous-window' traverses the same cycle, in the reverse order. */) 2653`previous-window' traverses the same cycle, in the reverse order. */)
2660 (Lisp_Object window, Lisp_Object minibuf, Lisp_Object all_frames) 2654 (Lisp_Object window, Lisp_Object minibuf, Lisp_Object all_frames)
2661{ 2655{
2662 return next_window (window, minibuf, all_frames, 1); 2656 return next_window (window, minibuf, all_frames, true);
2663} 2657}
2664 2658
2665 2659
@@ -2699,7 +2693,7 @@ started with. `next-window' traverses the same cycle, in the
2699reverse order. */) 2693reverse order. */)
2700 (Lisp_Object window, Lisp_Object minibuf, Lisp_Object all_frames) 2694 (Lisp_Object window, Lisp_Object minibuf, Lisp_Object all_frames)
2701{ 2695{
2702 return next_window (window, minibuf, all_frames, 0); 2696 return next_window (window, minibuf, all_frames, false);
2703} 2697}
2704 2698
2705 2699
@@ -2797,7 +2791,7 @@ be listed first but no error is signaled. */)
2797 Qnil, look at just the selected frame; 2791 Qnil, look at just the selected frame;
2798 Qvisible, look at visible frames; 2792 Qvisible, look at visible frames;
2799 a frame, just look at windows on that frame. 2793 a frame, just look at windows on that frame.
2800 If MINI is non-zero, perform the operation on minibuffer windows too. */ 2794 If MINI, perform the operation on minibuffer windows too. */
2801 2795
2802enum window_loop 2796enum window_loop
2803{ 2797{
@@ -2809,10 +2803,11 @@ enum window_loop
2809}; 2803};
2810 2804
2811static Lisp_Object 2805static Lisp_Object
2812window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frames) 2806window_loop (enum window_loop type, Lisp_Object obj, bool mini,
2807 Lisp_Object frames)
2813{ 2808{
2814 Lisp_Object window, windows, best_window, frame_arg; 2809 Lisp_Object window, windows, best_window, frame_arg;
2815 int frame_best_window_flag = 0; 2810 bool frame_best_window_flag = false;
2816 struct frame *f; 2811 struct frame *f;
2817 struct gcpro gcpro1; 2812 struct gcpro gcpro1;
2818 2813
@@ -2872,7 +2867,7 @@ window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frame
2872 if (EQ (w->contents, obj) 2867 if (EQ (w->contents, obj)
2873 /* Don't find any minibuffer window except the one that 2868 /* Don't find any minibuffer window except the one that
2874 is currently in use. */ 2869 is currently in use. */
2875 && (MINI_WINDOW_P (w) ? EQ (window, minibuf_window) : 1)) 2870 && (!MINI_WINDOW_P (w) || EQ (window, minibuf_window)))
2876 { 2871 {
2877 if (EQ (window, selected_window)) 2872 if (EQ (window, selected_window))
2878 /* Preferably return the selected window. */ 2873 /* Preferably return the selected window. */
@@ -2883,7 +2878,7 @@ window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frame
2883 choose another one if we have one already). */ 2878 choose another one if we have one already). */
2884 { 2879 {
2885 best_window = window; 2880 best_window = window;
2886 frame_best_window_flag = 1; 2881 frame_best_window_flag = true;
2887 } 2882 }
2888 else if (NILP (best_window)) 2883 else if (NILP (best_window))
2889 best_window = window; 2884 best_window = window;
@@ -2900,7 +2895,7 @@ window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frame
2900 /* Make WINDOW show the buffer returned by 2895 /* Make WINDOW show the buffer returned by
2901 other_buffer_safely, don't run any hooks. */ 2896 other_buffer_safely, don't run any hooks. */
2902 set_window_buffer 2897 set_window_buffer
2903 (window, other_buffer_safely (w->contents), 0, 0); 2898 (window, other_buffer_safely (w->contents), false, false);
2904 /* If WINDOW is the selected window, make its buffer 2899 /* If WINDOW is the selected window, make its buffer
2905 current. But do so only if the window shows the 2900 current. But do so only if the window shows the
2906 current buffer (Bug#6454). */ 2901 current buffer (Bug#6454). */
@@ -2913,9 +2908,9 @@ window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frame
2913 case REDISPLAY_BUFFER_WINDOWS: 2908 case REDISPLAY_BUFFER_WINDOWS:
2914 if (EQ (w->contents, obj)) 2909 if (EQ (w->contents, obj))
2915 { 2910 {
2916 mark_window_display_accurate (window, 0); 2911 mark_window_display_accurate (window, false);
2917 w->update_mode_line = 1; 2912 w->update_mode_line = true;
2918 XBUFFER (obj)->prevent_redisplay_optimizations_p = 1; 2913 XBUFFER (obj)->prevent_redisplay_optimizations_p = true;
2919 update_mode_lines = 27; 2914 update_mode_lines = 27;
2920 best_window = window; 2915 best_window = window;
2921 } 2916 }
@@ -2952,7 +2947,7 @@ extern void check_all_windows (void) EXTERNALLY_VISIBLE;
2952void 2947void
2953check_all_windows (void) 2948check_all_windows (void)
2954{ 2949{
2955 window_loop (CHECK_ALL_WINDOWS, Qnil, 1, Qt); 2950 window_loop (CHECK_ALL_WINDOWS, Qnil, true, Qt);
2956} 2951}
2957 2952
2958DEFUN ("get-buffer-window", Fget_buffer_window, Sget_buffer_window, 0, 2, 0, 2953DEFUN ("get-buffer-window", Fget_buffer_window, Sget_buffer_window, 0, 2, 0,
@@ -2983,7 +2978,7 @@ selected frame and no others. */)
2983 buffer = Fget_buffer (buffer_or_name); 2978 buffer = Fget_buffer (buffer_or_name);
2984 2979
2985 if (BUFFERP (buffer)) 2980 if (BUFFERP (buffer))
2986 return window_loop (GET_BUFFER_WINDOW, buffer, 1, all_frames); 2981 return window_loop (GET_BUFFER_WINDOW, buffer, true, all_frames);
2987 else 2982 else
2988 return Qnil; 2983 return Qnil;
2989} 2984}
@@ -3040,7 +3035,7 @@ window-start value is reasonable when this function is called. */)
3040 struct frame *f; 3035 struct frame *f;
3041 Lisp_Object sibling, pwindow, swindow IF_LINT (= Qnil), delta; 3036 Lisp_Object sibling, pwindow, swindow IF_LINT (= Qnil), delta;
3042 ptrdiff_t startpos IF_LINT (= 0), startbyte IF_LINT (= 0); 3037 ptrdiff_t startpos IF_LINT (= 0), startbyte IF_LINT (= 0);
3043 int top IF_LINT (= 0), new_top, resize_failed; 3038 int top IF_LINT (= 0), new_top;
3044 3039
3045 w = decode_valid_window (window); 3040 w = decode_valid_window (window);
3046 XSETWINDOW (window, w); 3041 XSETWINDOW (window, w);
@@ -3097,7 +3092,7 @@ window-start value is reasonable when this function is called. */)
3097 parents and comparing each one with WINDOW. If it isn't we 3092 parents and comparing each one with WINDOW. If it isn't we
3098 need a new selected window for this frame. */ 3093 need a new selected window for this frame. */
3099 swindow = FRAME_SELECTED_WINDOW (f); 3094 swindow = FRAME_SELECTED_WINDOW (f);
3100 while (1) 3095 while (true)
3101 { 3096 {
3102 pwindow = swindow; 3097 pwindow = swindow;
3103 while (!NILP (pwindow) && !EQ (window, pwindow)) 3098 while (!NILP (pwindow) && !EQ (window, pwindow))
@@ -3129,7 +3124,7 @@ window-start value is reasonable when this function is called. */)
3129 /* We are going to free the glyph matrices of WINDOW, and with 3124 /* We are going to free the glyph matrices of WINDOW, and with
3130 that we might lose any information about glyph rows that have 3125 that we might lose any information about glyph rows that have
3131 some of their glyphs highlighted in mouse face. (These rows 3126 some of their glyphs highlighted in mouse face. (These rows
3132 are marked with a non-zero mouse_face_p flag.) If WINDOW 3127 are marked with a mouse_face_p flag.) If WINDOW
3133 indeed has some glyphs highlighted in mouse face, signal to 3128 indeed has some glyphs highlighted in mouse face, signal to
3134 frame's up-to-date hook that mouse highlight was overwritten, 3129 frame's up-to-date hook that mouse highlight was overwritten,
3135 so that it will arrange for redisplaying the highlight. */ 3130 so that it will arrange for redisplaying the highlight. */
@@ -3140,8 +3135,8 @@ window-start value is reasonable when this function is called. */)
3140 3135
3141 fset_redisplay (f); 3136 fset_redisplay (f);
3142 Vwindow_list = Qnil; 3137 Vwindow_list = Qnil;
3143 FRAME_WINDOW_SIZES_CHANGED (f) = 1; 3138 FRAME_WINDOW_SIZES_CHANGED (f) = true;
3144 resize_failed = 0; 3139 bool resize_failed = false;
3145 3140
3146 if (!WINDOW_LEAF_P (w)) 3141 if (!WINDOW_LEAF_P (w))
3147 { 3142 {
@@ -3150,21 +3145,21 @@ window-start value is reasonable when this function is called. */)
3150 w->pixel_top = r->pixel_top; 3145 w->pixel_top = r->pixel_top;
3151 w->top_line = r->top_line; 3146 w->top_line = r->top_line;
3152 resize_root_window (window, delta, Qnil, Qnil, Qt); 3147 resize_root_window (window, delta, Qnil, Qnil, Qt);
3153 if (window_resize_check (w, 0)) 3148 if (window_resize_check (w, false))
3154 { 3149 {
3155 window_resize_apply (w, 0); 3150 window_resize_apply (w, false);
3156 window_pixel_to_total (w->frame, Qnil); 3151 window_pixel_to_total (w->frame, Qnil);
3157 } 3152 }
3158 else 3153 else
3159 { 3154 {
3160 resize_root_window (window, delta, Qnil, Qt, Qt); 3155 resize_root_window (window, delta, Qnil, Qt, Qt);
3161 if (window_resize_check (w, 0)) 3156 if (window_resize_check (w, false))
3162 { 3157 {
3163 window_resize_apply (w, 0); 3158 window_resize_apply (w, false);
3164 window_pixel_to_total (w->frame, Qnil); 3159 window_pixel_to_total (w->frame, Qnil);
3165 } 3160 }
3166 else 3161 else
3167 resize_failed = 1; 3162 resize_failed = true;
3168 } 3163 }
3169 3164
3170 /* Resize child windows horizontally. */ 3165 /* Resize child windows horizontally. */
@@ -3174,21 +3169,21 @@ window-start value is reasonable when this function is called. */)
3174 w->pixel_left = r->pixel_left; 3169 w->pixel_left = r->pixel_left;
3175 XSETINT (delta, r->pixel_width - w->pixel_width); 3170 XSETINT (delta, r->pixel_width - w->pixel_width);
3176 resize_root_window (window, delta, Qt, Qnil, Qt); 3171 resize_root_window (window, delta, Qt, Qnil, Qt);
3177 if (window_resize_check (w, 1)) 3172 if (window_resize_check (w, true))
3178 { 3173 {
3179 window_resize_apply (w, 1); 3174 window_resize_apply (w, true);
3180 window_pixel_to_total (w->frame, Qt); 3175 window_pixel_to_total (w->frame, Qt);
3181 } 3176 }
3182 else 3177 else
3183 { 3178 {
3184 resize_root_window (window, delta, Qt, Qt, Qt); 3179 resize_root_window (window, delta, Qt, Qt, Qt);
3185 if (window_resize_check (w, 1)) 3180 if (window_resize_check (w, true))
3186 { 3181 {
3187 window_resize_apply (w, 1); 3182 window_resize_apply (w, true);
3188 window_pixel_to_total (w->frame, Qt); 3183 window_pixel_to_total (w->frame, Qt);
3189 } 3184 }
3190 else 3185 else
3191 resize_failed = 1; 3186 resize_failed = true;
3192 } 3187 }
3193 } 3188 }
3194 3189
@@ -3224,10 +3219,10 @@ window-start value is reasonable when this function is called. */)
3224 if (WINDOWP (r->contents)) 3219 if (WINDOWP (r->contents))
3225 { 3220 {
3226 delete_all_child_windows (r->contents); 3221 delete_all_child_windows (r->contents);
3227 wset_combination (r, 0, Qnil); 3222 wset_combination (r, false, Qnil);
3228 } 3223 }
3229 3224
3230 replace_window (root, window, 1); 3225 replace_window (root, window, true);
3231 3226
3232 /* This must become SWINDOW anyway ....... */ 3227 /* This must become SWINDOW anyway ....... */
3233 if (BUFFERP (w->contents) && !resize_failed) 3228 if (BUFFERP (w->contents) && !resize_failed)
@@ -3251,12 +3246,12 @@ window-start value is reasonable when this function is called. */)
3251 pos = *vmotion (startpos, startbyte, -top, w); 3246 pos = *vmotion (startpos, startbyte, -top, w);
3252 3247
3253 set_marker_both (w->start, w->contents, pos.bufpos, pos.bytepos); 3248 set_marker_both (w->start, w->contents, pos.bufpos, pos.bytepos);
3254 w->window_end_valid = 0; 3249 w->window_end_valid = false;
3255 w->start_at_line_beg = (pos.bytepos == BEGV_BYTE 3250 w->start_at_line_beg = (pos.bytepos == BEGV_BYTE
3256 || FETCH_BYTE (pos.bytepos - 1) == '\n'); 3251 || FETCH_BYTE (pos.bytepos - 1) == '\n');
3257 /* We need to do this, so that the window-scroll-functions 3252 /* We need to do this, so that the window-scroll-functions
3258 get called. */ 3253 get called. */
3259 w->optional_new_start = 1; 3254 w->optional_new_start = true;
3260 3255
3261 set_buffer_internal (obuf); 3256 set_buffer_internal (obuf);
3262 } 3257 }
@@ -3291,7 +3286,7 @@ replace_buffer_in_windows_safely (Lisp_Object buffer)
3291 considers frames on the current keyboard. So loop manually over 3286 considers frames on the current keyboard. So loop manually over
3292 frames, and handle each one. */ 3287 frames, and handle each one. */
3293 FOR_EACH_FRAME (tail, frame) 3288 FOR_EACH_FRAME (tail, frame)
3294 window_loop (REPLACE_BUFFER_IN_WINDOWS_SAFELY, buffer, 1, frame); 3289 window_loop (REPLACE_BUFFER_IN_WINDOWS_SAFELY, buffer, true, frame);
3295 } 3290 }
3296} 3291}
3297 3292
@@ -3391,9 +3386,9 @@ If WINDOW is omitted or nil, it defaults to the selected window. */)
3391 return Qnil; 3386 return Qnil;
3392} 3387}
3393 3388
3394/* Make WINDOW display BUFFER. RUN_HOOKS_P non-zero means it's allowed 3389/* Make WINDOW display BUFFER. RUN_HOOKS_P means it's allowed
3395 to run hooks. See make_frame for a case where it's not allowed. 3390 to run hooks. See make_frame for a case where it's not allowed.
3396 KEEP_MARGINS_P non-zero means that the current margins, fringes, and 3391 KEEP_MARGINS_P means that the current margins, fringes, and
3397 scroll-bar settings of the window are not reset from the buffer's 3392 scroll-bar settings of the window are not reset from the buffer's
3398 local settings. */ 3393 local settings. */
3399 3394
@@ -3435,15 +3430,15 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer,
3435 doc-view-mode since it resets the image's position whenever we 3430 doc-view-mode since it resets the image's position whenever we
3436 resize the frame. */ 3431 resize the frame. */
3437 w->hscroll = w->min_hscroll = w->hscroll_whole = 0; 3432 w->hscroll = w->min_hscroll = w->hscroll_whole = 0;
3438 w->suspend_auto_hscroll = 0; 3433 w->suspend_auto_hscroll = false;
3439 w->vscroll = 0; 3434 w->vscroll = 0;
3440 set_marker_both (w->pointm, buffer, BUF_PT (b), BUF_PT_BYTE (b)); 3435 set_marker_both (w->pointm, buffer, BUF_PT (b), BUF_PT_BYTE (b));
3441 set_marker_both (w->old_pointm, buffer, BUF_PT (b), BUF_PT_BYTE (b)); 3436 set_marker_both (w->old_pointm, buffer, BUF_PT (b), BUF_PT_BYTE (b));
3442 set_marker_restricted (w->start, 3437 set_marker_restricted (w->start,
3443 make_number (b->last_window_start), 3438 make_number (b->last_window_start),
3444 buffer); 3439 buffer);
3445 w->start_at_line_beg = 0; 3440 w->start_at_line_beg = false;
3446 w->force_start = 0; 3441 w->force_start = false;
3447 } 3442 }
3448 /* Maybe we could move this into the `if' but it's not obviously safe and 3443 /* Maybe we could move this into the `if' but it's not obviously safe and
3449 I doubt it's worth the trouble. */ 3444 I doubt it's worth the trouble. */
@@ -3534,7 +3529,7 @@ This function runs `window-scroll-functions' before running
3534 unshow_buffer (w); 3529 unshow_buffer (w);
3535 } 3530 }
3536 3531
3537 set_window_buffer (window, buffer, 1, !NILP (keep_margins)); 3532 set_window_buffer (window, buffer, true, !NILP (keep_margins));
3538 3533
3539 return Qnil; 3534 return Qnil;
3540} 3535}
@@ -3563,10 +3558,10 @@ displaying that buffer. */)
3563 if (WINDOWP (object)) 3558 if (WINDOWP (object))
3564 { 3559 {
3565 struct window *w = XWINDOW (object); 3560 struct window *w = XWINDOW (object);
3566 mark_window_display_accurate (object, 0); 3561 mark_window_display_accurate (object, false);
3567 w->update_mode_line = 1; 3562 w->update_mode_line = true;
3568 if (BUFFERP (w->contents)) 3563 if (BUFFERP (w->contents))
3569 XBUFFER (w->contents)->prevent_redisplay_optimizations_p = 1; 3564 XBUFFER (w->contents)->prevent_redisplay_optimizations_p = true;
3570 update_mode_lines = 29; 3565 update_mode_lines = 29;
3571 return Qt; 3566 return Qt;
3572 } 3567 }
@@ -3578,7 +3573,7 @@ displaying that buffer. */)
3578 { 3573 {
3579 /* If buffer is live and shown in at least one window, find 3574 /* If buffer is live and shown in at least one window, find
3580 all windows showing this buffer and force update of them. */ 3575 all windows showing this buffer and force update of them. */
3581 object = window_loop (REDISPLAY_BUFFER_WINDOWS, object, 0, Qvisible); 3576 object = window_loop (REDISPLAY_BUFFER_WINDOWS, object, false, Qvisible);
3582 return NILP (object) ? Qnil : Qt; 3577 return NILP (object) ? Qnil : Qt;
3583 } 3578 }
3584 3579
@@ -3614,7 +3609,7 @@ temp_output_buffer_show (register Lisp_Object buf)
3614 Vminibuf_scroll_window = window; 3609 Vminibuf_scroll_window = window;
3615 w = XWINDOW (window); 3610 w = XWINDOW (window);
3616 w->hscroll = w->min_hscroll = w->hscroll_whole = 0; 3611 w->hscroll = w->min_hscroll = w->hscroll_whole = 0;
3617 w->suspend_auto_hscroll = 0; 3612 w->suspend_auto_hscroll = false;
3618 set_marker_restricted_both (w->start, buf, BEG, BEG); 3613 set_marker_restricted_both (w->start, buf, BEG, BEG);
3619 set_marker_restricted_both (w->pointm, buf, BEG, BEG); 3614 set_marker_restricted_both (w->pointm, buf, BEG, BEG);
3620 set_marker_restricted_both (w->old_pointm, buf, BEG, BEG); 3615 set_marker_restricted_both (w->old_pointm, buf, BEG, BEG);
@@ -3651,7 +3646,7 @@ allocate_window (void)
3651} 3646}
3652 3647
3653/* Make new window, have it replace WINDOW in window-tree, and make 3648/* Make new window, have it replace WINDOW in window-tree, and make
3654 WINDOW its only vertical child (HORFLAG 1 means make WINDOW its only 3649 WINDOW its only vertical child (HORFLAG means make WINDOW its only
3655 horizontal child). */ 3650 horizontal child). */
3656static void 3651static void
3657make_parent_window (Lisp_Object window, bool horflag) 3652make_parent_window (Lisp_Object window, bool horflag)
@@ -3670,7 +3665,7 @@ make_parent_window (Lisp_Object window, bool horflag)
3670 3665
3671 p->sequence_number = ++sequence_number; 3666 p->sequence_number = ++sequence_number;
3672 3667
3673 replace_window (window, parent, 1); 3668 replace_window (window, parent, true);
3674 3669
3675 wset_next (o, Qnil); 3670 wset_next (o, Qnil);
3676 wset_prev (o, Qnil); 3671 wset_prev (o, Qnil);
@@ -3799,14 +3794,14 @@ Note: This function does not operate on any child windows of WINDOW. */)
3799 return size; 3794 return size;
3800} 3795}
3801 3796
3802/* Return 1 if setting w->pixel_height (w->pixel_width if HORFLAG is 3797/* Return true if setting w->pixel_height (w->pixel_width if HORFLAG)
3803 non-zero) to w->new_pixel would result in correct heights (widths) 3798 to w->new_pixel would result in correct heights (widths)
3804 for window W and recursively all child windows of W. 3799 for window W and recursively all child windows of W.
3805 3800
3806 Note: This function does not check any of `window-fixed-size-p', 3801 Note: This function does not check any of `window-fixed-size-p',
3807 `window-min-height' or `window-min-width'. It does check that window 3802 `window-min-height' or `window-min-width'. It does check that window
3808 sizes do not drop below one line (two columns). */ 3803 sizes do not drop below one line (two columns). */
3809static int 3804static bool
3810window_resize_check (struct window *w, bool horflag) 3805window_resize_check (struct window *w, bool horflag)
3811{ 3806{
3812 struct frame *f = XFRAME (w->frame); 3807 struct frame *f = XFRAME (w->frame);
@@ -3823,12 +3818,12 @@ window_resize_check (struct window *w, bool horflag)
3823 { 3818 {
3824 if (XINT (c->new_pixel) != XINT (w->new_pixel) 3819 if (XINT (c->new_pixel) != XINT (w->new_pixel)
3825 || !window_resize_check (c, horflag)) 3820 || !window_resize_check (c, horflag))
3826 return 0; 3821 return false;
3827 3822
3828 c = NILP (c->next) ? 0 : XWINDOW (c->next); 3823 c = NILP (c->next) ? 0 : XWINDOW (c->next);
3829 } 3824 }
3830 3825
3831 return 1; 3826 return true;
3832 } 3827 }
3833 else 3828 else
3834 /* The sum of the heights of the child windows of W must equal 3829 /* The sum of the heights of the child windows of W must equal
@@ -3839,11 +3834,11 @@ window_resize_check (struct window *w, bool horflag)
3839 while (c) 3834 while (c)
3840 { 3835 {
3841 if (!window_resize_check (c, horflag)) 3836 if (!window_resize_check (c, horflag))
3842 return 0; 3837 return false;
3843 3838
3844 remaining_pixels -= XINT (c->new_pixel); 3839 remaining_pixels -= XINT (c->new_pixel);
3845 if (remaining_pixels < 0) 3840 if (remaining_pixels < 0)
3846 return 0; 3841 return false;
3847 c = NILP (c->next) ? 0 : XWINDOW (c->next); 3842 c = NILP (c->next) ? 0 : XWINDOW (c->next);
3848 } 3843 }
3849 3844
@@ -3863,11 +3858,11 @@ window_resize_check (struct window *w, bool horflag)
3863 while (c) 3858 while (c)
3864 { 3859 {
3865 if (!window_resize_check (c, horflag)) 3860 if (!window_resize_check (c, horflag))
3866 return 0; 3861 return false;
3867 3862
3868 remaining_pixels -= XINT (c->new_pixel); 3863 remaining_pixels -= XINT (c->new_pixel);
3869 if (remaining_pixels < 0) 3864 if (remaining_pixels < 0)
3870 return 0; 3865 return false;
3871 c = NILP (c->next) ? 0 : XWINDOW (c->next); 3866 c = NILP (c->next) ? 0 : XWINDOW (c->next);
3872 } 3867 }
3873 3868
@@ -3880,12 +3875,12 @@ window_resize_check (struct window *w, bool horflag)
3880 { 3875 {
3881 if (XINT (c->new_pixel) != XINT (w->new_pixel) 3876 if (XINT (c->new_pixel) != XINT (w->new_pixel)
3882 || !window_resize_check (c, horflag)) 3877 || !window_resize_check (c, horflag))
3883 return 0; 3878 return false;
3884 3879
3885 c = NILP (c->next) ? 0 : XWINDOW (c->next); 3880 c = NILP (c->next) ? 0 : XWINDOW (c->next);
3886 } 3881 }
3887 3882
3888 return 1; 3883 return true;
3889 } 3884 }
3890 } 3885 }
3891 else 3886 else
@@ -3898,7 +3893,7 @@ window_resize_check (struct window *w, bool horflag)
3898} 3893}
3899 3894
3900 3895
3901/* Set w->pixel_height (w->pixel_width if HORFLAG is non-zero) to 3896/* Set w->pixel_height (w->pixel_width if HORFLAG) to
3902 w->new_pixel for window W and recursively all child windows of W. 3897 w->new_pixel for window W and recursively all child windows of W.
3903 Also calculate and assign the new vertical (horizontal) pixel start 3898 Also calculate and assign the new vertical (horizontal) pixel start
3904 positions of each of these windows. 3899 positions of each of these windows.
@@ -3984,11 +3979,11 @@ window_resize_apply (struct window *w, bool horflag)
3984 } 3979 }
3985 else 3980 else
3986 /* Bug#15957. */ 3981 /* Bug#15957. */
3987 w->window_end_valid = 0; 3982 w->window_end_valid = false;
3988} 3983}
3989 3984
3990 3985
3991/* Set w->total_lines (w->total_cols if HORFLAG is non-zero) to 3986/* Set w->total_lines (w->total_cols if HORFLAG) to
3992 w->new_total for window W and recursively all child windows of W. 3987 w->new_total for window W and recursively all child windows of W.
3993 Also calculate and assign the new vertical (horizontal) start 3988 Also calculate and assign the new vertical (horizontal) start
3994 positions of each of these windows. */ 3989 positions of each of these windows. */
@@ -4083,7 +4078,7 @@ be applied on the Elisp level. */)
4083 window_resize_apply (r, horflag); 4078 window_resize_apply (r, horflag);
4084 4079
4085 fset_redisplay (f); 4080 fset_redisplay (f);
4086 FRAME_WINDOW_SIZES_CHANGED (f) = 1; 4081 FRAME_WINDOW_SIZES_CHANGED (f) = true;
4087 4082
4088 adjust_frame_glyphs (f); 4083 adjust_frame_glyphs (f);
4089 unblock_input (); 4084 unblock_input ();
@@ -4133,8 +4128,8 @@ values. */)
4133 4128
4134 4129
4135/* Resize frame F's windows when number of lines of F is set to SIZE. 4130/* Resize frame F's windows when number of lines of F is set to SIZE.
4136 HORFLAG 1 means resize windows when number of columns of F is set to 4131 HORFLAG means resize windows when number of columns of F is set to
4137 SIZE. PIXELWISE 1 means to interpret SIZE as pixels. */ 4132 SIZE. PIXELWISE means to interpret SIZE as pixels. */
4138void 4133void
4139resize_frame_windows (struct frame *f, int size, bool horflag, bool pixelwise) 4134resize_frame_windows (struct frame *f, int size, bool horflag, bool pixelwise)
4140{ 4135{
@@ -4168,12 +4163,9 @@ resize_frame_windows (struct frame *f, int size, bool horflag, bool pixelwise)
4168 } 4163 }
4169 else 4164 else
4170 { 4165 {
4171 new_size = max (horflag 4166 new_size = max (size - (!horflag
4172 ? size 4167 && FRAME_HAS_MINIBUF_P (f)
4173 : (size 4168 && !FRAME_MINIBUF_ONLY_P (f)),
4174 - ((FRAME_HAS_MINIBUF_P (f)
4175 && !FRAME_MINIBUF_ONLY_P (f))
4176 ? 1 : 0)),
4177 1); 4169 1);
4178 new_pixel_size = new_size * unit; 4170 new_pixel_size = new_size * unit;
4179 } 4171 }
@@ -4224,7 +4216,7 @@ resize_frame_windows (struct frame *f, int size, bool horflag, bool pixelwise)
4224 { 4216 {
4225 window_resize_apply (r, horflag); 4217 window_resize_apply (r, horflag);
4226 window_pixel_to_total (r->frame, horflag ? Qt : Qnil); 4218 window_pixel_to_total (r->frame, horflag ? Qt : Qnil);
4227#if 0 /* Let's try without safe sizes and/or killing other windows. */ 4219#if false /* Let's try without safe sizes and/or killing other windows. */
4228 } 4220 }
4229 else 4221 else
4230 { 4222 {
@@ -4254,7 +4246,7 @@ resize_frame_windows (struct frame *f, int size, bool horflag, bool pixelwise)
4254 XWINDOW (root)->pixel_height = new_pixel_size; 4246 XWINDOW (root)->pixel_height = new_pixel_size;
4255 } 4247 }
4256 } 4248 }
4257#endif /* 0 */ 4249#endif /* false */
4258 } 4250 }
4259 } 4251 }
4260 } 4252 }
@@ -4284,7 +4276,7 @@ resize_frame_windows (struct frame *f, int size, bool horflag, bool pixelwise)
4284DEFUN ("split-window-internal", Fsplit_window_internal, Ssplit_window_internal, 4, 4, 0, 4276DEFUN ("split-window-internal", Fsplit_window_internal, Ssplit_window_internal, 4, 4, 0,
4285 doc: /* Split window OLD. 4277 doc: /* Split window OLD.
4286Second argument PIXEL-SIZE specifies the number of pixels of the 4278Second argument PIXEL-SIZE specifies the number of pixels of the
4287new window. In any case TOTAL-SIZE must be a positive integer. 4279new window. It must be a positive integer.
4288 4280
4289Third argument SIDE nil (or `below') specifies that the new window shall 4281Third argument SIDE nil (or `below') specifies that the new window shall
4290be located below WINDOW. SIDE `above' means the new window shall be 4282be located below WINDOW. SIDE `above' means the new window shall be
@@ -4311,14 +4303,12 @@ set correctly. See the code of `split-window' for how this is done. */)
4311 provided OLD is a leaf window, or to the frame's selected window. 4303 provided OLD is a leaf window, or to the frame's selected window.
4312 NEW (*n) is the new window created with some parameters taken from 4304 NEW (*n) is the new window created with some parameters taken from
4313 REFERENCE (*r). */ 4305 REFERENCE (*r). */
4314 register Lisp_Object new, frame, reference; 4306 Lisp_Object new, frame, reference;
4315 register struct window *o, *p, *n, *r, *c; 4307 struct window *o, *p, *n, *r, *c;
4316 struct frame *f; 4308 struct frame *f;
4317 bool horflag 4309 bool horflag
4318 /* HORFLAG is 1 when we split side-by-side, 0 otherwise. */ 4310 /* HORFLAG is true when we split side-by-side, false otherwise. */
4319 = EQ (side, Qt) || EQ (side, Qleft) || EQ (side, Qright); 4311 = EQ (side, Qt) || EQ (side, Qleft) || EQ (side, Qright);
4320 int combination_limit = 0, sum = 0;
4321 int total_size;
4322 4312
4323 CHECK_WINDOW (old); 4313 CHECK_WINDOW (old);
4324 o = XWINDOW (old); 4314 o = XWINDOW (old);
@@ -4326,20 +4316,20 @@ set correctly. See the code of `split-window' for how this is done. */)
4326 f = XFRAME (frame); 4316 f = XFRAME (frame);
4327 4317
4328 CHECK_NUMBER (pixel_size); 4318 CHECK_NUMBER (pixel_size);
4329 total_size 4319 EMACS_INT total_size
4330 = XINT (pixel_size) / (horflag 4320 = XINT (pixel_size) / (horflag
4331 ? FRAME_COLUMN_WIDTH (f) 4321 ? FRAME_COLUMN_WIDTH (f)
4332 : FRAME_LINE_HEIGHT (f)); 4322 : FRAME_LINE_HEIGHT (f));
4333 4323
4334 /* Set combination_limit to 1 if we have to make a new parent window. 4324 /* Set combination_limit if we have to make a new parent window.
4335 We do that if either `window-combination-limit' is t, or OLD has no 4325 We do that if either `window-combination-limit' is t, or OLD has no
4336 parent, or OLD is ortho-combined. */ 4326 parent, or OLD is ortho-combined. */
4337 combination_limit = 4327 bool combination_limit
4338 EQ (Vwindow_combination_limit, Qt) 4328 = (EQ (Vwindow_combination_limit, Qt)
4339 || NILP (o->parent) 4329 || NILP (o->parent)
4340 || (horflag 4330 || (horflag
4341 ? WINDOW_VERTICAL_COMBINATION_P (XWINDOW (o->parent)) 4331 ? WINDOW_VERTICAL_COMBINATION_P (XWINDOW (o->parent))
4342 : WINDOW_HORIZONTAL_COMBINATION_P (XWINDOW (o->parent))); 4332 : WINDOW_HORIZONTAL_COMBINATION_P (XWINDOW (o->parent))));
4343 4333
4344 /* We need a live reference window to initialize some parameters. */ 4334 /* We need a live reference window to initialize some parameters. */
4345 if (WINDOW_LIVE_P (old)) 4335 if (WINDOW_LIVE_P (old))
@@ -4405,7 +4395,7 @@ set correctly. See the code of `split-window' for how this is done. */)
4405 p = XWINDOW (o->parent); 4395 p = XWINDOW (o->parent);
4406 4396
4407 fset_redisplay (f); 4397 fset_redisplay (f);
4408 FRAME_WINDOW_SIZES_CHANGED (f) = 1; 4398 FRAME_WINDOW_SIZES_CHANGED (f) = true;
4409 new = make_window (); 4399 new = make_window ();
4410 n = XWINDOW (new); 4400 n = XWINDOW (new);
4411 wset_frame (n, frame); 4401 wset_frame (n, frame);
@@ -4430,7 +4420,7 @@ set correctly. See the code of `split-window' for how this is done. */)
4430 wset_next (o, new); 4420 wset_next (o, new);
4431 } 4421 }
4432 4422
4433 n->window_end_valid = 0; 4423 n->window_end_valid = false;
4434 n->last_cursor_vpos = 0; 4424 n->last_cursor_vpos = 0;
4435 4425
4436 /* Get special geometry settings from reference window. */ 4426 /* Get special geometry settings from reference window. */
@@ -4463,6 +4453,7 @@ set correctly. See the code of `split-window' for how this is done. */)
4463 /* Iso-coordinates and sizes are assigned by window_resize_apply, 4453 /* Iso-coordinates and sizes are assigned by window_resize_apply,
4464 get them ready here. */ 4454 get them ready here. */
4465 wset_new_pixel (n, pixel_size); 4455 wset_new_pixel (n, pixel_size);
4456 EMACS_INT sum = 0;
4466 c = XWINDOW (p->contents); 4457 c = XWINDOW (p->contents);
4467 while (c) 4458 while (c)
4468 { 4459 {
@@ -4481,7 +4472,7 @@ set correctly. See the code of `split-window' for how this is done. */)
4481 adjust_frame_glyphs (f); 4472 adjust_frame_glyphs (f);
4482 /* Set buffer of NEW to buffer of reference window. Don't run 4473 /* Set buffer of NEW to buffer of reference window. Don't run
4483 any hooks. */ 4474 any hooks. */
4484 set_window_buffer (new, r->contents, 0, 1); 4475 set_window_buffer (new, r->contents, false, true);
4485 unblock_input (); 4476 unblock_input ();
4486 4477
4487 /* Maybe we should run the scroll functions in Elisp (which already 4478 /* Maybe we should run the scroll functions in Elisp (which already
@@ -4498,12 +4489,12 @@ DEFUN ("delete-window-internal", Fdelete_window_internal, Sdelete_window_interna
4498 doc: /* Remove WINDOW from its frame. 4489 doc: /* Remove WINDOW from its frame.
4499WINDOW defaults to the selected window. Return nil. 4490WINDOW defaults to the selected window. Return nil.
4500Signal an error when WINDOW is the only window on its frame. */) 4491Signal an error when WINDOW is the only window on its frame. */)
4501 (register Lisp_Object window) 4492 (Lisp_Object window)
4502{ 4493{
4503 register Lisp_Object parent, sibling, frame, root; 4494 Lisp_Object parent, sibling, frame, root;
4504 struct window *w, *p, *s, *r; 4495 struct window *w, *p, *s, *r;
4505 struct frame *f; 4496 struct frame *f;
4506 bool horflag, before_sibling = 0; 4497 bool horflag, before_sibling = false;
4507 4498
4508 w = decode_any_window (window); 4499 w = decode_any_window (window);
4509 XSETWINDOW (window, w); 4500 XSETWINDOW (window, w);
@@ -4533,9 +4524,9 @@ Signal an error when WINDOW is the only window on its frame. */)
4533 if (NILP (w->prev)) 4524 if (NILP (w->prev))
4534 /* Get SIBLING below (on the right of) WINDOW. */ 4525 /* Get SIBLING below (on the right of) WINDOW. */
4535 { 4526 {
4536 /* before_sibling 1 means WINDOW is the first child of its 4527 /* before_sibling means WINDOW is the first child of its
4537 parent and thus before the sibling. */ 4528 parent and thus before the sibling. */
4538 before_sibling = 1; 4529 before_sibling = true;
4539 sibling = w->next; 4530 sibling = w->next;
4540 s = XWINDOW (sibling); 4531 s = XWINDOW (sibling);
4541 wset_prev (s, Qnil); 4532 wset_prev (s, Qnil);
@@ -4572,7 +4563,7 @@ Signal an error when WINDOW is the only window on its frame. */)
4572 4563
4573 fset_redisplay (f); 4564 fset_redisplay (f);
4574 Vwindow_list = Qnil; 4565 Vwindow_list = Qnil;
4575 FRAME_WINDOW_SIZES_CHANGED (f) = 1; 4566 FRAME_WINDOW_SIZES_CHANGED (f) = true;
4576 4567
4577 wset_next (w, Qnil); /* Don't delete w->next too. */ 4568 wset_next (w, Qnil); /* Don't delete w->next too. */
4578 free_window_matrices (w); 4569 free_window_matrices (w);
@@ -4580,7 +4571,7 @@ Signal an error when WINDOW is the only window on its frame. */)
4580 if (WINDOWP (w->contents)) 4571 if (WINDOWP (w->contents))
4581 { 4572 {
4582 delete_all_child_windows (w->contents); 4573 delete_all_child_windows (w->contents);
4583 wset_combination (w, 0, Qnil); 4574 wset_combination (w, false, Qnil);
4584 } 4575 }
4585 else 4576 else
4586 { 4577 {
@@ -4596,13 +4587,13 @@ Signal an error when WINDOW is the only window on its frame. */)
4596 PARENT. */ 4587 PARENT. */
4597 { 4588 {
4598 /* Put SIBLING into PARENT's place. */ 4589 /* Put SIBLING into PARENT's place. */
4599 replace_window (parent, sibling, 0); 4590 replace_window (parent, sibling, false);
4600 /* Have SIBLING inherit the following three slot values from 4591 /* Have SIBLING inherit the following three slot values from
4601 PARENT (the combination_limit slot is not inherited). */ 4592 PARENT (the combination_limit slot is not inherited). */
4602 wset_normal_cols (s, p->normal_cols); 4593 wset_normal_cols (s, p->normal_cols);
4603 wset_normal_lines (s, p->normal_lines); 4594 wset_normal_lines (s, p->normal_lines);
4604 /* Mark PARENT as deleted. */ 4595 /* Mark PARENT as deleted. */
4605 wset_combination (p, 0, Qnil); 4596 wset_combination (p, false, Qnil);
4606 /* Try to merge SIBLING into its new parent. */ 4597 /* Try to merge SIBLING into its new parent. */
4607 recombine_windows (sibling); 4598 recombine_windows (sibling);
4608 } 4599 }
@@ -4687,10 +4678,10 @@ grow_mini_window (struct window *w, int delta, bool pixelwise)
4687 r = XWINDOW (root); 4678 r = XWINDOW (root);
4688 height = call3 (Qwindow_resize_root_window_vertically, 4679 height = call3 (Qwindow_resize_root_window_vertically,
4689 root, make_number (- delta), pixelwise ? Qt : Qnil); 4680 root, make_number (- delta), pixelwise ? Qt : Qnil);
4690 if (INTEGERP (height) && window_resize_check (r, 0)) 4681 if (INTEGERP (height) && window_resize_check (r, false))
4691 { 4682 {
4692 block_input (); 4683 block_input ();
4693 window_resize_apply (r, 0); 4684 window_resize_apply (r, false);
4694 4685
4695 if (pixelwise) 4686 if (pixelwise)
4696 { 4687 {
@@ -4742,10 +4733,10 @@ shrink_mini_window (struct window *w, bool pixelwise)
4742 delta = call3 (Qwindow_resize_root_window_vertically, 4733 delta = call3 (Qwindow_resize_root_window_vertically,
4743 root, make_number (height - unit), 4734 root, make_number (height - unit),
4744 pixelwise ? Qt : Qnil); 4735 pixelwise ? Qt : Qnil);
4745 if (INTEGERP (delta) && window_resize_check (r, 0)) 4736 if (INTEGERP (delta) && window_resize_check (r, false))
4746 { 4737 {
4747 block_input (); 4738 block_input ();
4748 window_resize_apply (r, 0); 4739 window_resize_apply (r, false);
4749 4740
4750 /* Shrink the mini-window. */ 4741 /* Shrink the mini-window. */
4751 w->top_line = r->top_line + r->total_lines; 4742 w->top_line = r->top_line + r->total_lines;
@@ -4784,12 +4775,12 @@ DEFUN ("resize-mini-window-internal", Fresize_mini_window_internal, Sresize_mini
4784 4775
4785 r = XWINDOW (FRAME_ROOT_WINDOW (f)); 4776 r = XWINDOW (FRAME_ROOT_WINDOW (f));
4786 height = r->pixel_height + w->pixel_height; 4777 height = r->pixel_height + w->pixel_height;
4787 if (window_resize_check (r, 0) 4778 if (window_resize_check (r, false)
4788 && XINT (w->new_pixel) > 0 4779 && XINT (w->new_pixel) > 0
4789 && height == XINT (r->new_pixel) + XINT (w->new_pixel)) 4780 && height == XINT (r->new_pixel) + XINT (w->new_pixel))
4790 { 4781 {
4791 block_input (); 4782 block_input ();
4792 window_resize_apply (r, 0); 4783 window_resize_apply (r, false);
4793 4784
4794 w->pixel_height = XFASTINT (w->new_pixel); 4785 w->pixel_height = XFASTINT (w->new_pixel);
4795 w->total_lines = w->pixel_height / FRAME_LINE_HEIGHT (f); 4786 w->total_lines = w->pixel_height / FRAME_LINE_HEIGHT (f);
@@ -4797,7 +4788,7 @@ DEFUN ("resize-mini-window-internal", Fresize_mini_window_internal, Sresize_mini
4797 w->top_line = r->top_line + r->total_lines; 4788 w->top_line = r->top_line + r->total_lines;
4798 4789
4799 fset_redisplay (f); 4790 fset_redisplay (f);
4800 FRAME_WINDOW_SIZES_CHANGED (f) = 1; 4791 FRAME_WINDOW_SIZES_CHANGED (f) = true;
4801 adjust_frame_glyphs (f); 4792 adjust_frame_glyphs (f);
4802 unblock_input (); 4793 unblock_input ();
4803 return Qt; 4794 return Qt;
@@ -4819,7 +4810,7 @@ mark_window_cursors_off (struct window *w)
4819 if (WINDOWP (w->contents)) 4810 if (WINDOWP (w->contents))
4820 mark_window_cursors_off (XWINDOW (w->contents)); 4811 mark_window_cursors_off (XWINDOW (w->contents));
4821 else 4812 else
4822 w->phys_cursor_on_p = 0; 4813 w->phys_cursor_on_p = false;
4823 4814
4824 w = NILP (w->next) ? 0 : XWINDOW (w->next); 4815 w = NILP (w->next) ? 0 : XWINDOW (w->next);
4825 } 4816 }
@@ -4854,19 +4845,19 @@ window_internal_height (struct window *w)
4854 Window Scrolling 4845 Window Scrolling
4855 ***********************************************************************/ 4846 ***********************************************************************/
4856 4847
4857/* Scroll contents of window WINDOW up. If WHOLE is non-zero, scroll 4848/* Scroll contents of window WINDOW up. If WHOLE, scroll
4858 N screen-fulls, which is defined as the height of the window minus 4849 N screen-fulls, which is defined as the height of the window minus
4859 next_screen_context_lines. If WHOLE is zero, scroll up N lines 4850 next_screen_context_lines. If WHOLE is zero, scroll up N lines
4860 instead. Negative values of N mean scroll down. NOERROR non-zero 4851 instead. Negative values of N mean scroll down. NOERROR
4861 means don't signal an error if we try to move over BEGV or ZV, 4852 means don't signal an error if we try to move over BEGV or ZV,
4862 respectively. */ 4853 respectively. */
4863 4854
4864static void 4855static void
4865window_scroll (Lisp_Object window, EMACS_INT n, bool whole, int noerror) 4856window_scroll (Lisp_Object window, EMACS_INT n, bool whole, bool noerror)
4866{ 4857{
4867 ptrdiff_t count = SPECPDL_INDEX (); 4858 ptrdiff_t count = SPECPDL_INDEX ();
4868 4859
4869 immediate_quit = 1; 4860 immediate_quit = true;
4870 n = clip_to_bounds (INT_MIN, n, INT_MAX); 4861 n = clip_to_bounds (INT_MIN, n, INT_MAX);
4871 4862
4872 wset_redisplay (XWINDOW (window)); 4863 wset_redisplay (XWINDOW (window));
@@ -4884,8 +4875,8 @@ window_scroll (Lisp_Object window, EMACS_INT n, bool whole, int noerror)
4884 unbind_to (count, Qnil); 4875 unbind_to (count, Qnil);
4885 4876
4886 /* Bug#15957. */ 4877 /* Bug#15957. */
4887 XWINDOW (window)->window_end_valid = 0; 4878 XWINDOW (window)->window_end_valid = false;
4888 immediate_quit = 0; 4879 immediate_quit = false;
4889} 4880}
4890 4881
4891 4882
@@ -4894,14 +4885,14 @@ window_scroll (Lisp_Object window, EMACS_INT n, bool whole, int noerror)
4894 descriptions. */ 4885 descriptions. */
4895 4886
4896static void 4887static void
4897window_scroll_pixel_based (Lisp_Object window, int n, bool whole, int noerror) 4888window_scroll_pixel_based (Lisp_Object window, int n, bool whole, bool noerror)
4898{ 4889{
4899 struct it it; 4890 struct it it;
4900 struct window *w = XWINDOW (window); 4891 struct window *w = XWINDOW (window);
4901 struct text_pos start; 4892 struct text_pos start;
4902 int this_scroll_margin; 4893 int this_scroll_margin;
4903 /* True if we fiddled the window vscroll field without really scrolling. */ 4894 /* True if we fiddled the window vscroll field without really scrolling. */
4904 int vscrolled = 0; 4895 bool vscrolled = false;
4905 int x, y, rtop, rbot, rowh, vpos; 4896 int x, y, rtop, rbot, rowh, vpos;
4906 void *itdata = NULL; 4897 void *itdata = NULL;
4907 int window_total_lines; 4898 int window_total_lines;
@@ -4944,7 +4935,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, bool whole, int noerror)
4944 } 4935 }
4945 4936
4946 start = it.current.pos; 4937 start = it.current.pos;
4947 bidi_unshelve_cache (itdata, 0); 4938 bidi_unshelve_cache (itdata, false);
4948 } 4939 }
4949 else if (auto_window_vscroll_p) 4940 else if (auto_window_vscroll_p)
4950 { 4941 {
@@ -4997,11 +4988,11 @@ window_scroll_pixel_based (Lisp_Object window, int n, bool whole, int noerror)
4997 spos = min (XINT (Fline_end_position (Qnil)) + 1, ZV); 4988 spos = min (XINT (Fline_end_position (Qnil)) + 1, ZV);
4998 set_marker_restricted (w->start, make_number (spos), 4989 set_marker_restricted (w->start, make_number (spos),
4999 w->contents); 4990 w->contents);
5000 w->start_at_line_beg = 1; 4991 w->start_at_line_beg = true;
5001 w->update_mode_line = 1; 4992 w->update_mode_line = true;
5002 /* Set force_start so that redisplay_window will run the 4993 /* Set force_start so that redisplay_window will run the
5003 window-scroll-functions. */ 4994 window-scroll-functions. */
5004 w->force_start = 1; 4995 w->force_start = true;
5005 return; 4996 return;
5006 } 4997 }
5007 } 4998 }
@@ -5095,7 +5086,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, bool whole, int noerror)
5095 } 5086 }
5096 else 5087 else
5097 { 5088 {
5098 bidi_unshelve_cache (itdata, 0); 5089 bidi_unshelve_cache (itdata, false);
5099 if (noerror) 5090 if (noerror)
5100 return; 5091 return;
5101 else if (n < 0) /* could happen with empty buffers */ 5092 else if (n < 0) /* could happen with empty buffers */
@@ -5112,7 +5103,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, bool whole, int noerror)
5112 w->vscroll = 0; 5103 w->vscroll = 0;
5113 else 5104 else
5114 { 5105 {
5115 bidi_unshelve_cache (itdata, 0); 5106 bidi_unshelve_cache (itdata, false);
5116 if (noerror) 5107 if (noerror)
5117 return; 5108 return;
5118 else 5109 else
@@ -5122,10 +5113,10 @@ window_scroll_pixel_based (Lisp_Object window, int n, bool whole, int noerror)
5122 5113
5123 /* If control gets here, then we vscrolled. */ 5114 /* If control gets here, then we vscrolled. */
5124 5115
5125 XBUFFER (w->contents)->prevent_redisplay_optimizations_p = 1; 5116 XBUFFER (w->contents)->prevent_redisplay_optimizations_p = true;
5126 5117
5127 /* Don't try to change the window start below. */ 5118 /* Don't try to change the window start below. */
5128 vscrolled = 1; 5119 vscrolled = true;
5129 } 5120 }
5130 5121
5131 if (! vscrolled) 5122 if (! vscrolled)
@@ -5146,10 +5137,10 @@ window_scroll_pixel_based (Lisp_Object window, int n, bool whole, int noerror)
5146 IT_BYTEPOS (it)); 5137 IT_BYTEPOS (it));
5147 bytepos = marker_byte_position (w->start); 5138 bytepos = marker_byte_position (w->start);
5148 w->start_at_line_beg = (pos == BEGV || FETCH_BYTE (bytepos - 1) == '\n'); 5139 w->start_at_line_beg = (pos == BEGV || FETCH_BYTE (bytepos - 1) == '\n');
5149 w->update_mode_line = 1; 5140 w->update_mode_line = true;
5150 /* Set force_start so that redisplay_window will run the 5141 /* Set force_start so that redisplay_window will run the
5151 window-scroll-functions. */ 5142 window-scroll-functions. */
5152 w->force_start = 1; 5143 w->force_start = true;
5153 } 5144 }
5154 5145
5155 /* The rest of this function uses current_y in a nonstandard way, 5146 /* The rest of this function uses current_y in a nonstandard way,
@@ -5182,8 +5173,8 @@ window_scroll_pixel_based (Lisp_Object window, int n, bool whole, int noerror)
5182 This is necessary because we set it.current_y to 0, above. */ 5173 This is necessary because we set it.current_y to 0, above. */
5183 move_it_to (&it, -1, 5174 move_it_to (&it, -1,
5184 window_scroll_pixel_based_preserve_x, 5175 window_scroll_pixel_based_preserve_x,
5185 window_scroll_pixel_based_preserve_y 5176 (window_scroll_pixel_based_preserve_y
5186 - (WINDOW_WANTS_HEADER_LINE_P (w) ? 1 : 0 ), 5177 - WINDOW_WANTS_HEADER_LINE_P (w)),
5187 -1, MOVE_TO_Y | MOVE_TO_X); 5178 -1, MOVE_TO_Y | MOVE_TO_X);
5188 SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it)); 5179 SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it));
5189 } 5180 }
@@ -5202,7 +5193,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, bool whole, int noerror)
5202 else if (n < 0) 5193 else if (n < 0)
5203 { 5194 {
5204 ptrdiff_t charpos, bytepos; 5195 ptrdiff_t charpos, bytepos;
5205 int partial_p; 5196 bool partial_p;
5206 5197
5207 /* Save our position, for the 5198 /* Save our position, for the
5208 window_scroll_pixel_based_preserve_y case. */ 5199 window_scroll_pixel_based_preserve_y case. */
@@ -5238,12 +5229,12 @@ window_scroll_pixel_based (Lisp_Object window, int n, bool whole, int noerror)
5238 { 5229 {
5239 charpos = IT_CHARPOS (it); 5230 charpos = IT_CHARPOS (it);
5240 bytepos = IT_BYTEPOS (it); 5231 bytepos = IT_BYTEPOS (it);
5241 bidi_unshelve_cache (it_data, 1); 5232 bidi_unshelve_cache (it_data, true);
5242 } 5233 }
5243 else 5234 else
5244 { 5235 {
5245 it = it2; 5236 it = it2;
5246 bidi_unshelve_cache (it_data, 0); 5237 bidi_unshelve_cache (it_data, false);
5247 } 5238 }
5248 } 5239 }
5249 5240
@@ -5287,7 +5278,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, bool whole, int noerror)
5287 SET_PT_BOTH (charpos, bytepos); 5278 SET_PT_BOTH (charpos, bytepos);
5288 } 5279 }
5289 } 5280 }
5290 bidi_unshelve_cache (itdata, 0); 5281 bidi_unshelve_cache (itdata, false);
5291 5282
5292 if (adjust_old_pointm) 5283 if (adjust_old_pointm)
5293 Fset_marker (w->old_pointm, 5284 Fset_marker (w->old_pointm,
@@ -5302,9 +5293,9 @@ window_scroll_pixel_based (Lisp_Object window, int n, bool whole, int noerror)
5302 See the comment of window_scroll for parameter descriptions. */ 5293 See the comment of window_scroll for parameter descriptions. */
5303 5294
5304static void 5295static void
5305window_scroll_line_based (Lisp_Object window, int n, bool whole, int noerror) 5296window_scroll_line_based (Lisp_Object window, int n, bool whole, bool noerror)
5306{ 5297{
5307 register struct window *w = XWINDOW (window); 5298 struct window *w = XWINDOW (window);
5308 /* Fvertical_motion enters redisplay, which can trigger 5299 /* Fvertical_motion enters redisplay, which can trigger
5309 fontification, which in turn can modify buffer text (e.g., if the 5300 fontification, which in turn can modify buffer text (e.g., if the
5310 fontification functions replace escape sequences with faces, as 5301 fontification functions replace escape sequences with faces, as
@@ -5334,7 +5325,7 @@ window_scroll_line_based (Lisp_Object window, int n, bool whole, int noerror)
5334 || NILP (Fget (KVAR (current_kboard, Vlast_command), Qscroll_command))) 5325 || NILP (Fget (KVAR (current_kboard, Vlast_command), Qscroll_command)))
5335 { 5326 {
5336 struct position posit 5327 struct position posit
5337 = *compute_motion (startpos, startbyte, 0, 0, 0, 5328 = *compute_motion (startpos, startbyte, 0, 0, false,
5338 PT, ht, 0, -1, w->hscroll, 0, w); 5329 PT, ht, 0, -1, w->hscroll, 0, w);
5339 5330
5340 window_scroll_preserve_vpos = posit.vpos; 5331 window_scroll_preserve_vpos = posit.vpos;
@@ -5380,10 +5371,10 @@ window_scroll_line_based (Lisp_Object window, int n, bool whole, int noerror)
5380 5371
5381 set_marker_restricted_both (w->start, w->contents, pos, pos_byte); 5372 set_marker_restricted_both (w->start, w->contents, pos, pos_byte);
5382 w->start_at_line_beg = !NILP (bolp); 5373 w->start_at_line_beg = !NILP (bolp);
5383 w->update_mode_line = 1; 5374 w->update_mode_line = true;
5384 /* Set force_start so that redisplay_window will run 5375 /* Set force_start so that redisplay_window will run
5385 the window-scroll-functions. */ 5376 the window-scroll-functions. */
5386 w->force_start = 1; 5377 w->force_start = true;
5387 5378
5388 if (!NILP (Vscroll_preserve_screen_position) 5379 if (!NILP (Vscroll_preserve_screen_position)
5389 && (whole || !EQ (Vscroll_preserve_screen_position, Qt))) 5380 && (whole || !EQ (Vscroll_preserve_screen_position, Qt)))
@@ -5485,13 +5476,13 @@ scroll_command (Lisp_Object n, int direction)
5485 } 5476 }
5486 5477
5487 if (NILP (n)) 5478 if (NILP (n))
5488 window_scroll (selected_window, direction, 1, 0); 5479 window_scroll (selected_window, direction, true, false);
5489 else if (EQ (n, Qminus)) 5480 else if (EQ (n, Qminus))
5490 window_scroll (selected_window, -direction, 1, 0); 5481 window_scroll (selected_window, -direction, true, false);
5491 else 5482 else
5492 { 5483 {
5493 n = Fprefix_numeric_value (n); 5484 n = Fprefix_numeric_value (n);
5494 window_scroll (selected_window, XINT (n) * direction, 0, 0); 5485 window_scroll (selected_window, XINT (n) * direction, false, false);
5495 } 5486 }
5496 5487
5497 unbind_to (count, Qnil); 5488 unbind_to (count, Qnil);
@@ -5599,15 +5590,15 @@ specifies the window to scroll. This takes precedence over
5599 SET_PT_BOTH (marker_position (w->old_pointm), marker_byte_position (w->old_pointm)); 5590 SET_PT_BOTH (marker_position (w->old_pointm), marker_byte_position (w->old_pointm));
5600 5591
5601 if (NILP (arg)) 5592 if (NILP (arg))
5602 window_scroll (window, 1, 1, 1); 5593 window_scroll (window, 1, true, true);
5603 else if (EQ (arg, Qminus)) 5594 else if (EQ (arg, Qminus))
5604 window_scroll (window, -1, 1, 1); 5595 window_scroll (window, -1, true, true);
5605 else 5596 else
5606 { 5597 {
5607 if (CONSP (arg)) 5598 if (CONSP (arg))
5608 arg = XCAR (arg); 5599 arg = XCAR (arg);
5609 CHECK_NUMBER (arg); 5600 CHECK_NUMBER (arg);
5610 window_scroll (window, XINT (arg), 0, 1); 5601 window_scroll (window, XINT (arg), false, true);
5611 } 5602 }
5612 5603
5613 set_marker_both (w->pointm, Qnil, PT, PT_BYTE); 5604 set_marker_both (w->pointm, Qnil, PT, PT_BYTE);
@@ -5637,7 +5628,7 @@ by this function. This happens in an interactive call. */)
5637 if (!NILP (set_minimum)) 5628 if (!NILP (set_minimum))
5638 w->min_hscroll = w->hscroll; 5629 w->min_hscroll = w->hscroll;
5639 5630
5640 w->suspend_auto_hscroll = 1; 5631 w->suspend_auto_hscroll = true;
5641 5632
5642 return result; 5633 return result;
5643} 5634}
@@ -5662,7 +5653,7 @@ by this function. This happens in an interactive call. */)
5662 if (!NILP (set_minimum)) 5653 if (!NILP (set_minimum))
5663 w->min_hscroll = w->hscroll; 5654 w->min_hscroll = w->hscroll;
5664 5655
5665 w->suspend_auto_hscroll = 1; 5656 w->suspend_auto_hscroll = true;
5666 5657
5667 return result; 5658 return result;
5668} 5659}
@@ -5710,7 +5701,7 @@ displayed_window_lines (struct window *w)
5710 start_display (&it, w, start); 5701 start_display (&it, w, start);
5711 move_it_vertically (&it, height); 5702 move_it_vertically (&it, height);
5712 bottom_y = line_bottom_y (&it); 5703 bottom_y = line_bottom_y (&it);
5713 bidi_unshelve_cache (itdata, 0); 5704 bidi_unshelve_cache (itdata, false);
5714 5705
5715 /* rms: On a non-window display, 5706 /* rms: On a non-window display,
5716 the value of it.vpos at the bottom of the screen 5707 the value of it.vpos at the bottom of the screen
@@ -5754,7 +5745,7 @@ and redisplay normally--don't erase and redraw the frame. */)
5754{ 5745{
5755 struct window *w = XWINDOW (selected_window); 5746 struct window *w = XWINDOW (selected_window);
5756 struct buffer *buf = XBUFFER (w->contents); 5747 struct buffer *buf = XBUFFER (w->contents);
5757 bool center_p = 0; 5748 bool center_p = false;
5758 ptrdiff_t charpos, bytepos; 5749 ptrdiff_t charpos, bytepos;
5759 EMACS_INT iarg IF_LINT (= 0); 5750 EMACS_INT iarg IF_LINT (= 0);
5760 int this_scroll_margin; 5751 int this_scroll_margin;
@@ -5783,10 +5774,10 @@ and redisplay normally--don't erase and redraw the frame. */)
5783 SET_FRAME_GARBAGED (WINDOW_XFRAME (w)); 5774 SET_FRAME_GARBAGED (WINDOW_XFRAME (w));
5784 } 5775 }
5785 5776
5786 center_p = 1; 5777 center_p = true;
5787 } 5778 }
5788 else if (CONSP (arg)) /* Just C-u. */ 5779 else if (CONSP (arg)) /* Just C-u. */
5789 center_p = 1; 5780 center_p = true;
5790 else 5781 else
5791 { 5782 {
5792 arg = Fprefix_numeric_value (arg); 5783 arg = Fprefix_numeric_value (arg);
@@ -5799,10 +5790,9 @@ and redisplay normally--don't erase and redraw the frame. */)
5799 this_scroll_margin 5790 this_scroll_margin
5800 = max (0, min (scroll_margin, w->total_lines / 4)); 5791 = max (0, min (scroll_margin, w->total_lines / 4));
5801 5792
5802 /* Handle centering on a graphical frame specially. Such frames can 5793 /* Don't use redisplay code for initial frames, as the necessary
5803 have variable-height lines and centering point on the basis of 5794 data structures might not be set up yet then. */
5804 line counts would lead to strange effects. */ 5795 if (!FRAME_INITIAL_P (XFRAME (w->frame)))
5805 if (FRAME_WINDOW_P (XFRAME (w->frame)))
5806 { 5796 {
5807 if (center_p) 5797 if (center_p)
5808 { 5798 {
@@ -5815,7 +5805,7 @@ and redisplay normally--don't erase and redraw the frame. */)
5815 move_it_vertically_backward (&it, window_box_height (w) / 2); 5805 move_it_vertically_backward (&it, window_box_height (w) / 2);
5816 charpos = IT_CHARPOS (it); 5806 charpos = IT_CHARPOS (it);
5817 bytepos = IT_BYTEPOS (it); 5807 bytepos = IT_BYTEPOS (it);
5818 bidi_unshelve_cache (itdata, 0); 5808 bidi_unshelve_cache (itdata, false);
5819 } 5809 }
5820 else if (iarg < 0) 5810 else if (iarg < 0)
5821 { 5811 {
@@ -5824,9 +5814,11 @@ and redisplay normally--don't erase and redraw the frame. */)
5824 ptrdiff_t nlines = min (PTRDIFF_MAX, -iarg); 5814 ptrdiff_t nlines = min (PTRDIFF_MAX, -iarg);
5825 int extra_line_spacing; 5815 int extra_line_spacing;
5826 int h = window_box_height (w); 5816 int h = window_box_height (w);
5817 int ht = window_internal_height (w);
5827 void *itdata = bidi_shelve_cache (); 5818 void *itdata = bidi_shelve_cache ();
5828 5819
5829 iarg = - max (-iarg, this_scroll_margin); 5820 nlines = clip_to_bounds (this_scroll_margin + 1, nlines,
5821 ht - this_scroll_margin);
5830 5822
5831 SET_TEXT_POS (pt, PT, PT_BYTE); 5823 SET_TEXT_POS (pt, PT, PT_BYTE);
5832 start_display (&it, w, pt); 5824 start_display (&it, w, pt);
@@ -5863,7 +5855,7 @@ and redisplay normally--don't erase and redraw the frame. */)
5863 } 5855 }
5864 if (h <= 0) 5856 if (h <= 0)
5865 { 5857 {
5866 bidi_unshelve_cache (itdata, 0); 5858 bidi_unshelve_cache (itdata, false);
5867 return Qnil; 5859 return Qnil;
5868 } 5860 }
5869 5861
@@ -5886,17 +5878,37 @@ and redisplay normally--don't erase and redraw the frame. */)
5886 charpos = IT_CHARPOS (it); 5878 charpos = IT_CHARPOS (it);
5887 bytepos = IT_BYTEPOS (it); 5879 bytepos = IT_BYTEPOS (it);
5888 5880
5889 bidi_unshelve_cache (itdata, 0); 5881 bidi_unshelve_cache (itdata, false);
5890 } 5882 }
5891 else 5883 else
5892 { 5884 {
5893 struct position pos; 5885 struct it it;
5886 struct text_pos pt;
5887 ptrdiff_t nlines = min (PTRDIFF_MAX, iarg);
5888 int ht = window_internal_height (w);
5889 void *itdata = bidi_shelve_cache ();
5890
5891 nlines = clip_to_bounds (this_scroll_margin, nlines,
5892 ht - this_scroll_margin - 1);
5893
5894 SET_TEXT_POS (pt, PT, PT_BYTE);
5895 start_display (&it, w, pt);
5894 5896
5895 iarg = max (iarg, this_scroll_margin); 5897 /* Move to the beginning of screen line containing PT. */
5898 move_it_by_lines (&it, 0);
5896 5899
5897 pos = *vmotion (PT, PT_BYTE, -iarg, w); 5900 /* Move back to find the point which is ARG screen lines above PT. */
5898 charpos = pos.bufpos; 5901 if (nlines > 0)
5899 bytepos = pos.bytepos; 5902 {
5903 it.current_y = 0;
5904 it.vpos = 0;
5905 move_it_by_lines (&it, -nlines);
5906 }
5907
5908 charpos = IT_CHARPOS (it);
5909 bytepos = IT_BYTEPOS (it);
5910
5911 bidi_unshelve_cache (itdata, false);
5900 } 5912 }
5901 } 5913 }
5902 else 5914 else
@@ -5920,9 +5932,9 @@ and redisplay normally--don't erase and redraw the frame. */)
5920 5932
5921 /* Set the new window start. */ 5933 /* Set the new window start. */
5922 set_marker_both (w->start, w->contents, charpos, bytepos); 5934 set_marker_both (w->start, w->contents, charpos, bytepos);
5923 w->window_end_valid = 0; 5935 w->window_end_valid = false;
5924 5936
5925 w->optional_new_start = 1; 5937 w->optional_new_start = true;
5926 5938
5927 w->start_at_line_beg = (bytepos == BEGV_BYTE 5939 w->start_at_line_beg = (bytepos == BEGV_BYTE
5928 || FETCH_BYTE (bytepos - 1) == '\n'); 5940 || FETCH_BYTE (bytepos - 1) == '\n');
@@ -5986,7 +5998,7 @@ zero means top of window, negative means relative to bottom of window. */)
5986 struct window *w = XWINDOW (selected_window); 5998 struct window *w = XWINDOW (selected_window);
5987 int lines, start; 5999 int lines, start;
5988 Lisp_Object window; 6000 Lisp_Object window;
5989#if 0 6001#if false
5990 int this_scroll_margin; 6002 int this_scroll_margin;
5991#endif 6003#endif
5992 6004
@@ -6003,14 +6015,14 @@ zero means top of window, negative means relative to bottom of window. */)
6003 Fvertical_motion (make_number (- (height / 2)), window, Qnil); 6015 Fvertical_motion (make_number (- (height / 2)), window, Qnil);
6004 set_marker_both (w->start, w->contents, PT, PT_BYTE); 6016 set_marker_both (w->start, w->contents, PT, PT_BYTE);
6005 w->start_at_line_beg = !NILP (Fbolp ()); 6017 w->start_at_line_beg = !NILP (Fbolp ());
6006 w->force_start = 1; 6018 w->force_start = true;
6007 } 6019 }
6008 else 6020 else
6009 Fgoto_char (w->start); 6021 Fgoto_char (w->start);
6010 6022
6011 lines = displayed_window_lines (w); 6023 lines = displayed_window_lines (w);
6012 6024
6013#if 0 6025#if false
6014 this_scroll_margin = max (0, min (scroll_margin, lines / 4)); 6026 this_scroll_margin = max (0, min (scroll_margin, lines / 4));
6015#endif 6027#endif
6016 6028
@@ -6023,11 +6035,11 @@ zero means top of window, negative means relative to bottom of window. */)
6023 if (iarg < 0) 6035 if (iarg < 0)
6024 iarg = iarg + lines; 6036 iarg = iarg + lines;
6025 6037
6026#if 0 /* This code would prevent move-to-window-line from moving point 6038#if false /* This code would prevent move-to-window-line from moving point
6027 to a place inside the scroll margins (which would cause the 6039 to a place inside the scroll margins (which would cause the
6028 next redisplay to scroll). I wrote this code, but then concluded 6040 next redisplay to scroll). I wrote this code, but then concluded
6029 it is probably better not to install it. However, it is here 6041 it is probably better not to install it. However, it is here
6030 inside #if 0 so as not to lose it. -- rms. */ 6042 inside #if false so as not to lose it. -- rms. */
6031 6043
6032 /* Don't let it get into the margin at either top or bottom. */ 6044 /* Don't let it get into the margin at either top or bottom. */
6033 iarg = max (iarg, this_scroll_margin); 6045 iarg = max (iarg, this_scroll_margin);
@@ -6193,14 +6205,12 @@ the return value is nil. Otherwise the value is t. */)
6193 { 6205 {
6194 Lisp_Object window; 6206 Lisp_Object window;
6195 Lisp_Object dead_windows = Qnil; 6207 Lisp_Object dead_windows = Qnil;
6196 register Lisp_Object tem, par, pers; 6208 Lisp_Object tem, par, pers;
6197 register struct window *w; 6209 struct window *w;
6198 register struct saved_window *p; 6210 struct saved_window *p;
6199 struct window *root_window; 6211 struct window *root_window;
6200 struct window **leaf_windows; 6212 struct window **leaf_windows;
6201 int n_leaf_windows; 6213 ptrdiff_t i, k, n_leaf_windows;
6202 ptrdiff_t k;
6203 int i, n;
6204 6214
6205 /* Don't do this within the main loop below: This may call Lisp 6215 /* Don't do this within the main loop below: This may call Lisp
6206 code and is thus potentially unsafe while input is blocked. */ 6216 code and is thus potentially unsafe while input is blocked. */
@@ -6238,14 +6248,14 @@ the return value is nil. Otherwise the value is t. */)
6238 } 6248 }
6239 6249
6240 fset_redisplay (f); 6250 fset_redisplay (f);
6241 FRAME_WINDOW_SIZES_CHANGED (f) = 1; 6251 FRAME_WINDOW_SIZES_CHANGED (f) = true;
6242 6252
6243 /* Problem: Freeing all matrices and later allocating them again 6253 /* Problem: Freeing all matrices and later allocating them again
6244 is a serious redisplay flickering problem. What we would 6254 is a serious redisplay flickering problem. What we would
6245 really like to do is to free only those matrices not reused 6255 really like to do is to free only those matrices not reused
6246 below. */ 6256 below. */
6247 root_window = XWINDOW (FRAME_ROOT_WINDOW (f)); 6257 root_window = XWINDOW (FRAME_ROOT_WINDOW (f));
6248 int nwindows = count_windows (root_window); 6258 ptrdiff_t nwindows = count_windows (root_window);
6249 SAFE_NALLOCA (leaf_windows, 1, nwindows); 6259 SAFE_NALLOCA (leaf_windows, 1, nwindows);
6250 n_leaf_windows = get_leaf_windows (root_window, leaf_windows, 0); 6260 n_leaf_windows = get_leaf_windows (root_window, leaf_windows, 0);
6251 6261
@@ -6369,7 +6379,7 @@ the return value is nil. Otherwise the value is t. */)
6369 (w->old_pointm, w->contents, 6379 (w->old_pointm, w->contents,
6370 BUF_PT (XBUFFER (w->contents)), 6380 BUF_PT (XBUFFER (w->contents)),
6371 BUF_PT_BYTE (XBUFFER (w->contents))); 6381 BUF_PT_BYTE (XBUFFER (w->contents)));
6372 w->start_at_line_beg = 1; 6382 w->start_at_line_beg = true;
6373 } 6383 }
6374 else if (!NILP (w->start)) 6384 else if (!NILP (w->start))
6375 /* Leaf window has no live buffer, get one. */ 6385 /* Leaf window has no live buffer, get one. */
@@ -6384,7 +6394,7 @@ the return value is nil. Otherwise the value is t. */)
6384 set_marker_restricted_both (w->start, w->contents, 0, 0); 6394 set_marker_restricted_both (w->start, w->contents, 0, 0);
6385 set_marker_restricted_both (w->pointm, w->contents, 0, 0); 6395 set_marker_restricted_both (w->pointm, w->contents, 0, 0);
6386 set_marker_restricted_both (w->old_pointm, w->contents, 0, 0); 6396 set_marker_restricted_both (w->old_pointm, w->contents, 0, 0);
6387 w->start_at_line_beg = 1; 6397 w->start_at_line_beg = true;
6388 if (!NILP (w->dedicated)) 6398 if (!NILP (w->dedicated))
6389 /* Record this window as dead. */ 6399 /* Record this window as dead. */
6390 dead_windows = Fcons (window, dead_windows); 6400 dead_windows = Fcons (window, dead_windows);
@@ -6408,7 +6418,7 @@ the return value is nil. Otherwise the value is t. */)
6408 6418
6409 Do not record the buffer here. We do that in a separate call 6419 Do not record the buffer here. We do that in a separate call
6410 to select_window below. See also Bug#16207. */ 6420 to select_window below. See also Bug#16207. */
6411 select_window (data->current_window, Qt, 1); 6421 select_window (data->current_window, Qt, true);
6412 BVAR (XBUFFER (XWINDOW (selected_window)->contents), 6422 BVAR (XBUFFER (XWINDOW (selected_window)->contents),
6413 last_selected_window) 6423 last_selected_window)
6414 = selected_window; 6424 = selected_window;
@@ -6419,18 +6429,14 @@ the return value is nil. Otherwise the value is t. */)
6419 Fredirect_frame_focus (frame, data->focus_frame); 6429 Fredirect_frame_focus (frame, data->focus_frame);
6420 6430
6421 /* Now, free glyph matrices in windows that were not reused. */ 6431 /* Now, free glyph matrices in windows that were not reused. */
6422 for (i = n = 0; i < n_leaf_windows; ++i) 6432 for (i = 0; i < n_leaf_windows; i++)
6423 { 6433 if (NILP (leaf_windows[i]->contents))
6424 if (NILP (leaf_windows[i]->contents)) 6434 free_window_matrices (leaf_windows[i]);
6425 free_window_matrices (leaf_windows[i]);
6426 else if (EQ (leaf_windows[i]->contents, new_current_buffer))
6427 ++n;
6428 }
6429 6435
6430 /* Allow x_set_window_size again and apply frame size changes if 6436 /* Allow x_set_window_size again and apply frame size changes if
6431 needed. */ 6437 needed. */
6432 f->can_x_set_window_size = true; 6438 f->can_x_set_window_size = true;
6433 adjust_frame_size (f, -1, -1, 1, 0, Qset_window_configuration); 6439 adjust_frame_size (f, -1, -1, 1, false, Qset_window_configuration);
6434 6440
6435 adjust_frame_glyphs (f); 6441 adjust_frame_glyphs (f);
6436 unblock_input (); 6442 unblock_input ();
@@ -6445,7 +6451,7 @@ the return value is nil. Otherwise the value is t. */)
6445 6451
6446 /* Record the selected window's buffer here. The window should 6452 /* Record the selected window's buffer here. The window should
6447 already be the selected one from the call above. */ 6453 already be the selected one from the call above. */
6448 select_window (data->current_window, Qnil, 0); 6454 select_window (data->current_window, Qnil, false);
6449 6455
6450 /* Fselect_window will have made f the selected frame, so we 6456 /* Fselect_window will have made f the selected frame, so we
6451 reselect the proper frame here. Fhandle_switch_frame will change the 6457 reselect the proper frame here. Fhandle_switch_frame will change the
@@ -6500,7 +6506,7 @@ delete_all_child_windows (Lisp_Object window)
6500 if (WINDOWP (w->contents)) 6506 if (WINDOWP (w->contents))
6501 { 6507 {
6502 delete_all_child_windows (w->contents); 6508 delete_all_child_windows (w->contents);
6503 wset_combination (w, 0, Qnil); 6509 wset_combination (w, false, Qnil);
6504 } 6510 }
6505 else if (BUFFERP (w->contents)) 6511 else if (BUFFERP (w->contents))
6506 { 6512 {
@@ -6518,10 +6524,10 @@ delete_all_child_windows (Lisp_Object window)
6518 Vwindow_list = Qnil; 6524 Vwindow_list = Qnil;
6519} 6525}
6520 6526
6521static int 6527static ptrdiff_t
6522count_windows (register struct window *window) 6528count_windows (struct window *window)
6523{ 6529{
6524 register int count = 1; 6530 ptrdiff_t count = 1;
6525 if (!NILP (window->next)) 6531 if (!NILP (window->next))
6526 count += count_windows (XWINDOW (window->next)); 6532 count += count_windows (XWINDOW (window->next));
6527 if (WINDOWP (window->contents)) 6533 if (WINDOWP (window->contents))
@@ -6532,8 +6538,8 @@ count_windows (register struct window *window)
6532 6538
6533/* Fill vector FLAT with leaf windows under W, starting at index I. 6539/* Fill vector FLAT with leaf windows under W, starting at index I.
6534 Value is last index + 1. */ 6540 Value is last index + 1. */
6535static int 6541static ptrdiff_t
6536get_leaf_windows (struct window *w, struct window **flat, int i) 6542get_leaf_windows (struct window *w, struct window **flat, ptrdiff_t i)
6537{ 6543{
6538 while (w) 6544 while (w)
6539 { 6545 {
@@ -6587,12 +6593,12 @@ get_phys_cursor_glyph (struct window *w)
6587} 6593}
6588 6594
6589 6595
6590static int 6596static ptrdiff_t
6591save_window_save (Lisp_Object window, struct Lisp_Vector *vector, int i) 6597save_window_save (Lisp_Object window, struct Lisp_Vector *vector, ptrdiff_t i)
6592{ 6598{
6593 register struct saved_window *p; 6599 struct saved_window *p;
6594 register struct window *w; 6600 struct window *w;
6595 register Lisp_Object tem, pers, par; 6601 Lisp_Object tem, pers, par;
6596 6602
6597 for (; !NILP (window); window = w->next) 6603 for (; !NILP (window); window = w->next)
6598 { 6604 {
@@ -6730,10 +6736,9 @@ redirection (see `redirect-frame-focus'). The variable
6730saved by this function. */) 6736saved by this function. */)
6731 (Lisp_Object frame) 6737 (Lisp_Object frame)
6732{ 6738{
6733 register Lisp_Object tem; 6739 Lisp_Object tem;
6734 register int n_windows; 6740 ptrdiff_t i, n_windows;
6735 register struct save_window_data *data; 6741 struct save_window_data *data;
6736 register int i;
6737 struct frame *f = decode_live_frame (frame); 6742 struct frame *f = decode_live_frame (frame);
6738 6743
6739 n_windows = count_windows (XWINDOW (FRAME_ROOT_WINDOW (f))); 6744 n_windows = count_windows (XWINDOW (FRAME_ROOT_WINDOW (f)));
@@ -6772,7 +6777,7 @@ apply_window_adjustment (struct window *w)
6772{ 6777{
6773 eassert (w); 6778 eassert (w);
6774 clear_glyph_matrix (w->current_matrix); 6779 clear_glyph_matrix (w->current_matrix);
6775 w->window_end_valid = 0; 6780 w->window_end_valid = false;
6776 windows_or_buffers_changed = 30; 6781 windows_or_buffers_changed = 30;
6777 wset_redisplay (w); 6782 wset_redisplay (w);
6778 adjust_frame_glyphs (XFRAME (WINDOW_FRAME (w))); 6783 adjust_frame_glyphs (XFRAME (WINDOW_FRAME (w)));
@@ -6783,17 +6788,22 @@ apply_window_adjustment (struct window *w)
6783 Marginal Areas 6788 Marginal Areas
6784 ***********************************************************************/ 6789 ***********************************************************************/
6785 6790
6791static int
6792extract_dimension (Lisp_Object dimension)
6793{
6794 if (NILP (dimension))
6795 return -1;
6796 CHECK_RANGED_INTEGER (dimension, 0, INT_MAX);
6797 return XINT (dimension);
6798}
6799
6786static struct window * 6800static struct window *
6787set_window_margins (struct window *w, Lisp_Object left_width, 6801set_window_margins (struct window *w, Lisp_Object left_width,
6788 Lisp_Object right_width) 6802 Lisp_Object right_width)
6789{ 6803{
6790 int left, right;
6791 int unit = WINDOW_FRAME_COLUMN_WIDTH (w); 6804 int unit = WINDOW_FRAME_COLUMN_WIDTH (w);
6792 6805 int left = NILP (left_width) ? 0 : extract_dimension (left_width);
6793 left = (NILP (left_width) ? 0 6806 int right = NILP (right_width) ? 0 : extract_dimension (right_width);
6794 : (CHECK_NATNUM (left_width), XINT (left_width)));
6795 right = (NILP (right_width) ? 0
6796 : (CHECK_NATNUM (right_width), XINT (right_width)));
6797 6807
6798 if (w->left_margin_cols != left || w->right_margin_cols != right) 6808 if (w->left_margin_cols != left || w->right_margin_cols != right)
6799 { 6809 {
@@ -6862,12 +6872,9 @@ static struct window *
6862set_window_fringes (struct window *w, Lisp_Object left_width, 6872set_window_fringes (struct window *w, Lisp_Object left_width,
6863 Lisp_Object right_width, Lisp_Object outside_margins) 6873 Lisp_Object right_width, Lisp_Object outside_margins)
6864{ 6874{
6865 int left, right, outside = !NILP (outside_margins); 6875 bool outside = !NILP (outside_margins);
6866 6876 int left = extract_dimension (left_width);
6867 left = (NILP (left_width) ? -1 6877 int right = extract_dimension (right_width);
6868 : (CHECK_NATNUM (left_width), XINT (left_width)));
6869 right = (NILP (right_width) ? -1
6870 : (CHECK_NATNUM (right_width), XINT (right_width)));
6871 6878
6872 /* Do nothing on a tty or if nothing to actually change. */ 6879 /* Do nothing on a tty or if nothing to actually change. */
6873 if (FRAME_WINDOW_P (WINDOW_XFRAME (w)) 6880 if (FRAME_WINDOW_P (WINDOW_XFRAME (w))
@@ -6947,8 +6954,8 @@ set_window_scroll_bars (struct window *w, Lisp_Object width,
6947 Lisp_Object vertical_type, Lisp_Object height, 6954 Lisp_Object vertical_type, Lisp_Object height,
6948 Lisp_Object horizontal_type) 6955 Lisp_Object horizontal_type)
6949{ 6956{
6950 int iwidth = (NILP (width) ? -1 : (CHECK_NATNUM (width), XINT (width))); 6957 int iwidth = extract_dimension (width);
6951 bool changed = 0; 6958 bool changed = false;
6952 6959
6953 if (iwidth == 0) 6960 if (iwidth == 0)
6954 vertical_type = Qnil; 6961 vertical_type = Qnil;
@@ -6971,13 +6978,13 @@ set_window_scroll_bars (struct window *w, Lisp_Object width,
6971 { 6978 {
6972 w->scroll_bar_width = iwidth; 6979 w->scroll_bar_width = iwidth;
6973 wset_vertical_scroll_bar_type (w, vertical_type); 6980 wset_vertical_scroll_bar_type (w, vertical_type);
6974 changed = 1; 6981 changed = true;
6975 } 6982 }
6976 } 6983 }
6977 6984
6978#if USE_HORIZONTAL_SCROLL_BARS 6985#if USE_HORIZONTAL_SCROLL_BARS
6979 { 6986 {
6980 int iheight = (NILP (height) ? -1 : (CHECK_NATNUM (height), XINT (height))); 6987 int iheight = extract_dimension (height);
6981 6988
6982 if (MINI_WINDOW_P (w) || iheight == 0) 6989 if (MINI_WINDOW_P (w) || iheight == 0)
6983 horizontal_type = Qnil; 6990 horizontal_type = Qnil;
@@ -6999,7 +7006,7 @@ set_window_scroll_bars (struct window *w, Lisp_Object width,
6999 { 7006 {
7000 w->scroll_bar_height = iheight; 7007 w->scroll_bar_height = iheight;
7001 wset_horizontal_scroll_bar_type (w, horizontal_type); 7008 wset_horizontal_scroll_bar_type (w, horizontal_type);
7002 changed = 1; 7009 changed = true;
7003 } 7010 }
7004 } 7011 }
7005 } 7012 }
@@ -7122,7 +7129,7 @@ If PIXELS-P is non-nil, the return value is VSCROLL. */)
7122 adjust_frame_glyphs (f); 7129 adjust_frame_glyphs (f);
7123 7130
7124 /* Prevent redisplay shortcuts. */ 7131 /* Prevent redisplay shortcuts. */
7125 XBUFFER (w->contents)->prevent_redisplay_optimizations_p = 1; 7132 XBUFFER (w->contents)->prevent_redisplay_optimizations_p = true;
7126 } 7133 }
7127 } 7134 }
7128 7135
@@ -7135,7 +7142,7 @@ If PIXELS-P is non-nil, the return value is VSCROLL. */)
7135 additional argument USER_DATA. Stops when FN returns 0. */ 7142 additional argument USER_DATA. Stops when FN returns 0. */
7136 7143
7137static void 7144static void
7138foreach_window (struct frame *f, int (*fn) (struct window *, void *), 7145foreach_window (struct frame *f, bool (*fn) (struct window *, void *),
7139 void *user_data) 7146 void *user_data)
7140{ 7147{
7141 /* delete_frame may set FRAME_ROOT_WINDOW (f) to Qnil. */ 7148 /* delete_frame may set FRAME_ROOT_WINDOW (f) to Qnil. */
@@ -7147,14 +7154,15 @@ foreach_window (struct frame *f, int (*fn) (struct window *, void *),
7147/* Helper function for foreach_window. Call FN for all leaf windows 7154/* Helper function for foreach_window. Call FN for all leaf windows
7148 reachable from W. FN is called with the first argument being a 7155 reachable from W. FN is called with the first argument being a
7149 pointer to the leaf window, and with additional argument USER_DATA. 7156 pointer to the leaf window, and with additional argument USER_DATA.
7150 Stop when FN returns 0. Value is 0 if stopped by FN. */ 7157 Stop when FN returns false. Value is false if stopped by FN. */
7151 7158
7152static int 7159static bool
7153foreach_window_1 (struct window *w, int (*fn) (struct window *, void *), void *user_data) 7160foreach_window_1 (struct window *w, bool (*fn) (struct window *, void *),
7161 void *user_data)
7154{ 7162{
7155 int cont; 7163 bool cont;
7156 7164
7157 for (cont = 1; w && cont;) 7165 for (cont = true; w && cont;)
7158 { 7166 {
7159 if (WINDOWP (w->contents)) 7167 if (WINDOWP (w->contents))
7160 cont = foreach_window_1 (XWINDOW (w->contents), fn, user_data); 7168 cont = foreach_window_1 (XWINDOW (w->contents), fn, user_data);
@@ -7171,7 +7179,7 @@ foreach_window_1 (struct window *w, int (*fn) (struct window *, void *), void *u
7171 Initialization 7179 Initialization
7172 ***********************************************************************/ 7180 ***********************************************************************/
7173 7181
7174/* Return 1 if window configurations CONFIGURATION1 and CONFIGURATION2 7182/* Return true if window configurations CONFIGURATION1 and CONFIGURATION2
7175 describe the same state of affairs. This is used by Fequal. 7183 describe the same state of affairs. This is used by Fequal.
7176 7184
7177 IGNORE_POSITIONS means ignore non-matching scroll positions 7185 IGNORE_POSITIONS means ignore non-matching scroll positions
@@ -7210,7 +7218,7 @@ compare_window_configurations (Lisp_Object configuration1,
7210 || !EQ (d1->focus_frame, d2->focus_frame) 7218 || !EQ (d1->focus_frame, d2->focus_frame)
7211 /* Verify that the two configurations have the same number of windows. */ 7219 /* Verify that the two configurations have the same number of windows. */
7212 || sws1->header.size != sws2->header.size) 7220 || sws1->header.size != sws2->header.size)
7213 return 0; 7221 return false;
7214 7222
7215 for (i = 0; i < sws1->header.size; i++) 7223 for (i = 0; i < sws1->header.size; i++)
7216 { 7224 {
@@ -7254,10 +7262,10 @@ compare_window_configurations (Lisp_Object configuration1,
7254 || !EQ (sw1->scroll_bar_height, sw2->scroll_bar_height) 7262 || !EQ (sw1->scroll_bar_height, sw2->scroll_bar_height)
7255 || !EQ (sw1->vertical_scroll_bar_type, sw2->vertical_scroll_bar_type) 7263 || !EQ (sw1->vertical_scroll_bar_type, sw2->vertical_scroll_bar_type)
7256 || !EQ (sw1->horizontal_scroll_bar_type, sw2->horizontal_scroll_bar_type)) 7264 || !EQ (sw1->horizontal_scroll_bar_type, sw2->horizontal_scroll_bar_type))
7257 return 0; 7265 return false;
7258 } 7266 }
7259 7267
7260 return 1; 7268 return true;
7261} 7269}
7262 7270
7263DEFUN ("compare-window-configurations", Fcompare_window_configurations, 7271DEFUN ("compare-window-configurations", Fcompare_window_configurations,
@@ -7267,7 +7275,7 @@ This function ignores details such as the values of point
7267and scrolling positions. */) 7275and scrolling positions. */)
7268 (Lisp_Object x, Lisp_Object y) 7276 (Lisp_Object x, Lisp_Object y)
7269{ 7277{
7270 if (compare_window_configurations (x, y, 1)) 7278 if (compare_window_configurations (x, y, true))
7271 return Qt; 7279 return Qt;
7272 return Qnil; 7280 return Qnil;
7273} 7281}
diff --git a/src/window.h b/src/window.h
index 2ec28ab4e56..eaff57eaedf 100644
--- a/src/window.h
+++ b/src/window.h
@@ -195,10 +195,10 @@ struct window
195 Lisp_Object next_buffers; 195 Lisp_Object next_buffers;
196 196
197 /* Number saying how recently window was selected. */ 197 /* Number saying how recently window was selected. */
198 int use_time; 198 EMACS_INT use_time;
199 199
200 /* Unique number of window assigned when it was created. */ 200 /* Unique number of window assigned when it was created. */
201 int sequence_number; 201 EMACS_INT sequence_number;
202 202
203 /* The upper left corner pixel coordinates of this window, as 203 /* The upper left corner pixel coordinates of this window, as
204 integers relative to upper left corner of frame = 0, 0. */ 204 integers relative to upper left corner of frame = 0, 0. */
@@ -256,7 +256,7 @@ struct window
256 256
257 /* Scaling factor for the glyph_matrix size calculation in this window. 257 /* Scaling factor for the glyph_matrix size calculation in this window.
258 Used if window contains many small images or uses proportional fonts, 258 Used if window contains many small images or uses proportional fonts,
259 as the normal may yield a matrix which is too small. */ 259 as the normal may yield a matrix which is too small. */
260 int nrows_scale_factor, ncols_scale_factor; 260 int nrows_scale_factor, ncols_scale_factor;
261 261
262 /* Intended cursor position. This is a position within the 262 /* Intended cursor position. This is a position within the
@@ -323,7 +323,7 @@ struct window
323 /* True if this window is a minibuffer window. */ 323 /* True if this window is a minibuffer window. */
324 bool_bf mini : 1; 324 bool_bf mini : 1;
325 325
326 /* Meaningful only if contents is a window, non-zero if this 326 /* Meaningful only if contents is a window, true if this
327 internal window is used in horizontal combination. */ 327 internal window is used in horizontal combination. */
328 bool_bf horizontal : 1; 328 bool_bf horizontal : 1;
329 329
@@ -921,7 +921,7 @@ wset_next_buffers (struct window *w, Lisp_Object val)
921 : 0) 921 : 0)
922 922
923#define WINDOW_MODE_LINE_LINES(W) \ 923#define WINDOW_MODE_LINE_LINES(W) \
924 (!! WINDOW_WANTS_MODELINE_P (W)) 924 WINDOW_WANTS_MODELINE_P (W)
925 925
926/* Height in pixels, and in lines, of the header line. 926/* Height in pixels, and in lines, of the header line.
927 Zero if W doesn't have a header line. */ 927 Zero if W doesn't have a header line. */
@@ -931,7 +931,7 @@ wset_next_buffers (struct window *w, Lisp_Object val)
931 : 0) 931 : 0)
932 932
933#define WINDOW_HEADER_LINE_LINES(W) \ 933#define WINDOW_HEADER_LINE_LINES(W) \
934 (!! WINDOW_WANTS_HEADER_LINE_P (W)) 934 WINDOW_WANTS_HEADER_LINE_P (W)
935 935
936/* Pixel height of window W without mode line, bottom scroll bar and 936/* Pixel height of window W without mode line, bottom scroll bar and
937 bottom divider. */ 937 bottom divider. */
@@ -990,7 +990,7 @@ extern Lisp_Object selected_window;
990 recently used window. Its only users are Fselect_window, 990 recently used window. Its only users are Fselect_window,
991 init_window_once, and make_frame. */ 991 init_window_once, and make_frame. */
992 992
993extern int window_select_count; 993extern EMACS_INT window_select_count;
994 994
995/* The minibuffer window of the selected frame. 995/* The minibuffer window of the selected frame.
996 Note that you cannot test for minibufferness of an arbitrary window 996 Note that you cannot test for minibufferness of an arbitrary window
@@ -1015,7 +1015,7 @@ extern int window_relative_x_coord (struct window *, enum window_part, int);
1015 1015
1016void run_window_configuration_change_hook (struct frame *f); 1016void run_window_configuration_change_hook (struct frame *f);
1017 1017
1018/* Make WINDOW display BUFFER. RUN_HOOKS_P non-zero means it's allowed 1018/* Make WINDOW display BUFFER. RUN_HOOKS_P means it's allowed
1019 to run hooks. See make_frame for a case where it's not allowed. */ 1019 to run hooks. See make_frame for a case where it's not allowed. */
1020 1020
1021void set_window_buffer (Lisp_Object window, Lisp_Object buffer, 1021void set_window_buffer (Lisp_Object window, Lisp_Object buffer,
@@ -1067,7 +1067,7 @@ extern void redisplay_other_windows (void);
1067 1067
1068struct glyph *get_phys_cursor_glyph (struct window *w); 1068struct glyph *get_phys_cursor_glyph (struct window *w);
1069 1069
1070/* Value is non-zero if WINDOW is a valid window. */ 1070/* True if WINDOW is a valid window. */
1071#define WINDOW_VALID_P(WINDOW) \ 1071#define WINDOW_VALID_P(WINDOW) \
1072 (WINDOWP (WINDOW) && !NILP (XWINDOW (WINDOW)->contents)) \ 1072 (WINDOWP (WINDOW) && !NILP (XWINDOW (WINDOW)->contents)) \
1073 1073
@@ -1076,7 +1076,7 @@ struct glyph *get_phys_cursor_glyph (struct window *w);
1076#define CHECK_VALID_WINDOW(WINDOW) \ 1076#define CHECK_VALID_WINDOW(WINDOW) \
1077 CHECK_TYPE (WINDOW_VALID_P (WINDOW), Qwindow_valid_p, WINDOW) 1077 CHECK_TYPE (WINDOW_VALID_P (WINDOW), Qwindow_valid_p, WINDOW)
1078 1078
1079/* Value is non-zero if WINDOW is a live window. */ 1079/* True if WINDOW is a live window. */
1080#define WINDOW_LIVE_P(WINDOW) \ 1080#define WINDOW_LIVE_P(WINDOW) \
1081 (WINDOWP (WINDOW) && BUFFERP (XWINDOW (WINDOW)->contents)) 1081 (WINDOWP (WINDOW) && BUFFERP (XWINDOW (WINDOW)->contents))
1082 1082
diff --git a/src/xdisp.c b/src/xdisp.c
index a17f5a9c34f..5a27adc2b18 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -6971,7 +6971,7 @@ get_next_display_element (struct it *it)
6971 if (CHAR_BYTE8_P (c)) 6971 if (CHAR_BYTE8_P (c))
6972 /* Display \200 instead of \17777600. */ 6972 /* Display \200 instead of \17777600. */
6973 c = CHAR_TO_BYTE8 (c); 6973 c = CHAR_TO_BYTE8 (c);
6974 len = sprintf (str, "%03o", c); 6974 len = sprintf (str, "%03o", c + 0u);
6975 6975
6976 XSETINT (it->ctl_chars[0], escape_glyph); 6976 XSETINT (it->ctl_chars[0], escape_glyph);
6977 for (i = 0; i < len; i++) 6977 for (i = 0; i < len; i++)
@@ -10053,8 +10053,8 @@ message3 (Lisp_Object m)
10053 message_dolog (buffer, nbytes, true, multibyte); 10053 message_dolog (buffer, nbytes, true, multibyte);
10054 SAFE_FREE (); 10054 SAFE_FREE ();
10055 } 10055 }
10056 message3_nolog (m); 10056 if (! inhibit_message)
10057 10057 message3_nolog (m);
10058 UNGCPRO; 10058 UNGCPRO;
10059} 10059}
10060 10060
@@ -26233,7 +26233,7 @@ produce_glyphless_glyph (struct it *it, bool for_no_font, Lisp_Object acronym)
26233 else 26233 else
26234 { 26234 {
26235 eassert (it->glyphless_method == GLYPHLESS_DISPLAY_HEX_CODE); 26235 eassert (it->glyphless_method == GLYPHLESS_DISPLAY_HEX_CODE);
26236 sprintf (buf, "%0*X", it->c < 0x10000 ? 4 : 6, it->c); 26236 sprintf (buf, "%0*X", it->c < 0x10000 ? 4 : 6, it->c + 0u);
26237 str = buf; 26237 str = buf;
26238 } 26238 }
26239 for (len = 0; str[len] && ASCII_CHAR_P (str[len]) && len < 6; len++) 26239 for (len = 0; str[len] && ASCII_CHAR_P (str[len]) && len < 6; len++)
@@ -30430,6 +30430,11 @@ syms_of_xdisp (void)
30430 30430
30431 DEFSYM (Qredisplay_internal, "redisplay_internal (C function)"); 30431 DEFSYM (Qredisplay_internal, "redisplay_internal (C function)");
30432 30432
30433 DEFVAR_BOOL("inhibit-message", inhibit_message,
30434 doc: /* Non-nil means calls to `message' are not displayed.
30435They are still logged to the *Messages* buffer. */);
30436 inhibit_message = 0;
30437
30433 message_dolog_marker1 = Fmake_marker (); 30438 message_dolog_marker1 = Fmake_marker ();
30434 staticpro (&message_dolog_marker1); 30439 staticpro (&message_dolog_marker1);
30435 message_dolog_marker2 = Fmake_marker (); 30440 message_dolog_marker2 = Fmake_marker ();
diff --git a/src/xfaces.c b/src/xfaces.c
index b2697220bce..d198c4be1a9 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -1822,7 +1822,7 @@ resolve_face_name (Lisp_Object face_name, bool signal_p)
1822 Lisp_Object tortoise, hare; 1822 Lisp_Object tortoise, hare;
1823 1823
1824 if (STRINGP (face_name)) 1824 if (STRINGP (face_name))
1825 face_name = intern (SSDATA (face_name)); 1825 face_name = Fintern (face_name, Qnil);
1826 1826
1827 if (NILP (face_name) || !SYMBOLP (face_name)) 1827 if (NILP (face_name) || !SYMBOLP (face_name))
1828 return face_name; 1828 return face_name;
diff --git a/src/xselect.c b/src/xselect.c
index 027192dfea2..1570c4fef9c 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -531,6 +531,16 @@ static struct prop_location *property_change_reply_object;
531 531
532static struct prop_location *property_change_wait_list; 532static struct prop_location *property_change_wait_list;
533 533
534static void
535set_property_change_object (struct prop_location *location)
536{
537 /* Input must be blocked so we don't get the event before we set these. */
538 if (! input_blocked_p ())
539 emacs_abort ();
540 XSETCAR (property_change_reply, Qnil);
541 property_change_reply_object = location;
542}
543
534 544
535/* Send the reply to a selection request event EVENT. */ 545/* Send the reply to a selection request event EVENT. */
536 546
@@ -633,6 +643,11 @@ x_reply_selection_request (struct input_event *event,
633 { 643 {
634 int format_bytes = cs->format / 8; 644 int format_bytes = cs->format / 8;
635 bool had_errors_p = x_had_errors_p (display); 645 bool had_errors_p = x_had_errors_p (display);
646
647 /* Must set this inside block_input (). unblock_input may read
648 events and setting property_change_reply in
649 wait_for_property_change is then too late. */
650 set_property_change_object (cs->wait_object);
636 unblock_input (); 651 unblock_input ();
637 652
638 bytes_remaining = cs->size; 653 bytes_remaining = cs->size;
@@ -673,6 +688,8 @@ x_reply_selection_request (struct input_event *event,
673 : format_bytes); 688 : format_bytes);
674 XFlush (display); 689 XFlush (display);
675 had_errors_p = x_had_errors_p (display); 690 had_errors_p = x_had_errors_p (display);
691 // See comment above about property_change_reply.
692 set_property_change_object (cs->wait_object);
676 unblock_input (); 693 unblock_input ();
677 694
678 if (had_errors_p) break; 695 if (had_errors_p) break;
@@ -1059,14 +1076,11 @@ wait_for_property_change (struct prop_location *location)
1059{ 1076{
1060 ptrdiff_t count = SPECPDL_INDEX (); 1077 ptrdiff_t count = SPECPDL_INDEX ();
1061 1078
1062 if (property_change_reply_object)
1063 emacs_abort ();
1064
1065 /* Make sure to do unexpect_property_change if we quit or err. */ 1079 /* Make sure to do unexpect_property_change if we quit or err. */
1066 record_unwind_protect_ptr (wait_for_property_change_unwind, location); 1080 record_unwind_protect_ptr (wait_for_property_change_unwind, location);
1067 1081
1068 XSETCAR (property_change_reply, Qnil); 1082 /* See comment in x_reply_selection_request about setting
1069 property_change_reply_object = location; 1083 property_change_reply. Do not do it here. */
1070 1084
1071 /* If the event we are waiting for arrives beyond here, it will set 1085 /* If the event we are waiting for arrives beyond here, it will set
1072 property_change_reply, because property_change_reply_object says so. */ 1086 property_change_reply, because property_change_reply_object says so. */
@@ -1381,6 +1395,8 @@ receive_incremental_selection (struct x_display_info *dpyinfo,
1381 wait_object = expect_property_change (display, window, property, 1395 wait_object = expect_property_change (display, window, property,
1382 PropertyNewValue); 1396 PropertyNewValue);
1383 XFlush (display); 1397 XFlush (display);
1398 // See comment in x_reply_selection_request about property_change_reply.
1399 set_property_change_object (wait_object);
1384 unblock_input (); 1400 unblock_input ();
1385 1401
1386 while (true) 1402 while (true)
@@ -1419,6 +1435,8 @@ receive_incremental_selection (struct x_display_info *dpyinfo,
1419 XDeleteProperty (display, window, property); 1435 XDeleteProperty (display, window, property);
1420 wait_object = expect_property_change (display, window, property, 1436 wait_object = expect_property_change (display, window, property,
1421 PropertyNewValue); 1437 PropertyNewValue);
1438 // See comment in x_reply_selection_request about property_change_reply.
1439 set_property_change_object (wait_object);
1422 XFlush (display); 1440 XFlush (display);
1423 unblock_input (); 1441 unblock_input ();
1424 1442
diff --git a/src/xterm.c b/src/xterm.c
index 6e7ef366d5f..3d3e0a70cfa 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -1955,7 +1955,7 @@ x_draw_glyphless_glyph_string_foreground (struct glyph_string *s)
1955 { 1955 {
1956 sprintf (buf, "%0*X", 1956 sprintf (buf, "%0*X",
1957 glyph->u.glyphless.ch < 0x10000 ? 4 : 6, 1957 glyph->u.glyphless.ch < 0x10000 ? 4 : 6,
1958 glyph->u.glyphless.ch); 1958 glyph->u.glyphless.ch + 0u);
1959 str = buf; 1959 str = buf;
1960 } 1960 }
1961 1961
@@ -2048,9 +2048,9 @@ x_alloc_lighter_color_for_widget (Widget widget, Display *display, Colormap cmap
2048 2048
2049static XtConvertArgRec cvt_string_to_pixel_args[] = 2049static XtConvertArgRec cvt_string_to_pixel_args[] =
2050 { 2050 {
2051 {XtWidgetBaseOffset, (XtPointer) XtOffset (Widget, core.screen), 2051 {XtWidgetBaseOffset, (XtPointer) offsetof (WidgetRec, core.screen),
2052 sizeof (Screen *)}, 2052 sizeof (Screen *)},
2053 {XtWidgetBaseOffset, (XtPointer) XtOffset (Widget, core.colormap), 2053 {XtWidgetBaseOffset, (XtPointer) offsetof (WidgetRec, core.colormap),
2054 sizeof (Colormap)} 2054 sizeof (Colormap)}
2055 }; 2055 };
2056 2056