summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog240
-rw-r--r--src/Makefile.in3
-rw-r--r--src/alloc.c4
-rw-r--r--src/bytecode.c12
-rw-r--r--src/coding.c200
-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.c152
-rw-r--r--src/keyboard.h12
-rw-r--r--src/keymap.c4
-rw-r--r--src/lisp.h4
-rw-r--r--src/lread.c74
-rw-r--r--src/nsfns.m66
-rw-r--r--src/nsterm.h4
-rw-r--r--src/nsterm.m19
-rw-r--r--src/region-cache.c68
-rw-r--r--src/scroll.c17
-rw-r--r--src/search.c64
-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/thread.h4
-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
37 files changed, 884 insertions, 418 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index fe084b160c4..3a2a36c0cf7 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,231 @@
+2013-03-16 Jan Djärv <jan.h.d@swipnet.se>
+
+ * nsterm.m (updateFrameSize:): Change resize increments if needed.
+ (ns_select): Don't return with result uninitialized.
+
+ * nsterm.h (EmacsSavePanel, EmacsOpenPanel): Add getFilename
+ and getDirectory.
+
+ * nsfns.m (ns_filename_from_panel, ns_directory_from_panel): New
+ functions.
+ (Fns_read_file_name): ret is BOOL. If ! dir_only_p, don't choose
+ directories. If filename is nil, get directory name (Bug#13932).
+ Use getFilename and getDirectory.
+ (getFilename, getDirectory): New methods for EmacsSavePanel and
+ EmacsOpenPanel.
+ (ok:): In EmacsOpenPanel, if we can't choose directories, just return.
+
+2013-03-15 Paul Eggert <eggert@cs.ucla.edu>
+
+ * coding.c (decode_coding_gap): Fix typo caught by static checking.
+
+2013-03-15 handa <handa@gnu.org>
+
+ * insdel.c (insert_from_gap): New arg text_at_gap_tail.
+ (adjust_after_replace): Make it back to static. Delete the third
+ arg text_at_gap_tail. Cancel the code for handling it.
+
+ * coding.h (struct coding_system): New member eol_seen.
+
+ * coding.c (detect_ascii): New function.
+ (detect_coding): Set coding->head_ascii and coding->eol_seen only
+ when the source bytes are actually scanned. On detecting for
+ coding_category_utf_8_auto, call detect_ascii instead of scanning
+ source bytes directly.
+ (produce_chars): Call insert_from_gap with the new arg 0.
+ (encode_coding): Likewise.
+ (decode_coding_gap): Control ASCII optimization by the variable
+ disable_ascii_optimization instead of #ifndef .. #endif.
+ Deccode EOL format according to coding->eol_seen.
+ (syms_of_coding): Declare disable-ascii-optimization as a Lisp
+ variable.
+
+ * global.h (struct emacs_globals): New member
+ f_disable_ascii_optimization.
+ (disable_ascii_optimization): New macro.
+
+ * lisp.h (adjust_after_replace): Cancel externing it.
+ (insert_from_gap): Adjust prototype.
+
+2013-03-15 Eli Zaretskii <eliz@gnu.org>
+
+ * w32term.c (w32fullscreen_hook): Swap FULLSCREEN_BOTH and
+ FULLSCREEN_MAXIMIZED. (Bug#13935)
+
+2013-03-15 Dmitry Antipov <dmantipov@yandex.ru>
+
+ * region-cache.c (find_cache_boundary, move_cache_gap)
+ (insert_cache_boundary, delete_cache_boundaries, set_cache_region):
+ Simplify debugging check and convert to eassert. Adjust comment.
+ (pp_cache): Put under ENABLE_CHECKING.
+
+2013-03-14 Eli Zaretskii <eliz@gnu.org>
+
+ * w32term.c (w32_read_socket) <WM_WINDOWPOSCHANGED>: Remove old
+ and incorrect code. Treat WM_WINDOWPOSCHANGED like WM_ACTIVATE
+ and WM_ACTIVATEAPP.
+ (w32fullscreen_hook): If the frame is visible, reset
+ f->want_fullscreen flag after changing the frame size. If the
+ frame is not visible, set f->want_fullscreen to FULLSCREEN_WAIT.
+ (Bug#13953)
+
+2013-03-13 Daniel Colascione <dancol@dancol.org>
+
+ * emacs.c (main): Call syms_of_cygw32 on CYGWIN non-NTGUI builds
+ too so that these builds can use Cygwin's file conversion
+ functions. (We've been building and linking cygw32.o all along
+ and just not using it.)
+
+2013-03-13 Paul Eggert <eggert@cs.ucla.edu>
+
+ File synchronization fixes (Bug#13944).
+ * Makefile.in (LIB_FDATASYNC): New macro.
+ (LIBES): Use it.
+ * conf_post.h (BSD_SYSTEM, BSD_SYSTEM_AHB): Remove; no longer needed.
+ * fileio.c (Fwrite_region, write_region_inhibit_fsync):
+ Don't worry about HAVE_FSYNC, since a substitute fsync is
+ available if the system lacks one.
+ (Fwrite_regin): Retry fsync if interrupted.
+
+2013-03-13 Eli Zaretskii <eliz@gnu.org>
+
+ * w32term.c (w32_read_socket): If the Emacs frame is being
+ activated, call w32fullscreen_hook, to make sure the new frame
+ dimensions are in effect. (Bug#13937)
+
+2013-03-13 Dmitry Antipov <dmantipov@yandex.ru>
+
+ * xdisp.c (init_iterator): Simplify because both character and byte
+ positions are either specified or -1. Add eassert. Adjust comment.
+ * window.c (Fscroll_other_window): Use SET_PT_BOTH because both
+ character and byte positions can be obtained from marker.
+
+2013-03-13 Paul Eggert <eggert@cs.ucla.edu>
+
+ Static checking by Sun C 5.12.
+ * alloc.c (buffer_memory_full) [REL_ALLOC]:
+ * bytecode.c (exec_byte_code):
+ * dispnew.c (init_display):
+ * eval.c (error):
+ * fileio.c (Fsubstitute_in_file_name):
+ * keyboard.c (Fevent_convert_list):
+ * keymap.c (Fsingle_key_description):
+ * term.c (maybe_fatal, fatal):
+ * xfns.c (Fx_display_backing_store, Fx_display_visual_class):
+ * xsmfns.c (Fhandle_save_session):
+ Omit unreachable code.
+ * keymap.c (map_keymap_char_table_item): Cast void * to
+ a function pointer type; the C Standard requires this.
+
+ * sysdep.c: Remove a use of BSD_SYSTEM, which I'm trying to phase out.
+ Include <sys/param.h> unconditionally, as that works elsewhere and
+ is simpler here. Include <sys/sysctl.h> if DARWIN_OS ||
+ __FreeBSD__, not if BSD_SYSTEM, since it's needed only for Darwin
+ and FreeBSD now.
+
+2013-03-11 Paul Eggert <eggert@cs.ucla.edu>
+
+ * insdel.c (adjust_after_replace): Use bool for boolean.
+
+2013-03-11 Stefan Monnier <monnier@iro.umontreal.ca>
+
+ * keyboard.c: Move keyboard decoding to read_key_sequence.
+ (decode_keyboard_code): Remove.
+ (tty_read_avail_input): Don't try to decode input.
+ (read_decoded_char): New function.
+ (read_key_sequence): Use it.
+
+2013-03-10 Daniel Colascione <dancol@dancol.org>
+
+ * w32term.h (GUISTR, GUI_ENCODE_FILE, GUI_ENCODE_SYSTEM, GUI_FN)
+ (GUI_SDATA, guichar_t): Macros to abstract out differences between
+ NTGUI_UNICODE and !NTGUI_UNICODE builds, some moved out of
+ w32fns.c.
+
+ * w32term.c (construct_drag_n_drop): Use the above macros to make
+ drag-and-drop work for non-ASCII filenames in cygw32 builds.
+
+ * w32fns.c (x_set_name, x_set_title): Use the above macros to
+ properly display non-ASCII frame titles in cygw32 builds.
+
+ * w32fns.c (Fw32_shell_execute): Use the above macros to properly
+ call ShellExecute in cygw32 builds.
+
+ * w32fn.c (Fx_file_dialog): Use the above macros to simplify the
+ common file dialog code.
+
+ * w32fns.c (Ffile_system_info): Remove from cygw32 builds, which
+ can just use du like other systems.
+
+ * coding.c (from_unicode_buffer): Declare.
+ * coding.c (from_unicode_buffer): Implement.
+
+2013-03-10 Stefan Monnier <monnier@iro.umontreal.ca>
+
+ * lread.c: Minor cleanup.
+ (FROM_FILE_P): New macro.
+ (skip_dyn_bytes, unreadchar, read1): Use it.
+ (read_list): Consolidate duplicated code.
+
+ * bytecode.c (struct byte_stack): Remove `constants' when unused.
+
+2013-03-10 Eli Zaretskii <eliz@gnu.org>
+
+ * xdisp.c (display_tool_bar_line, redisplay_tool_bar)
+ (redisplay_internal, set_cursor_from_row, try_window)
+ (try_window_id, dump_glyph_row, extend_face_to_end_of_line)
+ (display_line, notice_overwritten_cursor)
+ (mouse_face_from_buffer_pos, note_mouse_highlight):
+ Use MATRIX_ROW_DISPLAYS_TEXT_P.
+ (note_mouse_highlight): Use MATRIX_ROW_GLYPH_START.
+ (mouse_face_from_string_pos, fast_find_string_pos):
+ Use MATRIX_ROW_VPOS.
+
+ * xfns.c (Fx_show_tip): Use MATRIX_ROW_DISPLAYS_TEXT_P.
+
+ * w32fns.c (Fx_show_tip): Use MATRIX_ROW_DISPLAYS_TEXT_P.
+
+ * xdisp.c (try_cursor_movement): Use MATRIX_ROW and
+ MATRIX_MODE_LINE_ROW.
+
+ * dispnew.c (update_window): Use MATRIX_ROW and MATRIX_MODE_LINE_ROW.
+
+2013-03-10 handa <handa@gnu.org>
+
+ * lisp.h (adjust_after_replace): Extern it.
+
+ * coding.c (detect_coding): Cound the heading ASCII bytes in the
+ case of detection for coding_category_utf_8_auto.
+ (decode_coding_gap) [not CODING_DISABLE_ASCII_OPTIMIZATION]:
+ Skip decoding if all bytes are ASCII.
+
+ * insdel.c (adjust_after_replace): Make it public. New arg
+ text_at_gap_tail.
+ (adjust_after_insert): Call adjust_after_replace with the new arg
+ value 0.
+
+2013-03-09 Stefan Monnier <monnier@iro.umontreal.ca>
+
+ * keyboard.h (EVENT_START, EVENT_END, POSN_WINDOW, POSN_POSN)
+ (POSN_WINDOW_POSN, POSN_TIMESTAMP): Be careful since events may come
+ from Elisp via unread-command-events.
+
+ * keyboard.c (access_keymap_keyremap): Accept nil return value from
+ functions to mean "no change".
+
+2013-03-08 Paul Eggert <eggert@cs.ucla.edu>
+
+ region-cache.c, scroll.c, search.c: Use bool for booleans.
+ * lisp.h (compile_pattern):
+ * scroll.c (do_scrolling, do_direct_scrolling):
+ * search.c (struct regexp_cache, compile_pattern_1)
+ (compile_pattern, string_match_1, search_command)
+ (trivial_regexp_p, search_buffer, Freplace_match, match_limit)
+ (search_regs_saved, Fregexp_quote):
+ Use bool for boolean.
+ * region-cache.c (region_cache_forward, region_cache_backward):
+ Fix comments to match code: these functions return int, not boolean.
+
2013-03-08 Dmitry Antipov <dmantipov@yandex.ru>
* search.c (find_newline): Accept start and end byte positions
@@ -6,8 +234,8 @@
* lisp.h (find_newline, find_newline_no_quit): Adjust prototype.
* bidi.c (bidi_find_paragraph_start): Pass byte position to
find_newline_no_quit, thus eliminating CHAR_TO_BYTE.
- * editfns.c (Fconstrain_to_field): Break long line. Adjust
- call to find_newline.
+ * editfns.c (Fconstrain_to_field): Break long line.
+ Adjust call to find_newline.
* indent.c (vmotion): Adjust calls to find_newline_no_quit.
Use DEC_BOTH to start next search from the previous buffer
position, where appropriate.
@@ -257,8 +485,8 @@
2013-03-02 Eli Zaretskii <eliz@gnu.org>
- * textprop.c (Fadd_text_properties, Fremove_text_properties): If
- the interval tree changes as a side effect of calling
+ * textprop.c (Fadd_text_properties, Fremove_text_properties):
+ If the interval tree changes as a side effect of calling
modify_region, re-do processing starting from the call to
validate_interval_range. (Bug#13743)
@@ -334,8 +562,8 @@
* textprop.c (Fadd_text_properties, Fremove_text_properties)
(Fremove_list_of_text_properties): Skip all of the intervals in
the region between START and END that already have resp. don't
- have the requested properties, not just the first one. Add
- assertions that the loop afterwards always modifies the
+ have the requested properties, not just the first one.
+ Add assertions that the loop afterwards always modifies the
properties. (Bug#13743)
2013-02-25 Stefan Monnier <monnier@iro.umontreal.ca>
diff --git a/src/Makefile.in b/src/Makefile.in
index b42fc7faf02..eeb2b88bf32 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -139,6 +139,7 @@ M17N_FLT_LIBS = @M17N_FLT_LIBS@
LIB_CLOCK_GETTIME=@LIB_CLOCK_GETTIME@
LIB_EACCESS=@LIB_EACCESS@
+LIB_FDATASYNC=@LIB_FDATASYNC@
LIB_TIMER_TIME=@LIB_TIMER_TIME@
DBUS_CFLAGS = @DBUS_CFLAGS@
@@ -392,7 +393,7 @@ ALLOBJS = $(VMLIMIT_OBJ) $(obj) $(otherobj)
LIBES = $(LIBS) $(W32_LIBS) $(LIBS_GNUSTEP) $(LIBX_BASE) $(LIBIMAGE) \
$(LIBX_OTHER) $(LIBSOUND) \
$(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_CLOCK_GETTIME) \
- $(LIB_EACCESS) $(LIB_TIMER_TIME) $(DBUS_LIBS) \
+ $(LIB_EACCESS) $(LIB_FDATASYNC) $(LIB_TIMER_TIME) $(DBUS_LIBS) \
$(LIB_EXECINFO) \
$(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \
$(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \
diff --git a/src/alloc.c b/src/alloc.c
index 63fd973ffce..6da0ac428ab 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -413,11 +413,11 @@ buffer_memory_full (ptrdiff_t nbytes)
#ifndef REL_ALLOC
memory_full (nbytes);
-#endif
-
+#else
/* This used to call error, but if we've run out of memory, we could
get infinite recursion trying to build the string. */
xsignal (Qnil, Vmemory_signal_data);
+#endif
}
/* A common multiple of the positive integers A and B. Ideally this
diff --git a/src/bytecode.c b/src/bytecode.c
index 010477904be..45fe5d49154 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -313,9 +313,11 @@ struct byte_stack
Lisp_Object byte_string;
const unsigned char *byte_string_start;
+#if BYTE_MARK_STACK
/* The vector of constants used during byte-code execution. Storing
this here protects it from GC because mark_byte_stack marks it. */
Lisp_Object constants;
+#endif
/* Next entry in byte_stack_list. */
struct byte_stack *next;
@@ -376,12 +378,12 @@ unmark_byte_stack (struct byte_stack *stack)
}
-/* Fetch the next byte from the bytecode stream */
+/* Fetch the next byte from the bytecode stream. */
#define FETCH *stack.pc++
/* Fetch two bytes from the bytecode stream and make a 16-bit number
- out of them */
+ out of them. */
#define FETCH2 (op = FETCH, op + (FETCH << 8))
@@ -401,7 +403,7 @@ unmark_byte_stack (struct byte_stack *stack)
#define DISCARD(n) (top -= (n))
/* Get the value which is at the top of the execution stack, but don't
- pop it. */
+ pop it. */
#define TOP (*top)
@@ -532,7 +534,9 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
stack.byte_string = bytestr;
stack.pc = stack.byte_string_start = SDATA (bytestr);
+#if BYTE_MARK_STACK
stack.constants = vector;
+#endif
if (MAX_ALLOCA / word_size <= XFASTINT (maxdepth))
memory_full (SIZE_MAX);
top = alloca ((XFASTINT (maxdepth) + 1) * sizeof *top);
@@ -748,7 +752,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
{
BEFORE_POTENTIAL_GC ();
wrong_type_argument (Qlistp, v1);
- AFTER_POTENTIAL_GC ();
}
NEXT;
}
@@ -783,7 +786,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
{
BEFORE_POTENTIAL_GC ();
wrong_type_argument (Qlistp, v1);
- AFTER_POTENTIAL_GC ();
}
NEXT;
}
diff --git a/src/coding.c b/src/coding.c
index 32da72ab626..6cfcec905a1 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -286,6 +286,10 @@ encode_coding_XXX (struct coding_system *coding)
#include <config.h>
#include <stdio.h>
+#ifdef HAVE_WCHAR_H
+#include <wchar.h>
+#endif /* HAVE_WCHAR_H */
+
#include "lisp.h"
#include "character.h"
#include "buffer.h"
@@ -6067,6 +6071,93 @@ complement_process_encoding_system (Lisp_Object coding_system)
#define EOL_SEEN_CR 2
#define EOL_SEEN_CRLF 4
+
+static Lisp_Object adjust_coding_eol_type (struct coding_system *coding, int eol_seen);
+
+
+/* Return 1 if all the source bytes are ASCII, and return 0 otherwize.
+ By side effects, set coding->head_ascii and coding->eol_seen. The
+ value of coding->eol_seen is "logical or" of EOL_SEEN_LF,
+ EOL_SEEN_CR, and EOL_SEEN_CRLF, but the value is reliable only when
+ all the source bytes are ASCII. */
+
+static bool
+detect_ascii (struct coding_system *coding)
+{
+ const unsigned char *src, *end;
+ Lisp_Object eol_type = CODING_ID_EOL_TYPE (coding->id);
+ int eol_seen;
+
+ eol_seen = (VECTORP (eol_type) ? EOL_SEEN_NONE
+ : EQ (eol_type, Qunix) ? EOL_SEEN_LF
+ : EQ (eol_type, Qdos) ? EOL_SEEN_CRLF
+ : EOL_SEEN_CR);
+ coding_set_source (coding);
+ src = coding->source;
+ end = src + coding->src_bytes;
+
+ if (inhibit_eol_conversion)
+ {
+ /* We don't have to check EOL format. */
+ while (src < end && !( *src & 0x80)) src++;
+ eol_seen = EOL_SEEN_LF;
+ adjust_coding_eol_type (coding, eol_seen);
+ }
+ else if (eol_seen != EOL_SEEN_NONE)
+ {
+ /* We don't have to check EOL format either. */
+ while (src < end && !(*src & 0x80)) src++;
+ }
+ else
+ {
+ end--; /* We look ahead one byte. */
+ while (src < end)
+ {
+ int c = *src;
+
+ if (c & 0x80)
+ break;
+ src++;
+ if (c < 0x20)
+ {
+ if (c == '\r')
+ {
+ if (*src == '\n')
+ {
+ eol_seen |= EOL_SEEN_CRLF;
+ src++;
+ }
+ else
+ eol_seen |= EOL_SEEN_CR;
+ }
+ else if (c == '\n')
+ eol_seen |= EOL_SEEN_LF;
+ }
+ }
+ if (src > end)
+ /* The last two bytes are CR LF, which means that we have
+ scanned all bytes. */
+ end++;
+ else if (src == end)
+ {
+ end++;
+ if (! (*src & 0x80))
+ {
+ if (*src == '\r')
+ eol_seen |= EOL_SEEN_CR;
+ else if (*src == '\n')
+ eol_seen |= EOL_SEEN_LF;
+ src++;
+ }
+ }
+ adjust_coding_eol_type (coding, eol_seen);
+ }
+ coding->head_ascii = src - coding->source;
+ coding->eol_seen = eol_seen;
+ return (src == end);
+}
+
+
/* Detect how end-of-line of a text of length SRC_BYTES pointed by
SOURCE is encoded. If CATEGORY is one of
coding_category_utf_16_XXXX, assume that CR and LF are encoded by
@@ -6211,7 +6302,6 @@ detect_coding (struct coding_system *coding)
coding_set_source (coding);
src_end = coding->source + coding->src_bytes;
- coding->head_ascii = 0;
/* If we have not yet decided the text encoding type, detect it
now. */
@@ -6221,6 +6311,8 @@ detect_coding (struct coding_system *coding)
struct coding_detection_info detect_info;
bool null_byte_found = 0, eight_bit_found = 0;
+ coding->head_ascii = 0;
+ coding->eol_seen = EOL_SEEN_NONE;
detect_info.checked = detect_info.found = detect_info.rejected = 0;
for (src = coding->source; src < src_end; src++)
{
@@ -6259,6 +6351,26 @@ detect_coding (struct coding_system *coding)
if (eight_bit_found)
break;
}
+ else if (! disable_ascii_optimization
+ && ! inhibit_eol_conversion)
+ {
+ if (c == '\r')
+ {
+ if (src < src_end && src[1] == '\n')
+ {
+ coding->eol_seen |= EOL_SEEN_CRLF;
+ src++;
+ coding->head_ascii++;
+ }
+ else
+ coding->eol_seen |= EOL_SEEN_CR;
+ }
+ else if (c == '\n')
+ {
+ coding->eol_seen |= EOL_SEEN_LF;
+ }
+ }
+
if (! eight_bit_found)
coding->head_ascii++;
}
@@ -6349,14 +6461,20 @@ detect_coding (struct coding_system *coding)
coding_systems
= AREF (CODING_ID_ATTRS (coding->id), coding_attr_utf_bom);
detect_info.found = detect_info.rejected = 0;
- coding->head_ascii = 0;
- if (CONSP (coding_systems)
- && detect_coding_utf_8 (coding, &detect_info))
+ if (detect_ascii (coding))
{
- if (detect_info.found & CATEGORY_MASK_UTF_8_SIG)
- setup_coding_system (XCAR (coding_systems), coding);
- else
- setup_coding_system (XCDR (coding_systems), coding);
+ setup_coding_system (XCDR (coding_systems), coding);
+ }
+ else
+ {
+ if (CONSP (coding_systems)
+ && detect_coding_utf_8 (coding, &detect_info))
+ {
+ if (detect_info.found & CATEGORY_MASK_UTF_8_SIG)
+ setup_coding_system (XCAR (coding_systems), coding);
+ else
+ setup_coding_system (XCDR (coding_systems), coding);
+ }
}
}
else if (XINT (CODING_ATTR_CATEGORY (CODING_ID_ATTRS (coding->id)))
@@ -6369,6 +6487,7 @@ detect_coding (struct coding_system *coding)
= AREF (CODING_ID_ATTRS (coding->id), coding_attr_utf_bom);
detect_info.found = detect_info.rejected = 0;
coding->head_ascii = 0;
+ coding->eol_seen = EOL_SEEN_NONE;
if (CONSP (coding_systems)
&& detect_coding_utf_16 (coding, &detect_info))
{
@@ -6806,7 +6925,7 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table,
produced = dst - (coding->destination + coding->produced);
if (BUFFERP (coding->dst_object) && produced_chars > 0)
- insert_from_gap (produced_chars, produced);
+ insert_from_gap (produced_chars, produced, 0);
coding->produced += produced;
coding->produced_char += produced_chars;
return carryover;
@@ -7391,7 +7510,7 @@ encode_coding (struct coding_system *coding)
} while (coding->consumed_char < coding->src_chars);
if (BUFFERP (coding->dst_object) && coding->produced_char > 0)
- insert_from_gap (coding->produced_char, coding->produced);
+ insert_from_gap (coding->produced_char, coding->produced, 0);
SAFE_FREE ();
}
@@ -7487,8 +7606,6 @@ decode_coding_gap (struct coding_system *coding,
ptrdiff_t count = SPECPDL_INDEX ();
Lisp_Object attrs;
- code_conversion_save (0, 0);
-
coding->src_object = Fcurrent_buffer ();
coding->src_chars = chars;
coding->src_bytes = bytes;
@@ -7502,13 +7619,53 @@ decode_coding_gap (struct coding_system *coding,
if (CODING_REQUIRE_DETECTION (coding))
detect_coding (coding);
+ attrs = CODING_ID_ATTRS (coding->id);
+ if (! disable_ascii_optimization)
+ {
+ if (! NILP (CODING_ATTR_ASCII_COMPAT (attrs))
+ && NILP (CODING_ATTR_POST_READ (attrs))
+ && NILP (get_translation_table (attrs, 0, NULL))
+ && (coding->head_ascii >= 0 /* We've already called detect_coding */
+ ? coding->head_ascii == bytes
+ : detect_ascii (coding)))
+ {
+ if (coding->eol_seen == EOL_SEEN_CR)
+ {
+ unsigned char *src_end = GAP_END_ADDR;
+ unsigned char *src = src_end - coding->src_bytes;
+
+ while (src < src_end)
+ {
+ if (*src++ == '\r')
+ src[-1] = '\n';
+ }
+ }
+ else if (coding->eol_seen == EOL_SEEN_CRLF)
+ {
+ unsigned char *src = GAP_END_ADDR;
+ unsigned char *src_beg = src - coding->src_bytes;
+ unsigned char *dst = src;
+
+ while (src_beg < src)
+ {
+ *--dst = *--src;
+ if (*src == '\n')
+ src--;
+ }
+ bytes -= dst - src;
+ }
+ coding->produced_char = coding->produced = bytes;
+ insert_from_gap (bytes, bytes, 1);
+ return;
+ }
+ }
+ code_conversion_save (0, 0);
coding->mode |= CODING_MODE_LAST_BLOCK;
current_buffer->text->inhibit_shrinking = 1;
decode_coding (coding);
current_buffer->text->inhibit_shrinking = 0;
- attrs = CODING_ID_ATTRS (coding->id);
if (! NILP (CODING_ATTR_POST_READ (attrs)))
{
ptrdiff_t prev_Z = Z, prev_Z_BYTE = Z_BYTE;
@@ -7966,11 +8123,21 @@ from_unicode (Lisp_Object str)
return code_convert_string_norecord (str, Qutf_16le, 0);
}
+Lisp_Object
+from_unicode_buffer (const wchar_t* wstr)
+{
+ return from_unicode (
+ make_unibyte_string (
+ (char*) wstr,
+ /* we get one of the two final 0 bytes for free. */
+ 1 + sizeof (wchar_t) * wcslen (wstr)));
+}
+
wchar_t *
to_unicode (Lisp_Object str, Lisp_Object *buf)
{
*buf = code_convert_string_norecord (str, Qutf_16le, 1);
- /* We need to make a another copy (in addition to the one made by
+ /* We need to make another copy (in addition to the one made by
code_convert_string_norecord) to ensure that the final string is
_doubly_ zero terminated --- that is, that the string is
terminated by two zero bytes and one utf-16le null character.
@@ -10707,6 +10874,11 @@ from GNU Find and GNU Grep. Emacs will then ignore the null bytes and
decode text as usual. */);
inhibit_null_byte_detection = 0;
+ DEFVAR_BOOL ("disable-ascii-optimization", disable_ascii_optimization,
+ doc: /* If non-nil, Emacs does not optimize code decoder for ASCII files.
+Internal use only. Removed after the experimental optimizer gets stable. */);
+ disable_ascii_optimization = 0;
+
DEFVAR_LISP ("translation-table-for-input", Vtranslation_table_for_input,
doc: /* Char table for translating self-inserting characters.
This 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
/* How may heading bytes we can skip for decoding. This is set to
-1 in setup_coding_system, and updated by detect_coding. So,
when this is equal to the byte length of the text being
- converted, we can skip the actual conversion process. */
+ converted, we can skip the actual conversion process except for
+ the eol format. */
ptrdiff_t head_ascii;
+ /* Used internally in coding.c. See the comment of detect_ascii. */
+ int eol_seen;
+
/* The following members are set by encoding/decoding routine. */
ptrdiff_t produced, produced_char, consumed, consumed_char;
@@ -715,6 +719,9 @@ extern wchar_t *to_unicode (Lisp_Object str, Lisp_Object *buf);
failure modes. STR itself is not modified. */
extern Lisp_Object from_unicode (Lisp_Object str);
+/* Convert WSTR to an Emacs string. */
+extern Lisp_Object from_unicode_buffer (const wchar_t* wstr);
+
#endif /* WINDOWSNT || CYGWIN */
/* 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/>. */
# define __has_attribute(a) 0 /* non-clang */
#endif
-/* This silences a few compilation warnings on FreeBSD. */
-#ifdef BSD_SYSTEM_AHB
-#undef BSD_SYSTEM_AHB
-#undef BSD_SYSTEM
-#if __FreeBSD__ == 1
-#define BSD_SYSTEM 199103
-#elif __FreeBSD__ == 2
-#define BSD_SYSTEM 199306
-#elif __FreeBSD__ >= 3
-#define BSD_SYSTEM 199506
-#endif
-#endif
-
#ifdef DARWIN_OS
#ifdef emacs
#define malloc unexec_malloc
diff --git a/src/dispnew.c b/src/dispnew.c
index f9fed7de406..47adab6b8f7 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -3392,8 +3392,8 @@ update_window (struct window *w, bool force_p)
rif->update_window_begin_hook (w);
yb = window_text_bottom_y (w);
- row = desired_matrix->rows;
- end = row + desired_matrix->nrows - 1;
+ row = MATRIX_ROW (desired_matrix, 0);
+ end = MATRIX_MODE_LINE_ROW (desired_matrix);
/* Take note of the header line, if there is one. We will
update it below, after updating all of the window's lines. */
@@ -6100,10 +6100,7 @@ init_display (void)
/* If no window system has been specified, try to use the terminal. */
if (! isatty (0))
- {
- fatal ("standard input is not a tty");
- exit (1);
- }
+ fatal ("standard input is not a tty");
#ifdef WINDOWSNT
terminal_type = "w32console";
diff --git a/src/emacs.c b/src/emacs.c
index 7b6f147619b..148bb836927 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/>. */
#include "w32common.h"
#endif
-#if defined HAVE_NTGUI && defined CYGWIN
+#if defined CYGWIN
#include "cygw32.h"
#endif
@@ -1339,7 +1339,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
#ifdef WINDOWSNT
syms_of_ntproc ();
#endif /* WINDOWSNT */
-#if defined CYGWIN && defined HAVE_NTGUI
+#if defined CYGWIN
syms_of_cygw32 ();
#endif
syms_of_window ();
diff --git a/src/eval.c b/src/eval.c
index 6d34cd80802..a58a1508aaf 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1709,7 +1709,6 @@ error (const char *m, ...)
va_list ap;
va_start (ap, m);
verror (m, ap);
- va_end (ap);
}
DEFUN ("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. */)
error ("Missing \"}\" in environment-variable substitution");
badvar:
error ("Substituting nonexistent environment variable \"%s\"", target);
-
- /* NOTREACHED */
- return Qnil;
}
/* 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
return Qnil;
#endif
report_file_error ("Setting file times", Fcons (absname, Qnil));
- return Qnil;
}
}
@@ -4963,20 +4959,23 @@ This calls `write-region-annotate-functions' at the start, and
immediate_quit = 0;
-#ifdef HAVE_FSYNC
/* fsync appears to change the modtime on BSD4.2.
Disk full in NFS may be reported here. */
/* mib says that closing the file will try to write as fast as NFS can do
it, and that means the fsync here is not crucial for autosave files. */
- if (!auto_saving && !write_region_inhibit_fsync && fsync (desc) < 0)
+ if (!auto_saving && !write_region_inhibit_fsync)
{
- /* If fsync fails with EINTR, don't treat that as serious. Also
+ /* Transfer data and metadata to disk, retrying if interrupted. Also,
ignore EINVAL which happens when fsync is not supported on this
file. */
- if (errno != EINTR && errno != EINVAL)
- ok = 0, save_errno = errno;
+ while (fsync (desc) != 0)
+ if (errno != EINTR)
+ {
+ if (errno != EINVAL)
+ ok = 0, save_errno = errno;
+ break;
+ }
}
-#endif
modtime = invalid_emacs_time ();
if (visiting)
@@ -6050,13 +6049,11 @@ in the buffer; this is the default behavior, because the auto-save
file is usually more useful if it contains the deleted text. */);
Vauto_save_include_big_deletions = Qnil;
-#ifdef HAVE_FSYNC
DEFVAR_BOOL ("write-region-inhibit-fsync", write_region_inhibit_fsync,
doc: /* Non-nil means don't call fsync in `write-region'.
This variable affects calls to `write-region' as well as save commands.
A non-nil value may result in data loss! */);
write_region_inhibit_fsync = 0;
-#endif
DEFVAR_BOOL ("delete-by-moving-to-trash", delete_by_moving_to_trash,
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)
if (emacs_write (fd, lock_info_str, lock_info_len) != lock_info_len
|| (need_fchmod && fchmod (fd, world_readable) != 0))
err = errno;
+ else
+ while (fsync (fd) != 0)
+ if (errno != EINTR)
+ {
+ if (errno != EINVAL)
+ err = errno;
+ break;
+ }
if (emacs_close (fd) != 0)
err = errno;
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,
}
/* Insert a sequence of NCHARS chars which occupy NBYTES bytes
- starting at GPT_ADDR. */
+ starting at GAP_END_ADDR - NBYTES (if text_at_gap_tail) and at
+ GPT_ADDR (if not text_at_gap_tail). */
void
-insert_from_gap (ptrdiff_t nchars, ptrdiff_t nbytes)
+insert_from_gap (ptrdiff_t nchars, ptrdiff_t nbytes, bool text_at_gap_tail)
{
if (NILP (BVAR (current_buffer, enable_multibyte_characters)))
nchars = nbytes;
@@ -989,10 +990,13 @@ insert_from_gap (ptrdiff_t nchars, ptrdiff_t nbytes)
MODIFF++;
GAP_SIZE -= nbytes;
- GPT += nchars;
+ if (! text_at_gap_tail)
+ {
+ GPT += nchars;
+ GPT_BYTE += nbytes;
+ }
ZV += nchars;
Z += nchars;
- GPT_BYTE += nbytes;
ZV_BYTE += nbytes;
Z_BYTE += nbytes;
if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */
@@ -1010,7 +1014,7 @@ insert_from_gap (ptrdiff_t nchars, ptrdiff_t nbytes)
current_buffer, 0);
}
- if (GPT - nchars < PT)
+ if (! text_at_gap_tail && GPT - nchars < PT)
adjust_point (nchars, nbytes);
check_markers ();
diff --git a/src/keyboard.c b/src/keyboard.c
index 914378947ed..e43b7a73172 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -6552,10 +6552,7 @@ has the same base event type and all the specified modifiers. */)
else if (SYMBOLP (base))
return apply_modifiers (modifiers, base);
else
- {
- error ("Invalid base event");
- return Qnil;
- }
+ error ("Invalid base event");
}
/* Try to recognize SYMBOL as a modifier name.
@@ -6815,48 +6812,6 @@ gobble_input (void)
return nread;
}
-static void
-decode_keyboard_code (struct tty_display_info *tty,
- struct coding_system *coding,
- unsigned char *buf, int nbytes)
-{
- unsigned char *src = buf;
- const unsigned char *p;
- int i;
-
- if (nbytes == 0)
- return;
- if (tty->meta_key != 2)
- for (i = 0; i < nbytes; i++)
- buf[i] &= ~0x80;
- if (coding->carryover_bytes > 0)
- {
- src = alloca (coding->carryover_bytes + nbytes);
- memcpy (src, coding->carryover, coding->carryover_bytes);
- memcpy (src + coding->carryover_bytes, buf, nbytes);
- nbytes += coding->carryover_bytes;
- }
- coding->destination = alloca (nbytes * 4);
- coding->dst_bytes = nbytes * 4;
- decode_coding_c_string (coding, src, nbytes, Qnil);
- if (coding->produced_char == 0)
- return;
- for (i = 0, p = coding->destination; i < coding->produced_char; i++)
- {
- struct input_event event_buf;
-
- EVENT_INIT (event_buf);
- event_buf.code = STRING_CHAR_ADVANCE (p);
- event_buf.kind =
- (ASCII_CHAR_P (event_buf.code)
- ? ASCII_KEYSTROKE_EVENT : MULTIBYTE_CHAR_KEYSTROKE_EVENT);
- /* See the comment in tty_read_avail_input. */
- event_buf.frame_or_window = tty->top_frame;
- event_buf.arg = Qnil;
- kbd_buffer_store_event (&event_buf);
- }
-}
-
/* This is the tty way of reading available input.
Note that each terminal device has its own `struct terminal' object,
@@ -7014,36 +6969,6 @@ tty_read_avail_input (struct terminal *terminal,
#endif /* not MSDOS */
#endif /* not WINDOWSNT */
- if (TERMINAL_KEYBOARD_CODING (terminal)->common_flags
- & CODING_REQUIRE_DECODING_MASK)
- {
- struct coding_system *coding = TERMINAL_KEYBOARD_CODING (terminal);
- int from;
-
- /* Decode the key sequence except for those with meta
- modifiers. */
- for (i = from = 0; ; i++)
- if (i == nread || (tty->meta_key == 1 && (cbuf[i] & 0x80)))
- {
- struct input_event buf;
-
- decode_keyboard_code (tty, coding, cbuf + from, i - from);
- if (i == nread)
- break;
-
- EVENT_INIT (buf);
- buf.kind = ASCII_KEYSTROKE_EVENT;
- buf.modifiers = meta_modifier;
- buf.code = cbuf[i] & ~0x80;
- /* See the comment below. */
- buf.frame_or_window = tty->top_frame;
- buf.arg = Qnil;
- kbd_buffer_store_event (&buf);
- from = i + 1;
- }
- return nread;
- }
-
for (i = 0; i < nread; i++)
{
struct input_event buf;
@@ -8699,7 +8624,7 @@ access_keymap_keyremap (Lisp_Object map, Lisp_Object key, Lisp_Object prompt,
barf--don't ignore it.
(To ignore it safely, we would need to gcpro a bunch of
other variables.) */
- if (! (VECTORP (next) || STRINGP (next)))
+ if (! (NILP (next) || VECTORP (next) || STRINGP (next)))
error ("Function %s returns invalid key sequence",
SSDATA (SYMBOL_NAME (tem)));
}
@@ -8783,6 +8708,71 @@ test_undefined (Lisp_Object binding)
&& EQ (Fcommand_remapping (binding, Qnil, Qnil), Qundefined)));
}
+/* Like `read_char' but applies keyboard-coding-system to tty input. */
+static Lisp_Object
+read_decoded_char (int commandflag, Lisp_Object map,
+ Lisp_Object prev_event, bool *used_mouse_menu)
+{
+#define MAX_ENCODED_BYTES 16
+ Lisp_Object events[MAX_ENCODED_BYTES];
+ int n = 0;
+ while (true)
+ {
+ Lisp_Object nextevt
+ = read_char (commandflag, map, prev_event, used_mouse_menu, NULL);
+ struct frame *frame = XFRAME (selected_frame);
+ struct terminal *terminal = frame->terminal;
+ if (!((FRAME_TERMCAP_P (frame) || FRAME_MSDOS_P (frame))
+ && (TERMINAL_KEYBOARD_CODING (terminal)->common_flags
+ & CODING_REQUIRE_DECODING_MASK)))
+ return nextevt; /* No decoding needed. */
+ else
+ {
+ int meta_key = terminal->display_info.tty->meta_key;
+ eassert (n < MAX_ENCODED_BYTES);
+ events[n++] = nextevt;
+ if (NATNUMP (nextevt)
+ && XINT (nextevt) < (meta_key == 1 ? 0x80 : 0x100))
+ { /* An encoded byte sequence, let's try to decode it. */
+ struct coding_system *coding
+ = TERMINAL_KEYBOARD_CODING (terminal);
+ unsigned char *src = alloca (n);
+ int i;
+ for (i = 0; i < n; i++)
+ src[i] = XINT (events[i]);
+ if (meta_key != 2)
+ for (i = 0; i < n; i++)
+ src[i] &= ~0x80;
+ coding->destination = alloca (n * 4);
+ coding->dst_bytes = n * 4;
+ decode_coding_c_string (coding, src, n, Qnil);
+ eassert (coding->produced_char <= n);
+ if (coding->produced_char == 0)
+ { /* The encoded sequence is incomplete. */
+ if (n < MAX_ENCODED_BYTES) /* Avoid buffer overflow. */
+ continue; /* Read on! */
+ }
+ else
+ {
+ const unsigned char *p = coding->destination;
+ eassert (coding->carryover_bytes == 0);
+ n = 0;
+ while (n < coding->produced_char)
+ events[n++] = make_number (STRING_CHAR_ADVANCE (p));
+ }
+ }
+ /* Now `events' should hold decoded events.
+ Normally, n should be equal to 1, but better not rely on it.
+ We can only return one event here, so return the first we
+ had and keep the others (if any) for later. */
+ while (n > 1)
+ Vunread_command_events
+ = Fcons (events[--n], Vunread_command_events);
+ return events[0];
+ }
+ }
+}
+
/* Read a sequence of keys that ends with a non prefix character,
storing it in KEYBUF, a buffer of size BUFSIZE.
Prompt with PROMPT.
@@ -9060,9 +9050,9 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
{
KBOARD *interrupted_kboard = current_kboard;
struct frame *interrupted_frame = SELECTED_FRAME ();
- key = read_char (NILP (prompt),
- current_binding, last_nonmenu_event,
- &used_mouse_menu, NULL);
+ key = read_decoded_char (NILP (prompt),
+ current_binding, last_nonmenu_event,
+ &used_mouse_menu);
if ((INTEGERP (key) && XINT (key) == -2) /* wrong_kboard_jmpbuf */
/* When switching to a new tty (with a new keyboard),
read_char returns the new buffer, rather than -2
@@ -10553,7 +10543,7 @@ See also `current-input-mode'. */)
if (tty->flow_control != !NILP (flow))
{
#ifndef DOS_NT
- /* this causes startup screen to be restored and messes with the mouse */
+ /* This causes startup screen to be restored and messes with the mouse. */
reset_sys_modes (tty);
#endif
diff --git a/src/keyboard.h b/src/keyboard.h
index c6ade35dd52..8bb1c409efc 100644
--- a/src/keyboard.h
+++ b/src/keyboard.h
@@ -421,18 +421,18 @@ typedef struct _widget_value
(EVENT_HAS_PARAMETERS (event) ? XCAR (event) : (event))
/* Extract the starting and ending positions from a composite event. */
-#define EVENT_START(event) (XCAR (XCDR (event)))
-#define EVENT_END(event) (XCAR (XCDR (XCDR (event))))
+#define EVENT_START(event) (CAR_SAFE (CDR_SAFE (event)))
+#define EVENT_END(event) (CAR_SAFE (CDR_SAFE (CDR_SAFE (event))))
/* Extract the click count from a multi-click event. */
#define EVENT_CLICK_COUNT(event) (Fnth (make_number (2), (event)))
/* Extract the fields of a position. */
-#define POSN_WINDOW(posn) (XCAR (posn))
-#define POSN_POSN(posn) (XCAR (XCDR (posn)))
+#define POSN_WINDOW(posn) (CAR_SAFE (posn))
+#define POSN_POSN(posn) (CAR_SAFE (CDR_SAFE (posn)))
#define POSN_SET_POSN(posn,x) (XSETCAR (XCDR (posn), (x)))
-#define POSN_WINDOW_POSN(posn) (XCAR (XCDR (XCDR (posn))))
-#define POSN_TIMESTAMP(posn) (XCAR (XCDR (XCDR (XCDR (posn)))))
+#define POSN_WINDOW_POSN(posn) (CAR_SAFE (CDR_SAFE (CDR_SAFE (posn))))
+#define POSN_TIMESTAMP(posn) (CAR_SAFE (CDR_SAFE (CDR_SAFE (CDR_SAFE (posn)))))
#define POSN_SCROLLBAR_PART(posn) (Fnth (make_number (4), (posn)))
/* A cons (STRING . STRING-CHARPOS), or nil in mouse-click events.
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)
{
if (!NILP (val))
{
- map_keymap_function_t fun = XSAVE_POINTER (args, 0);
+ map_keymap_function_t fun
+ = (map_keymap_function_t) XSAVE_POINTER (args, 0);
/* If the key is a range, make a copy since map_char_table modifies
it in place. */
if (CONSP (key))
@@ -2310,7 +2311,6 @@ around function keys and event symbols. */)
return Fcopy_sequence (key);
else
error ("KEY must be an integer, cons, symbol, or string");
- return Qnil;
}
static char *
diff --git a/src/lisp.h b/src/lisp.h
index 735cf8097dd..44dde1860cc 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2894,7 +2894,7 @@ extern void insert (const char *, ptrdiff_t);
extern void insert_and_inherit (const char *, ptrdiff_t);
extern void insert_1_both (const char *, ptrdiff_t, ptrdiff_t,
bool, bool, bool);
-extern void insert_from_gap (ptrdiff_t, ptrdiff_t);
+extern void insert_from_gap (ptrdiff_t, ptrdiff_t, bool text_at_gap_tail);
extern void insert_from_string (Lisp_Object, ptrdiff_t, ptrdiff_t,
ptrdiff_t, ptrdiff_t, bool);
extern void insert_from_buffer (struct buffer *, ptrdiff_t, ptrdiff_t, bool);
@@ -3377,7 +3377,7 @@ extern void record_unwind_save_match_data (void);
struct re_registers;
extern struct re_pattern_buffer *compile_pattern (Lisp_Object,
struct re_registers *,
- Lisp_Object, int, bool);
+ Lisp_Object, bool, bool);
extern ptrdiff_t fast_string_match (Lisp_Object, Lisp_Object);
extern ptrdiff_t fast_c_string_match_ignore_case (Lisp_Object, const char *,
ptrdiff_t);
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)
return STRING_CHAR (buf);
}
+#define FROM_FILE_P(readcharfun) \
+ (EQ (readcharfun, Qget_file_char) \
+ || EQ (readcharfun, Qget_emacs_mule_file_char))
+
static void
skip_dyn_bytes (Lisp_Object readcharfun, ptrdiff_t n)
{
- if (EQ (readcharfun, Qget_file_char)
- || EQ (readcharfun, Qget_emacs_mule_file_char))
+ if (FROM_FILE_P (readcharfun))
{
block_input (); /* FIXME: Not sure if it's needed. */
fseek (instream, n, SEEK_CUR);
@@ -423,8 +426,7 @@ unreadchar (Lisp_Object readcharfun, int c)
{
unread_char = c;
}
- else if (EQ (readcharfun, Qget_file_char)
- || EQ (readcharfun, Qget_emacs_mule_file_char))
+ else if (FROM_FILE_P (readcharfun))
{
unread_char = c;
}
@@ -2636,8 +2638,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
UNREAD (c);
if (load_force_doc_strings
- && (EQ (readcharfun, Qget_file_char)
- || EQ (readcharfun, Qget_emacs_mule_file_char)))
+ && (FROM_FILE_P (readcharfun)))
{
/* If we are supposed to force doc strings into core right now,
record the last string that we skipped,
@@ -3573,8 +3574,10 @@ read_list (bool flag, Lisp_Object readcharfun)
{
if (doc_reference == 1)
return make_number (0);
- if (doc_reference == 2)
+ if (doc_reference == 2 && INTEGERP (XCDR (val)))
{
+ char *saved = NULL;
+ file_offset saved_position;
/* Get a doc string from the file we are loading.
If it's in saved_doc_string, get it from there.
@@ -3591,65 +3594,42 @@ read_list (bool flag, Lisp_Object readcharfun)
&& pos < (saved_doc_string_position
+ saved_doc_string_length))
{
- ptrdiff_t start = pos - saved_doc_string_position;
- ptrdiff_t from, to;
-
- /* Process quoting with ^A,
- and find the end of the string,
- which is marked with ^_ (037). */
- for (from = start, to = start;
- saved_doc_string[from] != 037;)
- {
- int c = saved_doc_string[from++];
- if (c == 1)
- {
- c = saved_doc_string[from++];
- if (c == 1)
- saved_doc_string[to++] = c;
- else if (c == '0')
- saved_doc_string[to++] = 0;
- else if (c == '_')
- saved_doc_string[to++] = 037;
- }
- else
- saved_doc_string[to++] = c;
- }
-
- return make_unibyte_string (saved_doc_string + start,
- to - start);
+ saved = saved_doc_string;
+ saved_position = saved_doc_string_position;
}
/* Look in prev_saved_doc_string the same way. */
else if (pos >= prev_saved_doc_string_position
&& pos < (prev_saved_doc_string_position
+ prev_saved_doc_string_length))
{
- ptrdiff_t start =
- pos - prev_saved_doc_string_position;
+ saved = prev_saved_doc_string;
+ saved_position = prev_saved_doc_string_position;
+ }
+ if (saved)
+ {
+ ptrdiff_t start = pos - saved_position;
ptrdiff_t from, to;
/* Process quoting with ^A,
and find the end of the string,
which is marked with ^_ (037). */
for (from = start, to = start;
- prev_saved_doc_string[from] != 037;)
+ saved[from] != 037;)
{
- int c = prev_saved_doc_string[from++];
+ int c = saved[from++];
if (c == 1)
{
- c = prev_saved_doc_string[from++];
- if (c == 1)
- prev_saved_doc_string[to++] = c;
- else if (c == '0')
- prev_saved_doc_string[to++] = 0;
- else if (c == '_')
- prev_saved_doc_string[to++] = 037;
+ c = saved[from++];
+ saved[to++] = (c == 1 ? c
+ : c == '0' ? 0
+ : c == '_' ? 037
+ : c);
}
else
- prev_saved_doc_string[to++] = c;
+ saved[to++] = c;
}
- return make_unibyte_string (prev_saved_doc_string
- + start,
+ return make_unibyte_string (saved + start,
to - start);
}
else
diff --git a/src/nsfns.m b/src/nsfns.m
index e4dde5fb894..ef18acaa045 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -261,6 +261,29 @@ ns_display_info_for_name (Lisp_Object name)
return dpyinfo;
}
+static NSString *
+ns_filename_from_panel (NSSavePanel *panel)
+{
+#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
+ NSURL *url = [panel URL];
+ NSString *str = [url path];
+ return str;
+#else
+ return [panel filename];
+#endif
+}
+
+static NSString *
+ns_directory_from_panel (NSSavePanel *panel)
+{
+#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
+ NSURL *url = [panel directoryURL];
+ NSString *str = [url path];
+ return str;
+#else
+ return [panel directory];
+#endif
+}
static Lisp_Object
interpret_services_menu (NSMenu *menu, Lisp_Object prefix, Lisp_Object old)
@@ -1471,7 +1494,7 @@ Optional arg DIR_ONLY_P, if non-nil, means choose only directories. */)
Lisp_Object init, Lisp_Object dir_only_p)
{
static id fileDelegate = nil;
- int ret;
+ BOOL ret;
id panel;
Lisp_Object fname;
@@ -1508,6 +1531,13 @@ Optional arg DIR_ONLY_P, if non-nil, means choose only directories. */)
[panel setCanChooseDirectories: YES];
[panel setCanChooseFiles: NO];
}
+ else
+ {
+ /* This is not quite what the documentation says, but it is compatible
+ with the Gtk+ code. Also, the menu entry says "Open File...". */
+ [panel setCanChooseDirectories: NO];
+ [panel setCanChooseFiles: YES];
+ }
block_input ();
#if defined (NS_IMPL_COCOA) && \
@@ -1528,15 +1558,19 @@ Optional arg DIR_ONLY_P, if non-nil, means choose only directories. */)
}
else
{
- [panel setCanChooseDirectories: YES];
ret = [panel runModalForDirectory: dirS file: initS types: nil];
}
#endif
ret = (ret == NSOKButton) || panelOK;
- if (ret)
- fname = build_string ([[panel filename] UTF8String]);
+ if (ret)
+ {
+ NSString *str = [panel getFilename];
+ if (! str) str = [panel getDirectory];
+ if (! str) ret = NO;
+ else fname = build_string ([str UTF8String]);
+ }
[[FRAME_NS_VIEW (SELECTED_FRAME ()) window] makeKeyWindow];
unblock_input ();
@@ -2603,6 +2637,14 @@ Value is t if tooltip was open, nil otherwise. */)
[NSApp stop: self];
}
#endif
+- (NSString *) getFilename
+{
+ return ns_filename_from_panel (self);
+}
+- (NSString *) getDirectory
+{
+ return ns_directory_from_panel (self);
+}
@end
@@ -2616,6 +2658,12 @@ Value is t if tooltip was open, nil otherwise. */)
- (void) ok: (id)sender
{
[super ok: sender];
+
+ // If not choosing directories, and Open is pressed on a directory, return.
+ if (! [self canChooseDirectories] && [self getDirectory] &&
+ ! [self getFilename])
+ return;
+
panelOK = 1;
[NSApp stop: self];
}
@@ -2624,7 +2672,17 @@ Value is t if tooltip was open, nil otherwise. */)
[super cancel: sender];
[NSApp stop: self];
}
+
#endif
+- (NSString *) getFilename
+{
+ return ns_filename_from_panel (self);
+}
+- (NSString *) getDirectory
+{
+ return ns_directory_from_panel (self);
+}
+
@end
diff --git a/src/nsterm.h b/src/nsterm.h
index 41dbaf3c0f7..6bd04b96684 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -267,10 +267,14 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
@interface EmacsSavePanel : NSSavePanel
{
}
+- (NSString *) getFilename;
+- (NSString *) getDirectory;
@end
@interface EmacsOpenPanel : NSOpenPanel
{
}
+- (NSString *) getFilename;
+- (NSString *) getDirectory;
@end
@interface EmacsFileDelegate : NSObject
diff --git a/src/nsterm.m b/src/nsterm.m
index 1f09e031592..40e506eab27 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -3601,6 +3601,11 @@ ns_select (int nfds, fd_set *readfds, fd_set *writefds,
result = t;
}
}
+ else
+ {
+ errno = EINTR;
+ result = -1;
+ }
return result;
}
@@ -5448,12 +5453,26 @@ not_in_argv (NSString *arg)
if (oldr != rows || oldc != cols || neww != oldw || newh != oldh)
{
+ struct frame *f = emacsframe;
NSView *view = FRAME_NS_VIEW (emacsframe);
+ NSWindow *win = [view window];
+ NSSize sz = [win resizeIncrements];
+
FRAME_PIXEL_WIDTH (emacsframe) = neww;
FRAME_PIXEL_HEIGHT (emacsframe) = newh;
change_frame_size (emacsframe, rows, cols, 0, delay, 0);
SET_FRAME_GARBAGED (emacsframe);
cancel_mouse_face (emacsframe);
+
+ // Did resize increments change because of a font change?
+ if (sz.width != FRAME_COLUMN_WIDTH (emacsframe) ||
+ sz.height != FRAME_LINE_HEIGHT (emacsframe))
+ {
+ sz.width = FRAME_COLUMN_WIDTH (emacsframe);
+ sz.height = FRAME_LINE_HEIGHT (emacsframe);
+ [win setResizeIncrements: sz];
+ }
+
[view setFrame: NSMakeRect (0, 0, neww, newh)];
[self windowDidMove:nil]; // Update top/left.
}
diff --git a/src/region-cache.c b/src/region-cache.c
index 14e6982cd9a..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)
}
/* Some testing. */
- if (BOUNDARY_POS (c, low) > pos
- || (low + 1 < c->cache_len
- && BOUNDARY_POS (c, low + 1) <= pos))
- emacs_abort ();
+ eassert (!(BOUNDARY_POS (c, low) > pos
+ || (low + 1 < c->cache_len
+ && BOUNDARY_POS (c, low + 1) <= pos)));
return low;
}
@@ -214,14 +213,9 @@ move_cache_gap (struct region_cache *c, ptrdiff_t pos, ptrdiff_t min_size)
ptrdiff_t buffer_beg = c->buffer_beg;
ptrdiff_t buffer_end = c->buffer_end;
- if (pos < 0
- || pos > c->cache_len)
- emacs_abort ();
-
/* We mustn't ever try to put the gap before the dummy start
boundary. That must always be start-relative. */
- if (pos == 0)
- emacs_abort ();
+ eassert (0 < pos && pos <= c->cache_len);
/* Need we move the gap right? */
while (gap_start < pos)
@@ -288,26 +282,19 @@ static void
insert_cache_boundary (struct region_cache *c, ptrdiff_t i, ptrdiff_t pos,
int value)
{
- /* i must be a valid cache index. */
- if (i < 0 || i > c->cache_len)
- emacs_abort ();
-
- /* We must never want to insert something before the dummy first
- boundary. */
- if (i == 0)
- emacs_abort ();
+ /* I must be a valid cache index, and we must never want
+ to insert something before the dummy first boundary. */
+ eassert (0 < i && i <= c->cache_len);
/* We must only be inserting things in order. */
- if (! (BOUNDARY_POS (c, i - 1) < pos
- && (i == c->cache_len
- || pos < BOUNDARY_POS (c, i))))
- emacs_abort ();
+ eassert ((BOUNDARY_POS (c, i - 1) < pos
+ && (i == c->cache_len
+ || pos < BOUNDARY_POS (c, i))));
/* The value must be different from the ones around it. However, we
temporarily create boundaries that establish the same value as
the subsequent boundary, so we're not going to flag that case. */
- if (BOUNDARY_VALUE (c, i - 1) == value)
- emacs_abort ();
+ eassert (BOUNDARY_VALUE (c, i - 1) != value);
move_cache_gap (c, i, 1);
@@ -328,18 +315,13 @@ delete_cache_boundaries (struct region_cache *c,
ptrdiff_t len = end - start;
/* Gotta be in range. */
- if (start < 0
- || end > c->cache_len)
- emacs_abort ();
+ eassert (0 <= start && end <= c->cache_len);
/* Gotta be in order. */
- if (start > end)
- emacs_abort ();
+ eassert (start <= end);
/* Can't delete the dummy entry. */
- if (start == 0
- && end >= 1)
- emacs_abort ();
+ eassert (!(start == 0 && end >= 1));
/* Minimize gap motion. If we're deleting nothing, do nothing. */
if (len == 0)
@@ -378,11 +360,8 @@ static void
set_cache_region (struct region_cache *c,
ptrdiff_t start, ptrdiff_t end, int value)
{
- if (start > end)
- emacs_abort ();
- if (start < c->buffer_beg
- || end > c->buffer_end)
- emacs_abort ();
+ eassert (start <= end);
+ eassert (c->buffer_beg <= start && end <= c->buffer_end);
/* Eliminate this case; then we can assume that start and end-1 are
both the locations of real characters in the buffer. */
@@ -695,8 +674,9 @@ know_region_cache (struct buffer *buf, struct region_cache *c,
/* Interface: using the cache. */
-/* Return true if the text immediately after POS in BUF is known, for
- the purposes of CACHE. If NEXT is non-zero, set *NEXT to the nearest
+/* Return the value for the text immediately after POS in BUF if the value
+ is known, for the purposes of CACHE, and return zero otherwise.
+ If NEXT is non-zero, set *NEXT to the nearest
position after POS where the knowledge changes. */
int
region_cache_forward (struct buffer *buf, struct region_cache *c,
@@ -732,8 +712,9 @@ region_cache_forward (struct buffer *buf, struct region_cache *c,
}
}
-/* Return true if the text immediately before POS in BUF is known, for
- the purposes of CACHE. If NEXT is non-zero, set *NEXT to the nearest
+/* Return the value for the text immediately before POS in BUF if the
+ value is known, for the purposes of CACHE, and return zero
+ otherwise. If NEXT is non-zero, set *NEXT to the nearest
position before POS where the knowledge changes. */
int region_cache_backward (struct buffer *buf, struct region_cache *c,
ptrdiff_t pos, ptrdiff_t *next)
@@ -770,7 +751,8 @@ int region_cache_backward (struct buffer *buf, struct region_cache *c,
}
}
-
+#ifdef ENABLE_CHECKING
+
/* Debugging: pretty-print a cache to the standard error output. */
void pp_cache (struct region_cache *) EXTERNALLY_VISIBLE;
@@ -801,3 +783,5 @@ pp_cache (struct region_cache *c)
fprintf (stderr, "%"pD"d : %d\n", pos, BOUNDARY_VALUE (c, i));
}
}
+
+#endif /* ENABLE_CHECKING */
diff --git a/src/scroll.c b/src/scroll.c
index 9e11feb64d4..037e338c696 100644
--- a/src/scroll.c
+++ b/src/scroll.c
@@ -246,9 +246,8 @@ do_scrolling (struct frame *frame, struct glyph_matrix *current_matrix,
struct matrix_elt *p;
int i, j, k;
- /* Set to 1 if we have set a terminal window with
- set_terminal_window. It's unsigned to work around GCC bug 48228. */
- unsigned int terminal_window_p = 0;
+ /* True if we have set a terminal window with set_terminal_window. */
+ bool terminal_window_p = 0;
/* A queue for line insertions to be done. */
struct queue { int count, pos; };
@@ -657,18 +656,16 @@ do_direct_scrolling (struct frame *frame, struct glyph_matrix *current_matrix,
alloca (window_size * sizeof *queue_start);
struct alt_queue *queue = queue_start;
- /* Set to 1 if a terminal window has been set with
- set_terminal_window: */
- int terminal_window_p = 0;
+ /* True if a terminal window has been set with set_terminal_window. */
+ bool terminal_window_p = 0;
- /* A nonzero value of write_follows indicates that a write has been
- selected, allowing either an insert or a delete to be selected
- next. When write_follows is zero, a delete cannot be selected
+ /* If true, a write has been selected, allowing either an insert or a
+ delete to be selected next. If false, a delete cannot be selected
unless j < i, and an insert cannot be selected unless i < j.
This corresponds to a similar restriction (with the ordering
reversed) in calculate_direct_scrolling, which is intended to
ensure that lines marked as inserted will be blank. */
- int write_follows_p = 1;
+ bool write_follows_p = 1;
/* For each row in the new matrix what row of the old matrix it is. */
int *copy_from = alloca (window_size * sizeof *copy_from);
diff --git a/src/search.c b/src/search.c
index 32ad6927442..4dd3260b735 100644
--- a/src/search.c
+++ b/src/search.c
@@ -49,8 +49,8 @@ struct regexp_cache
Lisp_Object syntax_table;
struct re_pattern_buffer buf;
char fastmap[0400];
- /* Nonzero means regexp was compiled to do full POSIX backtracking. */
- char posix;
+ /* True means regexp was compiled to do full POSIX backtracking. */
+ bool posix;
};
/* The instances of that struct. */
@@ -100,7 +100,7 @@ static EMACS_INT boyer_moore (EMACS_INT, unsigned char *, ptrdiff_t,
ptrdiff_t, int);
static EMACS_INT search_buffer (Lisp_Object, ptrdiff_t, ptrdiff_t,
ptrdiff_t, ptrdiff_t, EMACS_INT, int,
- Lisp_Object, Lisp_Object, int);
+ Lisp_Object, Lisp_Object, bool);
static _Noreturn void
matcher_overflow (void)
@@ -112,13 +112,14 @@ matcher_overflow (void)
PATTERN is the pattern to compile.
CP is the place to put the result.
TRANSLATE is a translation table for ignoring case, or nil for none.
- POSIX is nonzero if we want full backtracking (POSIX style)
- for this pattern. 0 means backtrack only enough to get a valid match.
+ POSIX is true if we want full backtracking (POSIX style) for this pattern.
+ False means backtrack only enough to get a valid match.
The behavior also depends on Vsearch_spaces_regexp. */
static void
-compile_pattern_1 (struct regexp_cache *cp, Lisp_Object pattern, Lisp_Object translate, int posix)
+compile_pattern_1 (struct regexp_cache *cp, Lisp_Object pattern,
+ Lisp_Object translate, bool posix)
{
char *val;
reg_syntax_t old;
@@ -205,12 +206,12 @@ clear_regexp_cache (void)
values that will result from matching this pattern.
If it is 0, we should compile the pattern not to record any
subexpression bounds.
- POSIX is nonzero if we want full backtracking (POSIX style)
- for this pattern. 0 means backtrack only enough to get a valid match. */
+ POSIX is true if we want full backtracking (POSIX style) for this pattern.
+ False means backtrack only enough to get a valid match. */
struct re_pattern_buffer *
compile_pattern (Lisp_Object pattern, struct re_registers *regp,
- Lisp_Object translate, int posix, bool multibyte)
+ Lisp_Object translate, bool posix, bool multibyte)
{
struct regexp_cache *cp, **cpp;
@@ -267,7 +268,7 @@ compile_pattern (Lisp_Object pattern, struct re_registers *regp,
static Lisp_Object
-looking_at_1 (Lisp_Object string, int posix)
+looking_at_1 (Lisp_Object string, bool posix)
{
Lisp_Object val;
unsigned char *p1, *p2;
@@ -365,7 +366,8 @@ data if you want to preserve them. */)
}
static Lisp_Object
-string_match_1 (Lisp_Object regexp, Lisp_Object string, Lisp_Object start, int posix)
+string_match_1 (Lisp_Object regexp, Lisp_Object string, Lisp_Object start,
+ bool posix)
{
ptrdiff_t val;
struct re_pattern_buffer *bufp;
@@ -975,9 +977,9 @@ find_before_next_newline (ptrdiff_t from, ptrdiff_t to,
static Lisp_Object
search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror,
- Lisp_Object count, int direction, int RE, int posix)
+ Lisp_Object count, int direction, int RE, bool posix)
{
- register EMACS_INT np;
+ EMACS_INT np;
EMACS_INT lim;
ptrdiff_t lim_byte;
EMACS_INT n = direction;
@@ -1047,9 +1049,9 @@ search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror,
return make_number (np);
}
-/* Return 1 if REGEXP it matches just one constant string. */
+/* Return true if REGEXP it matches just one constant string. */
-static int
+static bool
trivial_regexp_p (Lisp_Object regexp)
{
ptrdiff_t len = SBYTES (regexp);
@@ -1118,7 +1120,7 @@ static struct re_registers search_regs_1;
static EMACS_INT
search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte,
ptrdiff_t lim, ptrdiff_t lim_byte, EMACS_INT n,
- int RE, Lisp_Object trt, Lisp_Object inverse_trt, int posix)
+ int RE, Lisp_Object trt, Lisp_Object inverse_trt, bool posix)
{
ptrdiff_t len = SCHARS (string);
ptrdiff_t len_byte = SBYTES (string);
@@ -1273,7 +1275,7 @@ search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte,
/* Set to positive if we find a non-ASCII char that need
translation. Otherwise set to zero later. */
int char_base = -1;
- int boyer_moore_ok = 1;
+ bool boyer_moore_ok = 1;
/* MULTIBYTE says whether the text to be searched is multibyte.
We must convert PATTERN to match that, or we will not really
@@ -2282,12 +2284,12 @@ since only regular expressions have distinguished subexpressions. */)
(Lisp_Object newtext, Lisp_Object fixedcase, Lisp_Object literal, Lisp_Object string, Lisp_Object subexp)
{
enum { nochange, all_caps, cap_initial } case_action;
- register ptrdiff_t pos, pos_byte;
- int some_multiletter_word;
- int some_lowercase;
- int some_uppercase;
- int some_nonuppercase_initial;
- register int c, prevc;
+ ptrdiff_t pos, pos_byte;
+ bool some_multiletter_word;
+ bool some_lowercase;
+ bool some_uppercase;
+ bool some_nonuppercase_initial;
+ int c, prevc;
ptrdiff_t sub;
ptrdiff_t opoint, newpoint;
@@ -2432,7 +2434,7 @@ since only regular expressions have distinguished subexpressions. */)
{
ptrdiff_t substart = -1;
ptrdiff_t subend = 0;
- int delbackslash = 0;
+ bool delbackslash = 0;
FETCH_STRING_CHAR_ADVANCE (c, newtext, pos, pos_byte);
@@ -2529,7 +2531,7 @@ since only regular expressions have distinguished subexpressions. */)
ptrdiff_t substed_alloc_size, substed_len;
bool buf_multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters));
bool str_multibyte = STRING_MULTIBYTE (newtext);
- int really_changed = 0;
+ bool really_changed = 0;
substed_alloc_size = ((STRING_BYTES_BOUND - 100) / 2 < length
? STRING_BYTES_BOUND
@@ -2695,7 +2697,7 @@ since only regular expressions have distinguished subexpressions. */)
}
static Lisp_Object
-match_limit (Lisp_Object num, int beginningp)
+match_limit (Lisp_Object num, bool beginningp)
{
EMACS_INT n;
@@ -2968,9 +2970,9 @@ If optional arg RESEAT is non-nil, make markers on LIST point nowhere. */)
return Qnil;
}
-/* If non-zero the match data have been saved in saved_search_regs
+/* If true the match data have been saved in saved_search_regs
during the execution of a sentinel or filter. */
-/* static int search_regs_saved; */
+/* static bool search_regs_saved; */
/* static struct re_registers saved_search_regs; */
/* static Lisp_Object saved_last_thing_searched; */
@@ -3035,9 +3037,9 @@ DEFUN ("regexp-quote", Fregexp_quote, Sregexp_quote, 1, 1, 0,
doc: /* Return a regexp string which matches exactly STRING and nothing else. */)
(Lisp_Object string)
{
- register char *in, *out, *end;
- register char *temp;
- int backslashes_added = 0;
+ char *in, *out, *end;
+ char *temp;
+ ptrdiff_t backslashes_added = 0;
CHECK_STRING (string);
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/>. */
#include "sysselect.h"
#include "blockinput.h"
-#ifdef BSD_SYSTEM
-#include <sys/param.h>
-#include <sys/sysctl.h>
+#if defined DARWIN_OS || defined __FreeBSD__
+# include <sys/sysctl.h>
#endif
#ifdef __FreeBSD__
@@ -69,9 +68,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#ifdef MSDOS /* Demacs 1.1.2 91/10/20 Manabu Higashida, MW Aug 1993 */
#include "msdos.h"
-#include <sys/param.h>
#endif
+#include <sys/param.h>
#include <sys/file.h>
#include <fcntl.h>
@@ -1290,10 +1289,9 @@ reset_sys_modes (struct tty_display_info *tty_out)
if (tty_out->terminal->reset_terminal_modes_hook)
tty_out->terminal->reset_terminal_modes_hook (tty_out->terminal);
-#ifdef BSD_SYSTEM
/* Avoid possible loss of output when changing terminal modes. */
- fsync (fileno (tty_out->output));
-#endif
+ while (fdatasync (fileno (tty_out->output)) != 0 && errno == EINTR)
+ continue;
#ifndef DOS_NT
#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)
if (!KEYMAPP (KVAR (kboard, Vinput_decode_map)))
kset_input_decode_map (kboard, Fmake_sparse_keymap (Qnil));
- for (i = 0; i < (sizeof (keys)/sizeof (keys[0])); i++)
+ for (i = 0; i < (sizeof (keys) / sizeof (keys[0])); i++)
{
char *sequence = tgetstr (keys[i].cap, address);
if (sequence)
@@ -3426,9 +3426,6 @@ maybe_fatal (int must_succeed, struct terminal *terminal,
vfatal (str2, ap);
else
verror (str1, ap);
-
- va_end (ap);
- emacs_abort ();
}
void
@@ -3437,7 +3434,6 @@ fatal (const char *str, ...)
va_list ap;
va_start (ap, str);
vfatal (str, ap);
- va_end (ap);
}
diff --git a/src/termhooks.h b/src/termhooks.h
index 7385298d3d4..252dbabb6f9 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -382,7 +382,7 @@ struct terminal
struct image_cache *image_cache;
#endif /* HAVE_WINDOW_SYSTEM */
- /* Device-type dependent data shared amongst all frames on this terminal. */
+ /* Device-type dependent data shared amongst all frames on this terminal. */
union display_info
{
struct tty_display_info *tty; /* termchar.h */
@@ -403,22 +403,22 @@ struct terminal
the function `set-keyboard-coding-system'. */
struct coding_system *keyboard_coding;
- /* Terminal characteristics. */
- /* XXX Are these really used on non-termcap displays? */
+ /* Terminal characteristics. */
+ /* XXX Are these really used on non-termcap displays? */
int must_write_spaces; /* Nonzero means spaces in the text must
actually be output; can't just skip over
some columns to leave them blank. */
- int fast_clear_end_of_line; /* Nonzero means terminal has a `ce' string */
+ int fast_clear_end_of_line; /* Nonzero means terminal has a `ce' string. */
- int line_ins_del_ok; /* Terminal can insert and delete lines */
- int char_ins_del_ok; /* Terminal can insert and delete chars */
+ int line_ins_del_ok; /* Terminal can insert and delete lines. */
+ int char_ins_del_ok; /* Terminal can insert and delete chars. */
int scroll_region_ok; /* Terminal supports setting the scroll
- window */
+ window. */
int scroll_region_cost; /* Cost of setting the scroll window,
- measured in characters. */
+ measured in characters. */
int memory_below_frame; /* Terminal remembers lines scrolled
- off bottom */
+ off bottom. */
/* Window-based redisplay interface for this device (0 for tty
devices). */
@@ -617,7 +617,7 @@ tset_selection_alist (struct terminal *t, Lisp_Object val)
t->Vselection_alist = val;
}
-/* Chain of all terminal devices currently in use. */
+/* Chain of all terminal devices currently in use. */
extern struct terminal *terminal_list;
#define FRAME_MUST_WRITE_SPACES(f) ((f)->terminal->must_write_spaces)
@@ -638,14 +638,16 @@ extern struct terminal *terminal_list;
#define FRAME_TERMINAL(f) ((f)->terminal)
-/* Return true if the terminal device is not suspended. */
-#define TERMINAL_ACTIVE_P(d) (((d)->type != output_termcap && (d)->type !=output_msdos_raw) || (d)->display_info.tty->input)
+/* Return true if the terminal device is not suspended. */
+#define TERMINAL_ACTIVE_P(d) \
+ (((d)->type != output_termcap && (d)->type != output_msdos_raw) \
+ || (d)->display_info.tty->input)
extern struct terminal *get_terminal (Lisp_Object terminal, int);
extern struct terminal *create_terminal (void);
extern void delete_terminal (struct terminal *);
-/* The initial terminal device, created by initial_term_init. */
+/* The initial terminal device, created by initial_term_init. */
extern struct terminal *initial_terminal;
extern 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)
xfree (terminal->name);
terminal->name = NULL;
- /* Check for live frames that are still on this terminal. */
+ /* Check for live frames that are still on this terminal. */
FOR_EACH_FRAME (tail, frame)
{
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;
static Lisp_Object Qread_only;
Lisp_Object Qminibuffer_prompt;
-/* Sticky properties */
+/* Sticky properties. */
Lisp_Object Qfront_sticky, Qrear_nonsticky;
/* If o1 is a cons whose cdr is a cons, return non-zero and set o2 to
diff --git a/src/thread.h b/src/thread.h
index 989acec6afb..97bdb2c805c 100644
--- a/src/thread.h
+++ b/src/thread.h
@@ -1,5 +1,5 @@
/* Thread definitions
- Copyright (C) 2012 Free Software Foundation, Inc.
+ Copyright (C) 2012, 2013 Free Software Foundation, Inc.
This file is part of GNU Emacs.
@@ -138,7 +138,7 @@ struct thread_state
/* If non-zero the match data have been saved in saved_search_regs
during the execution of a sentinel or filter. */
- int m_search_regs_saved;
+ bool m_search_regs_saved;
#define search_regs_saved (current_thread->m_search_regs_saved)
struct re_registers m_saved_search_regs;
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)
if (FRAME_W32_WINDOW (f))
{
- if (STRING_MULTIBYTE (name))
- name = ENCODE_SYSTEM (name);
-
block_input ();
- SetWindowText (FRAME_W32_WINDOW (f), SDATA (name));
+ GUI_FN (SetWindowText) (FRAME_W32_WINDOW (f),
+ GUI_SDATA (GUI_ENCODE_SYSTEM (name)));
unblock_input ();
}
}
@@ -1767,11 +1765,9 @@ x_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name)
if (FRAME_W32_WINDOW (f))
{
- if (STRING_MULTIBYTE (name))
- name = ENCODE_SYSTEM (name);
-
block_input ();
- SetWindowText (FRAME_W32_WINDOW (f), SDATA (name));
+ GUI_FN (SetWindowText) (FRAME_W32_WINDOW (f),
+ GUI_SDATA (GUI_ENCODE_SYSTEM (name)));
unblock_input ();
}
}
@@ -5824,7 +5820,7 @@ Text larger than the specified size is clipped. */)
int row_width;
/* Stop at the first empty row at the end. */
- if (!row->enabled_p || !row->displays_text_p)
+ if (!row->enabled_p || !MATRIX_ROW_DISPLAYS_TEXT_P (row))
break;
/* Let the row go over the full width of the frame. */
@@ -5885,7 +5881,7 @@ Text larger than the specified size is clipped. */)
struct glyph *last;
int row_width;
- if (!row->enabled_p || !row->displays_text_p)
+ if (!row->enabled_p || !MATRIX_ROW_DISPLAYS_TEXT_P (row))
break;
row->full_width_p = 1;
row_width = row->pixel_width;
@@ -6006,14 +6002,6 @@ Value is t if tooltip was open, nil otherwise. */)
#define FILE_NAME_COMBO_BOX cmb13
#define FILE_NAME_LIST lst1
-#ifdef NTGUI_UNICODE
-#define GUISTR(x) (L ## x)
-typedef wchar_t guichar_t;
-#else /* !NTGUI_UNICODE */
-#define GUISTR(x) x
-typedef char guichar_t;
-#endif /* NTGUI_UNICODE */
-
/* Callback for altering the behavior of the Open File dialog.
Makes the Filename text field contain "Current Directory" and be
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. */)
block_input ();
file_details->lpfnHook = file_dialog_callback;
-#ifdef NTGUI_UNICODE
- file_opened = GetOpenFileNameW (file_details);
-#else /* !NTGUI_UNICODE */
- file_opened = GetOpenFileNameA (file_details);
-#endif /* NTGUI_UNICODE */
+ file_opened = GUI_FN (GetOpenFileName) (file_details);
unblock_input ();
unbind_to (count, Qnil);
}
@@ -6243,11 +6227,7 @@ Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */)
{
/* Get an Emacs string from the value Windows gave us. */
#ifdef NTGUI_UNICODE
- filename = from_unicode (
- make_unibyte_string (
- (char*) filename_buf,
- /* we get one of the two final 0 bytes for free. */
- 1 + sizeof (wchar_t) * wcslen (filename_buf)));
+ filename = from_unicode_buffer (filename_buf);
#else /* !NTGUI_UNICODE */
dostounix_filename (filename_buf, 0);
filename = DECODE_FILE (build_string (filename_buf));
@@ -6421,20 +6401,29 @@ an integer representing a ShowWindow flag:
CHECK_STRING (document);
/* Encode filename, current directory and parameters. */
- current_dir = ENCODE_FILE (BVAR (current_buffer, directory));
- document = ENCODE_FILE (document);
+ current_dir = BVAR (current_buffer, directory);
+
+#ifdef CYGWIN
+ current_dir = Fcygwin_convert_file_name_to_windows (current_dir, Qt);
+ if (STRINGP (document))
+ document = Fcygwin_convert_file_name_to_windows (document, Qt);
+#endif /* CYGWIN */
+
+ current_dir = GUI_ENCODE_FILE (current_dir);
+ if (STRINGP (document))
+ document = GUI_ENCODE_FILE (document);
if (STRINGP (parameters))
- parameters = ENCODE_SYSTEM (parameters);
-
- if ((int) ShellExecute (NULL,
- (STRINGP (operation) ?
- SDATA (operation) : NULL),
- SDATA (document),
- (STRINGP (parameters) ?
- SDATA (parameters) : NULL),
- SDATA (current_dir),
- (INTEGERP (show_flag) ?
- XINT (show_flag) : SW_SHOWDEFAULT))
+ parameters = GUI_ENCODE_SYSTEM (parameters);
+
+ if ((int) GUI_FN (ShellExecute) (NULL,
+ (STRINGP (operation) ?
+ GUI_SDATA (operation) : NULL),
+ GUI_SDATA (document),
+ (STRINGP (parameters) ?
+ GUI_SDATA (parameters) : NULL),
+ GUI_SDATA (current_dir),
+ (INTEGERP (show_flag) ?
+ XINT (show_flag) : SW_SHOWDEFAULT))
> 32)
return Qt;
errstr = w32_strerror (0);
@@ -6803,6 +6792,7 @@ The following %-sequences are provided:
}
+#ifdef WINDOWSNT
DEFUN ("file-system-info", Ffile_system_info, Sfile_system_info, 1, 1, 0,
doc: /* Return storage information about the file system FILENAME is on.
Value 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. */)
return value;
}
+#endif /* WINDOWSNT */
+
DEFUN ("default-printer-name", Fdefault_printer_name, Sdefault_printer_name,
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. */);
defsubr (&Sw32_window_exists_p);
defsubr (&Sw32_battery_status);
+#ifdef WINDOWSNT
defsubr (&Sfile_system_info);
+#endif
+
defsubr (&Sdefault_printer_name);
defsubr (&Sset_message_beep);
@@ -7805,3 +7800,15 @@ emacs_abort (void)
}
}
}
+
+#ifdef NTGUI_UNICODE
+
+Lisp_Object
+ntgui_encode_system (Lisp_Object str)
+{
+ Lisp_Object encoded;
+ to_unicode (str, &encoded);
+ return encoded;
+}
+
+#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);
#endif
static void my_set_foreground_window (HWND);
static void my_destroy_window (struct frame *, HWND);
+static void w32fullscreen_hook (FRAME_PTR);
#ifdef GLYPH_DEBUG
static 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)
HDROP hdrop;
POINT p;
WORD num_files;
- char *name;
+ guichar_t *name;
int i, len;
result->kind = DRAG_N_DROP_EVENT;
@@ -3186,12 +3187,17 @@ construct_drag_n_drop (struct input_event *result, W32Msg *msg, struct frame *f)
for (i = 0; i < num_files; i++)
{
- len = DragQueryFile (hdrop, i, NULL, 0);
+ len = GUI_FN (DragQueryFile) (hdrop, i, NULL, 0);
if (len <= 0)
continue;
- name = alloca (len + 1);
- DragQueryFile (hdrop, i, name, len + 1);
+
+ name = alloca ((len + 1) * sizeof (*name));
+ GUI_FN (DragQueryFile) (hdrop, i, name, len + 1);
+#ifdef NTGUI_UNICODE
+ files = Fcons (from_unicode_buffer (name), files);
+#else
files = Fcons (DECODE_FILE (build_string (name)), files);
+#endif /* NTGUI_UNICODE */
}
DragFinish (hdrop);
@@ -4699,20 +4705,23 @@ w32_read_socket (struct terminal *terminal,
}
case WM_WINDOWPOSCHANGED:
- f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
- if (f)
- {
- if (f->want_fullscreen & FULLSCREEN_WAIT)
- f->want_fullscreen &= ~(FULLSCREEN_WAIT|FULLSCREEN_BOTH);
- }
- check_visibility = 1;
- break;
-
case WM_ACTIVATE:
case WM_ACTIVATEAPP:
f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
if (f)
- x_check_fullscreen (f);
+ {
+ /* Run the full-screen hook function also when we are
+ being activated, to actually install the required
+ size in effect, if the WAIT flag is set. This is
+ because when the hook is run from x_set_fullscreen,
+ the frame might not yet be visible, if that call is a
+ result of make-frame, and in that case the hook just
+ sets the WAIT flag. */
+ if ((msg.msg.message == WM_WINDOWPOSCHANGED || msg.msg.wParam)
+ && (f->want_fullscreen & FULLSCREEN_WAIT))
+ w32fullscreen_hook (f);
+ x_check_fullscreen (f);
+ }
check_visibility = 1;
break;
@@ -5673,10 +5682,10 @@ w32fullscreen_hook (FRAME_PTR f)
switch (f->want_fullscreen)
{
- case FULLSCREEN_MAXIMIZED:
+ case FULLSCREEN_BOTH:
PostMessage (FRAME_W32_WINDOW (f), WM_SYSCOMMAND, SC_MAXIMIZE, 0);
break;
- case FULLSCREEN_BOTH:
+ case FULLSCREEN_MAXIMIZED:
height =
FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, pixel_height)
- XINT (Ftool_bar_lines_needed (selected_frame))
@@ -5724,8 +5733,11 @@ w32fullscreen_hook (FRAME_PTR f)
x_set_window_size (f, 1, width, height);
do_pending_window_change (0);
}
+ f->want_fullscreen = FULLSCREEN_NONE;
unblock_input ();
}
+ else
+ f->want_fullscreen |= FULLSCREEN_WAIT;
}
/* 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*
w32_name_of_message (UINT msg);
#endif /* EMACSDEBUG */
+#ifdef NTGUI_UNICODE
+extern Lisp_Object ntgui_encode_system (Lisp_Object str);
+#define GUISTR(x) (L ## x)
+#define GUI_ENCODE_FILE GUI_ENCODE_SYSTEM
+#define GUI_ENCODE_SYSTEM(x) ntgui_encode_system (x)
+#define GUI_FN(fn) fn ## W
+typedef wchar_t guichar_t;
+#else /* !NTGUI_UNICODE */
+#define GUISTR(x) x
+#define GUI_ENCODE_FILE ENCODE_FILE
+#define GUI_ENCODE_SYSTEM ENCODE_SYSTEM
+#define GUI_FN(fn) fn
+typedef char guichar_t;
+#endif /* NTGUI_UNICODE */
+
+#define GUI_SDATA(x) ((guichar_t*) SDATA (x))
+
extern void syms_of_w32term (void);
extern void syms_of_w32menu (void);
extern void syms_of_w32fns (void);
diff --git a/src/window.c b/src/window.c
index 4b30a9d55da..4109b752d8e 100644
--- a/src/window.c
+++ b/src/window.c
@@ -5021,7 +5021,7 @@ specifies the window to scroll. This takes precedence over
++windows_or_buffers_changed;
Fset_buffer (w->buffer);
- SET_PT (marker_position (w->pointm));
+ SET_PT_BOTH (marker_position (w->pointm), marker_byte_position (w->pointm));
if (NILP (arg))
window_scroll (window, 1, 1, 1);
diff --git a/src/xdisp.c b/src/xdisp.c
index c6e204702ce..a5bba1a81cd 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -2550,7 +2550,7 @@ markpos_of_region (void)
at character position CHARPOS. CHARPOS < 0 means that no buffer
position is specified which is useful when the iterator is assigned
a position later. BYTEPOS is the byte position corresponding to
- CHARPOS. BYTEPOS < 0 means compute it from CHARPOS.
+ CHARPOS.
If ROW is not null, calls to produce_glyphs with IT as parameter
will produce glyphs in that row.
@@ -2828,18 +2828,14 @@ init_iterator (struct it *it, struct window *w,
if (charpos >= BUF_BEG (current_buffer))
{
it->end_charpos = ZV;
+ eassert (charpos == BYTE_TO_CHAR (bytepos));
IT_CHARPOS (*it) = charpos;
+ IT_BYTEPOS (*it) = bytepos;
/* We will rely on `reseat' to set this up properly, via
handle_face_prop. */
it->face_id = it->base_face_id;
- /* Compute byte position if not specified. */
- if (bytepos < charpos)
- IT_BYTEPOS (*it) = CHAR_TO_BYTE (charpos);
- else
- IT_BYTEPOS (*it) = bytepos;
-
it->start = it->current;
/* Do we need to reorder bidirectional text? Not if this is a
unibyte buffer: by definition, none of the single-byte
@@ -11711,7 +11707,8 @@ display_tool_bar_line (struct it *it, int height)
no additional border below the possibly empty tool-bar lines.
So to make the extra empty lines look "normal", we have to
use the tool-bar face for the border too. */
- if (!row->displays_text_p && !EQ (Vauto_resize_tool_bars, Qgrow_only))
+ if (!MATRIX_ROW_DISPLAYS_TEXT_P (row)
+ && !EQ (Vauto_resize_tool_bars, Qgrow_only))
it->face_id = DEFAULT_FACE_ID;
extend_face_to_end_of_line (it);
@@ -11732,7 +11729,7 @@ display_tool_bar_line (struct it *it, int height)
compute_line_metrics (it);
/* If line is empty, make it occupy the rest of the tool-bar. */
- if (!row->displays_text_p)
+ if (!MATRIX_ROW_DISPLAYS_TEXT_P (row))
{
row->height = row->phys_height = it->last_visible_y - row->y;
row->visible_height = row->height;
@@ -11947,13 +11944,13 @@ redisplay_tool_bar (struct frame *f)
/* If there are blank lines at the end, except for a partially
visible blank line at the end that is smaller than
FRAME_LINE_HEIGHT, change the tool-bar's height. */
- if (!row->displays_text_p
+ if (!MATRIX_ROW_DISPLAYS_TEXT_P (row)
&& row->height >= FRAME_LINE_HEIGHT (f))
change_height_p = 1;
/* If row displays tool-bar items, but is partially visible,
change the tool-bar's height. */
- if (row->displays_text_p
+ if (MATRIX_ROW_DISPLAYS_TEXT_P (row)
&& MATRIX_ROW_BOTTOM_Y (row) > it.last_visible_y
&& MATRIX_ROW_BOTTOM_Y (row) < max_tool_bar_height)
change_height_p = 1;
@@ -13144,7 +13141,7 @@ redisplay_internal (void)
/* If this row displays text now but previously didn't,
or vice versa, w->window_end_vpos may have to be
adjusted. */
- if ((it.glyph_row - 1)->displays_text_p)
+ if (MATRIX_ROW_DISPLAYS_TEXT_P (it.glyph_row - 1))
{
if (XFASTINT (w->window_end_vpos) < this_line_vpos)
wset_window_end_vpos (w, make_number (this_line_vpos));
@@ -13754,7 +13751,7 @@ set_cursor_from_row (struct window *w, struct glyph_row *row,
/* Skip over glyphs not having an object at the start and the end of
the row. These are special glyphs like truncation marks on
terminal frames. */
- if (row->displays_text_p)
+ if (MATRIX_ROW_DISPLAYS_TEXT_P (row))
{
if (!row->reversed_p)
{
@@ -14931,8 +14928,7 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, int *scroll_ste
we would rather display cursor in the next line. */
while (MATRIX_ROW_BOTTOM_Y (row) < last_y
&& MATRIX_ROW_END_CHARPOS (row) == PT
- && row < w->current_matrix->rows
- + w->current_matrix->nrows - 1
+ && row < MATRIX_MODE_LINE_ROW (w->current_matrix)
&& MATRIX_ROW_START_CHARPOS (row+1) == PT
&& !cursor_row_p (row))
++row;
@@ -16171,8 +16167,8 @@ try_window (Lisp_Object window, struct text_pos pos, int flags)
wset_window_end_vpos
(w, make_number (MATRIX_ROW_VPOS (last_text_row, w->desired_matrix)));
eassert
- (MATRIX_ROW (w->desired_matrix,
- XFASTINT (w->window_end_vpos))->displays_text_p);
+ (MATRIX_ROW_DISPLAYS_TEXT_P (MATRIX_ROW (w->desired_matrix,
+ XFASTINT (w->window_end_vpos))));
}
else
{
@@ -17581,7 +17577,7 @@ try_window_id (struct window *w)
struct glyph_row *last_row = MATRIX_ROW (current_matrix, last_vpos);
/* If last_row is the window end line, it should display text. */
- eassert (last_row->displays_text_p);
+ eassert (MATRIX_ROW_DISPLAYS_TEXT_P (last_row));
/* If window end line was partially visible before, begin
displaying at that line. Otherwise begin displaying with the
@@ -17628,7 +17624,7 @@ try_window_id (struct window *w)
matrix. Set row to the last row displaying text in current
matrix starting at first_unchanged_at_end_row, after
scrolling. */
- eassert (first_unchanged_at_end_row->displays_text_p);
+ eassert (MATRIX_ROW_DISPLAYS_TEXT_P (first_unchanged_at_end_row));
row = find_last_row_displaying_text (w->current_matrix, &it,
first_unchanged_at_end_row);
eassert (row && MATRIX_ROW_DISPLAYS_TEXT_P (row));
@@ -17682,10 +17678,10 @@ try_window_id (struct window *w)
{
if (desired_row->enabled_p)
{
- if (desired_row->displays_text_p)
+ if (MATRIX_ROW_DISPLAYS_TEXT_P (desired_row))
row = desired_row;
}
- else if (current_row->displays_text_p)
+ else if (MATRIX_ROW_DISPLAYS_TEXT_P (current_row))
row = current_row;
}
@@ -17865,7 +17861,7 @@ dump_glyph_row (struct glyph_row *row, int vpos, int glyphs)
row->truncated_on_right_p,
row->continued_p,
MATRIX_ROW_CONTINUATION_LINE_P (row),
- row->displays_text_p,
+ MATRIX_ROW_DISPLAYS_TEXT_P (row),
row->ends_at_zv_p,
row->fill_line_p,
row->ends_in_middle_of_char_p,
@@ -18501,7 +18497,7 @@ extend_face_to_end_of_line (struct it *it)
face = FACE_FROM_ID (f, it->face_id);
if (FRAME_WINDOW_P (f)
- && it->glyph_row->displays_text_p
+ && MATRIX_ROW_DISPLAYS_TEXT_P (it->glyph_row)
&& face->box == FACE_NO_BOX
&& face->background == FRAME_BACKGROUND_PIXEL (f)
&& !face->stipple
@@ -19761,7 +19757,7 @@ display_line (struct it *it)
mark this glyph row as the one containing the overlay arrow.
This is clearly a mess with variable size fonts. It would be
better to let it be displayed like cursors under X. */
- if ((row->displays_text_p || !overlay_arrow_seen)
+ if ((MATRIX_ROW_DISPLAYS_TEXT_P (row) || !overlay_arrow_seen)
&& (overlay_arrow_string = overlay_arrow_at_row (it, row),
!NILP (overlay_arrow_string)))
{
@@ -19861,7 +19857,7 @@ display_line (struct it *it)
if (it->glyph_row < MATRIX_BOTTOM_TEXT_ROW (it->w->desired_matrix, it->w))
it->glyph_row->reversed_p = row->reversed_p;
it->start = row->end;
- return row->displays_text_p;
+ return MATRIX_ROW_DISPLAYS_TEXT_P (row);
#undef RECORD_MAX_MIN_POS
}
@@ -25660,7 +25656,7 @@ notice_overwritten_cursor (struct window *w, enum glyph_row_area area,
if (w->phys_cursor.vpos < 0
|| w->phys_cursor.vpos >= w->current_matrix->nrows
|| (row = w->current_matrix->rows + w->phys_cursor.vpos,
- !(row->enabled_p && row->displays_text_p)))
+ !(row->enabled_p && MATRIX_ROW_DISPLAYS_TEXT_P (row))))
return;
if (row->cursor_in_fringe_p)
@@ -26595,7 +26591,7 @@ mouse_face_from_buffer_pos (Lisp_Object window,
x = r1->x;
/* Skip truncation glyphs at the start of the glyph row. */
- if (r1->displays_text_p)
+ if (MATRIX_ROW_DISPLAYS_TEXT_P (r1))
for (; glyph < end
&& INTEGERP (glyph->object)
&& glyph->charpos < 0;
@@ -26646,7 +26642,7 @@ mouse_face_from_buffer_pos (Lisp_Object window,
glyph = end + r1->used[TEXT_AREA];
/* Skip truncation glyphs at the start of the glyph row. */
- if (r1->displays_text_p)
+ if (MATRIX_ROW_DISPLAYS_TEXT_P (r1))
for (; glyph > end
&& INTEGERP (glyph->object)
&& glyph->charpos < 0;
@@ -26897,7 +26893,7 @@ fast_find_string_pos (struct window *w, ptrdiff_t pos, Lisp_Object object,
}
*y = best_row->y;
- *vpos = best_row - w->current_matrix->rows;
+ *vpos = MATRIX_ROW_VPOS (best_row, w->current_matrix);
}
return best_glyph != NULL;
@@ -26935,7 +26931,8 @@ mouse_face_from_string_pos (struct window *w, Mouse_HLInfo *hlinfo,
if (EQ (g->object, object)
&& startpos <= g->charpos && g->charpos <= endpos)
{
- hlinfo->mouse_face_beg_row = r - w->current_matrix->rows;
+ hlinfo->mouse_face_beg_row
+ = MATRIX_ROW_VPOS (r, w->current_matrix);
hlinfo->mouse_face_beg_y = r->y;
hlinfo->mouse_face_beg_col = g - r->glyphs[TEXT_AREA];
hlinfo->mouse_face_beg_x = gx;
@@ -26953,7 +26950,8 @@ mouse_face_from_string_pos (struct window *w, Mouse_HLInfo *hlinfo,
if (EQ ((g-1)->object, object)
&& startpos <= (g-1)->charpos && (g-1)->charpos <= endpos)
{
- hlinfo->mouse_face_beg_row = r - w->current_matrix->rows;
+ hlinfo->mouse_face_beg_row
+ = MATRIX_ROW_VPOS (r, w->current_matrix);
hlinfo->mouse_face_beg_y = r->y;
hlinfo->mouse_face_beg_col = g - r->glyphs[TEXT_AREA];
for (gx = r->x, g1 = r->glyphs[TEXT_AREA]; g1 < g; ++g1)
@@ -26992,7 +26990,7 @@ mouse_face_from_string_pos (struct window *w, Mouse_HLInfo *hlinfo,
r--;
/* Set the end row and its vertical pixel coordinate. */
- hlinfo->mouse_face_end_row = r - w->current_matrix->rows;
+ hlinfo->mouse_face_end_row = MATRIX_ROW_VPOS (r, w->current_matrix);
hlinfo->mouse_face_end_y = r->y;
/* Compute and set the end column and the end column's horizontal
@@ -27676,7 +27674,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
/* Clear mouse face if X/Y not over text. */
if (glyph == NULL
|| area != TEXT_AREA
- || !MATRIX_ROW (w->current_matrix, vpos)->displays_text_p
+ || !MATRIX_ROW_DISPLAYS_TEXT_P (MATRIX_ROW (w->current_matrix, vpos))
/* Glyph's OBJECT is an integer for glyphs inserted by the
display engine for its internal purposes, like truncation
and continuation glyphs and blanks beyond the end of
@@ -27688,7 +27686,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
all beyond the end of text. Treat such stretch glyphs
like we do with NULL glyphs in L2R rows. */
|| (MATRIX_ROW (w->current_matrix, vpos)->reversed_p
- && glyph == MATRIX_ROW (w->current_matrix, vpos)->glyphs[TEXT_AREA]
+ && glyph == MATRIX_ROW_GLYPH_START (w->current_matrix, vpos)
&& glyph->type == STRETCH_GLYPH
&& glyph->avoid_cursor_p))
{
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. */)
default:
error ("Strange value for BackingStore parameter of screen");
- result = Qnil;
}
return result;
@@ -3811,7 +3810,6 @@ If omitted or nil, that stands for the selected frame's display. */)
break;
default:
error ("Display has an unknown visual class");
- result = Qnil;
}
return result;
@@ -5067,7 +5065,7 @@ Text larger than the specified size is clipped. */)
int row_width;
/* Stop at the first empty row at the end. */
- if (!row->enabled_p || !row->displays_text_p)
+ if (!row->enabled_p || !MATRIX_ROW_DISPLAYS_TEXT_P (row))
break;
/* Let the row go over the full width of the frame. */
@@ -5126,7 +5124,7 @@ Text larger than the specified size is clipped. */)
struct glyph *last;
int row_width;
- if (!row->enabled_p || !row->displays_text_p)
+ if (!row->enabled_p || !MATRIX_ROW_DISPLAYS_TEXT_P (row))
break;
row->full_width_p = 1;
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. */)
prevent. Fix this in next version. */
Fkill_emacs (Qnil);
+#if 0
/* This will not be reached, but we want kill-emacs-hook to be run. */
SmcCloseConnection (smc_conn, 0, 0);
ice_connection_closed ();
+#endif
}
return Qnil;