* Issue: compare-strings [not found] <873a33fmd8.fsf@harnisch.dyndns.org> @ 2009-12-23 3:32 ` Stephen J. Turnbull 2009-12-23 4:11 ` Eli Zaretskii 0 siblings, 1 reply; 5+ messages in thread From: Stephen J. Turnbull @ 2009-12-23 3:32 UTC (permalink / raw) To: emacs-devel Hi, Emacs. We have the following report on xemacs-beta. I would like a clarification as to the intended behavior of `compare-strings' for arguments out of range. The behavior of Emacs makes more sense to me. It seems silly to force users to check length of variable strings to avoid errors in cases like (compare-strings "the other string is too short" "the" 0 9 0 9) Marcus Harnisch writes: > `compare-strings', a primitive added in 21.5.9 mainly for GNU > compatibility as far as the ChangeLog says, is *not* compatible to the > same function in Emacs 22.2.1 (Ubuntu 9.10 version). Not sure if they > changed `compare-strings's behavior since we added it. > > We create an args out of range error when the positions don't seem to > make sense (e.g. END is beyond length of the string) -- GNU doesn't. > > In any case, the behavior in such cases is not specified. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Issue: compare-strings 2009-12-23 3:32 ` Issue: compare-strings Stephen J. Turnbull @ 2009-12-23 4:11 ` Eli Zaretskii 2009-12-23 9:08 ` David Kastrup 0 siblings, 1 reply; 5+ messages in thread From: Eli Zaretskii @ 2009-12-23 4:11 UTC (permalink / raw) To: Stephen J. Turnbull; +Cc: emacs-devel > From: "Stephen J. Turnbull" <stephen@xemacs.org> > Date: Wed, 23 Dec 2009 12:32:55 +0900 > > We have the following report on xemacs-beta. I would like a > clarification as to the intended behavior of `compare-strings' for > arguments out of range. The behavior of Emacs makes more sense to me. > It seems silly to force users to check length of variable strings to > avoid errors in cases like > > (compare-strings "the other string is too short" "the" 0 9 0 9) > > Marcus Harnisch writes: > > > `compare-strings', a primitive added in 21.5.9 mainly for GNU > > compatibility as far as the ChangeLog says, is *not* compatible to the > > same function in Emacs 22.2.1 (Ubuntu 9.10 version). Not sure if they > > changed `compare-strings's behavior since we added it. > > > > We create an args out of range error when the positions don't seem to > > make sense (e.g. END is beyond length of the string) -- GNU doesn't. > > > > In any case, the behavior in such cases is not specified. It's quite clear from the Emacs implementation that the behavior is intentional: end1_char = SCHARS (str1); if (! NILP (end1) && end1_char > XINT (end1)) end1_char = XINT (end1); end2_char = SCHARS (str2); if (! NILP (end2) && end2_char > XINT (end2)) end2_char = XINT (end2); According to "cvs annotate", this code did not change since April 1998, when this function was introduced. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Issue: compare-strings 2009-12-23 4:11 ` Eli Zaretskii @ 2009-12-23 9:08 ` David Kastrup 2009-12-23 13:02 ` Stephen J. Turnbull 0 siblings, 1 reply; 5+ messages in thread From: David Kastrup @ 2009-12-23 9:08 UTC (permalink / raw) To: emacs-devel Eli Zaretskii <eliz@gnu.org> writes: > It's quite clear from the Emacs implementation that the behavior is > intentional: > > end1_char = SCHARS (str1); > if (! NILP (end1) && end1_char > XINT (end1)) > end1_char = XINT (end1); > > end2_char = SCHARS (str2); > if (! NILP (end2) && end2_char > XINT (end2)) > end2_char = XINT (end2); > > According to "cvs annotate", this code did not change since April > 1998, when this function was introduced. Perhaps mention this facet in the DOC string so that people may make use of that convenience? -- David Kastrup ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Issue: compare-strings 2009-12-23 9:08 ` David Kastrup @ 2009-12-23 13:02 ` Stephen J. Turnbull 2010-01-01 18:21 ` Stephen J. Turnbull 0 siblings, 1 reply; 5+ messages in thread From: Stephen J. Turnbull @ 2009-12-23 13:02 UTC (permalink / raw) To: emacs-devel David Kastrup writes: > Perhaps mention this facet in the DOC string so that people may make use > of that convenience? +1. I may not look at the implementation of Emacs if I want to participate in the implementation of XEmacs. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Issue: compare-strings 2009-12-23 13:02 ` Stephen J. Turnbull @ 2010-01-01 18:21 ` Stephen J. Turnbull 0 siblings, 0 replies; 5+ messages in thread From: Stephen J. Turnbull @ 2010-01-01 18:21 UTC (permalink / raw) To: emacs-devel I have synchronized XEmacs behavior to the behavior our bug report describes, and Eli confirms is intended. I've also changed the docstring to one I consider more accurate. As I have assign.future on file for XEmacs, this is now copyright FSF, so you're welcome to use it. I suspect that the XEmacs docstring is the same as that of Emacs, so the patch might even work. diff -r 084056f46755 -r c45fdd4e1858 src/fns.c --- a/src/fns.c Fri Jan 01 00:21:07 2010 +0000 +++ b/src/fns.c Sat Jan 02 01:02:43 2010 +0900 @@ -315,9 +315,12 @@ Compare the contents of two strings, maybe ignoring case. In string STR1, skip the first START1 characters and stop at END1. In string STR2, skip the first START2 characters and stop at END2. -END1 and END2 default to the full lengths of the respective strings. - -Case is significant in this comparison if IGNORE-CASE is nil. +END1 and END2 default to the full lengths of the respective strings, +and arguments that are outside the string (negative STARTi or ENDi +greater than length) are coerced to 0 or string length as appropriate. + +Optional IGNORE-CASE non-nil means use case-insensitive comparison. +Case is significant by default. The value is t if the strings (or specified portions) match. If string STR1 is less, the value is a negative number N; ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-01-01 18:21 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <873a33fmd8.fsf@harnisch.dyndns.org> 2009-12-23 3:32 ` Issue: compare-strings Stephen J. Turnbull 2009-12-23 4:11 ` Eli Zaretskii 2009-12-23 9:08 ` David Kastrup 2009-12-23 13:02 ` Stephen J. Turnbull 2010-01-01 18:21 ` Stephen J. Turnbull
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.