From: Lars Ingebrigtsen <larsi@gnus.org>
To: "Mattias Engdegård" <mattiase@acm.org>
Cc: 43598@debbugs.gnu.org
Subject: bug#43598: replace-in-string: finishing touches
Date: Fri, 25 Sep 2020 13:11:15 +0200 [thread overview]
Message-ID: <87lfgyqffw.fsf@gnus.org> (raw)
In-Reply-To: <2CFAAACA-2FD3-44C2-B12E-E49DAA968115@acm.org> ("Mattias Engdegård"'s message of "Fri, 25 Sep 2020 12:42:06 +0200")
Mattias Engdegård <mattiase@acm.org> writes:
> 1. Check the range of the START-POS argument so that we don't crash.
> The permitted range is [0..N] where N is (length HAYSTACK), thus we
> permit a start right after the last character but no further.
> We could also return nil in these cases but I think an error is more useful.
Good point. :-)
> 2. Make the docs more precise about various things.
>
> 3. Slight simplification of the implementation logic to avoid testing
> the same conditions multiple times.
>
> 4. More tests, especially for edge cases. Can't have too many!
It all looks good to me; please apply.
> One test still fails:
>
> (string-search "ø" "\303\270")
>
> which should return nil but currently matches.
> I think it's wrong to convert the needle to unibyte (using
> Fstring_as_unibyte) in this case, but I haven't decided what the best
> solution would be.
Yeah, that's the bit I was most unsure about, because it just didn't
look quite correct to me, but I couldn't come up with the correct test
case last night; thanks.
> We should also consider the optimisations:
> - If SCHARS(needle)>SCHARS(haystack) then no match is possible.
Yup.
> - If either needle or haystack is all-ASCII (all bytes in 0..127),
> then we can use memmem without conversion.
Right, so if the multibyteness differs, then do another check to see
whether both strings are all-ASCII anyway, and do the comparison without
conversion... Yes, makes sense to me.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
next prev parent reply other threads:[~2020-09-25 11:11 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-24 20:52 bug#43598: replace-in-string: finishing touches Mattias Engdegård
2020-09-24 21:12 ` Lars Ingebrigtsen
2020-09-24 21:19 ` Lars Ingebrigtsen
2020-09-24 23:18 ` Lars Ingebrigtsen
2020-09-25 9:21 ` Eli Zaretskii
2020-09-25 10:09 ` Lars Ingebrigtsen
2020-09-24 23:54 ` Lars Ingebrigtsen
2020-09-25 10:42 ` Mattias Engdegård
2020-09-25 11:11 ` Lars Ingebrigtsen [this message]
2020-09-25 11:22 ` Mattias Engdegård
2020-09-25 11:32 ` Lars Ingebrigtsen
2020-09-27 0:03 ` Lars Ingebrigtsen
2020-09-27 0:34 ` Lars Ingebrigtsen
2020-09-27 8:45 ` Mattias Engdegård
2020-09-28 3:41 ` Richard Stallman
2020-09-28 9:40 ` Mattias Engdegård
2020-09-29 3:29 ` Richard Stallman
2020-09-29 4:12 ` Eli Zaretskii
2020-09-27 11:12 ` Mattias Engdegård
2020-09-27 11:48 ` Lars Ingebrigtsen
2020-09-27 11:57 ` Mattias Engdegård
2020-09-27 12:02 ` Lars Ingebrigtsen
2020-09-27 16:14 ` Mattias Engdegård
2020-09-27 16:19 ` Eli Zaretskii
2020-09-27 16:41 ` Lars Ingebrigtsen
2020-09-27 16:48 ` Eli Zaretskii
2020-09-26 22:44 ` Lars Ingebrigtsen
2020-09-26 22:25 ` Lars Ingebrigtsen
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87lfgyqffw.fsf@gnus.org \
--to=larsi@gnus.org \
--cc=43598@debbugs.gnu.org \
--cc=mattiase@acm.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 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.