From 090cf9dbb07e7ab0817c208b6d8dcd613180b7c3 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 1 Oct 2012 20:31:56 -0400 Subject: [PATCH] Misc minor simplifications in C code. * src/buffer.c (Fset_buffer_multibyte): Signal an error instead of widening. (Fmake_overlay): Remove redundant tests. * src/coding.h (ENCODE_FILE, DECODE_FILE, DECODE_SYSTEM): Remove special case for the special 0 coding-system. * src/frame.c (Fmake_terminal_frame): Prefer safer CONSP over !NILP. --- etc/NEWS | 2 ++ src/ChangeLog | 10 ++++++++++ src/buffer.c | 13 ++++++------- src/coding.h | 6 ------ src/frame.c | 2 +- 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 555f5cdf3f0..50b8e793717 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -619,6 +619,8 @@ inefficiency, and not namespace-clean. * Incompatible Lisp Changes in Emacs 24.3 +** set-buffer-multibyte now signals an error in narrowed buffers. + +++ ** (random) by default now returns a different random sequence in every Emacs run. Use (random S), where S is a string, to set the diff --git a/src/ChangeLog b/src/ChangeLog index 56e75b5efce..507fe80c8ab 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2012-10-02 Stefan Monnier + + * frame.c (Fmake_terminal_frame): Prefer safer CONSP over !NILP. + + * coding.h (ENCODE_FILE, DECODE_FILE, DECODE_SYSTEM): Remove special + case for the special 0 coding-system. + + * buffer.c (Fset_buffer_multibyte): Signal an error instead of widening. + (Fmake_overlay): Remove redundant tests. + 2012-10-02 Juanma Barranquero * makefile.w32-in ($(BLD)/alloc.$(O), $(BLD)/gmalloc.$(O)): diff --git a/src/buffer.c b/src/buffer.c index 580ea671b43..6925675fd5a 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -2464,7 +2464,7 @@ current buffer is cleared. */) begv = BEGV, zv = ZV; if (narrowed) - Fwiden (); + error ("Changing multibyteness in a narrowed buffer"); if (NILP (flag)) { @@ -3847,17 +3847,16 @@ for the rear of the overlay advance when text is inserted there end = OVERLAY_END (overlay); if (OVERLAY_POSITION (end) < b->overlay_center) { - if (b->overlays_after) - XOVERLAY (overlay)->next = b->overlays_after; + eassert (b->overlays_after); + XOVERLAY (overlay)->next = b->overlays_after; set_buffer_overlays_after (b, XOVERLAY (overlay)); } else { - if (b->overlays_before) - XOVERLAY (overlay)->next = b->overlays_before; + eassert (b->overlays_before); + XOVERLAY (overlay)->next = b->overlays_before; set_buffer_overlays_before (b, XOVERLAY (overlay)); } - /* This puts it in the right list, and in the right order. */ recenter_overlay_lists (b, b->overlay_center); @@ -4141,7 +4140,7 @@ DEFUN ("overlays-at", Foverlays_at, Soverlays_at, 1, 1, 0, /* Put all the overlays we want in a vector in overlay_vec. Store the length in len. */ noverlays = overlays_at (XINT (pos), 1, &overlay_vec, &len, - 0, 0, 0); + NULL, NULL, 0); /* Make a list of them all. */ result = Flist (noverlays, overlay_vec); diff --git a/src/coding.h b/src/coding.h index c45d2ef86e2..989552bf667 100644 --- a/src/coding.h +++ b/src/coding.h @@ -646,10 +646,8 @@ struct coding_system for file names, if any. */ #define ENCODE_FILE(name) \ (! NILP (Vfile_name_coding_system) \ - && !EQ (Vfile_name_coding_system, make_number (0)) \ ? code_convert_string_norecord (name, Vfile_name_coding_system, 1) \ : (! NILP (Vdefault_file_name_coding_system) \ - && !EQ (Vdefault_file_name_coding_system, make_number (0)) \ ? code_convert_string_norecord (name, Vdefault_file_name_coding_system, 1) \ : name)) @@ -658,10 +656,8 @@ struct coding_system for file names, if any. */ #define DECODE_FILE(name) \ (! NILP (Vfile_name_coding_system) \ - && !EQ (Vfile_name_coding_system, make_number (0)) \ ? code_convert_string_norecord (name, Vfile_name_coding_system, 0) \ : (! NILP (Vdefault_file_name_coding_system) \ - && !EQ (Vdefault_file_name_coding_system, make_number (0)) \ ? code_convert_string_norecord (name, Vdefault_file_name_coding_system, 0) \ : name)) @@ -670,7 +666,6 @@ struct coding_system for system functions, if any. */ #define ENCODE_SYSTEM(str) \ (! NILP (Vlocale_coding_system) \ - && !EQ (Vlocale_coding_system, make_number (0)) \ ? code_convert_string_norecord (str, Vlocale_coding_system, 1) \ : str) @@ -678,7 +673,6 @@ struct coding_system for system functions, if any. */ #define DECODE_SYSTEM(str) \ (! NILP (Vlocale_coding_system) \ - && !EQ (Vlocale_coding_system, make_number (0)) \ ? code_convert_string_norecord (str, Vlocale_coding_system, 0) \ : str) diff --git a/src/frame.c b/src/frame.c index edb90038a48..2fcf7275f9c 100644 --- a/src/frame.c +++ b/src/frame.c @@ -632,7 +632,7 @@ affects all frames on the same terminal device. */) Lisp_Object terminal; terminal = Fassq (Qterminal, parms); - if (!NILP (terminal)) + if (CONSP (terminal)) { terminal = XCDR (terminal); t = get_terminal (terminal, 1); -- 2.39.2