[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Issue: compare-strings
From: |
Eli Zaretskii |
Subject: |
Re: Issue: compare-strings |
Date: |
Wed, 23 Dec 2009 06:11:16 +0200 |
> From: "Stephen J. Turnbull" <address@hidden>
> 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.