From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Matt Armstrong Newsgroups: gmane.emacs.bugs Subject: bug#46915: [PATCH] Remove unecessary change_req arg from overlays_at() Date: Wed, 03 Mar 2021 18:29:28 -0800 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13860"; mail-complaints-to="usenet@ciao.gmane.io" To: 46915@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Mar 04 03:30:10 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lHdkg-0003Ig-6v for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 04 Mar 2021 03:30:10 +0100 Original-Received: from localhost ([::1]:37038 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lHdkf-0005lP-8G for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 03 Mar 2021 21:30:09 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46306) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lHdkY-0005lD-QK for bug-gnu-emacs@gnu.org; Wed, 03 Mar 2021 21:30:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45799) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lHdkY-0002Bj-Ic for bug-gnu-emacs@gnu.org; Wed, 03 Mar 2021 21:30:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lHdkY-0000LB-EU for bug-gnu-emacs@gnu.org; Wed, 03 Mar 2021 21:30:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Matt Armstrong Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 04 Mar 2021 02:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 46915 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.16148249801257 (code B ref -1); Thu, 04 Mar 2021 02:30:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 4 Mar 2021 02:29:40 +0000 Original-Received: from localhost ([127.0.0.1]:57345 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lHdkC-0000KD-9J for submit@debbugs.gnu.org; Wed, 03 Mar 2021 21:29:40 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:38622) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lHdkB-0000K6-88 for submit@debbugs.gnu.org; Wed, 03 Mar 2021 21:29:39 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46202) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lHdkB-0005hV-1M for bug-gnu-emacs@gnu.org; Wed, 03 Mar 2021 21:29:39 -0500 Original-Received: from relay2-d.mail.gandi.net ([217.70.183.194]:50971) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lHdk7-0001vv-Gh for bug-gnu-emacs@gnu.org; Wed, 03 Mar 2021 21:29:38 -0500 X-Originating-IP: 24.113.169.116 Original-Received: from matts-mbp-2016.lan (24-113-169-116.wavecable.com [24.113.169.116]) (Authenticated sender: matt@rfc20.org) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 7433840002 for ; Thu, 4 Mar 2021 02:29:31 +0000 (UTC) Received-SPF: pass client-ip=217.70.183.194; envelope-from=matt@rfc20.org; helo=relay2-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:201352 Archived-At: --=-=-= Content-Type: text/plain Tags: patch I was scratching my head trying to figure out why overlays_at() had such a complex function signature. It turns out that it does not need to be so complex now and, I think, it never did. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Remove-unecessary-change_req-arg-from-overlays_at.patch >From 0337e4823b32dd15bdae1f61df12b5f68170e360 Mon Sep 17 00:00:00 2001 From: Matt Armstrong Date: Wed, 3 Mar 2021 16:31:02 -0800 Subject: [PATCH] Remove unecessary change_req arg from overlays_at() The change_req arg was an unecessary complexity. It only changed what might be assigned to the *prev_ptr arg, and all callers that passed a non-null prev_ptr also passed a true change_req. This makes it clear that no caller desires the behavior that would have occurred with a non-null prev_ptr and a false change_req. For archaeologists, the above invariants appear to have been true from the beginning, and whatever bug fixed by the commits below need not have been controlled with a new boolean arg. See commits ac869cf715 ((overlays_at): Add CHANGE_REQ parameter, 2000-08-08) and 1d5f4c1de4 ((overlays_at): Only let CHANGE_REQ inhibit an assignment of startpos to prev when startpos == pos, 2000-10-25). * src/buffer.c (overlays_at): * src/buffer.h (GET_OVERLAYS_AT): Remove the change_req arg. * src/buffer.c (Foverlays_at): (Fnext_overlay_change): * src/textprop.c (get_char_property_and_overlay): (note_mouse_highlight): * src/xfaces.c (face_at_buffer_position): * src/xdisp.c (next_overlay_change): (note_mouse_highlight): Omit the change_req arg. --- src/buffer.c | 13 ++++++------- src/buffer.h | 11 +++++------ src/textprop.c | 2 +- src/xdisp.c | 4 ++-- src/xfaces.c | 2 +- 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/buffer.c b/src/buffer.c index 5bd9b37702..84edf18eb0 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -2843,14 +2843,13 @@ DEFUN ("kill-all-local-variables", Fkill_all_local_variables, and store only as many overlays as will fit. But still return the total number of overlays. - If CHANGE_REQ, any position written into *PREV_PTR or - *NEXT_PTR is guaranteed to be not equal to POS, unless it is the - default (BEGV or ZV). */ + Any position written into *PREV_PTR or *NEXT_PTR is guaranteed to + be not equal to POS, unless it is the default (BEGV or ZV). */ ptrdiff_t overlays_at (EMACS_INT pos, bool extend, Lisp_Object **vec_ptr, ptrdiff_t *len_ptr, - ptrdiff_t *next_ptr, ptrdiff_t *prev_ptr, bool change_req) + ptrdiff_t *next_ptr, ptrdiff_t *prev_ptr) { ptrdiff_t idx = 0; ptrdiff_t len = *len_ptr; @@ -2944,7 +2943,7 @@ overlays_at (EMACS_INT pos, bool extend, Lisp_Object **vec_ptr, else if (endpos < pos && endpos > prev) prev = endpos; else if (endpos == pos && startpos > prev - && (!change_req || startpos < pos)) + && startpos < pos) prev = startpos; } @@ -4232,7 +4231,7 @@ DEFUN ("overlays-at", Foverlays_at, Soverlays_at, 1, 2, 0, /* Put all the overlays we want in a vector in overlay_vec. Store the length in len. */ noverlays = overlays_at (XFIXNUM (pos), 1, &overlay_vec, &len, - NULL, NULL, 0); + NULL, NULL); if (!NILP (sorted)) noverlays = sort_overlays (overlay_vec, noverlays, @@ -4308,7 +4307,7 @@ DEFUN ("next-overlay-change", Fnext_overlay_change, Snext_overlay_change, Store the length in len. endpos gets the position where the next overlay starts. */ noverlays = overlays_at (XFIXNUM (pos), 1, &overlay_vec, &len, - &endpos, 0, 1); + &endpos, 0); /* If any of these overlays ends before endpos, use its ending point instead. */ diff --git a/src/buffer.h b/src/buffer.h index 24e9c3fcbc..a53b476d72 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -1145,7 +1145,7 @@ #define CHECK_FIXNUM_COERCE_MARKER(x) ((x) = make_fixnum (fix_position (x))) extern void compact_buffer (struct buffer *); extern void evaporate_overlays (ptrdiff_t); extern ptrdiff_t overlays_at (EMACS_INT, bool, Lisp_Object **, - ptrdiff_t *, ptrdiff_t *, ptrdiff_t *, bool); + ptrdiff_t *, ptrdiff_t *, ptrdiff_t *); extern ptrdiff_t sort_overlays (Lisp_Object *, ptrdiff_t, struct window *); extern void recenter_overlay_lists (struct buffer *, ptrdiff_t); extern ptrdiff_t overlay_strings (ptrdiff_t, struct window *, unsigned char **); @@ -1195,22 +1195,21 @@ record_unwind_current_buffer (void) /* Get overlays at POSN into array OVERLAYS with NOVERLAYS elements. If NEXTP is non-NULL, return next overlay there. - See overlay_at arg CHANGE_REQ for meaning of CHRQ arg. This macro might evaluate its args multiple times, - and it treat some args as lvalues. */ + and it treats some args as lvalues. */ -#define GET_OVERLAYS_AT(posn, overlays, noverlays, nextp, chrq) \ +#define GET_OVERLAYS_AT(posn, overlays, noverlays, nextp) \ do { \ ptrdiff_t maxlen = 40; \ SAFE_NALLOCA (overlays, 1, maxlen); \ (noverlays) = overlays_at (posn, false, &(overlays), &maxlen, \ - nextp, NULL, chrq); \ + nextp, NULL); \ if ((noverlays) > maxlen) \ { \ maxlen = noverlays; \ SAFE_NALLOCA (overlays, 1, maxlen); \ (noverlays) = overlays_at (posn, false, &(overlays), &maxlen, \ - nextp, NULL, chrq); \ + nextp, NULL); \ } \ } while (false) diff --git a/src/textprop.c b/src/textprop.c index d7d6a66923..854bb1c971 100644 --- a/src/textprop.c +++ b/src/textprop.c @@ -636,7 +636,7 @@ get_char_property_and_overlay (Lisp_Object position, register Lisp_Object prop, set_buffer_temp (XBUFFER (object)); USE_SAFE_ALLOCA; - GET_OVERLAYS_AT (pos, overlay_vec, noverlays, NULL, false); + GET_OVERLAYS_AT (pos, overlay_vec, noverlays, NULL); noverlays = sort_overlays (overlay_vec, noverlays, w); set_buffer_temp (obuf); diff --git a/src/xdisp.c b/src/xdisp.c index cc0a689ba3..f64b42f2d8 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -4070,7 +4070,7 @@ next_overlay_change (ptrdiff_t pos) USE_SAFE_ALLOCA; /* Get all overlays at the given position. */ - GET_OVERLAYS_AT (pos, overlays, noverlays, &endpos, true); + GET_OVERLAYS_AT (pos, overlays, noverlays, &endpos); /* If any of these overlays ends before endpos, use its ending point instead. */ @@ -33729,7 +33729,7 @@ note_mouse_highlight (struct frame *f, int x, int y) if (BUFFERP (object)) { /* Put all the overlays we want in a vector in overlay_vec. */ - GET_OVERLAYS_AT (pos, overlay_vec, noverlays, NULL, false); + GET_OVERLAYS_AT (pos, overlay_vec, noverlays, NULL); /* Sort overlays into increasing priority order. */ noverlays = sort_overlays (overlay_vec, noverlays, w); } diff --git a/src/xfaces.c b/src/xfaces.c index ab4440f46a..8df318e33e 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -6397,7 +6397,7 @@ face_at_buffer_position (struct window *w, ptrdiff_t pos, { ptrdiff_t next_overlay; - GET_OVERLAYS_AT (pos, overlay_vec, noverlays, &next_overlay, false); + GET_OVERLAYS_AT (pos, overlay_vec, noverlays, &next_overlay); if (next_overlay < endpos) endpos = next_overlay; } -- 2.30.0 --=-=-=--