unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: "Stephen J. Turnbull" <stephen@xemacs.org>
Cc: emacs-devel@gnu.org
Subject: Re: Issue: compare-strings
Date: Wed, 23 Dec 2009 06:11:16 +0200	[thread overview]
Message-ID: <83k4we5nyz.fsf@gnu.org> (raw)
In-Reply-To: <87skb2qs9k.fsf@uwakimon.sk.tsukuba.ac.jp>

> 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.




  reply	other threads:[~2009-12-23  4:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [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 [this message]
2009-12-23  9:08     ` David Kastrup
2009-12-23 13:02       ` Stephen J. Turnbull
2010-01-01 18:21         ` Stephen J. Turnbull

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83k4we5nyz.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=stephen@xemacs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).