From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh Newsgroups: gmane.emacs.bugs Subject: bug#48264: [PATCH v4 02/14] Take offset not idx in PER_BUFFER_VALUE_P Date: Fri, 7 May 2021 22:08:53 -0400 Message-ID: <20210508020905.13583-4-sbaugh@catern.com> References: <20210506213346.9730-1-sbaugh@catern.com> <20210508020905.13583-1-sbaugh@catern.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39553"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Spencer Baugh To: 48264@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat May 08 04:39:31 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 1lfCsN-000ABp-5v for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 08 May 2021 04:39:31 +0200 Original-Received: from localhost ([::1]:46566 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lfCsM-00009a-3M for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 07 May 2021 22:39:30 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44784) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lfCPt-0001KQ-L5 for bug-gnu-emacs@gnu.org; Fri, 07 May 2021 22:10:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:35645) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lfCPr-0007Wd-Ii for bug-gnu-emacs@gnu.org; Fri, 07 May 2021 22:10:05 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lfCPr-0006Ub-EO for bug-gnu-emacs@gnu.org; Fri, 07 May 2021 22:10:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 08 May 2021 02:10:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48264 X-GNU-PR-Package: emacs Original-Received: via spool by 48264-submit@debbugs.gnu.org id=B48264.162043976024783 (code B ref 48264); Sat, 08 May 2021 02:10:03 +0000 Original-Received: (at 48264) by debbugs.gnu.org; 8 May 2021 02:09:20 +0000 Original-Received: from localhost ([127.0.0.1]:47152 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lfCP9-0006RR-8p for submit@debbugs.gnu.org; Fri, 07 May 2021 22:09:19 -0400 Original-Received: from venus.catern.com ([68.183.49.163]:47894) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lfCP5-0006Qr-GP for 48264@debbugs.gnu.org; Fri, 07 May 2021 22:09:16 -0400 Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235; helo=localhost; envelope-from=sbaugh@catern.com; receiver= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail; t=1620439755; bh=Qma0rUKzeh7JnjVA+FpsVJYp5tSJoSCqw7sDFOwzNE8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=HtShTSxExXi9ixjjwg9LKoBgYYSvZjy4GMVKibxIaAWBxeHTfdjNoQTqSwLA34+lW wRE9u6moNWuVcAajZLAeGF8++9q2z5GMjsMOIRPR8NL+abbWPLsJDi1ir8e+HCIOJf KtcrxYfaDXTUpxPooBNE0DLAV+3N3vN9XzYM8kBs= Original-Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235]) by venus.catern.com (Postfix) with ESMTPSA id 41EAC2E97B0; Sat, 8 May 2021 02:09:15 +0000 (UTC) X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210508020905.13583-1-sbaugh@catern.com> 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:205968 Archived-At: This improves clarity and allows us to more easily change how PER_BUFFER_VALUE_P works. * src/buffer.h (PER_BUFFER_VALUE_P): Move to be in scope of PER_BUFFER_IDX. Take offset instead of idx, and perform the common "idx == -1" check internally. * src/data.c (store_symval_forwarding, set_internal) (set_default_internal, Flocal_variable_p): * src/buffer.c (buffer_local_variables_1): Pass offset not idx to PER_BUFFER_VALUE_P, and remove idx == -1 checks. --- src/buffer.c | 3 +-- src/buffer.h | 21 +++++++++++---------- src/data.c | 11 +++++------ 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/buffer.c b/src/buffer.c index 8b3e15bc81..c395c6ec98 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -1319,8 +1319,7 @@ buffer_lisp_local_variables (struct buffer *buf, bool clone) static Lisp_Object buffer_local_variables_1 (struct buffer *buf, int offset, Lisp_Object sym) { - int idx = PER_BUFFER_IDX (offset); - if ((idx == -1 || PER_BUFFER_VALUE_P (buf, idx)) + if (PER_BUFFER_VALUE_P (buf, offset) && SYMBOLP (PER_BUFFER_SYMBOL (offset))) { sym = NILP (sym) ? PER_BUFFER_SYMBOL (offset) : sym; diff --git a/src/buffer.h b/src/buffer.h index 24e9c3fcbc..7367c2cb2b 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -1415,16 +1415,6 @@ OVERLAY_POSITION (Lisp_Object p) extern bool valid_per_buffer_idx (int); -/* Value is true if the variable with index IDX has a local value - in buffer B. */ - -INLINE bool -PER_BUFFER_VALUE_P (struct buffer *b, int idx) -{ - eassert (valid_per_buffer_idx (idx)); - return b->local_flags[idx]; -} - /* Set whether per-buffer variable with index IDX has a buffer-local value in buffer B. VAL zero means it hasn't. */ @@ -1491,6 +1481,17 @@ set_per_buffer_value (struct buffer *b, int offset, Lisp_Object value) *(Lisp_Object *)(offset + (char *) b) = value; } +/* Value is true if the variable with offset OFFSET has a local value + in buffer B. */ + +INLINE bool +PER_BUFFER_VALUE_P (struct buffer *b, int offset) +{ + int idx = PER_BUFFER_IDX (offset); + eassert (idx == -1 || valid_per_buffer_idx (idx)); + return idx == -1 || b->local_flags[idx]; +} + /* Downcase a character C, or make no change if that cannot be done. */ INLINE int downcase (int c) diff --git a/src/data.c b/src/data.c index d547f5da5e..bd399e0439 100644 --- a/src/data.c +++ b/src/data.c @@ -1280,7 +1280,7 @@ store_symval_forwarding (lispfwd valcontents, Lisp_Object newval, { struct buffer *b = XBUFFER (buf); - if (! PER_BUFFER_VALUE_P (b, idx)) + if (! PER_BUFFER_VALUE_P (b, offset)) set_per_buffer_value (b, offset, newval); } } @@ -1597,8 +1597,8 @@ set_internal (Lisp_Object symbol, Lisp_Object newval, Lisp_Object where, { int offset = XBUFFER_OBJFWD (innercontents)->offset; int idx = PER_BUFFER_IDX (offset); - if (idx > 0 && bindflag == SET_INTERNAL_SET - && !PER_BUFFER_VALUE_P (buf, idx)) + if (bindflag == SET_INTERNAL_SET + && !PER_BUFFER_VALUE_P (buf, offset)) { if (let_shadows_buffer_binding_p (sym)) set_default_internal (symbol, newval, bindflag); @@ -1899,7 +1899,7 @@ set_default_internal (Lisp_Object symbol, Lisp_Object value, { struct buffer *b = XBUFFER (buf); - if (!PER_BUFFER_VALUE_P (b, idx)) + if (!PER_BUFFER_VALUE_P (b, offset)) set_per_buffer_value (b, offset, value); } } @@ -2238,8 +2238,7 @@ BUFFER defaults to the current buffer. */) if (BUFFER_OBJFWDP (valcontents)) { int offset = XBUFFER_OBJFWD (valcontents)->offset; - int idx = PER_BUFFER_IDX (offset); - if (idx == -1 || PER_BUFFER_VALUE_P (buf, idx)) + if (PER_BUFFER_VALUE_P (buf, offset)) return Qt; } return Qnil; -- 2.31.1