aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2014-04-16 12:43:46 -0700
committerPaul Eggert2014-04-16 12:43:46 -0700
commit290d7ac277986bd118e594a8100b3f40e4492cb1 (patch)
treed63a3aa61cac577dd119665edaffe2def8d194e2 /src
parent37eccff4f72c5a36dcd4b89d417b0047aab84e50 (diff)
parentb262bde327db2cd9b2f01f2d3ed946d0b188cb9d (diff)
downloademacs-290d7ac277986bd118e594a8100b3f40e4492cb1.tar.gz
emacs-290d7ac277986bd118e594a8100b3f40e4492cb1.zip
Merge from emacs-24; up to 2014-04-16T15:28:26Z!monnier@iro.umontreal.ca
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog99
-rw-r--r--src/alloc.c4
-rw-r--r--src/buffer.c11
-rw-r--r--src/bytecode.c17
-rw-r--r--src/callproc.c20
-rw-r--r--src/conf_post.h13
-rw-r--r--src/data.c2
-rw-r--r--src/dired.c4
-rw-r--r--src/emacs.c7
-rw-r--r--src/font.h4
-rw-r--r--src/insdel.c32
-rw-r--r--src/keyboard.c15
-rw-r--r--src/lisp.h3
-rw-r--r--src/menu.c5
-rw-r--r--src/msdos.c127
-rw-r--r--src/msdos.h17
-rw-r--r--src/process.c50
-rw-r--r--src/sysdep.c8
-rw-r--r--src/term.c4
-rw-r--r--src/termhooks.h2
-rw-r--r--src/unexcoff.c13
-rw-r--r--src/w32term.c2
-rw-r--r--src/window.c7
23 files changed, 382 insertions, 84 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 118ca723a5d..b3cc3ff32ec 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,100 @@
12014-04-16 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * window.c (save_window_save): Lookup window_point_insertion_type in
4 the right buffer (bug#15457).
5 (Qwindow_point_insertion_type): New var.
6 (syms_of_window): Initialize it.
7
82014-04-16 Eli Zaretskii <eliz@gnu.org>
9
10 * unexcoff.c [MSDOS]: Include libc/atexit.h.
11 (copy_text_and_data): Zero out the atexit chain pointer before
12 dumping Emacs.
13
14 * termhooks.h (encode_terminal_code): Update prototype.
15
16 * term.c (encode_terminal_code) [DOS_NT]: Make it externally
17 visible for all DOS_NT ports, not just WINDOWSNT.
18 (syms_of_term) [!MSDOS]: Don't define 'tty-menu-*' symbols on MSDOS.
19
20 * sysdep.c (emacs_sigaction_init, init_signals): Don't use SIGCHLD
21 unless it is defined.
22 (emacs_pipe) [MSDOS]: Redirect to 'pipe'.
23
24 * process.c (close_on_exec, accept4, process_socket): Move into
25 the "ifdef subprocesses" part.
26 (catch_child_signal): Condition by "ifdef subprocesses".
27 (syms_of_process) <Qinternal_default_process_sentinel>
28 <Qinternal_default_process_filter>: Condition by "ifdef subprocesses".
29
30 * msdos.h: Add prototypes for new functions.
31 (EINPROGRESS): Define.
32 (O_CLOEXEC): Define to zero.
33
34 * msdos.c (check_window_system): Remove unnecessary an
35 incompatible duplicate function.
36 (sys_opendir, readlinkat, faccessat, fstatat, unsetenv):
37 New functions in support of new functionality.
38
39 * menu.c (single_menu_item): Add visual indication of submenu
40 also for menus on MSDOS frames.
41 (Fx_popup_menu) [!MSDOS]: Do not call tty_menu_show on MSDOS.
42
43 * lisp.h (CHECK_PROCESS) [!subprocesses]: Do not define
44 when async subprocesses aren't supported.
45
46 * font.h (FONT_WIDTH) [MSDOS]: MSDOS-specific definition.
47
48 * emacs.c (close_output_streams): Zero out errno before calling
49 close_stream.
50
51 * dired.c [MSDOS]: Include msdos.h.
52
53 * conf_post.h (opendir) [MSDOS]: Redirect to sys_opendir.
54 (DATA_START) [MSDOS]: Define.
55 (SYSTEM_PURESIZE_EXTRA) [MSDOS]: Enlarge by 25K.
56
57 * callproc.c (block_child_signal, unblock_child_signal) [MSDOS]:
58 Ifdef away for MSDOS.
59 (record_kill_process) [MSDOS]: Ifdef away the entire body for MSDOS.
60 (call_process_cleanup) [MSDOS]: Ifdef away portions not relevant
61 for MSDOS.
62 (call_process) [MSDOS]: Fix call sequence of dostounix_filename.
63 Use temporary file template that is compatible with mkostemp.
64 Move vfork-related portions under #ifndef MSDOS.
65 (syms_of_callproc): Unify templates of MSDOS and WINDOWSNT.
66
672014-04-16 Stefan Monnier <monnier@iro.umontreal.ca>
68
69 * buffer.c (Foverlays_at): Add argument `sorted'.
70
712014-04-16 Eli Zaretskii <eliz@gnu.org>
72
73 * insdel.c (invalidate_buffer_caches): When deleting or replacing
74 text, invalidate the bidi_paragraph_cache upto and including the
75 preceding newline.
76
772014-04-16 Paul Eggert <eggert@cs.ucla.edu>
78
79 Port to IRIX 6.5 (Bug#9684).
80 * conf_post.h (INET6) [IRIX6_5]: Define.
81 (HAVE_GETADDRINFO) [IRIX6_5]: Undef.
82 * data.c (BITS_PER_ULL): Don't assume ULLONG_MAX is defined.
83
842014-04-16 Eli Zaretskii <eliz@gnu.org>
85
86 * keyboard.c (Fopen_dribble_file): Encode the dribble file-name
87 before passing it to system APIs.
88
892014-04-16 Stefan Monnier <monnier@iro.umontreal.ca>
90
91 * bytecode.c (exec_byte_code): Rework the volatiles. Most importantly,
92 make sure stack.byte_string_start is not de-adjusted by pushhandler.
93
942014-04-16 Paul Eggert <eggert@cs.ucla.edu>
95
96 * keyboard.c (Fopen_dribble_file): Avoid some races. (Bug#17187)
97
12014-04-15 Paul Eggert <eggert@cs.ucla.edu> 982014-04-15 Paul Eggert <eggert@cs.ucla.edu>
2 99
3 Remove DATA_SEG_BITS. 100 Remove DATA_SEG_BITS.
@@ -280,7 +377,7 @@
280 (adjust_after_replace): 377 (adjust_after_replace):
281 (replace_range): Pass value for new record_markers arg to 378 (replace_range): Pass value for new record_markers arg to
282 delete_record. 379 delete_record.
283 * undo.c (record_marker_adjustment): Renamed to 380 * undo.c (record_marker_adjustment): Rename to
284 record_marker_adjustments and made static. 381 record_marker_adjustments and made static.
285 (record_delete): Check record_markers arg and call 382 (record_delete): Check record_markers arg and call
286 record_marker_adjustments. 383 record_marker_adjustments.
diff --git a/src/alloc.c b/src/alloc.c
index 8b7c8aab535..6bee0c990c4 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -2685,7 +2685,9 @@ DEFUN ("make-list", Fmake_list, Smake_list, 2, 2, 0,
2685 ***********************************************************************/ 2685 ***********************************************************************/
2686 2686
2687/* Sometimes a vector's contents are merely a pointer internally used 2687/* Sometimes a vector's contents are merely a pointer internally used
2688 in vector allocation code. Usually you don't want to touch this. */ 2688 in vector allocation code. On the rare platforms where a null
2689 pointer cannot be tagged, represent it with a Lisp 0.
2690 Usually you don't want to touch this. */
2689 2691
2690static struct Lisp_Vector * 2692static struct Lisp_Vector *
2691next_vector (struct Lisp_Vector *v) 2693next_vector (struct Lisp_Vector *v)
diff --git a/src/buffer.c b/src/buffer.c
index a22c6d7dd54..6a1a74ac1ec 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -4163,9 +4163,10 @@ OVERLAY. */)
4163} 4163}
4164 4164
4165 4165
4166DEFUN ("overlays-at", Foverlays_at, Soverlays_at, 1, 1, 0, 4166DEFUN ("overlays-at", Foverlays_at, Soverlays_at, 1, 2, 0,
4167 doc: /* Return a list of the overlays that contain the character at POS. */) 4167 doc: /* Return a list of the overlays that contain the character at POS.
4168 (Lisp_Object pos) 4168If SORTED is non-nil, then sort them by decreasing priority. */)
4169 (Lisp_Object pos, Lisp_Object sorted)
4169{ 4170{
4170 ptrdiff_t len, noverlays; 4171 ptrdiff_t len, noverlays;
4171 Lisp_Object *overlay_vec; 4172 Lisp_Object *overlay_vec;
@@ -4185,6 +4186,10 @@ DEFUN ("overlays-at", Foverlays_at, Soverlays_at, 1, 1, 0,
4185 noverlays = overlays_at (XINT (pos), 1, &overlay_vec, &len, 4186 noverlays = overlays_at (XINT (pos), 1, &overlay_vec, &len,
4186 NULL, NULL, 0); 4187 NULL, NULL, 0);
4187 4188
4189 if (!NILP (sorted))
4190 noverlays = sort_overlays (overlay_vec, noverlays,
4191 WINDOWP (sorted) ? XWINDOW (sorted) : NULL);
4192
4188 /* Make a list of them all. */ 4193 /* Make a list of them all. */
4189 result = Flist (noverlays, overlay_vec); 4194 result = Flist (noverlays, overlay_vec);
4190 4195
diff --git a/src/bytecode.c b/src/bytecode.c
index 0ea646a9741..f1bdfd9d9c5 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -501,7 +501,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
501 Lisp_Object args_template, ptrdiff_t nargs, Lisp_Object *args) 501 Lisp_Object args_template, ptrdiff_t nargs, Lisp_Object *args)
502{ 502{
503 ptrdiff_t count = SPECPDL_INDEX (); 503 ptrdiff_t count = SPECPDL_INDEX ();
504 ptrdiff_t volatile count_volatile;
505#ifdef BYTE_CODE_METER 504#ifdef BYTE_CODE_METER
506 int volatile this_op = 0; 505 int volatile this_op = 0;
507 int prev_op; 506 int prev_op;
@@ -509,14 +508,12 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
509 int op; 508 int op;
510 /* Lisp_Object v1, v2; */ 509 /* Lisp_Object v1, v2; */
511 Lisp_Object *vectorp; 510 Lisp_Object *vectorp;
512 Lisp_Object *volatile vectorp_volatile;
513#ifdef BYTE_CODE_SAFE 511#ifdef BYTE_CODE_SAFE
514 ptrdiff_t volatile const_length; 512 ptrdiff_t const_length;
515 Lisp_Object *volatile stacke; 513 Lisp_Object *stacke;
516 ptrdiff_t volatile bytestr_length; 514 ptrdiff_t bytestr_length;
517#endif 515#endif
518 struct byte_stack stack; 516 struct byte_stack stack;
519 struct byte_stack volatile stack_volatile;
520 Lisp_Object *top; 517 Lisp_Object *top;
521 Lisp_Object result; 518 Lisp_Object result;
522 enum handlertype type; 519 enum handlertype type;
@@ -1122,9 +1119,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1122 PUSH_HANDLER (c, tag, type); 1119 PUSH_HANDLER (c, tag, type);
1123 c->bytecode_dest = dest; 1120 c->bytecode_dest = dest;
1124 c->bytecode_top = top; 1121 c->bytecode_top = top;
1125 count_volatile = count;
1126 stack_volatile = stack;
1127 vectorp_volatile = vectorp;
1128 1122
1129 if (sys_setjmp (c->jmp)) 1123 if (sys_setjmp (c->jmp))
1130 { 1124 {
@@ -1135,12 +1129,11 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1135 handlerlist = c->next; 1129 handlerlist = c->next;
1136 PUSH (c->val); 1130 PUSH (c->val);
1137 CHECK_RANGE (dest); 1131 CHECK_RANGE (dest);
1138 stack = stack_volatile; 1132 /* Might have been re-set by longjmp! */
1133 stack.byte_string_start = SDATA (stack.byte_string);
1139 stack.pc = stack.byte_string_start + dest; 1134 stack.pc = stack.byte_string_start + dest;
1140 } 1135 }
1141 1136
1142 count = count_volatile;
1143 vectorp = vectorp_volatile;
1144 NEXT; 1137 NEXT;
1145 } 1138 }
1146 1139
diff --git a/src/callproc.c b/src/callproc.c
index 2147c173655..a2c52e5b5ba 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -105,6 +105,8 @@ enum
105 105
106static Lisp_Object call_process (ptrdiff_t, Lisp_Object *, int, ptrdiff_t); 106static Lisp_Object call_process (ptrdiff_t, Lisp_Object *, int, ptrdiff_t);
107 107
108
109#ifndef MSDOS
108/* Block SIGCHLD. */ 110/* Block SIGCHLD. */
109 111
110void 112void
@@ -124,6 +126,8 @@ unblock_child_signal (sigset_t const *oldset)
124 pthread_sigmask (SIG_SETMASK, oldset, 0); 126 pthread_sigmask (SIG_SETMASK, oldset, 0);
125} 127}
126 128
129#endif /* !MSDOS */
130
127/* Return the current buffer's working directory, or the home 131/* Return the current buffer's working directory, or the home
128 directory if it's unreachable, as a string suitable for a system call. 132 directory if it's unreachable, as a string suitable for a system call.
129 Signal an error if the result would not be an accessible directory. */ 133 Signal an error if the result would not be an accessible directory. */
@@ -162,6 +166,7 @@ encode_current_directory (void)
162void 166void
163record_kill_process (struct Lisp_Process *p, Lisp_Object tempfile) 167record_kill_process (struct Lisp_Process *p, Lisp_Object tempfile)
164{ 168{
169#ifndef MSDOS
165 sigset_t oldset; 170 sigset_t oldset;
166 block_child_signal (&oldset); 171 block_child_signal (&oldset);
167 172
@@ -173,6 +178,7 @@ record_kill_process (struct Lisp_Process *p, Lisp_Object tempfile)
173 } 178 }
174 179
175 unblock_child_signal (&oldset); 180 unblock_child_signal (&oldset);
181#endif /* !MSDOS */
176} 182}
177 183
178/* Clean up files, file descriptors and processes created by Fcall_process. */ 184/* Clean up files, file descriptors and processes created by Fcall_process. */
@@ -212,6 +218,7 @@ call_process_cleanup (Lisp_Object buffer)
212{ 218{
213 Fset_buffer (buffer); 219 Fset_buffer (buffer);
214 220
221#ifndef MSDOS
215 if (synch_process_pid) 222 if (synch_process_pid)
216 { 223 {
217 kill (-synch_process_pid, SIGINT); 224 kill (-synch_process_pid, SIGINT);
@@ -223,6 +230,7 @@ call_process_cleanup (Lisp_Object buffer)
223 immediate_quit = 0; 230 immediate_quit = 0;
224 message1 ("Waiting for process to die...done"); 231 message1 ("Waiting for process to die...done");
225 } 232 }
233#endif /* !MSDOS */
226} 234}
227 235
228#ifdef DOS_NT 236#ifdef DOS_NT
@@ -520,10 +528,10 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd,
520 char const *outf = tmpdir ? tmpdir : ""; 528 char const *outf = tmpdir ? tmpdir : "";
521 tempfile = alloca (strlen (outf) + 20); 529 tempfile = alloca (strlen (outf) + 20);
522 strcpy (tempfile, outf); 530 strcpy (tempfile, outf);
523 dostounix_filename (tempfile, 0); 531 dostounix_filename (tempfile);
524 if (*tempfile == '\0' || tempfile[strlen (tempfile) - 1] != '/') 532 if (*tempfile == '\0' || tempfile[strlen (tempfile) - 1] != '/')
525 strcat (tempfile, "/"); 533 strcat (tempfile, "/");
526 strcat (tempfile, "detmp.XXX"); 534 strcat (tempfile, "emXXXXXX");
527 mktemp (tempfile); 535 mktemp (tempfile);
528 if (!*tempfile) 536 if (!*tempfile)
529 report_file_error ("Opening process output file", Qnil); 537 report_file_error ("Opening process output file", Qnil);
@@ -712,8 +720,6 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd,
712 unblock_child_signal (&oldset); 720 unblock_child_signal (&oldset);
713 unblock_input (); 721 unblock_input ();
714 722
715#endif /* not MSDOS */
716
717 if (pid < 0) 723 if (pid < 0)
718 report_file_errno ("Doing vfork", Qnil, child_errno); 724 report_file_errno ("Doing vfork", Qnil, child_errno);
719 725
@@ -728,6 +734,8 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd,
728 emacs_close (filefd); 734 emacs_close (filefd);
729 clear_unwind_protect (count - 1); 735 clear_unwind_protect (count - 1);
730 736
737#endif /* not MSDOS */
738
731 if (INTEGERP (buffer)) 739 if (INTEGERP (buffer))
732 return unbind_to (count, Qnil); 740 return unbind_to (count, Qnil);
733 741
@@ -1674,10 +1682,8 @@ syms_of_callproc (void)
1674{ 1682{
1675#ifndef DOS_NT 1683#ifndef DOS_NT
1676 Vtemp_file_name_pattern = build_string ("emacsXXXXXX"); 1684 Vtemp_file_name_pattern = build_string ("emacsXXXXXX");
1677#elif defined (WINDOWSNT) 1685#else /* DOS_NT */
1678 Vtemp_file_name_pattern = build_string ("emXXXXXX"); 1686 Vtemp_file_name_pattern = build_string ("emXXXXXX");
1679#else
1680 Vtemp_file_name_pattern = build_string ("detmp.XXX");
1681#endif 1687#endif
1682 staticpro (&Vtemp_file_name_pattern); 1688 staticpro (&Vtemp_file_name_pattern);
1683 1689
diff --git a/src/conf_post.h b/src/conf_post.h
index 05abe057afd..e9101ce1c57 100644
--- a/src/conf_post.h
+++ b/src/conf_post.h
@@ -95,7 +95,8 @@ typedef bool bool_bf;
95#ifdef emacs 95#ifdef emacs
96char *_getpty(); 96char *_getpty();
97#endif 97#endif
98 98#define INET6 /* Needed for struct sockaddr_in6. */
99#undef HAVE_GETADDRINFO /* IRIX has getaddrinfo but not struct addrinfo. */
99#endif /* IRIX6_5 */ 100#endif /* IRIX6_5 */
100 101
101#ifdef MSDOS 102#ifdef MSDOS
@@ -116,6 +117,11 @@ You lose; /* Emacs for DOS must be compiled with DJGPP */
116#else 117#else
117# define lstat stat 118# define lstat stat
118#endif 119#endif
120
121/* We must intercept 'opendir' calls to stash away the directory name,
122 so we could reuse it in realinkat, see msdos.c. */
123#define opendir sys_opendir
124
119/* The "portable" definition of _GL_INLINE on config.h does not work 125/* The "portable" definition of _GL_INLINE on config.h does not work
120 with DJGPP GCC 3.4.4: it causes unresolved externals in sysdep.c, 126 with DJGPP GCC 3.4.4: it causes unresolved externals in sysdep.c,
121 although lib/execinfo.h is included and the inline functions there 127 although lib/execinfo.h is included and the inline functions there
@@ -127,6 +133,9 @@ You lose; /* Emacs for DOS must be compiled with DJGPP */
127 133
128#define emacs_raise(sig) msdos_fatal_signal (sig) 134#define emacs_raise(sig) msdos_fatal_signal (sig)
129 135
136/* DATA_START is needed by vm-limit.c and unexcoff.c. */
137#define DATA_START (&etext + 1)
138
130/* Define one of these for easier conditionals. */ 139/* Define one of these for easier conditionals. */
131#ifdef HAVE_X_WINDOWS 140#ifdef HAVE_X_WINDOWS
132/* We need a little extra space, see ../../lisp/loadup.el and the 141/* We need a little extra space, see ../../lisp/loadup.el and the
@@ -143,7 +152,7 @@ You lose; /* Emacs for DOS must be compiled with DJGPP */
143 directory tree). Given the unknown policy of different DPMI 152 directory tree). Given the unknown policy of different DPMI
144 hosts regarding loading of untouched pages, I'm not going to risk 153 hosts regarding loading of untouched pages, I'm not going to risk
145 enlarging Emacs footprint by another 100+ KBytes. */ 154 enlarging Emacs footprint by another 100+ KBytes. */
146#define SYSTEM_PURESIZE_EXTRA (-170000+65000) 155#define SYSTEM_PURESIZE_EXTRA (-170000+90000)
147#endif 156#endif
148#endif /* MSDOS */ 157#endif /* MSDOS */
149 158
diff --git a/src/data.c b/src/data.c
index dd220987fd7..965ddd215f5 100644
--- a/src/data.c
+++ b/src/data.c
@@ -2987,7 +2987,7 @@ bool_vector_spare_mask (EMACS_INT nr_bits)
2987/* Info about unsigned long long, falling back on unsigned long 2987/* Info about unsigned long long, falling back on unsigned long
2988 if unsigned long long is not available. */ 2988 if unsigned long long is not available. */
2989 2989
2990#if HAVE_UNSIGNED_LONG_LONG_INT 2990#if HAVE_UNSIGNED_LONG_LONG_INT && defined ULLONG_MAX
2991enum { BITS_PER_ULL = CHAR_BIT * sizeof (unsigned long long) }; 2991enum { BITS_PER_ULL = CHAR_BIT * sizeof (unsigned long long) };
2992# define ULL_MAX ULLONG_MAX 2992# define ULL_MAX ULLONG_MAX
2993#else 2993#else
diff --git a/src/dired.c b/src/dired.c
index d8da45bf776..d3fe5b4943d 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -47,6 +47,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
47#include "regex.h" 47#include "regex.h"
48#include "blockinput.h" 48#include "blockinput.h"
49 49
50#ifdef MSDOS
51#include "msdos.h" /* for fstatat */
52#endif
53
50static Lisp_Object Qdirectory_files; 54static Lisp_Object Qdirectory_files;
51static Lisp_Object Qdirectory_files_and_attributes; 55static Lisp_Object Qdirectory_files_and_attributes;
52static Lisp_Object Qfile_name_completion; 56static Lisp_Object Qfile_name_completion;
diff --git a/src/emacs.c b/src/emacs.c
index deebb2280c7..9cfc09469c2 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -690,6 +690,11 @@ void (*__malloc_initialize_hook) (void) EXTERNALLY_VISIBLE = malloc_initialize_h
690static void 690static void
691close_output_streams (void) 691close_output_streams (void)
692{ 692{
693 int err = errno;
694
695 /* close_stream checks errno, so make sure it doesn't inherit some
696 random value. */
697 errno = 0;
693 if (close_stream (stdout) != 0) 698 if (close_stream (stdout) != 0)
694 { 699 {
695 emacs_perror ("Write error to standard output"); 700 emacs_perror ("Write error to standard output");
@@ -698,6 +703,8 @@ close_output_streams (void)
698 703
699 if (close_stream (stderr) != 0) 704 if (close_stream (stderr) != 0)
700 _exit (EXIT_FAILURE); 705 _exit (EXIT_FAILURE);
706
707 errno = err;
701} 708}
702 709
703/* ARGSUSED */ 710/* ARGSUSED */
diff --git a/src/font.h b/src/font.h
index 93d514fe665..e2e36460583 100644
--- a/src/font.h
+++ b/src/font.h
@@ -236,7 +236,11 @@ enum font_property_index
236#define FONT_SET_STYLE(font, prop, val) \ 236#define FONT_SET_STYLE(font, prop, val) \
237 ASET ((font), prop, make_number (font_style_to_value (prop, val, true))) 237 ASET ((font), prop, make_number (font_style_to_value (prop, val, true)))
238 238
239#ifndef MSDOS
239#define FONT_WIDTH(f) ((f)->max_width) 240#define FONT_WIDTH(f) ((f)->max_width)
241#else
242#define FONT_WIDTH(f) 1
243#endif
240#define FONT_HEIGHT(f) ((f)->height) 244#define FONT_HEIGHT(f) ((f)->height)
241#define FONT_BASE(f) ((f)->ascent) 245#define FONT_BASE(f) ((f)->ascent)
242#define FONT_DESCENT(f) ((f)->descent) 246#define FONT_DESCENT(f) ((f)->descent)
diff --git a/src/insdel.c b/src/insdel.c
index 15cdaf6f910..82896758a15 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -1858,9 +1858,35 @@ invalidate_buffer_caches (struct buffer *buf, ptrdiff_t start, ptrdiff_t end)
1858 buf->width_run_cache, 1858 buf->width_run_cache,
1859 start - BUF_BEG (buf), BUF_Z (buf) - end); 1859 start - BUF_BEG (buf), BUF_Z (buf) - end);
1860 if (buf->bidi_paragraph_cache) 1860 if (buf->bidi_paragraph_cache)
1861 invalidate_region_cache (buf, 1861 {
1862 buf->bidi_paragraph_cache, 1862 if (start != end
1863 start - BUF_BEG (buf), BUF_Z (buf) - end); 1863 && start > BUF_BEG (buf))
1864 {
1865 /* If we are deleting or replacing characters, we could
1866 create a paragraph start, because all of the characters
1867 from START to the beginning of START's line are
1868 whitespace. Therefore, we must extend the region to be
1869 invalidated up to the newline before START. */
1870 ptrdiff_t line_beg = start;
1871 ptrdiff_t start_byte = buf_charpos_to_bytepos (buf, start);
1872
1873 if (BUF_FETCH_BYTE (buf, start_byte - 1) != '\n')
1874 {
1875 struct buffer *old = current_buffer;
1876
1877 set_buffer_internal (buf);
1878
1879 line_beg = find_newline_no_quit (start, start_byte, -1,
1880 &start_byte);
1881 set_buffer_internal (old);
1882 }
1883 if (line_beg > BUF_BEG (buf))
1884 start = line_beg - 1;
1885 }
1886 invalidate_region_cache (buf,
1887 buf->bidi_paragraph_cache,
1888 start - BUF_BEG (buf), BUF_Z (buf) - end);
1889 }
1864} 1890}
1865 1891
1866/* These macros work with an argument named `preserve_ptr' 1892/* These macros work with an argument named `preserve_ptr'
diff --git a/src/keyboard.c b/src/keyboard.c
index ddfbc9a567b..678cf5abcbd 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -10084,16 +10084,13 @@ This may include sensitive information such as passwords. */)
10084 if (!NILP (file)) 10084 if (!NILP (file))
10085 { 10085 {
10086 int fd; 10086 int fd;
10087 Lisp_Object encfile;
10088
10087 file = Fexpand_file_name (file, Qnil); 10089 file = Fexpand_file_name (file, Qnil);
10088 /* This isn't robust, since eg file could be created after we 10090 encfile = ENCODE_FILE (file);
10089 check whether it exists but before emacs_open. 10091 fd = emacs_open (SSDATA (encfile), O_WRONLY | O_CREAT | O_EXCL, 0600);
10090 Feel free to improve it, but this is not critical. (Bug#17187) */ 10092 if (fd < 0 && errno == EEXIST && unlink (SSDATA (encfile)) == 0)
10091 if (! NILP (Ffile_exists_p (file))) 10093 fd = emacs_open (SSDATA (encfile), O_WRONLY | O_CREAT | O_EXCL, 0600);
10092 {
10093 if (chmod (SSDATA (file), 0600) < 0)
10094 report_file_error ("Doing chmod", file);
10095 }
10096 fd = emacs_open (SSDATA (file), O_WRONLY | O_CREAT | O_TRUNC, 0600);
10097 dribble = fd < 0 ? 0 : fdopen (fd, "w"); 10094 dribble = fd < 0 ? 0 : fdopen (fd, "w");
10098 if (dribble == 0) 10095 if (dribble == 0)
10099 report_file_error ("Opening dribble", file); 10096 report_file_error ("Opening dribble", file);
diff --git a/src/lisp.h b/src/lisp.h
index 3e4ab174546..6ef0f83aea4 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2527,11 +2527,13 @@ CHECK_WINDOW (Lisp_Object x)
2527{ 2527{
2528 CHECK_TYPE (WINDOWP (x), Qwindowp, x); 2528 CHECK_TYPE (WINDOWP (x), Qwindowp, x);
2529} 2529}
2530#ifdef subprocesses
2530INLINE void 2531INLINE void
2531CHECK_PROCESS (Lisp_Object x) 2532CHECK_PROCESS (Lisp_Object x)
2532{ 2533{
2533 CHECK_TYPE (PROCESSP (x), Qprocessp, x); 2534 CHECK_TYPE (PROCESSP (x), Qprocessp, x);
2534} 2535}
2536#endif
2535INLINE void 2537INLINE void
2536CHECK_NATNUM (Lisp_Object x) 2538CHECK_NATNUM (Lisp_Object x)
2537{ 2539{
@@ -4136,7 +4138,6 @@ extern bool running_asynch_code;
4136 4138
4137/* Defined in process.c. */ 4139/* Defined in process.c. */
4138extern Lisp_Object QCtype, Qlocal; 4140extern Lisp_Object QCtype, Qlocal;
4139extern Lisp_Object Qprocessp;
4140extern void kill_buffer_processes (Lisp_Object); 4141extern void kill_buffer_processes (Lisp_Object);
4141extern bool wait_reading_process_output (intmax_t, int, int, bool, 4142extern bool wait_reading_process_output (intmax_t, int, int, bool,
4142 Lisp_Object, 4143 Lisp_Object,
diff --git a/src/menu.c b/src/menu.c
index 9c08ff17665..468f2814eb4 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -415,7 +415,8 @@ single_menu_item (Lisp_Object key, Lisp_Object item, Lisp_Object dummy, void *sk
415 item_string = concat2 (prefix, item_string); 415 item_string = concat2 (prefix, item_string);
416 } 416 }
417 417
418 if (FRAME_TERMCAP_P (XFRAME (Vmenu_updating_frame)) 418 if ((FRAME_TERMCAP_P (XFRAME (Vmenu_updating_frame))
419 || FRAME_MSDOS_P (XFRAME (Vmenu_updating_frame)))
419 && !NILP (map)) 420 && !NILP (map))
420 /* Indicate visually that this is a submenu. */ 421 /* Indicate visually that this is a submenu. */
421 item_string = concat2 (item_string, build_string (" >")); 422 item_string = concat2 (item_string, build_string (" >"));
@@ -1442,6 +1443,7 @@ no quit occurs and `x-popup-menu' returns nil. */)
1442 keymaps, title, &error_name); 1443 keymaps, title, &error_name);
1443 else 1444 else
1444#endif 1445#endif
1446#ifndef MSDOS
1445 if (FRAME_TERMCAP_P (f)) 1447 if (FRAME_TERMCAP_P (f))
1446 { 1448 {
1447 ptrdiff_t count1 = SPECPDL_INDEX (); 1449 ptrdiff_t count1 = SPECPDL_INDEX ();
@@ -1453,6 +1455,7 @@ no quit occurs and `x-popup-menu' returns nil. */)
1453 kbd_menu_navigation, &error_name); 1455 kbd_menu_navigation, &error_name);
1454 unbind_to (count1, Qnil); 1456 unbind_to (count1, Qnil);
1455 } 1457 }
1458#endif
1456 1459
1457#ifdef HAVE_NS 1460#ifdef HAVE_NS
1458 unbind_to (specpdl_count, Qnil); 1461 unbind_to (specpdl_count, Qnil);
diff --git a/src/msdos.c b/src/msdos.c
index 6b677bb2f02..21794341222 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -50,6 +50,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
50#include <unistd.h> /* for chdir, dup, dup2, etc. */ 50#include <unistd.h> /* for chdir, dup, dup2, etc. */
51#include <dir.h> /* for getdisk */ 51#include <dir.h> /* for getdisk */
52#pragma pack(0) /* dir.h does a pack(4), which isn't GCC's default */ 52#pragma pack(0) /* dir.h does a pack(4), which isn't GCC's default */
53#undef opendir
54#include <dirent.h> /* for opendir */
53#include <fcntl.h> 55#include <fcntl.h>
54#include <io.h> /* for setmode */ 56#include <io.h> /* for setmode */
55#include <dpmi.h> /* for __dpmi_xxx stuff */ 57#include <dpmi.h> /* for __dpmi_xxx stuff */
@@ -1883,18 +1885,6 @@ dos_get_saved_screen (char **screen, int *rows, int *cols)
1883#endif 1885#endif
1884} 1886}
1885 1887
1886#ifndef HAVE_X_WINDOWS
1887
1888/* We are not X, but we can emulate it well enough for our needs... */
1889void
1890check_window_system (void)
1891{
1892 if (! FRAME_MSDOS_P (SELECTED_FRAME ()))
1893 error ("Not running under a window system");
1894}
1895
1896#endif
1897
1898 1888
1899/* ----------------------- Keyboard control ---------------------- 1889/* ----------------------- Keyboard control ----------------------
1900 * 1890 *
@@ -3875,6 +3865,9 @@ int setpgid (int pid, int pgid) { return 0; }
3875int setpriority (int x, int y, int z) { return 0; } 3865int setpriority (int x, int y, int z) { return 0; }
3876pid_t setsid (void) { return 0; } 3866pid_t setsid (void) { return 0; }
3877 3867
3868
3869/* Gnulib support and emulation. */
3870
3878#if __DJGPP__ == 2 && __DJGPP_MINOR__ < 4 3871#if __DJGPP__ == 2 && __DJGPP_MINOR__ < 4
3879ssize_t 3872ssize_t
3880readlink (const char *name, char *dummy1, size_t dummy2) 3873readlink (const char *name, char *dummy1, size_t dummy2)
@@ -3886,6 +3879,38 @@ readlink (const char *name, char *dummy1, size_t dummy2)
3886} 3879}
3887#endif 3880#endif
3888 3881
3882/* dir_pathname is set by sys_opendir and used in readlinkat and in
3883 fstatat, when they get a special FD of zero, which means use the
3884 last directory opened by opendir. */
3885static char dir_pathname[MAXPATHLEN];
3886DIR *
3887sys_opendir (const char *dirname)
3888{
3889 _fixpath (dirname, dir_pathname);
3890 return opendir (dirname);
3891}
3892
3893ssize_t
3894readlinkat (int fd, char const *name, char *buffer, size_t buffer_size)
3895{
3896 /* Rely on a hack: an open directory is modeled as file descriptor 0,
3897 as in fstatat. FIXME: Add proper support for readlinkat. */
3898 char fullname[MAXPATHLEN];
3899
3900 if (fd != AT_FDCWD)
3901 {
3902 if (strlen (dir_pathname) + strlen (name) + 1 >= MAXPATHLEN)
3903 {
3904 errno = ENAMETOOLONG;
3905 return -1;
3906 }
3907 sprintf (fullname, "%s/%s", dir_pathname, name);
3908 name = fullname;
3909 }
3910
3911 return readlink (name, buffer, buffer_size);
3912}
3913
3889char * 3914char *
3890careadlinkat (int fd, char const *filename, 3915careadlinkat (int fd, char const *filename,
3891 char *buffer, size_t buffer_size, 3916 char *buffer, size_t buffer_size,
@@ -3913,6 +3938,82 @@ careadlinkat (int fd, char const *filename,
3913 return buffer; 3938 return buffer;
3914} 3939}
3915 3940
3941/* Emulate faccessat(2). */
3942int
3943faccessat (int dirfd, const char * path, int mode, int flags)
3944{
3945 /* We silently ignore FLAGS. */
3946 flags = flags;
3947
3948 if (dirfd != AT_FDCWD
3949 && !(IS_DIRECTORY_SEP (path[0])
3950 || IS_DEVICE_SEP (path[1])))
3951 {
3952 errno = EBADF;
3953 return -1;
3954 }
3955
3956 return access (path, mode);
3957}
3958
3959/* Emulate fstatat. */
3960int
3961fstatat (int fd, char const *name, struct stat *st, int flags)
3962{
3963 /* Rely on a hack: an open directory is modeled as file descriptor 0.
3964 This is good enough for the current usage in Emacs, but is fragile.
3965
3966 FIXME: Add proper support for fdopendir, fstatat, readlinkat.
3967 Gnulib does this and can serve as a model. */
3968 char fullname[MAXPATHLEN];
3969
3970 flags = flags;
3971
3972 if (fd != AT_FDCWD)
3973 {
3974 char lastc = dir_pathname[strlen (dir_pathname) - 1];
3975
3976 if (strlen (dir_pathname) + strlen (name) + IS_DIRECTORY_SEP (lastc)
3977 >= MAXPATHLEN)
3978 {
3979 errno = ENAMETOOLONG;
3980 return -1;
3981 }
3982
3983 sprintf (fullname, "%s%s%s",
3984 dir_pathname, IS_DIRECTORY_SEP (lastc) ? "" : "/", name);
3985 name = fullname;
3986 }
3987
3988#if __DJGPP__ > 2 || __DJGPP_MINOR__ > 3
3989 return (flags & AT_SYMLINK_NOFOLLOW) ? lstat (name, st) : stat (name, st);
3990#else
3991 return stat (name, st);
3992#endif
3993}
3994
3995#if __DJGPP__ == 2 && __DJGPP_MINOR__ < 4
3996/* Emulate the Posix unsetenv. DJGPP v2.04 has this in the library. */
3997int
3998unsetenv (const char *name)
3999{
4000 char *var;
4001 size_t name_len;
4002 int retval;
4003
4004 if (name == NULL || *name == '\0' || strchr (name, '=') != NULL)
4005 {
4006 errno = EINVAL;
4007 return -1;
4008 }
4009
4010 /* DJGPP's 'putenv' deletes the entry if it doesn't include '='. */
4011 putenv (name);
4012
4013 return 0;
4014}
4015#endif
4016
3916 4017
3917#if __DJGPP__ == 2 && __DJGPP_MINOR__ < 2 4018#if __DJGPP__ == 2 && __DJGPP_MINOR__ < 2
3918 4019
@@ -4038,7 +4139,7 @@ dos_yield_time_slice (void)
4038/* We don't have to call timer_check here 4139/* We don't have to call timer_check here
4039 because wait_reading_process_output takes care of that. */ 4140 because wait_reading_process_output takes care of that. */
4040int 4141int
4041sys_select (int nfds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, 4142sys_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds,
4042 struct timespec *timeout, void *ignored) 4143 struct timespec *timeout, void *ignored)
4043{ 4144{
4044 int check_input; 4145 int check_input;
diff --git a/src/msdos.h b/src/msdos.h
index 5d5f5df091f..e863c7cea4e 100644
--- a/src/msdos.h
+++ b/src/msdos.h
@@ -41,9 +41,25 @@ void mouse_on (void);
41void mouse_off (void); 41void mouse_off (void);
42void mouse_moveto (int, int); 42void mouse_moveto (int, int);
43 43
44#include <sys/types.h>
45#include <sys/stat.h>
46
44#if __DJGPP__ == 2 && __DJGPP_MINOR__ < 4 47#if __DJGPP__ == 2 && __DJGPP_MINOR__ < 4
45int readlink (const char *, char *, size_t); 48int readlink (const char *, char *, size_t);
46#endif 49#endif
50ssize_t readlinkat (int, const char *, char *, size_t);
51int fstatat (int, char const *, struct stat *, int);
52int unsetenv (const char *);
53
54/* Constants. */
55#define EINPROGRESS 112
56/* Gnulib sets O_CLOEXEC to O_NOINHERIT, which gets in the way when we
57 need to redirect standard handles for subprocesses using temporary
58 files created by mkostemp, see callproc.c. */
59#ifdef O_CLOEXEC
60# undef O_CLOEXEC
61#endif
62#define O_CLOEXEC 0
47 63
48 64
49#ifndef HAVE_X_WINDOWS 65#ifndef HAVE_X_WINDOWS
@@ -83,7 +99,6 @@ extern void x_set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
83#define XMenuSetAEQ (void) 99#define XMenuSetAEQ (void)
84#define XMenuSetFreeze (void) 100#define XMenuSetFreeze (void)
85#define XMenuRecompute (void) 101#define XMenuRecompute (void)
86#define FONT_WIDTH(foo) 1
87#define XM_FAILURE -1 102#define XM_FAILURE -1
88#define XM_SUCCESS 1 103#define XM_SUCCESS 1
89#define XM_NO_SELECT 2 104#define XM_NO_SELECT 2
diff --git a/src/process.c b/src/process.c
index 5a5ce0ce674..fdb0501f9ec 100644
--- a/src/process.c
+++ b/src/process.c
@@ -134,6 +134,29 @@ extern int sys_select (int, fd_set *, fd_set *, fd_set *,
134 struct timespec *, void *); 134 struct timespec *, void *);
135#endif 135#endif
136 136
137/* Work around GCC 4.7.0 bug with strict overflow checking; see
138 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52904>.
139 These lines can be removed once the GCC bug is fixed. */
140#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
141# pragma GCC diagnostic ignored "-Wstrict-overflow"
142#endif
143
144Lisp_Object Qeuid, Qegid, Qcomm, Qstate, Qppid, Qpgrp, Qsess, Qttname, Qtpgid;
145Lisp_Object Qminflt, Qmajflt, Qcminflt, Qcmajflt, Qutime, Qstime, Qcstime;
146Lisp_Object Qcutime, Qpri, Qnice, Qthcount, Qstart, Qvsize, Qrss, Qargs;
147Lisp_Object Quser, Qgroup, Qetime, Qpcpu, Qpmem, Qtime, Qctime;
148Lisp_Object QCname, QCtype;
149
150/* True if keyboard input is on hold, zero otherwise. */
151
152static bool kbd_is_on_hold;
153
154/* Nonzero means don't run process sentinels. This is used
155 when exiting. */
156bool inhibit_sentinels;
157
158#ifdef subprocesses
159
137#ifndef SOCK_CLOEXEC 160#ifndef SOCK_CLOEXEC
138# define SOCK_CLOEXEC 0 161# define SOCK_CLOEXEC 0
139#endif 162#endif
@@ -165,29 +188,6 @@ process_socket (int domain, int type, int protocol)
165# define socket(domain, type, protocol) process_socket (domain, type, protocol) 188# define socket(domain, type, protocol) process_socket (domain, type, protocol)
166#endif 189#endif
167 190
168/* Work around GCC 4.7.0 bug with strict overflow checking; see
169 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52904>.
170 These lines can be removed once the GCC bug is fixed. */
171#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
172# pragma GCC diagnostic ignored "-Wstrict-overflow"
173#endif
174
175Lisp_Object Qeuid, Qegid, Qcomm, Qstate, Qppid, Qpgrp, Qsess, Qttname, Qtpgid;
176Lisp_Object Qminflt, Qmajflt, Qcminflt, Qcmajflt, Qutime, Qstime, Qcstime;
177Lisp_Object Qcutime, Qpri, Qnice, Qthcount, Qstart, Qvsize, Qrss, Qargs;
178Lisp_Object Quser, Qgroup, Qetime, Qpcpu, Qpmem, Qtime, Qctime;
179Lisp_Object QCname, QCtype;
180
181/* True if keyboard input is on hold, zero otherwise. */
182
183static bool kbd_is_on_hold;
184
185/* Nonzero means don't run process sentinels. This is used
186 when exiting. */
187bool inhibit_sentinels;
188
189#ifdef subprocesses
190
191Lisp_Object Qprocessp; 191Lisp_Object Qprocessp;
192static Lisp_Object Qrun, Qstop, Qsignal; 192static Lisp_Object Qrun, Qstop, Qsignal;
193static Lisp_Object Qopen, Qclosed, Qconnect, Qfailed, Qlisten; 193static Lisp_Object Qopen, Qclosed, Qconnect, Qfailed, Qlisten;
@@ -7059,6 +7059,7 @@ integer or floating point values.
7059 return system_process_attributes (pid); 7059 return system_process_attributes (pid);
7060} 7060}
7061 7061
7062#ifdef subprocesses
7062/* Arrange to catch SIGCHLD if this hasn't already been arranged. 7063/* Arrange to catch SIGCHLD if this hasn't already been arranged.
7063 Invoke this after init_process_emacs, and after glib and/or GNUstep 7064 Invoke this after init_process_emacs, and after glib and/or GNUstep
7064 futz with the SIGCHLD handler, but before Emacs forks any children. 7065 futz with the SIGCHLD handler, but before Emacs forks any children.
@@ -7084,6 +7085,7 @@ catch_child_signal (void)
7084 : old_action.sa_handler); 7085 : old_action.sa_handler);
7085 unblock_child_signal (&oldset); 7086 unblock_child_signal (&oldset);
7086} 7087}
7088#endif /* subprocesses */
7087 7089
7088 7090
7089/* This is not called "init_process" because that is the name of a 7091/* This is not called "init_process" because that is the name of a
@@ -7290,10 +7292,12 @@ syms_of_process (void)
7290 DEFSYM (Qcutime, "cutime"); 7292 DEFSYM (Qcutime, "cutime");
7291 DEFSYM (Qcstime, "cstime"); 7293 DEFSYM (Qcstime, "cstime");
7292 DEFSYM (Qctime, "ctime"); 7294 DEFSYM (Qctime, "ctime");
7295#ifdef subprocesses
7293 DEFSYM (Qinternal_default_process_sentinel, 7296 DEFSYM (Qinternal_default_process_sentinel,
7294 "internal-default-process-sentinel"); 7297 "internal-default-process-sentinel");
7295 DEFSYM (Qinternal_default_process_filter, 7298 DEFSYM (Qinternal_default_process_filter,
7296 "internal-default-process-filter"); 7299 "internal-default-process-filter");
7300#endif
7297 DEFSYM (Qpri, "pri"); 7301 DEFSYM (Qpri, "pri");
7298 DEFSYM (Qnice, "nice"); 7302 DEFSYM (Qnice, "nice");
7299 DEFSYM (Qthcount, "thcount"); 7303 DEFSYM (Qthcount, "thcount");
diff --git a/src/sysdep.c b/src/sysdep.c
index 7a888834bcc..e5b29205e96 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -1509,7 +1509,9 @@ emacs_sigaction_init (struct sigaction *action, signal_handler_t handler)
1509 /* When handling a signal, block nonfatal system signals that are caught 1509 /* When handling a signal, block nonfatal system signals that are caught
1510 by Emacs. This makes race conditions less likely. */ 1510 by Emacs. This makes race conditions less likely. */
1511 sigaddset (&action->sa_mask, SIGALRM); 1511 sigaddset (&action->sa_mask, SIGALRM);
1512#ifdef SIGCHLD
1512 sigaddset (&action->sa_mask, SIGCHLD); 1513 sigaddset (&action->sa_mask, SIGCHLD);
1514#endif
1513#ifdef SIGDANGER 1515#ifdef SIGDANGER
1514 sigaddset (&action->sa_mask, SIGDANGER); 1516 sigaddset (&action->sa_mask, SIGDANGER);
1515#endif 1517#endif
@@ -1714,7 +1716,9 @@ init_signals (bool dumping)
1714# ifdef SIGBUS 1716# ifdef SIGBUS
1715 sys_siglist[SIGBUS] = "Bus error"; 1717 sys_siglist[SIGBUS] = "Bus error";
1716# endif 1718# endif
1719# ifdef SIGCHLD
1717 sys_siglist[SIGCHLD] = "Child status changed"; 1720 sys_siglist[SIGCHLD] = "Child status changed";
1721# endif
1718# ifdef SIGCONT 1722# ifdef SIGCONT
1719 sys_siglist[SIGCONT] = "Continued"; 1723 sys_siglist[SIGCONT] = "Continued";
1720# endif 1724# endif
@@ -2185,6 +2189,9 @@ emacs_fopen (char const *file, char const *mode)
2185int 2189int
2186emacs_pipe (int fd[2]) 2190emacs_pipe (int fd[2])
2187{ 2191{
2192#ifdef MSDOS
2193 return pipe (fd);
2194#else /* !MSDOS */
2188 int result = pipe2 (fd, O_CLOEXEC); 2195 int result = pipe2 (fd, O_CLOEXEC);
2189 if (! O_CLOEXEC && result == 0) 2196 if (! O_CLOEXEC && result == 0)
2190 { 2197 {
@@ -2192,6 +2199,7 @@ emacs_pipe (int fd[2])
2192 fcntl (fd[1], F_SETFD, FD_CLOEXEC); 2199 fcntl (fd[1], F_SETFD, FD_CLOEXEC);
2193 } 2200 }
2194 return result; 2201 return result;
2202#endif /* !MSDOS */
2195} 2203}
2196 2204
2197/* Approximate posix_close and POSIX_CLOSE_RESTART well enough for Emacs. 2205/* Approximate posix_close and POSIX_CLOSE_RESTART well enough for Emacs.
diff --git a/src/term.c b/src/term.c
index 6512f12fcab..47be788f31a 100644
--- a/src/term.c
+++ b/src/term.c
@@ -500,7 +500,7 @@ static ptrdiff_t encode_terminal_dst_size;
500 Set CODING->produced to the byte-length of the resulting byte 500 Set CODING->produced to the byte-length of the resulting byte
501 sequence, and return a pointer to that byte sequence. */ 501 sequence, and return a pointer to that byte sequence. */
502 502
503#ifndef WINDOWSNT 503#ifndef DOS_NT
504static 504static
505#endif 505#endif
506unsigned char * 506unsigned char *
@@ -4562,6 +4562,7 @@ bigger, or it may make it blink, or it may do nothing at all. */);
4562 encode_terminal_src = NULL; 4562 encode_terminal_src = NULL;
4563 encode_terminal_dst = NULL; 4563 encode_terminal_dst = NULL;
4564 4564
4565#ifndef MSDOS
4565 DEFSYM (Qtty_menu_next_item, "tty-menu-next-item"); 4566 DEFSYM (Qtty_menu_next_item, "tty-menu-next-item");
4566 DEFSYM (Qtty_menu_prev_item, "tty-menu-prev-item"); 4567 DEFSYM (Qtty_menu_prev_item, "tty-menu-prev-item");
4567 DEFSYM (Qtty_menu_next_menu, "tty-menu-next-menu"); 4568 DEFSYM (Qtty_menu_next_menu, "tty-menu-next-menu");
@@ -4571,4 +4572,5 @@ bigger, or it may make it blink, or it may do nothing at all. */);
4571 DEFSYM (Qtty_menu_exit, "tty-menu-exit"); 4572 DEFSYM (Qtty_menu_exit, "tty-menu-exit");
4572 DEFSYM (Qtty_menu_mouse_movement, "tty-menu-mouse-movement"); 4573 DEFSYM (Qtty_menu_mouse_movement, "tty-menu-mouse-movement");
4573 DEFSYM (Qtty_menu_navigation_map, "tty-menu-navigation-map"); 4574 DEFSYM (Qtty_menu_navigation_map, "tty-menu-navigation-map");
4575#endif
4574} 4576}
diff --git a/src/termhooks.h b/src/termhooks.h
index 961b321891d..708351da83d 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -643,7 +643,7 @@ extern void delete_terminal (struct terminal *);
643/* The initial terminal device, created by initial_term_init. */ 643/* The initial terminal device, created by initial_term_init. */
644extern struct terminal *initial_terminal; 644extern struct terminal *initial_terminal;
645 645
646#ifdef WINDOWSNT 646#ifdef DOS_NT
647extern unsigned char *encode_terminal_code (struct glyph *, int, 647extern unsigned char *encode_terminal_code (struct glyph *, int,
648 struct coding_system *); 648 struct coding_system *);
649#endif 649#endif
diff --git a/src/unexcoff.c b/src/unexcoff.c
index cb0b6f2f0b5..0e47bdd8656 100644
--- a/src/unexcoff.c
+++ b/src/unexcoff.c
@@ -65,6 +65,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
65#include <crt0.h> /* for _crt0_startup_flags and its bits */ 65#include <crt0.h> /* for _crt0_startup_flags and its bits */
66#include <sys/exceptn.h> 66#include <sys/exceptn.h>
67static int save_djgpp_startup_flags; 67static int save_djgpp_startup_flags;
68#include <libc/atexit.h>
69static struct __atexit *save_atexit_ptr;
68#define filehdr external_filehdr 70#define filehdr external_filehdr
69#define scnhdr external_scnhdr 71#define scnhdr external_scnhdr
70#define syment external_syment 72#define syment external_syment
@@ -82,7 +84,7 @@ struct aouthdr
82 unsigned long text_start;/* base of text used for this file */ 84 unsigned long text_start;/* base of text used for this file */
83 unsigned long data_start;/* base of data used for this file */ 85 unsigned long data_start;/* base of data used for this file */
84}; 86};
85#endif /* not MSDOS */ 87#endif /* MSDOS */
86#else /* not HAVE_COFF_H */ 88#else /* not HAVE_COFF_H */
87#include <a.out.h> 89#include <a.out.h>
88#endif /* not HAVE_COFF_H */ 90#endif /* not HAVE_COFF_H */
@@ -368,6 +370,12 @@ copy_text_and_data (int new, int a_out)
368 and which might change the way that dumped Emacs works. */ 370 and which might change the way that dumped Emacs works. */
369 save_djgpp_startup_flags = _crt0_startup_flags; 371 save_djgpp_startup_flags = _crt0_startup_flags;
370 _crt0_startup_flags &= ~(_CRT0_FLAG_NO_LFN | _CRT0_FLAG_NEARPTR); 372 _crt0_startup_flags &= ~(_CRT0_FLAG_NO_LFN | _CRT0_FLAG_NEARPTR);
373
374 /* Zero out the 'atexit' chain in the dumped executable, to avoid
375 calling the atexit functions twice. (emacs.c:main installs an
376 atexit function.) */
377 save_atexit_ptr = __atexit_ptr;
378 __atexit_ptr = NULL;
371#endif 379#endif
372 380
373 lseek (new, (long) text_scnptr, 0); 381 lseek (new, (long) text_scnptr, 0);
@@ -386,6 +394,9 @@ copy_text_and_data (int new, int a_out)
386 394
387 /* Restore the startup flags. */ 395 /* Restore the startup flags. */
388 _crt0_startup_flags = save_djgpp_startup_flags; 396 _crt0_startup_flags = save_djgpp_startup_flags;
397
398 /* Restore the atexit chain. */
399 __atexit_ptr = save_atexit_ptr;
389#endif 400#endif
390 401
391 402
diff --git a/src/w32term.c b/src/w32term.c
index 40c1e591233..3aabf92357a 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -4723,7 +4723,7 @@ w32_read_socket (struct terminal *terminal,
4723 here since Windows sends a WM_MOVE message 4723 here since Windows sends a WM_MOVE message
4724 BEFORE telling us the Window is minimized 4724 BEFORE telling us the Window is minimized
4725 when the Window is iconified, with 3000,3000 4725 when the Window is iconified, with 3000,3000
4726 as the co-ords. */ 4726 as the co-ords. */
4727 x_real_positions (f, &f->left_pos, &f->top_pos); 4727 x_real_positions (f, &f->left_pos, &f->top_pos);
4728 4728
4729 inev.kind = DEICONIFY_EVENT; 4729 inev.kind = DEICONIFY_EVENT;
diff --git a/src/window.c b/src/window.c
index f42219cae94..8e8252d3b76 100644
--- a/src/window.c
+++ b/src/window.c
@@ -55,6 +55,7 @@ static Lisp_Object Qwindow_pixel_to_total;
55static Lisp_Object Qscroll_up, Qscroll_down, Qscroll_command; 55static Lisp_Object Qscroll_up, Qscroll_down, Qscroll_command;
56static Lisp_Object Qsafe, Qabove, Qbelow, Qwindow_size, Qclone_of; 56static Lisp_Object Qsafe, Qabove, Qbelow, Qwindow_size, Qclone_of;
57static Lisp_Object Qfloor, Qceiling; 57static Lisp_Object Qfloor, Qceiling;
58static Lisp_Object Qwindow_point_insertion_type;
58 59
59static int displayed_window_lines (struct window *); 60static int displayed_window_lines (struct window *);
60static int count_windows (struct window *); 61static int count_windows (struct window *);
@@ -124,7 +125,7 @@ static int window_initialized;
124/* Hook to run when window config changes. */ 125/* Hook to run when window config changes. */
125static Lisp_Object Qwindow_configuration_change_hook; 126static Lisp_Object Qwindow_configuration_change_hook;
126 127
127/* Used by the function window_scroll_pixel_based */ 128/* Used by the function window_scroll_pixel_based. */
128static int window_scroll_pixel_based_preserve_x; 129static int window_scroll_pixel_based_preserve_x;
129static int window_scroll_pixel_based_preserve_y; 130static int window_scroll_pixel_based_preserve_y;
130 131
@@ -6618,7 +6619,8 @@ save_window_save (Lisp_Object window, struct Lisp_Vector *vector, int i)
6618 else 6619 else
6619 p->pointm = Fcopy_marker (w->pointm, Qnil); 6620 p->pointm = Fcopy_marker (w->pointm, Qnil);
6620 XMARKER (p->pointm)->insertion_type 6621 XMARKER (p->pointm)->insertion_type
6621 = !NILP (Vwindow_point_insertion_type); 6622 = !NILP (buffer_local_value_1 /* Don't signal error if void. */
6623 (Qwindow_point_insertion_type, w->contents));
6622 6624
6623 p->start = Fcopy_marker (w->start, Qnil); 6625 p->start = Fcopy_marker (w->start, Qnil);
6624 p->start_at_line_beg = w->start_at_line_beg ? Qt : Qnil; 6626 p->start_at_line_beg = w->start_at_line_beg ? Qt : Qnil;
@@ -7235,6 +7237,7 @@ on their symbols to be controlled by this variable. */);
7235 DEFVAR_LISP ("window-point-insertion-type", Vwindow_point_insertion_type, 7237 DEFVAR_LISP ("window-point-insertion-type", Vwindow_point_insertion_type,
7236 doc: /* Type of marker to use for `window-point'. */); 7238 doc: /* Type of marker to use for `window-point'. */);
7237 Vwindow_point_insertion_type = Qnil; 7239 Vwindow_point_insertion_type = Qnil;
7240 DEFSYM (Qwindow_point_insertion_type, "window_point_insertion_type");
7238 7241
7239 DEFVAR_LISP ("window-configuration-change-hook", 7242 DEFVAR_LISP ("window-configuration-change-hook",
7240 Vwindow_configuration_change_hook, 7243 Vwindow_configuration_change_hook,