aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoakim Verona2013-03-26 15:31:46 +0100
committerJoakim Verona2013-03-26 15:31:46 +0100
commite11705b616777a8a72363b2037d989987630e863 (patch)
treefda56011e9ac37da9e53762d8dc24c7a87cbee82 /src
parentc446797d60edf1058f6cbec28e57255d245dd47b (diff)
parentcded56c19b30e038537398b5213438c339428ed9 (diff)
downloademacs-e11705b616777a8a72363b2037d989987630e863.tar.gz
emacs-e11705b616777a8a72363b2037d989987630e863.zip
conflict resolve
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog189
-rw-r--r--src/Makefile.in3
-rw-r--r--src/alloc.c4
-rw-r--r--src/bytecode.c12
-rw-r--r--src/coding.c198
-rw-r--r--src/coding.h9
-rw-r--r--src/conf_post.h13
-rw-r--r--src/dispnew.c9
-rw-r--r--src/emacs.c4
-rw-r--r--src/eval.c1
-rw-r--r--src/fileio.c21
-rw-r--r--src/filelock.c8
-rw-r--r--src/insdel.c14
-rw-r--r--src/keyboard.c150
-rw-r--r--src/keymap.c4
-rw-r--r--src/lisp.h2
-rw-r--r--src/lread.c74
-rw-r--r--src/region-cache.c58
-rw-r--r--src/sysdep.c12
-rw-r--r--src/term.c6
-rw-r--r--src/termhooks.h28
-rw-r--r--src/terminal.c2
-rw-r--r--src/textprop.c2
-rw-r--r--src/w32fns.c89
-rw-r--r--src/w32term.c44
-rw-r--r--src/w32term.h17
-rw-r--r--src/window.c2
-rw-r--r--src/xdisp.c66
-rw-r--r--src/xfns.c6
-rw-r--r--src/xsmfns.c2
30 files changed, 697 insertions, 352 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index ae25a3c5d00..288996fffb2 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,192 @@
12013-03-15 Paul Eggert <eggert@cs.ucla.edu>
2
3 * coding.c (decode_coding_gap): Fix typo caught by static checking.
4
52013-03-15 handa <handa@gnu.org>
6
7 * insdel.c (insert_from_gap): New arg text_at_gap_tail.
8 (adjust_after_replace): Make it back to static. Delete the third
9 arg text_at_gap_tail. Cancel the code for handling it.
10
11 * coding.h (struct coding_system): New member eol_seen.
12
13 * coding.c (detect_ascii): New function.
14 (detect_coding): Set coding->head_ascii and coding->eol_seen only
15 when the source bytes are actually scanned. On detecting for
16 coding_category_utf_8_auto, call detect_ascii instead of scanning
17 source bytes directly.
18 (produce_chars): Call insert_from_gap with the new arg 0.
19 (encode_coding): Likewise.
20 (decode_coding_gap): Control ASCII optimization by the variable
21 disable_ascii_optimization instead of #ifndef .. #endif.
22 Deccode EOL format according to coding->eol_seen.
23 (syms_of_coding): Declare disable-ascii-optimization as a Lisp
24 variable.
25
26 * global.h (struct emacs_globals): New member
27 f_disable_ascii_optimization.
28 (disable_ascii_optimization): New macro.
29
30 * lisp.h (adjust_after_replace): Cancel externing it.
31 (insert_from_gap): Adjust prototype.
32
332013-03-15 Eli Zaretskii <eliz@gnu.org>
34
35 * w32term.c (w32fullscreen_hook): Swap FULLSCREEN_BOTH and
36 FULLSCREEN_MAXIMIZED. (Bug#13935)
37
382013-03-15 Dmitry Antipov <dmantipov@yandex.ru>
39
40 * region-cache.c (find_cache_boundary, move_cache_gap)
41 (insert_cache_boundary, delete_cache_boundaries, set_cache_region):
42 Simplify debugging check and convert to eassert. Adjust comment.
43 (pp_cache): Put under ENABLE_CHECKING.
44
452013-03-14 Eli Zaretskii <eliz@gnu.org>
46
47 * w32term.c (w32_read_socket) <WM_WINDOWPOSCHANGED>: Remove old
48 and incorrect code. Treat WM_WINDOWPOSCHANGED like WM_ACTIVATE
49 and WM_ACTIVATEAPP.
50 (w32fullscreen_hook): If the frame is visible, reset
51 f->want_fullscreen flag after changing the frame size. If the
52 frame is not visible, set f->want_fullscreen to FULLSCREEN_WAIT.
53 (Bug#13953)
54
552013-03-13 Daniel Colascione <dancol@dancol.org>
56
57 * emacs.c (main): Call syms_of_cygw32 on CYGWIN non-NTGUI builds
58 too so that these builds can use Cygwin's file conversion
59 functions. (We've been building and linking cygw32.o all along
60 and just not using it.)
61
622013-03-13 Paul Eggert <eggert@cs.ucla.edu>
63
64 File synchronization fixes (Bug#13944).
65 * Makefile.in (LIB_FDATASYNC): New macro.
66 (LIBES): Use it.
67 * conf_post.h (BSD_SYSTEM, BSD_SYSTEM_AHB): Remove; no longer needed.
68 * fileio.c (Fwrite_region, write_region_inhibit_fsync):
69 Don't worry about HAVE_FSYNC, since a substitute fsync is
70 available if the system lacks one.
71 (Fwrite_regin): Retry fsync if interrupted.
72
732013-03-13 Eli Zaretskii <eliz@gnu.org>
74
75 * w32term.c (w32_read_socket): If the Emacs frame is being
76 activated, call w32fullscreen_hook, to make sure the new frame
77 dimensions are in effect. (Bug#13937)
78
792013-03-13 Dmitry Antipov <dmantipov@yandex.ru>
80
81 * xdisp.c (init_iterator): Simplify because both character and byte
82 positions are either specified or -1. Add eassert. Adjust comment.
83 * window.c (Fscroll_other_window): Use SET_PT_BOTH because both
84 character and byte positions can be obtained from marker.
85
862013-03-13 Paul Eggert <eggert@cs.ucla.edu>
87
88 Static checking by Sun C 5.12.
89 * alloc.c (buffer_memory_full) [REL_ALLOC]:
90 * bytecode.c (exec_byte_code):
91 * dispnew.c (init_display):
92 * eval.c (error):
93 * fileio.c (Fsubstitute_in_file_name):
94 * keyboard.c (Fevent_convert_list):
95 * keymap.c (Fsingle_key_description):
96 * term.c (maybe_fatal, fatal):
97 * xfns.c (Fx_display_backing_store, Fx_display_visual_class):
98 * xsmfns.c (Fhandle_save_session):
99 Omit unreachable code.
100 * keymap.c (map_keymap_char_table_item): Cast void * to
101 a function pointer type; the C Standard requires this.
102
103 * sysdep.c: Remove a use of BSD_SYSTEM, which I'm trying to phase out.
104 Include <sys/param.h> unconditionally, as that works elsewhere and
105 is simpler here. Include <sys/sysctl.h> if DARWIN_OS ||
106 __FreeBSD__, not if BSD_SYSTEM, since it's needed only for Darwin
107 and FreeBSD now.
108
1092013-03-11 Paul Eggert <eggert@cs.ucla.edu>
110
111 * insdel.c (adjust_after_replace): Use bool for boolean.
112
1132013-03-11 Stefan Monnier <monnier@iro.umontreal.ca>
114
115 * keyboard.c: Move keyboard decoding to read_key_sequence.
116 (decode_keyboard_code): Remove.
117 (tty_read_avail_input): Don't try to decode input.
118 (read_decoded_char): New function.
119 (read_key_sequence): Use it.
120
1212013-03-10 Daniel Colascione <dancol@dancol.org>
122
123 * w32term.h (GUISTR, GUI_ENCODE_FILE, GUI_ENCODE_SYSTEM, GUI_FN)
124 (GUI_SDATA, guichar_t): Macros to abstract out differences between
125 NTGUI_UNICODE and !NTGUI_UNICODE builds, some moved out of
126 w32fns.c.
127
128 * w32term.c (construct_drag_n_drop): Use the above macros to make
129 drag-and-drop work for non-ASCII filenames in cygw32 builds.
130
131 * w32fns.c (x_set_name, x_set_title): Use the above macros to
132 properly display non-ASCII frame titles in cygw32 builds.
133
134 * w32fns.c (Fw32_shell_execute): Use the above macros to properly
135 call ShellExecute in cygw32 builds.
136
137 * w32fn.c (Fx_file_dialog): Use the above macros to simplify the
138 common file dialog code.
139
140 * w32fns.c (Ffile_system_info): Remove from cygw32 builds, which
141 can just use du like other systems.
142
143 * coding.c (from_unicode_buffer): Declare.
144 * coding.c (from_unicode_buffer): Implement.
145
1462013-03-10 Stefan Monnier <monnier@iro.umontreal.ca>
147
148 * lread.c: Minor cleanup.
149 (FROM_FILE_P): New macro.
150 (skip_dyn_bytes, unreadchar, read1): Use it.
151 (read_list): Consolidate duplicated code.
152
153 * bytecode.c (struct byte_stack): Remove `constants' when unused.
154
1552013-03-10 Eli Zaretskii <eliz@gnu.org>
156
157 * xdisp.c (display_tool_bar_line, redisplay_tool_bar)
158 (redisplay_internal, set_cursor_from_row, try_window)
159 (try_window_id, dump_glyph_row, extend_face_to_end_of_line)
160 (display_line, notice_overwritten_cursor)
161 (mouse_face_from_buffer_pos, note_mouse_highlight):
162 Use MATRIX_ROW_DISPLAYS_TEXT_P.
163 (note_mouse_highlight): Use MATRIX_ROW_GLYPH_START.
164 (mouse_face_from_string_pos, fast_find_string_pos):
165 Use MATRIX_ROW_VPOS.
166
167 * xfns.c (Fx_show_tip): Use MATRIX_ROW_DISPLAYS_TEXT_P.
168
169 * w32fns.c (Fx_show_tip): Use MATRIX_ROW_DISPLAYS_TEXT_P.
170
171 * xdisp.c (try_cursor_movement): Use MATRIX_ROW and
172 MATRIX_MODE_LINE_ROW.
173
174 * dispnew.c (update_window): Use MATRIX_ROW and MATRIX_MODE_LINE_ROW.
175
1762013-03-10 handa <handa@gnu.org>
177
178 * lisp.h (adjust_after_replace): Extern it.
179
180 * coding.c (detect_coding): Cound the heading ASCII bytes in the
181 case of detection for coding_category_utf_8_auto.
182 (decode_coding_gap) [not CODING_DISABLE_ASCII_OPTIMIZATION]:
183 Skip decoding if all bytes are ASCII.
184
185 * insdel.c (adjust_after_replace): Make it public. New arg
186 text_at_gap_tail.
187 (adjust_after_insert): Call adjust_after_replace with the new arg
188 value 0.
189
12013-03-09 Stefan Monnier <monnier@iro.umontreal.ca> 1902013-03-09 Stefan Monnier <monnier@iro.umontreal.ca>
2 191
3 * keyboard.h (EVENT_START, EVENT_END, POSN_WINDOW, POSN_POSN) 192 * keyboard.h (EVENT_START, EVENT_END, POSN_WINDOW, POSN_POSN)
diff --git a/src/Makefile.in b/src/Makefile.in
index 8a9a43ac124..93d65867fa7 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -139,6 +139,7 @@ M17N_FLT_LIBS = @M17N_FLT_LIBS@
139 139
140LIB_CLOCK_GETTIME=@LIB_CLOCK_GETTIME@ 140LIB_CLOCK_GETTIME=@LIB_CLOCK_GETTIME@
141LIB_EACCESS=@LIB_EACCESS@ 141LIB_EACCESS=@LIB_EACCESS@
142LIB_FDATASYNC=@LIB_FDATASYNC@
142LIB_TIMER_TIME=@LIB_TIMER_TIME@ 143LIB_TIMER_TIME=@LIB_TIMER_TIME@
143 144
144DBUS_CFLAGS = @DBUS_CFLAGS@ 145DBUS_CFLAGS = @DBUS_CFLAGS@
@@ -404,7 +405,7 @@ LIBES = $(LIBS) $(W32_LIBS) $(LIBS_GNUSTEP) $(LIBX_BASE) $(LIBIMAGE) \
404 $(LIBX_OTHER) $(LIBSOUND) \ 405 $(LIBX_OTHER) $(LIBSOUND) \
405 $(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_CLOCK_GETTIME) \ 406 $(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_CLOCK_GETTIME) \
406 $(WEBKIT_LIBS) $(CLUTTER_LIBS) $(GIR_LIBS) \ 407 $(WEBKIT_LIBS) $(CLUTTER_LIBS) $(GIR_LIBS) \
407 $(LIB_EACCESS) $(LIB_TIMER_TIME) $(DBUS_LIBS) \ 408 $(LIB_EACCESS) $(LIB_FDATASYNC) $(LIB_TIMER_TIME) $(DBUS_LIBS) \
408 $(LIB_EXECINFO) \ 409 $(LIB_EXECINFO) \
409 $(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \ 410 $(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \
410 $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \ 411 $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \
diff --git a/src/alloc.c b/src/alloc.c
index 80086433e65..b2703c5f961 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -422,11 +422,11 @@ buffer_memory_full (ptrdiff_t nbytes)
422 422
423#ifndef REL_ALLOC 423#ifndef REL_ALLOC
424 memory_full (nbytes); 424 memory_full (nbytes);
425#endif 425#else
426
427 /* This used to call error, but if we've run out of memory, we could 426 /* This used to call error, but if we've run out of memory, we could
428 get infinite recursion trying to build the string. */ 427 get infinite recursion trying to build the string. */
429 xsignal (Qnil, Vmemory_signal_data); 428 xsignal (Qnil, Vmemory_signal_data);
429#endif
430} 430}
431 431
432/* A common multiple of the positive integers A and B. Ideally this 432/* A common multiple of the positive integers A and B. Ideally this
diff --git a/src/bytecode.c b/src/bytecode.c
index bd8abe85e04..acb96c1e61b 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -313,9 +313,11 @@ struct byte_stack
313 Lisp_Object byte_string; 313 Lisp_Object byte_string;
314 const unsigned char *byte_string_start; 314 const unsigned char *byte_string_start;
315 315
316#if BYTE_MARK_STACK
316 /* The vector of constants used during byte-code execution. Storing 317 /* The vector of constants used during byte-code execution. Storing
317 this here protects it from GC because mark_byte_stack marks it. */ 318 this here protects it from GC because mark_byte_stack marks it. */
318 Lisp_Object constants; 319 Lisp_Object constants;
320#endif
319 321
320 /* Next entry in byte_stack_list. */ 322 /* Next entry in byte_stack_list. */
321 struct byte_stack *next; 323 struct byte_stack *next;
@@ -379,12 +381,12 @@ unmark_byte_stack (void)
379} 381}
380 382
381 383
382/* Fetch the next byte from the bytecode stream */ 384/* Fetch the next byte from the bytecode stream. */
383 385
384#define FETCH *stack.pc++ 386#define FETCH *stack.pc++
385 387
386/* Fetch two bytes from the bytecode stream and make a 16-bit number 388/* Fetch two bytes from the bytecode stream and make a 16-bit number
387 out of them */ 389 out of them. */
388 390
389#define FETCH2 (op = FETCH, op + (FETCH << 8)) 391#define FETCH2 (op = FETCH, op + (FETCH << 8))
390 392
@@ -404,7 +406,7 @@ unmark_byte_stack (void)
404#define DISCARD(n) (top -= (n)) 406#define DISCARD(n) (top -= (n))
405 407
406/* Get the value which is at the top of the execution stack, but don't 408/* Get the value which is at the top of the execution stack, but don't
407 pop it. */ 409 pop it. */
408 410
409#define TOP (*top) 411#define TOP (*top)
410 412
@@ -535,7 +537,9 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
535 537
536 stack.byte_string = bytestr; 538 stack.byte_string = bytestr;
537 stack.pc = stack.byte_string_start = SDATA (bytestr); 539 stack.pc = stack.byte_string_start = SDATA (bytestr);
540#if BYTE_MARK_STACK
538 stack.constants = vector; 541 stack.constants = vector;
542#endif
539 if (MAX_ALLOCA / word_size <= XFASTINT (maxdepth)) 543 if (MAX_ALLOCA / word_size <= XFASTINT (maxdepth))
540 memory_full (SIZE_MAX); 544 memory_full (SIZE_MAX);
541 top = alloca ((XFASTINT (maxdepth) + 1) * sizeof *top); 545 top = alloca ((XFASTINT (maxdepth) + 1) * sizeof *top);
@@ -751,7 +755,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
751 { 755 {
752 BEFORE_POTENTIAL_GC (); 756 BEFORE_POTENTIAL_GC ();
753 wrong_type_argument (Qlistp, v1); 757 wrong_type_argument (Qlistp, v1);
754 AFTER_POTENTIAL_GC ();
755 } 758 }
756 NEXT; 759 NEXT;
757 } 760 }
@@ -786,7 +789,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
786 { 789 {
787 BEFORE_POTENTIAL_GC (); 790 BEFORE_POTENTIAL_GC ();
788 wrong_type_argument (Qlistp, v1); 791 wrong_type_argument (Qlistp, v1);
789 AFTER_POTENTIAL_GC ();
790 } 792 }
791 NEXT; 793 NEXT;
792 } 794 }
diff --git a/src/coding.c b/src/coding.c
index 78e6cff7078..6cfcec905a1 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -286,6 +286,10 @@ encode_coding_XXX (struct coding_system *coding)
286#include <config.h> 286#include <config.h>
287#include <stdio.h> 287#include <stdio.h>
288 288
289#ifdef HAVE_WCHAR_H
290#include <wchar.h>
291#endif /* HAVE_WCHAR_H */
292
289#include "lisp.h" 293#include "lisp.h"
290#include "character.h" 294#include "character.h"
291#include "buffer.h" 295#include "buffer.h"
@@ -6067,6 +6071,93 @@ complement_process_encoding_system (Lisp_Object coding_system)
6067#define EOL_SEEN_CR 2 6071#define EOL_SEEN_CR 2
6068#define EOL_SEEN_CRLF 4 6072#define EOL_SEEN_CRLF 4
6069 6073
6074
6075static Lisp_Object adjust_coding_eol_type (struct coding_system *coding, int eol_seen);
6076
6077
6078/* Return 1 if all the source bytes are ASCII, and return 0 otherwize.
6079 By side effects, set coding->head_ascii and coding->eol_seen. The
6080 value of coding->eol_seen is "logical or" of EOL_SEEN_LF,
6081 EOL_SEEN_CR, and EOL_SEEN_CRLF, but the value is reliable only when
6082 all the source bytes are ASCII. */
6083
6084static bool
6085detect_ascii (struct coding_system *coding)
6086{
6087 const unsigned char *src, *end;
6088 Lisp_Object eol_type = CODING_ID_EOL_TYPE (coding->id);
6089 int eol_seen;
6090
6091 eol_seen = (VECTORP (eol_type) ? EOL_SEEN_NONE
6092 : EQ (eol_type, Qunix) ? EOL_SEEN_LF
6093 : EQ (eol_type, Qdos) ? EOL_SEEN_CRLF
6094 : EOL_SEEN_CR);
6095 coding_set_source (coding);
6096 src = coding->source;
6097 end = src + coding->src_bytes;
6098
6099 if (inhibit_eol_conversion)
6100 {
6101 /* We don't have to check EOL format. */
6102 while (src < end && !( *src & 0x80)) src++;
6103 eol_seen = EOL_SEEN_LF;
6104 adjust_coding_eol_type (coding, eol_seen);
6105 }
6106 else if (eol_seen != EOL_SEEN_NONE)
6107 {
6108 /* We don't have to check EOL format either. */
6109 while (src < end && !(*src & 0x80)) src++;
6110 }
6111 else
6112 {
6113 end--; /* We look ahead one byte. */
6114 while (src < end)
6115 {
6116 int c = *src;
6117
6118 if (c & 0x80)
6119 break;
6120 src++;
6121 if (c < 0x20)
6122 {
6123 if (c == '\r')
6124 {
6125 if (*src == '\n')
6126 {
6127 eol_seen |= EOL_SEEN_CRLF;
6128 src++;
6129 }
6130 else
6131 eol_seen |= EOL_SEEN_CR;
6132 }
6133 else if (c == '\n')
6134 eol_seen |= EOL_SEEN_LF;
6135 }
6136 }
6137 if (src > end)
6138 /* The last two bytes are CR LF, which means that we have
6139 scanned all bytes. */
6140 end++;
6141 else if (src == end)
6142 {
6143 end++;
6144 if (! (*src & 0x80))
6145 {
6146 if (*src == '\r')
6147 eol_seen |= EOL_SEEN_CR;
6148 else if (*src == '\n')
6149 eol_seen |= EOL_SEEN_LF;
6150 src++;
6151 }
6152 }
6153 adjust_coding_eol_type (coding, eol_seen);
6154 }
6155 coding->head_ascii = src - coding->source;
6156 coding->eol_seen = eol_seen;
6157 return (src == end);
6158}
6159
6160
6070/* Detect how end-of-line of a text of length SRC_BYTES pointed by 6161/* Detect how end-of-line of a text of length SRC_BYTES pointed by
6071 SOURCE is encoded. If CATEGORY is one of 6162 SOURCE is encoded. If CATEGORY is one of
6072 coding_category_utf_16_XXXX, assume that CR and LF are encoded by 6163 coding_category_utf_16_XXXX, assume that CR and LF are encoded by
@@ -6211,7 +6302,6 @@ detect_coding (struct coding_system *coding)
6211 coding_set_source (coding); 6302 coding_set_source (coding);
6212 6303
6213 src_end = coding->source + coding->src_bytes; 6304 src_end = coding->source + coding->src_bytes;
6214 coding->head_ascii = 0;
6215 6305
6216 /* If we have not yet decided the text encoding type, detect it 6306 /* If we have not yet decided the text encoding type, detect it
6217 now. */ 6307 now. */
@@ -6221,6 +6311,8 @@ detect_coding (struct coding_system *coding)
6221 struct coding_detection_info detect_info; 6311 struct coding_detection_info detect_info;
6222 bool null_byte_found = 0, eight_bit_found = 0; 6312 bool null_byte_found = 0, eight_bit_found = 0;
6223 6313
6314 coding->head_ascii = 0;
6315 coding->eol_seen = EOL_SEEN_NONE;
6224 detect_info.checked = detect_info.found = detect_info.rejected = 0; 6316 detect_info.checked = detect_info.found = detect_info.rejected = 0;
6225 for (src = coding->source; src < src_end; src++) 6317 for (src = coding->source; src < src_end; src++)
6226 { 6318 {
@@ -6259,6 +6351,26 @@ detect_coding (struct coding_system *coding)
6259 if (eight_bit_found) 6351 if (eight_bit_found)
6260 break; 6352 break;
6261 } 6353 }
6354 else if (! disable_ascii_optimization
6355 && ! inhibit_eol_conversion)
6356 {
6357 if (c == '\r')
6358 {
6359 if (src < src_end && src[1] == '\n')
6360 {
6361 coding->eol_seen |= EOL_SEEN_CRLF;
6362 src++;
6363 coding->head_ascii++;
6364 }
6365 else
6366 coding->eol_seen |= EOL_SEEN_CR;
6367 }
6368 else if (c == '\n')
6369 {
6370 coding->eol_seen |= EOL_SEEN_LF;
6371 }
6372 }
6373
6262 if (! eight_bit_found) 6374 if (! eight_bit_found)
6263 coding->head_ascii++; 6375 coding->head_ascii++;
6264 } 6376 }
@@ -6349,14 +6461,20 @@ detect_coding (struct coding_system *coding)
6349 coding_systems 6461 coding_systems
6350 = AREF (CODING_ID_ATTRS (coding->id), coding_attr_utf_bom); 6462 = AREF (CODING_ID_ATTRS (coding->id), coding_attr_utf_bom);
6351 detect_info.found = detect_info.rejected = 0; 6463 detect_info.found = detect_info.rejected = 0;
6352 coding->head_ascii = 0; 6464 if (detect_ascii (coding))
6353 if (CONSP (coding_systems)
6354 && detect_coding_utf_8 (coding, &detect_info))
6355 { 6465 {
6356 if (detect_info.found & CATEGORY_MASK_UTF_8_SIG) 6466 setup_coding_system (XCDR (coding_systems), coding);
6357 setup_coding_system (XCAR (coding_systems), coding); 6467 }
6358 else 6468 else
6359 setup_coding_system (XCDR (coding_systems), coding); 6469 {
6470 if (CONSP (coding_systems)
6471 && detect_coding_utf_8 (coding, &detect_info))
6472 {
6473 if (detect_info.found & CATEGORY_MASK_UTF_8_SIG)
6474 setup_coding_system (XCAR (coding_systems), coding);
6475 else
6476 setup_coding_system (XCDR (coding_systems), coding);
6477 }
6360 } 6478 }
6361 } 6479 }
6362 else if (XINT (CODING_ATTR_CATEGORY (CODING_ID_ATTRS (coding->id))) 6480 else if (XINT (CODING_ATTR_CATEGORY (CODING_ID_ATTRS (coding->id)))
@@ -6369,6 +6487,7 @@ detect_coding (struct coding_system *coding)
6369 = AREF (CODING_ID_ATTRS (coding->id), coding_attr_utf_bom); 6487 = AREF (CODING_ID_ATTRS (coding->id), coding_attr_utf_bom);
6370 detect_info.found = detect_info.rejected = 0; 6488 detect_info.found = detect_info.rejected = 0;
6371 coding->head_ascii = 0; 6489 coding->head_ascii = 0;
6490 coding->eol_seen = EOL_SEEN_NONE;
6372 if (CONSP (coding_systems) 6491 if (CONSP (coding_systems)
6373 && detect_coding_utf_16 (coding, &detect_info)) 6492 && detect_coding_utf_16 (coding, &detect_info))
6374 { 6493 {
@@ -6806,7 +6925,7 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table,
6806 6925
6807 produced = dst - (coding->destination + coding->produced); 6926 produced = dst - (coding->destination + coding->produced);
6808 if (BUFFERP (coding->dst_object) && produced_chars > 0) 6927 if (BUFFERP (coding->dst_object) && produced_chars > 0)
6809 insert_from_gap (produced_chars, produced); 6928 insert_from_gap (produced_chars, produced, 0);
6810 coding->produced += produced; 6929 coding->produced += produced;
6811 coding->produced_char += produced_chars; 6930 coding->produced_char += produced_chars;
6812 return carryover; 6931 return carryover;
@@ -7391,7 +7510,7 @@ encode_coding (struct coding_system *coding)
7391 } while (coding->consumed_char < coding->src_chars); 7510 } while (coding->consumed_char < coding->src_chars);
7392 7511
7393 if (BUFFERP (coding->dst_object) && coding->produced_char > 0) 7512 if (BUFFERP (coding->dst_object) && coding->produced_char > 0)
7394 insert_from_gap (coding->produced_char, coding->produced); 7513 insert_from_gap (coding->produced_char, coding->produced, 0);
7395 7514
7396 SAFE_FREE (); 7515 SAFE_FREE ();
7397} 7516}
@@ -7487,8 +7606,6 @@ decode_coding_gap (struct coding_system *coding,
7487 ptrdiff_t count = SPECPDL_INDEX (); 7606 ptrdiff_t count = SPECPDL_INDEX ();
7488 Lisp_Object attrs; 7607 Lisp_Object attrs;
7489 7608
7490 code_conversion_save (0, 0);
7491
7492 coding->src_object = Fcurrent_buffer (); 7609 coding->src_object = Fcurrent_buffer ();
7493 coding->src_chars = chars; 7610 coding->src_chars = chars;
7494 coding->src_bytes = bytes; 7611 coding->src_bytes = bytes;
@@ -7502,13 +7619,53 @@ decode_coding_gap (struct coding_system *coding,
7502 7619
7503 if (CODING_REQUIRE_DETECTION (coding)) 7620 if (CODING_REQUIRE_DETECTION (coding))
7504 detect_coding (coding); 7621 detect_coding (coding);
7622 attrs = CODING_ID_ATTRS (coding->id);
7623 if (! disable_ascii_optimization)
7624 {
7625 if (! NILP (CODING_ATTR_ASCII_COMPAT (attrs))
7626 && NILP (CODING_ATTR_POST_READ (attrs))
7627 && NILP (get_translation_table (attrs, 0, NULL))
7628 && (coding->head_ascii >= 0 /* We've already called detect_coding */
7629 ? coding->head_ascii == bytes
7630 : detect_ascii (coding)))
7631 {
7632 if (coding->eol_seen == EOL_SEEN_CR)
7633 {
7634 unsigned char *src_end = GAP_END_ADDR;
7635 unsigned char *src = src_end - coding->src_bytes;
7636
7637 while (src < src_end)
7638 {
7639 if (*src++ == '\r')
7640 src[-1] = '\n';
7641 }
7642 }
7643 else if (coding->eol_seen == EOL_SEEN_CRLF)
7644 {
7645 unsigned char *src = GAP_END_ADDR;
7646 unsigned char *src_beg = src - coding->src_bytes;
7647 unsigned char *dst = src;
7648
7649 while (src_beg < src)
7650 {
7651 *--dst = *--src;
7652 if (*src == '\n')
7653 src--;
7654 }
7655 bytes -= dst - src;
7656 }
7657 coding->produced_char = coding->produced = bytes;
7658 insert_from_gap (bytes, bytes, 1);
7659 return;
7660 }
7661 }
7662 code_conversion_save (0, 0);
7505 7663
7506 coding->mode |= CODING_MODE_LAST_BLOCK; 7664 coding->mode |= CODING_MODE_LAST_BLOCK;
7507 current_buffer->text->inhibit_shrinking = 1; 7665 current_buffer->text->inhibit_shrinking = 1;
7508 decode_coding (coding); 7666 decode_coding (coding);
7509 current_buffer->text->inhibit_shrinking = 0; 7667 current_buffer->text->inhibit_shrinking = 0;
7510 7668
7511 attrs = CODING_ID_ATTRS (coding->id);
7512 if (! NILP (CODING_ATTR_POST_READ (attrs))) 7669 if (! NILP (CODING_ATTR_POST_READ (attrs)))
7513 { 7670 {
7514 ptrdiff_t prev_Z = Z, prev_Z_BYTE = Z_BYTE; 7671 ptrdiff_t prev_Z = Z, prev_Z_BYTE = Z_BYTE;
@@ -7966,6 +8123,16 @@ from_unicode (Lisp_Object str)
7966 return code_convert_string_norecord (str, Qutf_16le, 0); 8123 return code_convert_string_norecord (str, Qutf_16le, 0);
7967} 8124}
7968 8125
8126Lisp_Object
8127from_unicode_buffer (const wchar_t* wstr)
8128{
8129 return from_unicode (
8130 make_unibyte_string (
8131 (char*) wstr,
8132 /* we get one of the two final 0 bytes for free. */
8133 1 + sizeof (wchar_t) * wcslen (wstr)));
8134}
8135
7969wchar_t * 8136wchar_t *
7970to_unicode (Lisp_Object str, Lisp_Object *buf) 8137to_unicode (Lisp_Object str, Lisp_Object *buf)
7971{ 8138{
@@ -10707,6 +10874,11 @@ from GNU Find and GNU Grep. Emacs will then ignore the null bytes and
10707decode text as usual. */); 10874decode text as usual. */);
10708 inhibit_null_byte_detection = 0; 10875 inhibit_null_byte_detection = 0;
10709 10876
10877 DEFVAR_BOOL ("disable-ascii-optimization", disable_ascii_optimization,
10878 doc: /* If non-nil, Emacs does not optimize code decoder for ASCII files.
10879Internal use only. Removed after the experimental optimizer gets stable. */);
10880 disable_ascii_optimization = 0;
10881
10710 DEFVAR_LISP ("translation-table-for-input", Vtranslation_table_for_input, 10882 DEFVAR_LISP ("translation-table-for-input", Vtranslation_table_for_input,
10711 doc: /* Char table for translating self-inserting characters. 10883 doc: /* Char table for translating self-inserting characters.
10712This is applied to the result of input methods, not their input. 10884This is applied to the result of input methods, not their input.
diff --git a/src/coding.h b/src/coding.h
index 28a7d776b63..d40209be68f 100644
--- a/src/coding.h
+++ b/src/coding.h
@@ -440,9 +440,13 @@ struct coding_system
440 /* How may heading bytes we can skip for decoding. This is set to 440 /* How may heading bytes we can skip for decoding. This is set to
441 -1 in setup_coding_system, and updated by detect_coding. So, 441 -1 in setup_coding_system, and updated by detect_coding. So,
442 when this is equal to the byte length of the text being 442 when this is equal to the byte length of the text being
443 converted, we can skip the actual conversion process. */ 443 converted, we can skip the actual conversion process except for
444 the eol format. */
444 ptrdiff_t head_ascii; 445 ptrdiff_t head_ascii;
445 446
447 /* Used internally in coding.c. See the comment of detect_ascii. */
448 int eol_seen;
449
446 /* The following members are set by encoding/decoding routine. */ 450 /* The following members are set by encoding/decoding routine. */
447 ptrdiff_t produced, produced_char, consumed, consumed_char; 451 ptrdiff_t produced, produced_char, consumed, consumed_char;
448 452
@@ -715,6 +719,9 @@ extern wchar_t *to_unicode (Lisp_Object str, Lisp_Object *buf);
715 failure modes. STR itself is not modified. */ 719 failure modes. STR itself is not modified. */
716extern Lisp_Object from_unicode (Lisp_Object str); 720extern Lisp_Object from_unicode (Lisp_Object str);
717 721
722/* Convert WSTR to an Emacs string. */
723extern Lisp_Object from_unicode_buffer (const wchar_t* wstr);
724
718#endif /* WINDOWSNT || CYGWIN */ 725#endif /* WINDOWSNT || CYGWIN */
719 726
720/* Macros for backward compatibility. */ 727/* Macros for backward compatibility. */
diff --git a/src/conf_post.h b/src/conf_post.h
index 6c9747a436c..5cb385d9029 100644
--- a/src/conf_post.h
+++ b/src/conf_post.h
@@ -44,19 +44,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
44# define __has_attribute(a) 0 /* non-clang */ 44# define __has_attribute(a) 0 /* non-clang */
45#endif 45#endif
46 46
47/* This silences a few compilation warnings on FreeBSD. */
48#ifdef BSD_SYSTEM_AHB
49#undef BSD_SYSTEM_AHB
50#undef BSD_SYSTEM
51#if __FreeBSD__ == 1
52#define BSD_SYSTEM 199103
53#elif __FreeBSD__ == 2
54#define BSD_SYSTEM 199306
55#elif __FreeBSD__ >= 3
56#define BSD_SYSTEM 199506
57#endif
58#endif
59
60#ifdef DARWIN_OS 47#ifdef DARWIN_OS
61#ifdef emacs 48#ifdef emacs
62#define malloc unexec_malloc 49#define malloc unexec_malloc
diff --git a/src/dispnew.c b/src/dispnew.c
index 54004daada9..763a01ab934 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -3394,8 +3394,8 @@ update_window (struct window *w, bool force_p)
3394 3394
3395 rif->update_window_begin_hook (w); 3395 rif->update_window_begin_hook (w);
3396 yb = window_text_bottom_y (w); 3396 yb = window_text_bottom_y (w);
3397 row = desired_matrix->rows; 3397 row = MATRIX_ROW (desired_matrix, 0);
3398 end = row + desired_matrix->nrows - 1; 3398 end = MATRIX_MODE_LINE_ROW (desired_matrix);
3399 3399
3400 /* Take note of the header line, if there is one. We will 3400 /* Take note of the header line, if there is one. We will
3401 update it below, after updating all of the window's lines. */ 3401 update it below, after updating all of the window's lines. */
@@ -6111,10 +6111,7 @@ init_display (void)
6111 6111
6112 /* If no window system has been specified, try to use the terminal. */ 6112 /* If no window system has been specified, try to use the terminal. */
6113 if (! isatty (0)) 6113 if (! isatty (0))
6114 { 6114 fatal ("standard input is not a tty");
6115 fatal ("standard input is not a tty");
6116 exit (1);
6117 }
6118 6115
6119#ifdef WINDOWSNT 6116#ifdef WINDOWSNT
6120 terminal_type = "w32console"; 6117 terminal_type = "w32console";
diff --git a/src/emacs.c b/src/emacs.c
index 2d5a61c62b0..31191dceb3e 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -44,7 +44,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
44#include "w32common.h" 44#include "w32common.h"
45#endif 45#endif
46 46
47#if defined HAVE_NTGUI && defined CYGWIN 47#if defined CYGWIN
48#include "cygw32.h" 48#include "cygw32.h"
49#endif 49#endif
50 50
@@ -1351,7 +1351,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1351#ifdef WINDOWSNT 1351#ifdef WINDOWSNT
1352 syms_of_ntproc (); 1352 syms_of_ntproc ();
1353#endif /* WINDOWSNT */ 1353#endif /* WINDOWSNT */
1354#if defined CYGWIN && defined HAVE_NTGUI 1354#if defined CYGWIN
1355 syms_of_cygw32 (); 1355 syms_of_cygw32 ();
1356#endif 1356#endif
1357 syms_of_window (); 1357 syms_of_window ();
diff --git a/src/eval.c b/src/eval.c
index 5db6f9d0bf3..69483a9b205 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1690,7 +1690,6 @@ error (const char *m, ...)
1690 va_list ap; 1690 va_list ap;
1691 va_start (ap, m); 1691 va_start (ap, m);
1692 verror (m, ap); 1692 verror (m, ap);
1693 va_end (ap);
1694} 1693}
1695 1694
1696DEFUN ("commandp", Fcommandp, Scommandp, 1, 2, 0, 1695DEFUN ("commandp", Fcommandp, Scommandp, 1, 2, 0,
diff --git a/src/fileio.c b/src/fileio.c
index d7363077b35..724250c8aaa 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -1850,9 +1850,6 @@ those `/' is discarded. */)
1850 error ("Missing \"}\" in environment-variable substitution"); 1850 error ("Missing \"}\" in environment-variable substitution");
1851 badvar: 1851 badvar:
1852 error ("Substituting nonexistent environment variable \"%s\"", target); 1852 error ("Substituting nonexistent environment variable \"%s\"", target);
1853
1854 /* NOTREACHED */
1855 return Qnil;
1856} 1853}
1857 1854
1858/* A slightly faster and more convenient way to get 1855/* A slightly faster and more convenient way to get
@@ -3305,7 +3302,6 @@ Use the current time if TIMESTAMP is nil. TIMESTAMP is in the format of
3305 return Qnil; 3302 return Qnil;
3306#endif 3303#endif
3307 report_file_error ("Setting file times", Fcons (absname, Qnil)); 3304 report_file_error ("Setting file times", Fcons (absname, Qnil));
3308 return Qnil;
3309 } 3305 }
3310 } 3306 }
3311 3307
@@ -4963,20 +4959,23 @@ This calls `write-region-annotate-functions' at the start, and
4963 4959
4964 immediate_quit = 0; 4960 immediate_quit = 0;
4965 4961
4966#ifdef HAVE_FSYNC
4967 /* fsync appears to change the modtime on BSD4.2. 4962 /* fsync appears to change the modtime on BSD4.2.
4968 Disk full in NFS may be reported here. */ 4963 Disk full in NFS may be reported here. */
4969 /* mib says that closing the file will try to write as fast as NFS can do 4964 /* mib says that closing the file will try to write as fast as NFS can do
4970 it, and that means the fsync here is not crucial for autosave files. */ 4965 it, and that means the fsync here is not crucial for autosave files. */
4971 if (!auto_saving && !write_region_inhibit_fsync && fsync (desc) < 0) 4966 if (!auto_saving && !write_region_inhibit_fsync)
4972 { 4967 {
4973 /* If fsync fails with EINTR, don't treat that as serious. Also 4968 /* Transfer data and metadata to disk, retrying if interrupted. Also,
4974 ignore EINVAL which happens when fsync is not supported on this 4969 ignore EINVAL which happens when fsync is not supported on this
4975 file. */ 4970 file. */
4976 if (errno != EINTR && errno != EINVAL) 4971 while (fsync (desc) != 0)
4977 ok = 0, save_errno = errno; 4972 if (errno != EINTR)
4973 {
4974 if (errno != EINVAL)
4975 ok = 0, save_errno = errno;
4976 break;
4977 }
4978 } 4978 }
4979#endif
4980 4979
4981 modtime = invalid_emacs_time (); 4980 modtime = invalid_emacs_time ();
4982 if (visiting) 4981 if (visiting)
@@ -6050,13 +6049,11 @@ in the buffer; this is the default behavior, because the auto-save
6050file is usually more useful if it contains the deleted text. */); 6049file is usually more useful if it contains the deleted text. */);
6051 Vauto_save_include_big_deletions = Qnil; 6050 Vauto_save_include_big_deletions = Qnil;
6052 6051
6053#ifdef HAVE_FSYNC
6054 DEFVAR_BOOL ("write-region-inhibit-fsync", write_region_inhibit_fsync, 6052 DEFVAR_BOOL ("write-region-inhibit-fsync", write_region_inhibit_fsync,
6055 doc: /* Non-nil means don't call fsync in `write-region'. 6053 doc: /* Non-nil means don't call fsync in `write-region'.
6056This variable affects calls to `write-region' as well as save commands. 6054This variable affects calls to `write-region' as well as save commands.
6057A non-nil value may result in data loss! */); 6055A non-nil value may result in data loss! */);
6058 write_region_inhibit_fsync = 0; 6056 write_region_inhibit_fsync = 0;
6059#endif
6060 6057
6061 DEFVAR_BOOL ("delete-by-moving-to-trash", delete_by_moving_to_trash, 6058 DEFVAR_BOOL ("delete-by-moving-to-trash", delete_by_moving_to_trash,
6062 doc: /* Specifies whether to use the system's trash can. 6059 doc: /* Specifies whether to use the system's trash can.
diff --git a/src/filelock.c b/src/filelock.c
index 32992896c2b..f17d3182eab 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -437,6 +437,14 @@ create_lock_file (char *lfname, char *lock_info_str, bool force)
437 if (emacs_write (fd, lock_info_str, lock_info_len) != lock_info_len 437 if (emacs_write (fd, lock_info_str, lock_info_len) != lock_info_len
438 || (need_fchmod && fchmod (fd, world_readable) != 0)) 438 || (need_fchmod && fchmod (fd, world_readable) != 0))
439 err = errno; 439 err = errno;
440 else
441 while (fsync (fd) != 0)
442 if (errno != EINTR)
443 {
444 if (errno != EINVAL)
445 err = errno;
446 break;
447 }
440 if (emacs_close (fd) != 0) 448 if (emacs_close (fd) != 0)
441 err = errno; 449 err = errno;
442 if (!err && rename_lock_file (nonce, lfname, force) != 0) 450 if (!err && rename_lock_file (nonce, lfname, force) != 0)
diff --git a/src/insdel.c b/src/insdel.c
index fc5a4576dc2..a60fed0c32e 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -977,10 +977,11 @@ insert_from_string_1 (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte,
977} 977}
978 978
979/* Insert a sequence of NCHARS chars which occupy NBYTES bytes 979/* Insert a sequence of NCHARS chars which occupy NBYTES bytes
980 starting at GPT_ADDR. */ 980 starting at GAP_END_ADDR - NBYTES (if text_at_gap_tail) and at
981 GPT_ADDR (if not text_at_gap_tail). */
981 982
982void 983void
983insert_from_gap (ptrdiff_t nchars, ptrdiff_t nbytes) 984insert_from_gap (ptrdiff_t nchars, ptrdiff_t nbytes, bool text_at_gap_tail)
984{ 985{
985 if (NILP (BVAR (current_buffer, enable_multibyte_characters))) 986 if (NILP (BVAR (current_buffer, enable_multibyte_characters)))
986 nchars = nbytes; 987 nchars = nbytes;
@@ -989,10 +990,13 @@ insert_from_gap (ptrdiff_t nchars, ptrdiff_t nbytes)
989 MODIFF++; 990 MODIFF++;
990 991
991 GAP_SIZE -= nbytes; 992 GAP_SIZE -= nbytes;
992 GPT += nchars; 993 if (! text_at_gap_tail)
994 {
995 GPT += nchars;
996 GPT_BYTE += nbytes;
997 }
993 ZV += nchars; 998 ZV += nchars;
994 Z += nchars; 999 Z += nchars;
995 GPT_BYTE += nbytes;
996 ZV_BYTE += nbytes; 1000 ZV_BYTE += nbytes;
997 Z_BYTE += nbytes; 1001 Z_BYTE += nbytes;
998 if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */ 1002 if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */
@@ -1010,7 +1014,7 @@ insert_from_gap (ptrdiff_t nchars, ptrdiff_t nbytes)
1010 current_buffer, 0); 1014 current_buffer, 0);
1011 } 1015 }
1012 1016
1013 if (GPT - nchars < PT) 1017 if (! text_at_gap_tail && GPT - nchars < PT)
1014 adjust_point (nchars, nbytes); 1018 adjust_point (nchars, nbytes);
1015 1019
1016 check_markers (); 1020 check_markers ();
diff --git a/src/keyboard.c b/src/keyboard.c
index 65d44ca3d1f..cf05d2f3855 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -6571,10 +6571,7 @@ has the same base event type and all the specified modifiers. */)
6571 else if (SYMBOLP (base)) 6571 else if (SYMBOLP (base))
6572 return apply_modifiers (modifiers, base); 6572 return apply_modifiers (modifiers, base);
6573 else 6573 else
6574 { 6574 error ("Invalid base event");
6575 error ("Invalid base event");
6576 return Qnil;
6577 }
6578} 6575}
6579 6576
6580/* Try to recognize SYMBOL as a modifier name. 6577/* Try to recognize SYMBOL as a modifier name.
@@ -6834,48 +6831,6 @@ gobble_input (void)
6834 return nread; 6831 return nread;
6835} 6832}
6836 6833
6837static void
6838decode_keyboard_code (struct tty_display_info *tty,
6839 struct coding_system *coding,
6840 unsigned char *buf, int nbytes)
6841{
6842 unsigned char *src = buf;
6843 const unsigned char *p;
6844 int i;
6845
6846 if (nbytes == 0)
6847 return;
6848 if (tty->meta_key != 2)
6849 for (i = 0; i < nbytes; i++)
6850 buf[i] &= ~0x80;
6851 if (coding->carryover_bytes > 0)
6852 {
6853 src = alloca (coding->carryover_bytes + nbytes);
6854 memcpy (src, coding->carryover, coding->carryover_bytes);
6855 memcpy (src + coding->carryover_bytes, buf, nbytes);
6856 nbytes += coding->carryover_bytes;
6857 }
6858 coding->destination = alloca (nbytes * 4);
6859 coding->dst_bytes = nbytes * 4;
6860 decode_coding_c_string (coding, src, nbytes, Qnil);
6861 if (coding->produced_char == 0)
6862 return;
6863 for (i = 0, p = coding->destination; i < coding->produced_char; i++)
6864 {
6865 struct input_event event_buf;
6866
6867 EVENT_INIT (event_buf);
6868 event_buf.code = STRING_CHAR_ADVANCE (p);
6869 event_buf.kind =
6870 (ASCII_CHAR_P (event_buf.code)
6871 ? ASCII_KEYSTROKE_EVENT : MULTIBYTE_CHAR_KEYSTROKE_EVENT);
6872 /* See the comment in tty_read_avail_input. */
6873 event_buf.frame_or_window = tty->top_frame;
6874 event_buf.arg = Qnil;
6875 kbd_buffer_store_event (&event_buf);
6876 }
6877}
6878
6879/* This is the tty way of reading available input. 6834/* This is the tty way of reading available input.
6880 6835
6881 Note that each terminal device has its own `struct terminal' object, 6836 Note that each terminal device has its own `struct terminal' object,
@@ -7033,36 +6988,6 @@ tty_read_avail_input (struct terminal *terminal,
7033#endif /* not MSDOS */ 6988#endif /* not MSDOS */
7034#endif /* not WINDOWSNT */ 6989#endif /* not WINDOWSNT */
7035 6990
7036 if (TERMINAL_KEYBOARD_CODING (terminal)->common_flags
7037 & CODING_REQUIRE_DECODING_MASK)
7038 {
7039 struct coding_system *coding = TERMINAL_KEYBOARD_CODING (terminal);
7040 int from;
7041
7042 /* Decode the key sequence except for those with meta
7043 modifiers. */
7044 for (i = from = 0; ; i++)
7045 if (i == nread || (tty->meta_key == 1 && (cbuf[i] & 0x80)))
7046 {
7047 struct input_event buf;
7048
7049 decode_keyboard_code (tty, coding, cbuf + from, i - from);
7050 if (i == nread)
7051 break;
7052
7053 EVENT_INIT (buf);
7054 buf.kind = ASCII_KEYSTROKE_EVENT;
7055 buf.modifiers = meta_modifier;
7056 buf.code = cbuf[i] & ~0x80;
7057 /* See the comment below. */
7058 buf.frame_or_window = tty->top_frame;
7059 buf.arg = Qnil;
7060 kbd_buffer_store_event (&buf);
7061 from = i + 1;
7062 }
7063 return nread;
7064 }
7065
7066 for (i = 0; i < nread; i++) 6991 for (i = 0; i < nread; i++)
7067 { 6992 {
7068 struct input_event buf; 6993 struct input_event buf;
@@ -8802,6 +8727,71 @@ test_undefined (Lisp_Object binding)
8802 && EQ (Fcommand_remapping (binding, Qnil, Qnil), Qundefined))); 8727 && EQ (Fcommand_remapping (binding, Qnil, Qnil), Qundefined)));
8803} 8728}
8804 8729
8730/* Like `read_char' but applies keyboard-coding-system to tty input. */
8731static Lisp_Object
8732read_decoded_char (int commandflag, Lisp_Object map,
8733 Lisp_Object prev_event, bool *used_mouse_menu)
8734{
8735#define MAX_ENCODED_BYTES 16
8736 Lisp_Object events[MAX_ENCODED_BYTES];
8737 int n = 0;
8738 while (true)
8739 {
8740 Lisp_Object nextevt
8741 = read_char (commandflag, map, prev_event, used_mouse_menu, NULL);
8742 struct frame *frame = XFRAME (selected_frame);
8743 struct terminal *terminal = frame->terminal;
8744 if (!((FRAME_TERMCAP_P (frame) || FRAME_MSDOS_P (frame))
8745 && (TERMINAL_KEYBOARD_CODING (terminal)->common_flags
8746 & CODING_REQUIRE_DECODING_MASK)))
8747 return nextevt; /* No decoding needed. */
8748 else
8749 {
8750 int meta_key = terminal->display_info.tty->meta_key;
8751 eassert (n < MAX_ENCODED_BYTES);
8752 events[n++] = nextevt;
8753 if (NATNUMP (nextevt)
8754 && XINT (nextevt) < (meta_key == 1 ? 0x80 : 0x100))
8755 { /* An encoded byte sequence, let's try to decode it. */
8756 struct coding_system *coding
8757 = TERMINAL_KEYBOARD_CODING (terminal);
8758 unsigned char *src = alloca (n);
8759 int i;
8760 for (i = 0; i < n; i++)
8761 src[i] = XINT (events[i]);
8762 if (meta_key != 2)
8763 for (i = 0; i < n; i++)
8764 src[i] &= ~0x80;
8765 coding->destination = alloca (n * 4);
8766 coding->dst_bytes = n * 4;
8767 decode_coding_c_string (coding, src, n, Qnil);
8768 eassert (coding->produced_char <= n);
8769 if (coding->produced_char == 0)
8770 { /* The encoded sequence is incomplete. */
8771 if (n < MAX_ENCODED_BYTES) /* Avoid buffer overflow. */
8772 continue; /* Read on! */
8773 }
8774 else
8775 {
8776 const unsigned char *p = coding->destination;
8777 eassert (coding->carryover_bytes == 0);
8778 n = 0;
8779 while (n < coding->produced_char)
8780 events[n++] = make_number (STRING_CHAR_ADVANCE (p));
8781 }
8782 }
8783 /* Now `events' should hold decoded events.
8784 Normally, n should be equal to 1, but better not rely on it.
8785 We can only return one event here, so return the first we
8786 had and keep the others (if any) for later. */
8787 while (n > 1)
8788 Vunread_command_events
8789 = Fcons (events[--n], Vunread_command_events);
8790 return events[0];
8791 }
8792 }
8793}
8794
8805/* Read a sequence of keys that ends with a non prefix character, 8795/* Read a sequence of keys that ends with a non prefix character,
8806 storing it in KEYBUF, a buffer of size BUFSIZE. 8796 storing it in KEYBUF, a buffer of size BUFSIZE.
8807 Prompt with PROMPT. 8797 Prompt with PROMPT.
@@ -9079,9 +9069,9 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9079 { 9069 {
9080 KBOARD *interrupted_kboard = current_kboard; 9070 KBOARD *interrupted_kboard = current_kboard;
9081 struct frame *interrupted_frame = SELECTED_FRAME (); 9071 struct frame *interrupted_frame = SELECTED_FRAME ();
9082 key = read_char (NILP (prompt), 9072 key = read_decoded_char (NILP (prompt),
9083 current_binding, last_nonmenu_event, 9073 current_binding, last_nonmenu_event,
9084 &used_mouse_menu, NULL); 9074 &used_mouse_menu);
9085 if ((INTEGERP (key) && XINT (key) == -2) /* wrong_kboard_jmpbuf */ 9075 if ((INTEGERP (key) && XINT (key) == -2) /* wrong_kboard_jmpbuf */
9086 /* When switching to a new tty (with a new keyboard), 9076 /* When switching to a new tty (with a new keyboard),
9087 read_char returns the new buffer, rather than -2 9077 read_char returns the new buffer, rather than -2
@@ -10572,7 +10562,7 @@ See also `current-input-mode'. */)
10572 if (tty->flow_control != !NILP (flow)) 10562 if (tty->flow_control != !NILP (flow))
10573 { 10563 {
10574#ifndef DOS_NT 10564#ifndef DOS_NT
10575 /* this causes startup screen to be restored and messes with the mouse */ 10565 /* This causes startup screen to be restored and messes with the mouse. */
10576 reset_sys_modes (tty); 10566 reset_sys_modes (tty);
10577#endif 10567#endif
10578 10568
diff --git a/src/keymap.c b/src/keymap.c
index 922c1703edf..00eefb375ef 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -565,7 +565,8 @@ map_keymap_char_table_item (Lisp_Object args, Lisp_Object key, Lisp_Object val)
565{ 565{
566 if (!NILP (val)) 566 if (!NILP (val))
567 { 567 {
568 map_keymap_function_t fun = XSAVE_POINTER (args, 0); 568 map_keymap_function_t fun
569 = (map_keymap_function_t) XSAVE_POINTER (args, 0);
569 /* If the key is a range, make a copy since map_char_table modifies 570 /* If the key is a range, make a copy since map_char_table modifies
570 it in place. */ 571 it in place. */
571 if (CONSP (key)) 572 if (CONSP (key))
@@ -2310,7 +2311,6 @@ around function keys and event symbols. */)
2310 return Fcopy_sequence (key); 2311 return Fcopy_sequence (key);
2311 else 2312 else
2312 error ("KEY must be an integer, cons, symbol, or string"); 2313 error ("KEY must be an integer, cons, symbol, or string");
2313 return Qnil;
2314} 2314}
2315 2315
2316static char * 2316static char *
diff --git a/src/lisp.h b/src/lisp.h
index b46f466406b..b209a7b1351 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2885,7 +2885,7 @@ extern void insert (const char *, ptrdiff_t);
2885extern void insert_and_inherit (const char *, ptrdiff_t); 2885extern void insert_and_inherit (const char *, ptrdiff_t);
2886extern void insert_1_both (const char *, ptrdiff_t, ptrdiff_t, 2886extern void insert_1_both (const char *, ptrdiff_t, ptrdiff_t,
2887 bool, bool, bool); 2887 bool, bool, bool);
2888extern void insert_from_gap (ptrdiff_t, ptrdiff_t); 2888extern void insert_from_gap (ptrdiff_t, ptrdiff_t, bool text_at_gap_tail);
2889extern void insert_from_string (Lisp_Object, ptrdiff_t, ptrdiff_t, 2889extern void insert_from_string (Lisp_Object, ptrdiff_t, ptrdiff_t,
2890 ptrdiff_t, ptrdiff_t, bool); 2890 ptrdiff_t, ptrdiff_t, bool);
2891extern void insert_from_buffer (struct buffer *, ptrdiff_t, ptrdiff_t, bool); 2891extern void insert_from_buffer (struct buffer *, ptrdiff_t, ptrdiff_t, bool);
diff --git a/src/lread.c b/src/lread.c
index e7af86aa664..f8ab03af218 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -348,11 +348,14 @@ readchar (Lisp_Object readcharfun, bool *multibyte)
348 return STRING_CHAR (buf); 348 return STRING_CHAR (buf);
349} 349}
350 350
351#define FROM_FILE_P(readcharfun) \
352 (EQ (readcharfun, Qget_file_char) \
353 || EQ (readcharfun, Qget_emacs_mule_file_char))
354
351static void 355static void
352skip_dyn_bytes (Lisp_Object readcharfun, ptrdiff_t n) 356skip_dyn_bytes (Lisp_Object readcharfun, ptrdiff_t n)
353{ 357{
354 if (EQ (readcharfun, Qget_file_char) 358 if (FROM_FILE_P (readcharfun))
355 || EQ (readcharfun, Qget_emacs_mule_file_char))
356 { 359 {
357 block_input (); /* FIXME: Not sure if it's needed. */ 360 block_input (); /* FIXME: Not sure if it's needed. */
358 fseek (instream, n, SEEK_CUR); 361 fseek (instream, n, SEEK_CUR);
@@ -423,8 +426,7 @@ unreadchar (Lisp_Object readcharfun, int c)
423 { 426 {
424 unread_char = c; 427 unread_char = c;
425 } 428 }
426 else if (EQ (readcharfun, Qget_file_char) 429 else if (FROM_FILE_P (readcharfun))
427 || EQ (readcharfun, Qget_emacs_mule_file_char))
428 { 430 {
429 unread_char = c; 431 unread_char = c;
430 } 432 }
@@ -2636,8 +2638,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
2636 UNREAD (c); 2638 UNREAD (c);
2637 2639
2638 if (load_force_doc_strings 2640 if (load_force_doc_strings
2639 && (EQ (readcharfun, Qget_file_char) 2641 && (FROM_FILE_P (readcharfun)))
2640 || EQ (readcharfun, Qget_emacs_mule_file_char)))
2641 { 2642 {
2642 /* If we are supposed to force doc strings into core right now, 2643 /* If we are supposed to force doc strings into core right now,
2643 record the last string that we skipped, 2644 record the last string that we skipped,
@@ -3573,8 +3574,10 @@ read_list (bool flag, Lisp_Object readcharfun)
3573 { 3574 {
3574 if (doc_reference == 1) 3575 if (doc_reference == 1)
3575 return make_number (0); 3576 return make_number (0);
3576 if (doc_reference == 2) 3577 if (doc_reference == 2 && INTEGERP (XCDR (val)))
3577 { 3578 {
3579 char *saved = NULL;
3580 file_offset saved_position;
3578 /* Get a doc string from the file we are loading. 3581 /* Get a doc string from the file we are loading.
3579 If it's in saved_doc_string, get it from there. 3582 If it's in saved_doc_string, get it from there.
3580 3583
@@ -3591,65 +3594,42 @@ read_list (bool flag, Lisp_Object readcharfun)
3591 && pos < (saved_doc_string_position 3594 && pos < (saved_doc_string_position
3592 + saved_doc_string_length)) 3595 + saved_doc_string_length))
3593 { 3596 {
3594 ptrdiff_t start = pos - saved_doc_string_position; 3597 saved = saved_doc_string;
3595 ptrdiff_t from, to; 3598 saved_position = saved_doc_string_position;
3596
3597 /* Process quoting with ^A,
3598 and find the end of the string,
3599 which is marked with ^_ (037). */
3600 for (from = start, to = start;
3601 saved_doc_string[from] != 037;)
3602 {
3603 int c = saved_doc_string[from++];
3604 if (c == 1)
3605 {
3606 c = saved_doc_string[from++];
3607 if (c == 1)
3608 saved_doc_string[to++] = c;
3609 else if (c == '0')
3610 saved_doc_string[to++] = 0;
3611 else if (c == '_')
3612 saved_doc_string[to++] = 037;
3613 }
3614 else
3615 saved_doc_string[to++] = c;
3616 }
3617
3618 return make_unibyte_string (saved_doc_string + start,
3619 to - start);
3620 } 3599 }
3621 /* Look in prev_saved_doc_string the same way. */ 3600 /* Look in prev_saved_doc_string the same way. */
3622 else if (pos >= prev_saved_doc_string_position 3601 else if (pos >= prev_saved_doc_string_position
3623 && pos < (prev_saved_doc_string_position 3602 && pos < (prev_saved_doc_string_position
3624 + prev_saved_doc_string_length)) 3603 + prev_saved_doc_string_length))
3625 { 3604 {
3626 ptrdiff_t start = 3605 saved = prev_saved_doc_string;
3627 pos - prev_saved_doc_string_position; 3606 saved_position = prev_saved_doc_string_position;
3607 }
3608 if (saved)
3609 {
3610 ptrdiff_t start = pos - saved_position;
3628 ptrdiff_t from, to; 3611 ptrdiff_t from, to;
3629 3612
3630 /* Process quoting with ^A, 3613 /* Process quoting with ^A,
3631 and find the end of the string, 3614 and find the end of the string,
3632 which is marked with ^_ (037). */ 3615 which is marked with ^_ (037). */
3633 for (from = start, to = start; 3616 for (from = start, to = start;
3634 prev_saved_doc_string[from] != 037;) 3617 saved[from] != 037;)
3635 { 3618 {
3636 int c = prev_saved_doc_string[from++]; 3619 int c = saved[from++];
3637 if (c == 1) 3620 if (c == 1)
3638 { 3621 {
3639 c = prev_saved_doc_string[from++]; 3622 c = saved[from++];
3640 if (c == 1) 3623 saved[to++] = (c == 1 ? c
3641 prev_saved_doc_string[to++] = c; 3624 : c == '0' ? 0
3642 else if (c == '0') 3625 : c == '_' ? 037
3643 prev_saved_doc_string[to++] = 0; 3626 : c);
3644 else if (c == '_')
3645 prev_saved_doc_string[to++] = 037;
3646 } 3627 }
3647 else 3628 else
3648 prev_saved_doc_string[to++] = c; 3629 saved[to++] = c;
3649 } 3630 }
3650 3631
3651 return make_unibyte_string (prev_saved_doc_string 3632 return make_unibyte_string (saved + start,
3652 + start,
3653 to - start); 3633 to - start);
3654 } 3634 }
3655 else 3635 else
diff --git a/src/region-cache.c b/src/region-cache.c
index 452a5b3a065..be7d50a50e4 100644
--- a/src/region-cache.c
+++ b/src/region-cache.c
@@ -190,10 +190,9 @@ find_cache_boundary (struct region_cache *c, ptrdiff_t pos)
190 } 190 }
191 191
192 /* Some testing. */ 192 /* Some testing. */
193 if (BOUNDARY_POS (c, low) > pos 193 eassert (!(BOUNDARY_POS (c, low) > pos
194 || (low + 1 < c->cache_len 194 || (low + 1 < c->cache_len
195 && BOUNDARY_POS (c, low + 1) <= pos)) 195 && BOUNDARY_POS (c, low + 1) <= pos)));
196 emacs_abort ();
197 196
198 return low; 197 return low;
199} 198}
@@ -214,14 +213,9 @@ move_cache_gap (struct region_cache *c, ptrdiff_t pos, ptrdiff_t min_size)
214 ptrdiff_t buffer_beg = c->buffer_beg; 213 ptrdiff_t buffer_beg = c->buffer_beg;
215 ptrdiff_t buffer_end = c->buffer_end; 214 ptrdiff_t buffer_end = c->buffer_end;
216 215
217 if (pos < 0
218 || pos > c->cache_len)
219 emacs_abort ();
220
221 /* We mustn't ever try to put the gap before the dummy start 216 /* We mustn't ever try to put the gap before the dummy start
222 boundary. That must always be start-relative. */ 217 boundary. That must always be start-relative. */
223 if (pos == 0) 218 eassert (0 < pos && pos <= c->cache_len);
224 emacs_abort ();
225 219
226 /* Need we move the gap right? */ 220 /* Need we move the gap right? */
227 while (gap_start < pos) 221 while (gap_start < pos)
@@ -288,26 +282,19 @@ static void
288insert_cache_boundary (struct region_cache *c, ptrdiff_t i, ptrdiff_t pos, 282insert_cache_boundary (struct region_cache *c, ptrdiff_t i, ptrdiff_t pos,
289 int value) 283 int value)
290{ 284{
291 /* i must be a valid cache index. */ 285 /* I must be a valid cache index, and we must never want
292 if (i < 0 || i > c->cache_len) 286 to insert something before the dummy first boundary. */
293 emacs_abort (); 287 eassert (0 < i && i <= c->cache_len);
294
295 /* We must never want to insert something before the dummy first
296 boundary. */
297 if (i == 0)
298 emacs_abort ();
299 288
300 /* We must only be inserting things in order. */ 289 /* We must only be inserting things in order. */
301 if (! (BOUNDARY_POS (c, i - 1) < pos 290 eassert ((BOUNDARY_POS (c, i - 1) < pos
302 && (i == c->cache_len 291 && (i == c->cache_len
303 || pos < BOUNDARY_POS (c, i)))) 292 || pos < BOUNDARY_POS (c, i))));
304 emacs_abort ();
305 293
306 /* The value must be different from the ones around it. However, we 294 /* The value must be different from the ones around it. However, we
307 temporarily create boundaries that establish the same value as 295 temporarily create boundaries that establish the same value as
308 the subsequent boundary, so we're not going to flag that case. */ 296 the subsequent boundary, so we're not going to flag that case. */
309 if (BOUNDARY_VALUE (c, i - 1) == value) 297 eassert (BOUNDARY_VALUE (c, i - 1) != value);
310 emacs_abort ();
311 298
312 move_cache_gap (c, i, 1); 299 move_cache_gap (c, i, 1);
313 300
@@ -328,18 +315,13 @@ delete_cache_boundaries (struct region_cache *c,
328 ptrdiff_t len = end - start; 315 ptrdiff_t len = end - start;
329 316
330 /* Gotta be in range. */ 317 /* Gotta be in range. */
331 if (start < 0 318 eassert (0 <= start && end <= c->cache_len);
332 || end > c->cache_len)
333 emacs_abort ();
334 319
335 /* Gotta be in order. */ 320 /* Gotta be in order. */
336 if (start > end) 321 eassert (start <= end);
337 emacs_abort ();
338 322
339 /* Can't delete the dummy entry. */ 323 /* Can't delete the dummy entry. */
340 if (start == 0 324 eassert (!(start == 0 && end >= 1));
341 && end >= 1)
342 emacs_abort ();
343 325
344 /* Minimize gap motion. If we're deleting nothing, do nothing. */ 326 /* Minimize gap motion. If we're deleting nothing, do nothing. */
345 if (len == 0) 327 if (len == 0)
@@ -378,11 +360,8 @@ static void
378set_cache_region (struct region_cache *c, 360set_cache_region (struct region_cache *c,
379 ptrdiff_t start, ptrdiff_t end, int value) 361 ptrdiff_t start, ptrdiff_t end, int value)
380{ 362{
381 if (start > end) 363 eassert (start <= end);
382 emacs_abort (); 364 eassert (c->buffer_beg <= start && end <= c->buffer_end);
383 if (start < c->buffer_beg
384 || end > c->buffer_end)
385 emacs_abort ();
386 365
387 /* Eliminate this case; then we can assume that start and end-1 are 366 /* Eliminate this case; then we can assume that start and end-1 are
388 both the locations of real characters in the buffer. */ 367 both the locations of real characters in the buffer. */
@@ -772,7 +751,8 @@ int region_cache_backward (struct buffer *buf, struct region_cache *c,
772 } 751 }
773} 752}
774 753
775 754#ifdef ENABLE_CHECKING
755
776/* Debugging: pretty-print a cache to the standard error output. */ 756/* Debugging: pretty-print a cache to the standard error output. */
777 757
778void pp_cache (struct region_cache *) EXTERNALLY_VISIBLE; 758void pp_cache (struct region_cache *) EXTERNALLY_VISIBLE;
@@ -803,3 +783,5 @@ pp_cache (struct region_cache *c)
803 fprintf (stderr, "%"pD"d : %d\n", pos, BOUNDARY_VALUE (c, i)); 783 fprintf (stderr, "%"pD"d : %d\n", pos, BOUNDARY_VALUE (c, i));
804 } 784 }
805} 785}
786
787#endif /* ENABLE_CHECKING */
diff --git a/src/sysdep.c b/src/sysdep.c
index fe6371623a9..bff11fc9f75 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -38,9 +38,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
38#include "sysselect.h" 38#include "sysselect.h"
39#include "blockinput.h" 39#include "blockinput.h"
40 40
41#ifdef BSD_SYSTEM 41#if defined DARWIN_OS || defined __FreeBSD__
42#include <sys/param.h> 42# include <sys/sysctl.h>
43#include <sys/sysctl.h>
44#endif 43#endif
45 44
46#ifdef __FreeBSD__ 45#ifdef __FreeBSD__
@@ -69,9 +68,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
69 68
70#ifdef MSDOS /* Demacs 1.1.2 91/10/20 Manabu Higashida, MW Aug 1993 */ 69#ifdef MSDOS /* Demacs 1.1.2 91/10/20 Manabu Higashida, MW Aug 1993 */
71#include "msdos.h" 70#include "msdos.h"
72#include <sys/param.h>
73#endif 71#endif
74 72
73#include <sys/param.h>
75#include <sys/file.h> 74#include <sys/file.h>
76#include <fcntl.h> 75#include <fcntl.h>
77 76
@@ -1290,10 +1289,9 @@ reset_sys_modes (struct tty_display_info *tty_out)
1290 if (tty_out->terminal->reset_terminal_modes_hook) 1289 if (tty_out->terminal->reset_terminal_modes_hook)
1291 tty_out->terminal->reset_terminal_modes_hook (tty_out->terminal); 1290 tty_out->terminal->reset_terminal_modes_hook (tty_out->terminal);
1292 1291
1293#ifdef BSD_SYSTEM
1294 /* Avoid possible loss of output when changing terminal modes. */ 1292 /* Avoid possible loss of output when changing terminal modes. */
1295 fsync (fileno (tty_out->output)); 1293 while (fdatasync (fileno (tty_out->output)) != 0 && errno == EINTR)
1296#endif 1294 continue;
1297 1295
1298#ifndef DOS_NT 1296#ifndef DOS_NT
1299#ifdef F_SETOWN 1297#ifdef F_SETOWN
diff --git a/src/term.c b/src/term.c
index a31fd51084e..38706602a02 100644
--- a/src/term.c
+++ b/src/term.c
@@ -1321,7 +1321,7 @@ term_get_fkeys_1 (void)
1321 if (!KEYMAPP (KVAR (kboard, Vinput_decode_map))) 1321 if (!KEYMAPP (KVAR (kboard, Vinput_decode_map)))
1322 kset_input_decode_map (kboard, Fmake_sparse_keymap (Qnil)); 1322 kset_input_decode_map (kboard, Fmake_sparse_keymap (Qnil));
1323 1323
1324 for (i = 0; i < (sizeof (keys)/sizeof (keys[0])); i++) 1324 for (i = 0; i < (sizeof (keys) / sizeof (keys[0])); i++)
1325 { 1325 {
1326 char *sequence = tgetstr (keys[i].cap, address); 1326 char *sequence = tgetstr (keys[i].cap, address);
1327 if (sequence) 1327 if (sequence)
@@ -3426,9 +3426,6 @@ maybe_fatal (int must_succeed, struct terminal *terminal,
3426 vfatal (str2, ap); 3426 vfatal (str2, ap);
3427 else 3427 else
3428 verror (str1, ap); 3428 verror (str1, ap);
3429
3430 va_end (ap);
3431 emacs_abort ();
3432} 3429}
3433 3430
3434void 3431void
@@ -3437,7 +3434,6 @@ fatal (const char *str, ...)
3437 va_list ap; 3434 va_list ap;
3438 va_start (ap, str); 3435 va_start (ap, str);
3439 vfatal (str, ap); 3436 vfatal (str, ap);
3440 va_end (ap);
3441} 3437}
3442 3438
3443 3439
diff --git a/src/termhooks.h b/src/termhooks.h
index a770734bac6..cdb788cfb07 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -385,7 +385,7 @@ struct terminal
385 struct image_cache *image_cache; 385 struct image_cache *image_cache;
386#endif /* HAVE_WINDOW_SYSTEM */ 386#endif /* HAVE_WINDOW_SYSTEM */
387 387
388 /* Device-type dependent data shared amongst all frames on this terminal. */ 388 /* Device-type dependent data shared amongst all frames on this terminal. */
389 union display_info 389 union display_info
390 { 390 {
391 struct tty_display_info *tty; /* termchar.h */ 391 struct tty_display_info *tty; /* termchar.h */
@@ -406,22 +406,22 @@ struct terminal
406 the function `set-keyboard-coding-system'. */ 406 the function `set-keyboard-coding-system'. */
407 struct coding_system *keyboard_coding; 407 struct coding_system *keyboard_coding;
408 408
409 /* Terminal characteristics. */ 409 /* Terminal characteristics. */
410 /* XXX Are these really used on non-termcap displays? */ 410 /* XXX Are these really used on non-termcap displays? */
411 411
412 int must_write_spaces; /* Nonzero means spaces in the text must 412 int must_write_spaces; /* Nonzero means spaces in the text must
413 actually be output; can't just skip over 413 actually be output; can't just skip over
414 some columns to leave them blank. */ 414 some columns to leave them blank. */
415 int fast_clear_end_of_line; /* Nonzero means terminal has a `ce' string */ 415 int fast_clear_end_of_line; /* Nonzero means terminal has a `ce' string. */
416 416
417 int line_ins_del_ok; /* Terminal can insert and delete lines */ 417 int line_ins_del_ok; /* Terminal can insert and delete lines. */
418 int char_ins_del_ok; /* Terminal can insert and delete chars */ 418 int char_ins_del_ok; /* Terminal can insert and delete chars. */
419 int scroll_region_ok; /* Terminal supports setting the scroll 419 int scroll_region_ok; /* Terminal supports setting the scroll
420 window */ 420 window. */
421 int scroll_region_cost; /* Cost of setting the scroll window, 421 int scroll_region_cost; /* Cost of setting the scroll window,
422 measured in characters. */ 422 measured in characters. */
423 int memory_below_frame; /* Terminal remembers lines scrolled 423 int memory_below_frame; /* Terminal remembers lines scrolled
424 off bottom */ 424 off bottom. */
425 425
426 /* Window-based redisplay interface for this device (0 for tty 426 /* Window-based redisplay interface for this device (0 for tty
427 devices). */ 427 devices). */
@@ -620,7 +620,7 @@ tset_selection_alist (struct terminal *t, Lisp_Object val)
620 t->Vselection_alist = val; 620 t->Vselection_alist = val;
621} 621}
622 622
623/* Chain of all terminal devices currently in use. */ 623/* Chain of all terminal devices currently in use. */
624extern struct terminal *terminal_list; 624extern struct terminal *terminal_list;
625 625
626#define FRAME_MUST_WRITE_SPACES(f) ((f)->terminal->must_write_spaces) 626#define FRAME_MUST_WRITE_SPACES(f) ((f)->terminal->must_write_spaces)
@@ -641,14 +641,16 @@ extern struct terminal *terminal_list;
641 641
642#define FRAME_TERMINAL(f) ((f)->terminal) 642#define FRAME_TERMINAL(f) ((f)->terminal)
643 643
644/* Return true if the terminal device is not suspended. */ 644/* Return true if the terminal device is not suspended. */
645#define TERMINAL_ACTIVE_P(d) (((d)->type != output_termcap && (d)->type !=output_msdos_raw) || (d)->display_info.tty->input) 645#define TERMINAL_ACTIVE_P(d) \
646 (((d)->type != output_termcap && (d)->type != output_msdos_raw) \
647 || (d)->display_info.tty->input)
646 648
647extern struct terminal *get_terminal (Lisp_Object terminal, int); 649extern struct terminal *get_terminal (Lisp_Object terminal, int);
648extern struct terminal *create_terminal (void); 650extern struct terminal *create_terminal (void);
649extern void delete_terminal (struct terminal *); 651extern void delete_terminal (struct terminal *);
650 652
651/* The initial terminal device, created by initial_term_init. */ 653/* The initial terminal device, created by initial_term_init. */
652extern struct terminal *initial_terminal; 654extern struct terminal *initial_terminal;
653 655
654extern unsigned char *encode_terminal_code (struct glyph *, int, 656extern unsigned char *encode_terminal_code (struct glyph *, int,
diff --git a/src/terminal.c b/src/terminal.c
index 5e1f1ff77f7..c99c39c64ae 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -280,7 +280,7 @@ delete_terminal (struct terminal *terminal)
280 xfree (terminal->name); 280 xfree (terminal->name);
281 terminal->name = NULL; 281 terminal->name = NULL;
282 282
283 /* Check for live frames that are still on this terminal. */ 283 /* Check for live frames that are still on this terminal. */
284 FOR_EACH_FRAME (tail, frame) 284 FOR_EACH_FRAME (tail, frame)
285 { 285 {
286 struct frame *f = XFRAME (frame); 286 struct frame *f = XFRAME (frame);
diff --git a/src/textprop.c b/src/textprop.c
index 18e893b3ef2..2b454485370 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -60,7 +60,7 @@ Lisp_Object Qinvisible, Qintangible, Qmouse_face;
60static Lisp_Object Qread_only; 60static Lisp_Object Qread_only;
61Lisp_Object Qminibuffer_prompt; 61Lisp_Object Qminibuffer_prompt;
62 62
63/* Sticky properties */ 63/* Sticky properties. */
64Lisp_Object Qfront_sticky, Qrear_nonsticky; 64Lisp_Object Qfront_sticky, Qrear_nonsticky;
65 65
66/* If o1 is a cons whose cdr is a cons, return non-zero and set o2 to 66/* If o1 is a cons whose cdr is a cons, return non-zero and set o2 to
diff --git a/src/w32fns.c b/src/w32fns.c
index 6fd980c6b70..cef2009d7a1 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -1721,11 +1721,9 @@ x_set_name (struct frame *f, Lisp_Object name, int explicit)
1721 1721
1722 if (FRAME_W32_WINDOW (f)) 1722 if (FRAME_W32_WINDOW (f))
1723 { 1723 {
1724 if (STRING_MULTIBYTE (name))
1725 name = ENCODE_SYSTEM (name);
1726
1727 block_input (); 1724 block_input ();
1728 SetWindowText (FRAME_W32_WINDOW (f), SDATA (name)); 1725 GUI_FN (SetWindowText) (FRAME_W32_WINDOW (f),
1726 GUI_SDATA (GUI_ENCODE_SYSTEM (name)));
1729 unblock_input (); 1727 unblock_input ();
1730 } 1728 }
1731} 1729}
@@ -1767,11 +1765,9 @@ x_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name)
1767 1765
1768 if (FRAME_W32_WINDOW (f)) 1766 if (FRAME_W32_WINDOW (f))
1769 { 1767 {
1770 if (STRING_MULTIBYTE (name))
1771 name = ENCODE_SYSTEM (name);
1772
1773 block_input (); 1768 block_input ();
1774 SetWindowText (FRAME_W32_WINDOW (f), SDATA (name)); 1769 GUI_FN (SetWindowText) (FRAME_W32_WINDOW (f),
1770 GUI_SDATA (GUI_ENCODE_SYSTEM (name)));
1775 unblock_input (); 1771 unblock_input ();
1776 } 1772 }
1777} 1773}
@@ -5824,7 +5820,7 @@ Text larger than the specified size is clipped. */)
5824 int row_width; 5820 int row_width;
5825 5821
5826 /* Stop at the first empty row at the end. */ 5822 /* Stop at the first empty row at the end. */
5827 if (!row->enabled_p || !row->displays_text_p) 5823 if (!row->enabled_p || !MATRIX_ROW_DISPLAYS_TEXT_P (row))
5828 break; 5824 break;
5829 5825
5830 /* Let the row go over the full width of the frame. */ 5826 /* Let the row go over the full width of the frame. */
@@ -5885,7 +5881,7 @@ Text larger than the specified size is clipped. */)
5885 struct glyph *last; 5881 struct glyph *last;
5886 int row_width; 5882 int row_width;
5887 5883
5888 if (!row->enabled_p || !row->displays_text_p) 5884 if (!row->enabled_p || !MATRIX_ROW_DISPLAYS_TEXT_P (row))
5889 break; 5885 break;
5890 row->full_width_p = 1; 5886 row->full_width_p = 1;
5891 row_width = row->pixel_width; 5887 row_width = row->pixel_width;
@@ -6006,14 +6002,6 @@ Value is t if tooltip was open, nil otherwise. */)
6006#define FILE_NAME_COMBO_BOX cmb13 6002#define FILE_NAME_COMBO_BOX cmb13
6007#define FILE_NAME_LIST lst1 6003#define FILE_NAME_LIST lst1
6008 6004
6009#ifdef NTGUI_UNICODE
6010#define GUISTR(x) (L ## x)
6011typedef wchar_t guichar_t;
6012#else /* !NTGUI_UNICODE */
6013#define GUISTR(x) x
6014typedef char guichar_t;
6015#endif /* NTGUI_UNICODE */
6016
6017/* Callback for altering the behavior of the Open File dialog. 6005/* Callback for altering the behavior of the Open File dialog.
6018 Makes the Filename text field contain "Current Directory" and be 6006 Makes the Filename text field contain "Current Directory" and be
6019 read-only when "Directories" is selected in the filter. This 6007 read-only when "Directories" is selected in the filter. This
@@ -6230,11 +6218,7 @@ Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */)
6230 block_input (); 6218 block_input ();
6231 file_details->lpfnHook = file_dialog_callback; 6219 file_details->lpfnHook = file_dialog_callback;
6232 6220
6233#ifdef NTGUI_UNICODE 6221 file_opened = GUI_FN (GetOpenFileName) (file_details);
6234 file_opened = GetOpenFileNameW (file_details);
6235#else /* !NTGUI_UNICODE */
6236 file_opened = GetOpenFileNameA (file_details);
6237#endif /* NTGUI_UNICODE */
6238 unblock_input (); 6222 unblock_input ();
6239 unbind_to (count, Qnil); 6223 unbind_to (count, Qnil);
6240 } 6224 }
@@ -6243,11 +6227,7 @@ Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */)
6243 { 6227 {
6244 /* Get an Emacs string from the value Windows gave us. */ 6228 /* Get an Emacs string from the value Windows gave us. */
6245#ifdef NTGUI_UNICODE 6229#ifdef NTGUI_UNICODE
6246 filename = from_unicode ( 6230 filename = from_unicode_buffer (filename_buf);
6247 make_unibyte_string (
6248 (char*) filename_buf,
6249 /* we get one of the two final 0 bytes for free. */
6250 1 + sizeof (wchar_t) * wcslen (filename_buf)));
6251#else /* !NTGUI_UNICODE */ 6231#else /* !NTGUI_UNICODE */
6252 dostounix_filename (filename_buf, 0); 6232 dostounix_filename (filename_buf, 0);
6253 filename = DECODE_FILE (build_string (filename_buf)); 6233 filename = DECODE_FILE (build_string (filename_buf));
@@ -6421,20 +6401,29 @@ an integer representing a ShowWindow flag:
6421 CHECK_STRING (document); 6401 CHECK_STRING (document);
6422 6402
6423 /* Encode filename, current directory and parameters. */ 6403 /* Encode filename, current directory and parameters. */
6424 current_dir = ENCODE_FILE (BVAR (current_buffer, directory)); 6404 current_dir = BVAR (current_buffer, directory);
6425 document = ENCODE_FILE (document); 6405
6406#ifdef CYGWIN
6407 current_dir = Fcygwin_convert_file_name_to_windows (current_dir, Qt);
6408 if (STRINGP (document))
6409 document = Fcygwin_convert_file_name_to_windows (document, Qt);
6410#endif /* CYGWIN */
6411
6412 current_dir = GUI_ENCODE_FILE (current_dir);
6413 if (STRINGP (document))
6414 document = GUI_ENCODE_FILE (document);
6426 if (STRINGP (parameters)) 6415 if (STRINGP (parameters))
6427 parameters = ENCODE_SYSTEM (parameters); 6416 parameters = GUI_ENCODE_SYSTEM (parameters);
6428 6417
6429 if ((int) ShellExecute (NULL, 6418 if ((int) GUI_FN (ShellExecute) (NULL,
6430 (STRINGP (operation) ? 6419 (STRINGP (operation) ?
6431 SDATA (operation) : NULL), 6420 GUI_SDATA (operation) : NULL),
6432 SDATA (document), 6421 GUI_SDATA (document),
6433 (STRINGP (parameters) ? 6422 (STRINGP (parameters) ?
6434 SDATA (parameters) : NULL), 6423 GUI_SDATA (parameters) : NULL),
6435 SDATA (current_dir), 6424 GUI_SDATA (current_dir),
6436 (INTEGERP (show_flag) ? 6425 (INTEGERP (show_flag) ?
6437 XINT (show_flag) : SW_SHOWDEFAULT)) 6426 XINT (show_flag) : SW_SHOWDEFAULT))
6438 > 32) 6427 > 32)
6439 return Qt; 6428 return Qt;
6440 errstr = w32_strerror (0); 6429 errstr = w32_strerror (0);
@@ -6803,6 +6792,7 @@ The following %-sequences are provided:
6803} 6792}
6804 6793
6805 6794
6795#ifdef WINDOWSNT
6806DEFUN ("file-system-info", Ffile_system_info, Sfile_system_info, 1, 1, 0, 6796DEFUN ("file-system-info", Ffile_system_info, Sfile_system_info, 1, 1, 0,
6807 doc: /* Return storage information about the file system FILENAME is on. 6797 doc: /* Return storage information about the file system FILENAME is on.
6808Value is a list of floats (TOTAL FREE AVAIL), where TOTAL is the total 6798Value is a list of floats (TOTAL FREE AVAIL), where TOTAL is the total
@@ -6898,6 +6888,8 @@ If the underlying system call fails, value is nil. */)
6898 6888
6899 return value; 6889 return value;
6900} 6890}
6891#endif /* WINDOWSNT */
6892
6901 6893
6902DEFUN ("default-printer-name", Fdefault_printer_name, Sdefault_printer_name, 6894DEFUN ("default-printer-name", Fdefault_printer_name, Sdefault_printer_name,
6903 0, 0, 0, doc: /* Return the name of Windows default printer device. */) 6895 0, 0, 0, doc: /* Return the name of Windows default printer device. */)
@@ -7624,7 +7616,10 @@ only be necessary if the default setting causes problems. */);
7624 defsubr (&Sw32_window_exists_p); 7616 defsubr (&Sw32_window_exists_p);
7625 defsubr (&Sw32_battery_status); 7617 defsubr (&Sw32_battery_status);
7626 7618
7619#ifdef WINDOWSNT
7627 defsubr (&Sfile_system_info); 7620 defsubr (&Sfile_system_info);
7621#endif
7622
7628 defsubr (&Sdefault_printer_name); 7623 defsubr (&Sdefault_printer_name);
7629 defsubr (&Sset_message_beep); 7624 defsubr (&Sset_message_beep);
7630 7625
@@ -7805,3 +7800,15 @@ emacs_abort (void)
7805 } 7800 }
7806 } 7801 }
7807} 7802}
7803
7804#ifdef NTGUI_UNICODE
7805
7806Lisp_Object
7807ntgui_encode_system (Lisp_Object str)
7808{
7809 Lisp_Object encoded;
7810 to_unicode (str, &encoded);
7811 return encoded;
7812}
7813
7814#endif /* NTGUI_UNICODE */
diff --git a/src/w32term.c b/src/w32term.c
index 170f33ecd67..989ceb0f847 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -236,6 +236,7 @@ static void my_set_focus (struct frame *, HWND);
236#endif 236#endif
237static void my_set_foreground_window (HWND); 237static void my_set_foreground_window (HWND);
238static void my_destroy_window (struct frame *, HWND); 238static void my_destroy_window (struct frame *, HWND);
239static void w32fullscreen_hook (FRAME_PTR);
239 240
240#ifdef GLYPH_DEBUG 241#ifdef GLYPH_DEBUG
241static void x_check_font (struct frame *, struct font *); 242static void x_check_font (struct frame *, struct font *);
@@ -3161,7 +3162,7 @@ construct_drag_n_drop (struct input_event *result, W32Msg *msg, struct frame *f)
3161 HDROP hdrop; 3162 HDROP hdrop;
3162 POINT p; 3163 POINT p;
3163 WORD num_files; 3164 WORD num_files;
3164 char *name; 3165 guichar_t *name;
3165 int i, len; 3166 int i, len;
3166 3167
3167 result->kind = DRAG_N_DROP_EVENT; 3168 result->kind = DRAG_N_DROP_EVENT;
@@ -3186,12 +3187,17 @@ construct_drag_n_drop (struct input_event *result, W32Msg *msg, struct frame *f)
3186 3187
3187 for (i = 0; i < num_files; i++) 3188 for (i = 0; i < num_files; i++)
3188 { 3189 {
3189 len = DragQueryFile (hdrop, i, NULL, 0); 3190 len = GUI_FN (DragQueryFile) (hdrop, i, NULL, 0);
3190 if (len <= 0) 3191 if (len <= 0)
3191 continue; 3192 continue;
3192 name = alloca (len + 1); 3193
3193 DragQueryFile (hdrop, i, name, len + 1); 3194 name = alloca ((len + 1) * sizeof (*name));
3195 GUI_FN (DragQueryFile) (hdrop, i, name, len + 1);
3196#ifdef NTGUI_UNICODE
3197 files = Fcons (from_unicode_buffer (name), files);
3198#else
3194 files = Fcons (DECODE_FILE (build_string (name)), files); 3199 files = Fcons (DECODE_FILE (build_string (name)), files);
3200#endif /* NTGUI_UNICODE */
3195 } 3201 }
3196 3202
3197 DragFinish (hdrop); 3203 DragFinish (hdrop);
@@ -4699,20 +4705,23 @@ w32_read_socket (struct terminal *terminal,
4699 } 4705 }
4700 4706
4701 case WM_WINDOWPOSCHANGED: 4707 case WM_WINDOWPOSCHANGED:
4702 f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
4703 if (f)
4704 {
4705 if (f->want_fullscreen & FULLSCREEN_WAIT)
4706 f->want_fullscreen &= ~(FULLSCREEN_WAIT|FULLSCREEN_BOTH);
4707 }
4708 check_visibility = 1;
4709 break;
4710
4711 case WM_ACTIVATE: 4708 case WM_ACTIVATE:
4712 case WM_ACTIVATEAPP: 4709 case WM_ACTIVATEAPP:
4713 f = x_window_to_frame (dpyinfo, msg.msg.hwnd); 4710 f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
4714 if (f) 4711 if (f)
4715 x_check_fullscreen (f); 4712 {
4713 /* Run the full-screen hook function also when we are
4714 being activated, to actually install the required
4715 size in effect, if the WAIT flag is set. This is
4716 because when the hook is run from x_set_fullscreen,
4717 the frame might not yet be visible, if that call is a
4718 result of make-frame, and in that case the hook just
4719 sets the WAIT flag. */
4720 if ((msg.msg.message == WM_WINDOWPOSCHANGED || msg.msg.wParam)
4721 && (f->want_fullscreen & FULLSCREEN_WAIT))
4722 w32fullscreen_hook (f);
4723 x_check_fullscreen (f);
4724 }
4716 check_visibility = 1; 4725 check_visibility = 1;
4717 break; 4726 break;
4718 4727
@@ -5673,10 +5682,10 @@ w32fullscreen_hook (FRAME_PTR f)
5673 5682
5674 switch (f->want_fullscreen) 5683 switch (f->want_fullscreen)
5675 { 5684 {
5676 case FULLSCREEN_MAXIMIZED: 5685 case FULLSCREEN_BOTH:
5677 PostMessage (FRAME_W32_WINDOW (f), WM_SYSCOMMAND, SC_MAXIMIZE, 0); 5686 PostMessage (FRAME_W32_WINDOW (f), WM_SYSCOMMAND, SC_MAXIMIZE, 0);
5678 break; 5687 break;
5679 case FULLSCREEN_BOTH: 5688 case FULLSCREEN_MAXIMIZED:
5680 height = 5689 height =
5681 FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, pixel_height) 5690 FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, pixel_height)
5682 - XINT (Ftool_bar_lines_needed (selected_frame)) 5691 - XINT (Ftool_bar_lines_needed (selected_frame))
@@ -5724,8 +5733,11 @@ w32fullscreen_hook (FRAME_PTR f)
5724 x_set_window_size (f, 1, width, height); 5733 x_set_window_size (f, 1, width, height);
5725 do_pending_window_change (0); 5734 do_pending_window_change (0);
5726 } 5735 }
5736 f->want_fullscreen = FULLSCREEN_NONE;
5727 unblock_input (); 5737 unblock_input ();
5728 } 5738 }
5739 else
5740 f->want_fullscreen |= FULLSCREEN_WAIT;
5729} 5741}
5730 5742
5731/* Call this to change the size of frame F's x-window. 5743/* Call this to change the size of frame F's x-window.
diff --git a/src/w32term.h b/src/w32term.h
index 7154d549f21..a31c5de193d 100644
--- a/src/w32term.h
+++ b/src/w32term.h
@@ -761,6 +761,23 @@ extern const char*
761w32_name_of_message (UINT msg); 761w32_name_of_message (UINT msg);
762#endif /* EMACSDEBUG */ 762#endif /* EMACSDEBUG */
763 763
764#ifdef NTGUI_UNICODE
765extern Lisp_Object ntgui_encode_system (Lisp_Object str);
766#define GUISTR(x) (L ## x)
767#define GUI_ENCODE_FILE GUI_ENCODE_SYSTEM
768#define GUI_ENCODE_SYSTEM(x) ntgui_encode_system (x)
769#define GUI_FN(fn) fn ## W
770typedef wchar_t guichar_t;
771#else /* !NTGUI_UNICODE */
772#define GUISTR(x) x
773#define GUI_ENCODE_FILE ENCODE_FILE
774#define GUI_ENCODE_SYSTEM ENCODE_SYSTEM
775#define GUI_FN(fn) fn
776typedef char guichar_t;
777#endif /* NTGUI_UNICODE */
778
779#define GUI_SDATA(x) ((guichar_t*) SDATA (x))
780
764extern void syms_of_w32term (void); 781extern void syms_of_w32term (void);
765extern void syms_of_w32menu (void); 782extern void syms_of_w32menu (void);
766extern void syms_of_w32fns (void); 783extern void syms_of_w32fns (void);
diff --git a/src/window.c b/src/window.c
index ee25a668981..c987d08534e 100644
--- a/src/window.c
+++ b/src/window.c
@@ -5025,7 +5025,7 @@ specifies the window to scroll. This takes precedence over
5025 ++windows_or_buffers_changed; 5025 ++windows_or_buffers_changed;
5026 5026
5027 Fset_buffer (w->buffer); 5027 Fset_buffer (w->buffer);
5028 SET_PT (marker_position (w->pointm)); 5028 SET_PT_BOTH (marker_position (w->pointm), marker_byte_position (w->pointm));
5029 5029
5030 if (NILP (arg)) 5030 if (NILP (arg))
5031 window_scroll (window, 1, 1, 1); 5031 window_scroll (window, 1, 1, 1);
diff --git a/src/xdisp.c b/src/xdisp.c
index 48fc95a9a34..b60b393e614 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -2555,7 +2555,7 @@ markpos_of_region (void)
2555 at character position CHARPOS. CHARPOS < 0 means that no buffer 2555 at character position CHARPOS. CHARPOS < 0 means that no buffer
2556 position is specified which is useful when the iterator is assigned 2556 position is specified which is useful when the iterator is assigned
2557 a position later. BYTEPOS is the byte position corresponding to 2557 a position later. BYTEPOS is the byte position corresponding to
2558 CHARPOS. BYTEPOS < 0 means compute it from CHARPOS. 2558 CHARPOS.
2559 2559
2560 If ROW is not null, calls to produce_glyphs with IT as parameter 2560 If ROW is not null, calls to produce_glyphs with IT as parameter
2561 will produce glyphs in that row. 2561 will produce glyphs in that row.
@@ -2833,18 +2833,14 @@ init_iterator (struct it *it, struct window *w,
2833 if (charpos >= BUF_BEG (current_buffer)) 2833 if (charpos >= BUF_BEG (current_buffer))
2834 { 2834 {
2835 it->end_charpos = ZV; 2835 it->end_charpos = ZV;
2836 eassert (charpos == BYTE_TO_CHAR (bytepos));
2836 IT_CHARPOS (*it) = charpos; 2837 IT_CHARPOS (*it) = charpos;
2838 IT_BYTEPOS (*it) = bytepos;
2837 2839
2838 /* We will rely on `reseat' to set this up properly, via 2840 /* We will rely on `reseat' to set this up properly, via
2839 handle_face_prop. */ 2841 handle_face_prop. */
2840 it->face_id = it->base_face_id; 2842 it->face_id = it->base_face_id;
2841 2843
2842 /* Compute byte position if not specified. */
2843 if (bytepos < charpos)
2844 IT_BYTEPOS (*it) = CHAR_TO_BYTE (charpos);
2845 else
2846 IT_BYTEPOS (*it) = bytepos;
2847
2848 it->start = it->current; 2844 it->start = it->current;
2849 /* Do we need to reorder bidirectional text? Not if this is a 2845 /* Do we need to reorder bidirectional text? Not if this is a
2850 unibyte buffer: by definition, none of the single-byte 2846 unibyte buffer: by definition, none of the single-byte
@@ -11765,7 +11761,8 @@ display_tool_bar_line (struct it *it, int height)
11765 no additional border below the possibly empty tool-bar lines. 11761 no additional border below the possibly empty tool-bar lines.
11766 So to make the extra empty lines look "normal", we have to 11762 So to make the extra empty lines look "normal", we have to
11767 use the tool-bar face for the border too. */ 11763 use the tool-bar face for the border too. */
11768 if (!row->displays_text_p && !EQ (Vauto_resize_tool_bars, Qgrow_only)) 11764 if (!MATRIX_ROW_DISPLAYS_TEXT_P (row)
11765 && !EQ (Vauto_resize_tool_bars, Qgrow_only))
11769 it->face_id = DEFAULT_FACE_ID; 11766 it->face_id = DEFAULT_FACE_ID;
11770 11767
11771 extend_face_to_end_of_line (it); 11768 extend_face_to_end_of_line (it);
@@ -11786,7 +11783,7 @@ display_tool_bar_line (struct it *it, int height)
11786 compute_line_metrics (it); 11783 compute_line_metrics (it);
11787 11784
11788 /* If line is empty, make it occupy the rest of the tool-bar. */ 11785 /* If line is empty, make it occupy the rest of the tool-bar. */
11789 if (!row->displays_text_p) 11786 if (!MATRIX_ROW_DISPLAYS_TEXT_P (row))
11790 { 11787 {
11791 row->height = row->phys_height = it->last_visible_y - row->y; 11788 row->height = row->phys_height = it->last_visible_y - row->y;
11792 row->visible_height = row->height; 11789 row->visible_height = row->height;
@@ -12001,13 +11998,13 @@ redisplay_tool_bar (struct frame *f)
12001 /* If there are blank lines at the end, except for a partially 11998 /* If there are blank lines at the end, except for a partially
12002 visible blank line at the end that is smaller than 11999 visible blank line at the end that is smaller than
12003 FRAME_LINE_HEIGHT, change the tool-bar's height. */ 12000 FRAME_LINE_HEIGHT, change the tool-bar's height. */
12004 if (!row->displays_text_p 12001 if (!MATRIX_ROW_DISPLAYS_TEXT_P (row)
12005 && row->height >= FRAME_LINE_HEIGHT (f)) 12002 && row->height >= FRAME_LINE_HEIGHT (f))
12006 change_height_p = 1; 12003 change_height_p = 1;
12007 12004
12008 /* If row displays tool-bar items, but is partially visible, 12005 /* If row displays tool-bar items, but is partially visible,
12009 change the tool-bar's height. */ 12006 change the tool-bar's height. */
12010 if (row->displays_text_p 12007 if (MATRIX_ROW_DISPLAYS_TEXT_P (row)
12011 && MATRIX_ROW_BOTTOM_Y (row) > it.last_visible_y 12008 && MATRIX_ROW_BOTTOM_Y (row) > it.last_visible_y
12012 && MATRIX_ROW_BOTTOM_Y (row) < max_tool_bar_height) 12009 && MATRIX_ROW_BOTTOM_Y (row) < max_tool_bar_height)
12013 change_height_p = 1; 12010 change_height_p = 1;
@@ -13198,7 +13195,7 @@ redisplay_internal (void)
13198 /* If this row displays text now but previously didn't, 13195 /* If this row displays text now but previously didn't,
13199 or vice versa, w->window_end_vpos may have to be 13196 or vice versa, w->window_end_vpos may have to be
13200 adjusted. */ 13197 adjusted. */
13201 if ((it.glyph_row - 1)->displays_text_p) 13198 if (MATRIX_ROW_DISPLAYS_TEXT_P (it.glyph_row - 1))
13202 { 13199 {
13203 if (XFASTINT (w->window_end_vpos) < this_line_vpos) 13200 if (XFASTINT (w->window_end_vpos) < this_line_vpos)
13204 wset_window_end_vpos (w, make_number (this_line_vpos)); 13201 wset_window_end_vpos (w, make_number (this_line_vpos));
@@ -13815,7 +13812,7 @@ set_cursor_from_row (struct window *w, struct glyph_row *row,
13815 /* Skip over glyphs not having an object at the start and the end of 13812 /* Skip over glyphs not having an object at the start and the end of
13816 the row. These are special glyphs like truncation marks on 13813 the row. These are special glyphs like truncation marks on
13817 terminal frames. */ 13814 terminal frames. */
13818 if (row->displays_text_p) 13815 if (MATRIX_ROW_DISPLAYS_TEXT_P (row))
13819 { 13816 {
13820 if (!row->reversed_p) 13817 if (!row->reversed_p)
13821 { 13818 {
@@ -14992,8 +14989,7 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, int *scroll_ste
14992 we would rather display cursor in the next line. */ 14989 we would rather display cursor in the next line. */
14993 while (MATRIX_ROW_BOTTOM_Y (row) < last_y 14990 while (MATRIX_ROW_BOTTOM_Y (row) < last_y
14994 && MATRIX_ROW_END_CHARPOS (row) == PT 14991 && MATRIX_ROW_END_CHARPOS (row) == PT
14995 && row < w->current_matrix->rows 14992 && row < MATRIX_MODE_LINE_ROW (w->current_matrix)
14996 + w->current_matrix->nrows - 1
14997 && MATRIX_ROW_START_CHARPOS (row+1) == PT 14993 && MATRIX_ROW_START_CHARPOS (row+1) == PT
14998 && !cursor_row_p (row)) 14994 && !cursor_row_p (row))
14999 ++row; 14995 ++row;
@@ -16239,8 +16235,8 @@ try_window (Lisp_Object window, struct text_pos pos, int flags)
16239 wset_window_end_vpos 16235 wset_window_end_vpos
16240 (w, make_number (MATRIX_ROW_VPOS (last_text_row, w->desired_matrix))); 16236 (w, make_number (MATRIX_ROW_VPOS (last_text_row, w->desired_matrix)));
16241 eassert 16237 eassert
16242 (MATRIX_ROW (w->desired_matrix, 16238 (MATRIX_ROW_DISPLAYS_TEXT_P (MATRIX_ROW (w->desired_matrix,
16243 XFASTINT (w->window_end_vpos))->displays_text_p); 16239 XFASTINT (w->window_end_vpos))));
16244 } 16240 }
16245 else 16241 else
16246 { 16242 {
@@ -17663,7 +17659,7 @@ try_window_id (struct window *w)
17663 struct glyph_row *last_row = MATRIX_ROW (current_matrix, last_vpos); 17659 struct glyph_row *last_row = MATRIX_ROW (current_matrix, last_vpos);
17664 17660
17665 /* If last_row is the window end line, it should display text. */ 17661 /* If last_row is the window end line, it should display text. */
17666 eassert (last_row->displays_text_p); 17662 eassert (MATRIX_ROW_DISPLAYS_TEXT_P (last_row));
17667 17663
17668 /* If window end line was partially visible before, begin 17664 /* If window end line was partially visible before, begin
17669 displaying at that line. Otherwise begin displaying with the 17665 displaying at that line. Otherwise begin displaying with the
@@ -17710,7 +17706,7 @@ try_window_id (struct window *w)
17710 matrix. Set row to the last row displaying text in current 17706 matrix. Set row to the last row displaying text in current
17711 matrix starting at first_unchanged_at_end_row, after 17707 matrix starting at first_unchanged_at_end_row, after
17712 scrolling. */ 17708 scrolling. */
17713 eassert (first_unchanged_at_end_row->displays_text_p); 17709 eassert (MATRIX_ROW_DISPLAYS_TEXT_P (first_unchanged_at_end_row));
17714 row = find_last_row_displaying_text (w->current_matrix, &it, 17710 row = find_last_row_displaying_text (w->current_matrix, &it,
17715 first_unchanged_at_end_row); 17711 first_unchanged_at_end_row);
17716 eassert (row && MATRIX_ROW_DISPLAYS_TEXT_P (row)); 17712 eassert (row && MATRIX_ROW_DISPLAYS_TEXT_P (row));
@@ -17764,10 +17760,10 @@ try_window_id (struct window *w)
17764 { 17760 {
17765 if (desired_row->enabled_p) 17761 if (desired_row->enabled_p)
17766 { 17762 {
17767 if (desired_row->displays_text_p) 17763 if (MATRIX_ROW_DISPLAYS_TEXT_P (desired_row))
17768 row = desired_row; 17764 row = desired_row;
17769 } 17765 }
17770 else if (current_row->displays_text_p) 17766 else if (MATRIX_ROW_DISPLAYS_TEXT_P (current_row))
17771 row = current_row; 17767 row = current_row;
17772 } 17768 }
17773 17769
@@ -17970,7 +17966,7 @@ dump_glyph_row (struct glyph_row *row, int vpos, int glyphs)
17970 row->truncated_on_right_p, 17966 row->truncated_on_right_p,
17971 row->continued_p, 17967 row->continued_p,
17972 MATRIX_ROW_CONTINUATION_LINE_P (row), 17968 MATRIX_ROW_CONTINUATION_LINE_P (row),
17973 row->displays_text_p, 17969 MATRIX_ROW_DISPLAYS_TEXT_P (row),
17974 row->ends_at_zv_p, 17970 row->ends_at_zv_p,
17975 row->fill_line_p, 17971 row->fill_line_p,
17976 row->ends_in_middle_of_char_p, 17972 row->ends_in_middle_of_char_p,
@@ -18606,7 +18602,7 @@ extend_face_to_end_of_line (struct it *it)
18606 face = FACE_FROM_ID (f, it->face_id); 18602 face = FACE_FROM_ID (f, it->face_id);
18607 18603
18608 if (FRAME_WINDOW_P (f) 18604 if (FRAME_WINDOW_P (f)
18609 && it->glyph_row->displays_text_p 18605 && MATRIX_ROW_DISPLAYS_TEXT_P (it->glyph_row)
18610 && face->box == FACE_NO_BOX 18606 && face->box == FACE_NO_BOX
18611 && face->background == FRAME_BACKGROUND_PIXEL (f) 18607 && face->background == FRAME_BACKGROUND_PIXEL (f)
18612 && !face->stipple 18608 && !face->stipple
@@ -19866,7 +19862,7 @@ display_line (struct it *it)
19866 mark this glyph row as the one containing the overlay arrow. 19862 mark this glyph row as the one containing the overlay arrow.
19867 This is clearly a mess with variable size fonts. It would be 19863 This is clearly a mess with variable size fonts. It would be
19868 better to let it be displayed like cursors under X. */ 19864 better to let it be displayed like cursors under X. */
19869 if ((row->displays_text_p || !overlay_arrow_seen) 19865 if ((MATRIX_ROW_DISPLAYS_TEXT_P (row) || !overlay_arrow_seen)
19870 && (overlay_arrow_string = overlay_arrow_at_row (it, row), 19866 && (overlay_arrow_string = overlay_arrow_at_row (it, row),
19871 !NILP (overlay_arrow_string))) 19867 !NILP (overlay_arrow_string)))
19872 { 19868 {
@@ -19966,7 +19962,7 @@ display_line (struct it *it)
19966 if (it->glyph_row < MATRIX_BOTTOM_TEXT_ROW (it->w->desired_matrix, it->w)) 19962 if (it->glyph_row < MATRIX_BOTTOM_TEXT_ROW (it->w->desired_matrix, it->w))
19967 it->glyph_row->reversed_p = row->reversed_p; 19963 it->glyph_row->reversed_p = row->reversed_p;
19968 it->start = row->end; 19964 it->start = row->end;
19969 return row->displays_text_p; 19965 return MATRIX_ROW_DISPLAYS_TEXT_P (row);
19970 19966
19971#undef RECORD_MAX_MIN_POS 19967#undef RECORD_MAX_MIN_POS
19972} 19968}
@@ -25912,7 +25908,7 @@ notice_overwritten_cursor (struct window *w, enum glyph_row_area area,
25912 if (w->phys_cursor.vpos < 0 25908 if (w->phys_cursor.vpos < 0
25913 || w->phys_cursor.vpos >= w->current_matrix->nrows 25909 || w->phys_cursor.vpos >= w->current_matrix->nrows
25914 || (row = w->current_matrix->rows + w->phys_cursor.vpos, 25910 || (row = w->current_matrix->rows + w->phys_cursor.vpos,
25915 !(row->enabled_p && row->displays_text_p))) 25911 !(row->enabled_p && MATRIX_ROW_DISPLAYS_TEXT_P (row))))
25916 return; 25912 return;
25917 25913
25918 if (row->cursor_in_fringe_p) 25914 if (row->cursor_in_fringe_p)
@@ -26847,7 +26843,7 @@ mouse_face_from_buffer_pos (Lisp_Object window,
26847 x = r1->x; 26843 x = r1->x;
26848 26844
26849 /* Skip truncation glyphs at the start of the glyph row. */ 26845 /* Skip truncation glyphs at the start of the glyph row. */
26850 if (r1->displays_text_p) 26846 if (MATRIX_ROW_DISPLAYS_TEXT_P (r1))
26851 for (; glyph < end 26847 for (; glyph < end
26852 && INTEGERP (glyph->object) 26848 && INTEGERP (glyph->object)
26853 && glyph->charpos < 0; 26849 && glyph->charpos < 0;
@@ -26898,7 +26894,7 @@ mouse_face_from_buffer_pos (Lisp_Object window,
26898 glyph = end + r1->used[TEXT_AREA]; 26894 glyph = end + r1->used[TEXT_AREA];
26899 26895
26900 /* Skip truncation glyphs at the start of the glyph row. */ 26896 /* Skip truncation glyphs at the start of the glyph row. */
26901 if (r1->displays_text_p) 26897 if (MATRIX_ROW_DISPLAYS_TEXT_P (r1))
26902 for (; glyph > end 26898 for (; glyph > end
26903 && INTEGERP (glyph->object) 26899 && INTEGERP (glyph->object)
26904 && glyph->charpos < 0; 26900 && glyph->charpos < 0;
@@ -27149,7 +27145,7 @@ fast_find_string_pos (struct window *w, ptrdiff_t pos, Lisp_Object object,
27149 } 27145 }
27150 27146
27151 *y = best_row->y; 27147 *y = best_row->y;
27152 *vpos = best_row - w->current_matrix->rows; 27148 *vpos = MATRIX_ROW_VPOS (best_row, w->current_matrix);
27153 } 27149 }
27154 27150
27155 return best_glyph != NULL; 27151 return best_glyph != NULL;
@@ -27187,7 +27183,8 @@ mouse_face_from_string_pos (struct window *w, Mouse_HLInfo *hlinfo,
27187 if (EQ (g->object, object) 27183 if (EQ (g->object, object)
27188 && startpos <= g->charpos && g->charpos <= endpos) 27184 && startpos <= g->charpos && g->charpos <= endpos)
27189 { 27185 {
27190 hlinfo->mouse_face_beg_row = r - w->current_matrix->rows; 27186 hlinfo->mouse_face_beg_row
27187 = MATRIX_ROW_VPOS (r, w->current_matrix);
27191 hlinfo->mouse_face_beg_y = r->y; 27188 hlinfo->mouse_face_beg_y = r->y;
27192 hlinfo->mouse_face_beg_col = g - r->glyphs[TEXT_AREA]; 27189 hlinfo->mouse_face_beg_col = g - r->glyphs[TEXT_AREA];
27193 hlinfo->mouse_face_beg_x = gx; 27190 hlinfo->mouse_face_beg_x = gx;
@@ -27205,7 +27202,8 @@ mouse_face_from_string_pos (struct window *w, Mouse_HLInfo *hlinfo,
27205 if (EQ ((g-1)->object, object) 27202 if (EQ ((g-1)->object, object)
27206 && startpos <= (g-1)->charpos && (g-1)->charpos <= endpos) 27203 && startpos <= (g-1)->charpos && (g-1)->charpos <= endpos)
27207 { 27204 {
27208 hlinfo->mouse_face_beg_row = r - w->current_matrix->rows; 27205 hlinfo->mouse_face_beg_row
27206 = MATRIX_ROW_VPOS (r, w->current_matrix);
27209 hlinfo->mouse_face_beg_y = r->y; 27207 hlinfo->mouse_face_beg_y = r->y;
27210 hlinfo->mouse_face_beg_col = g - r->glyphs[TEXT_AREA]; 27208 hlinfo->mouse_face_beg_col = g - r->glyphs[TEXT_AREA];
27211 for (gx = r->x, g1 = r->glyphs[TEXT_AREA]; g1 < g; ++g1) 27209 for (gx = r->x, g1 = r->glyphs[TEXT_AREA]; g1 < g; ++g1)
@@ -27244,7 +27242,7 @@ mouse_face_from_string_pos (struct window *w, Mouse_HLInfo *hlinfo,
27244 r--; 27242 r--;
27245 27243
27246 /* Set the end row and its vertical pixel coordinate. */ 27244 /* Set the end row and its vertical pixel coordinate. */
27247 hlinfo->mouse_face_end_row = r - w->current_matrix->rows; 27245 hlinfo->mouse_face_end_row = MATRIX_ROW_VPOS (r, w->current_matrix);
27248 hlinfo->mouse_face_end_y = r->y; 27246 hlinfo->mouse_face_end_y = r->y;
27249 27247
27250 /* Compute and set the end column and the end column's horizontal 27248 /* Compute and set the end column and the end column's horizontal
@@ -27928,7 +27926,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
27928 /* Clear mouse face if X/Y not over text. */ 27926 /* Clear mouse face if X/Y not over text. */
27929 if (glyph == NULL 27927 if (glyph == NULL
27930 || area != TEXT_AREA 27928 || area != TEXT_AREA
27931 || !MATRIX_ROW (w->current_matrix, vpos)->displays_text_p 27929 || !MATRIX_ROW_DISPLAYS_TEXT_P (MATRIX_ROW (w->current_matrix, vpos))
27932 /* Glyph's OBJECT is an integer for glyphs inserted by the 27930 /* Glyph's OBJECT is an integer for glyphs inserted by the
27933 display engine for its internal purposes, like truncation 27931 display engine for its internal purposes, like truncation
27934 and continuation glyphs and blanks beyond the end of 27932 and continuation glyphs and blanks beyond the end of
@@ -27940,7 +27938,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
27940 all beyond the end of text. Treat such stretch glyphs 27938 all beyond the end of text. Treat such stretch glyphs
27941 like we do with NULL glyphs in L2R rows. */ 27939 like we do with NULL glyphs in L2R rows. */
27942 || (MATRIX_ROW (w->current_matrix, vpos)->reversed_p 27940 || (MATRIX_ROW (w->current_matrix, vpos)->reversed_p
27943 && glyph == MATRIX_ROW (w->current_matrix, vpos)->glyphs[TEXT_AREA] 27941 && glyph == MATRIX_ROW_GLYPH_START (w->current_matrix, vpos)
27944 && glyph->type == STRETCH_GLYPH 27942 && glyph->type == STRETCH_GLYPH
27945 && glyph->avoid_cursor_p)) 27943 && glyph->avoid_cursor_p))
27946 { 27944 {
diff --git a/src/xfns.c b/src/xfns.c
index 5c93b8ef4da..100fd81a155 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -3769,7 +3769,6 @@ If omitted or nil, that stands for the selected frame's display. */)
3769 3769
3770 default: 3770 default:
3771 error ("Strange value for BackingStore parameter of screen"); 3771 error ("Strange value for BackingStore parameter of screen");
3772 result = Qnil;
3773 } 3772 }
3774 3773
3775 return result; 3774 return result;
@@ -3811,7 +3810,6 @@ If omitted or nil, that stands for the selected frame's display. */)
3811 break; 3810 break;
3812 default: 3811 default:
3813 error ("Display has an unknown visual class"); 3812 error ("Display has an unknown visual class");
3814 result = Qnil;
3815 } 3813 }
3816 3814
3817 return result; 3815 return result;
@@ -5067,7 +5065,7 @@ Text larger than the specified size is clipped. */)
5067 int row_width; 5065 int row_width;
5068 5066
5069 /* Stop at the first empty row at the end. */ 5067 /* Stop at the first empty row at the end. */
5070 if (!row->enabled_p || !row->displays_text_p) 5068 if (!row->enabled_p || !MATRIX_ROW_DISPLAYS_TEXT_P (row))
5071 break; 5069 break;
5072 5070
5073 /* Let the row go over the full width of the frame. */ 5071 /* Let the row go over the full width of the frame. */
@@ -5126,7 +5124,7 @@ Text larger than the specified size is clipped. */)
5126 struct glyph *last; 5124 struct glyph *last;
5127 int row_width; 5125 int row_width;
5128 5126
5129 if (!row->enabled_p || !row->displays_text_p) 5127 if (!row->enabled_p || !MATRIX_ROW_DISPLAYS_TEXT_P (row))
5130 break; 5128 break;
5131 row->full_width_p = 1; 5129 row->full_width_p = 1;
5132 row_width = row->pixel_width; 5130 row_width = row->pixel_width;
diff --git a/src/xsmfns.c b/src/xsmfns.c
index fe2dfbaf83e..cb7122202df 100644
--- a/src/xsmfns.c
+++ b/src/xsmfns.c
@@ -514,9 +514,11 @@ Do not call this function yourself. */)
514 prevent. Fix this in next version. */ 514 prevent. Fix this in next version. */
515 Fkill_emacs (Qnil); 515 Fkill_emacs (Qnil);
516 516
517#if 0
517 /* This will not be reached, but we want kill-emacs-hook to be run. */ 518 /* This will not be reached, but we want kill-emacs-hook to be run. */
518 SmcCloseConnection (smc_conn, 0, 0); 519 SmcCloseConnection (smc_conn, 0, 0);
519 ice_connection_closed (); 520 ice_connection_closed ();
521#endif
520 } 522 }
521 523
522 return Qnil; 524 return Qnil;