all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] Fix a possibly problematic string comparison
@ 2023-08-27 21:43 Rudolf Adamkovič
  2023-08-28  8:45 ` Ihor Radchenko
  2024-05-09  9:00 ` Ihor Radchenko
  0 siblings, 2 replies; 6+ messages in thread
From: Rudolf Adamkovič @ 2023-08-27 21:43 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Rudolf Adamkovič

* lisp/org-table.el (org-table-make-reference): Replace 'eq' with
'string-empty-p' to resolve "Warning: 'eq' called with literal string
that may never match" issued on every 'make' invocation.
---
 lisp/org-table.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org-table.el b/lisp/org-table.el
index f5a433c7d..b82749469 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -2864,7 +2864,7 @@ list, `literal' is for the format specifier L."
       (if lispp
 	  (if (eq lispp 'literal)
 	      elements
-	    (if (and (eq elements "") (not keep-empty))
+	    (if (and (string-empty-p elements) (not keep-empty))
 		""
 	      (prin1-to-string
 	       (if numbers (string-to-number elements) elements))))
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] Fix a possibly problematic string comparison
  2023-08-27 21:43 [PATCH] Fix a possibly problematic string comparison Rudolf Adamkovič
@ 2023-08-28  8:45 ` Ihor Radchenko
  2023-08-29  0:02   ` Rudolf Adamkovič
  2024-05-09  9:00 ` Ihor Radchenko
  1 sibling, 1 reply; 6+ messages in thread
From: Ihor Radchenko @ 2023-08-28  8:45 UTC (permalink / raw)
  To: Rudolf Adamkovič; +Cc: emacs-orgmode

Rudolf Adamkovič <salutis@me.com> writes:

> * lisp/org-table.el (org-table-make-reference): Replace 'eq' with
> 'string-empty-p' to resolve "Warning: 'eq' called with literal string
> that may never match" issued on every 'make' invocation.
>
> -	    (if (and (eq elements "") (not keep-empty))
> +	    (if (and (string-empty-p elements) (not keep-empty))

This is not as trivial. Applying this patch will break tests.
One needs to carefully examine the org-table logic to fix this
particular warning.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Fix a possibly problematic string comparison
  2023-08-28  8:45 ` Ihor Radchenko
@ 2023-08-29  0:02   ` Rudolf Adamkovič
  2023-08-29  5:10     ` Ihor Radchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Rudolf Adamkovič @ 2023-08-29  0:02 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

Ihor Radchenko <yantar92@posteo.net> writes:

> This is not as trivial. Applying this patch will break tests.
> One needs to carefully examine the org-table logic to fix this
> particular warning.

Wow!  You are right.  How is that even possible?  In other words, what
value (of 'elements') can possibly be object-equal to a literal "" but
not string-equal to the same literal "" or vice versa?

Rudy
-- 
"Logic is a science of the necessary laws of thought, without which no
employment of the understanding and the reason takes place."
-- Immanuel Kant, 1785

Rudolf Adamkovič <salutis@me.com> [he/him]
Studenohorská 25
84103 Bratislava
Slovakia


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Fix a possibly problematic string comparison
  2023-08-29  0:02   ` Rudolf Adamkovič
@ 2023-08-29  5:10     ` Ihor Radchenko
  2023-08-29 23:56       ` Rudolf Adamkovič
  0 siblings, 1 reply; 6+ messages in thread
From: Ihor Radchenko @ 2023-08-29  5:10 UTC (permalink / raw)
  To: Rudolf Adamkovič; +Cc: emacs-orgmode

Rudolf Adamkovič <salutis@me.com> writes:

> Ihor Radchenko <yantar92@posteo.net> writes:
>
>> This is not as trivial. Applying this patch will break tests.
>> One needs to carefully examine the org-table logic to fix this
>> particular warning.
>
> Wow!  You are right.  How is that even possible?  In other words, what
> value (of 'elements') can possibly be object-equal to a literal "" but
> not string-equal to the same literal "" or vice versa?

This is not what is happening. 

-	    (if (and (eq elements "") (not keep-empty))

(eq elements "") is always nil - the warning is right. We never enter
this branch of `if'.

+	    (if (and (string-empty-p elements) (not keep-empty))

After the patch, we do enter this branch of `if', but it breaks tests.

So, it is not just an innocent warning - it reveals a fault in logic
elsewhere in the code.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Fix a possibly problematic string comparison
  2023-08-29  5:10     ` Ihor Radchenko
@ 2023-08-29 23:56       ` Rudolf Adamkovič
  0 siblings, 0 replies; 6+ messages in thread
From: Rudolf Adamkovič @ 2023-08-29 23:56 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

Thank you for the explanation!

Given the complexity of the caller, that is
the `org-table-eval-formula' function, as
well as, the fact that I have yet to learn
about the spreadsheet functionality, I am
backing away from this bugfix.

Sorry for the noise.

Rudy
-- 
"Programming reliably -- must be an activity
of an undeniably mathematical nature […] You
see, mathematics is about thinking, and doing
mathematics is always trying to think as well
as possible."  -- Edsger W. Dijkstra, 1981

Rudolf Adamkovič <salutis@me.com> [he/him]
Studenohorská 25
84103 Bratislava
Slovakia


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Fix a possibly problematic string comparison
  2023-08-27 21:43 [PATCH] Fix a possibly problematic string comparison Rudolf Adamkovič
  2023-08-28  8:45 ` Ihor Radchenko
@ 2024-05-09  9:00 ` Ihor Radchenko
  1 sibling, 0 replies; 6+ messages in thread
From: Ihor Radchenko @ 2024-05-09  9:00 UTC (permalink / raw)
  To: Rudolf Adamkovič; +Cc: emacs-orgmode

Rudolf Adamkovič <salutis@me.com> writes:

> * lisp/org-table.el (org-table-make-reference): Replace 'eq' with
> 'string-empty-p' to resolve "Warning: 'eq' called with literal string
> that may never match" issued on every 'make' invocation.

Handled, on main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=bd5665e01
I went with the non-breaking change.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-05-09  9:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-27 21:43 [PATCH] Fix a possibly problematic string comparison Rudolf Adamkovič
2023-08-28  8:45 ` Ihor Radchenko
2023-08-29  0:02   ` Rudolf Adamkovič
2023-08-29  5:10     ` Ihor Radchenko
2023-08-29 23:56       ` Rudolf Adamkovič
2024-05-09  9:00 ` Ihor Radchenko

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.