From: YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 3687@emacsbugs.donarmstrong.com
Subject: bug#3687: 23.1.50; inconsistency in multibyte eight-bit regexps
Date: Sat, 27 Jun 2009 10:30:10 +0900 [thread overview]
Message-ID: <wlskhmxy3h.wl%mituharu@math.s.chiba-u.ac.jp> (raw)
In-Reply-To: <83my7vyute.fsf@gnu.org>
>>>>> On Fri, 26 Jun 2009 16:43:25 +0300, Eli Zaretskii <eliz@gnu.org> said:
>> Date: Fri, 26 Jun 2009 18:56:50 +0900 (JST)
>> From: YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
>> Cc:
>>
>> The following results look inconsistent:
>>
>> (string-match (string-to-multibyte "\x80") (string-to-multibyte "\x80"))
>> => 0
>> (string-match (string-to-multibyte "\x80") "\x80")
>> => nil
>>
>> (string-match (string-to-multibyte "[\x80]") (string-to-multibyte "\x80"))
>> => nil
>> (string-match (string-to-multibyte "[\x80]") "\x80")
>> => 0
> Please tell why you think they are inconsistent.
I thought there's no room for argument about their inconsistency with
respect to the specification of "[...]" in regexps.
> More importantly, please show real-life examples of code or
> situations where this gets in your way.
If you decode some data containing invalid (undecodable) byte
sequences using a coding system such as utf-8, then such sequences are
embedded in the decoded result as eight-bit characters in multibyte
form. You can detect particular such sequences by searching a
"characer alternative" regexp (or its multibyte form) in the decoded
result if it works.
Further examples that look inconsistent:
(string-match (string-to-multibyte "[\x80\x81]") (string-to-multibyte "\x80"))
=> nil
(string-match (string-to-multibyte "[\x80-\xbf]") (string-to-multibyte "\x80"))
=> nil
(string-match (string-to-multibyte "[\x80-\xc0]") (string-to-multibyte "\x80"))
=> 0
(string-match (string-to-multibyte "[\x80-\xc0]") (string-to-multibyte "\xbf"))
=> 0
(string-match (string-to-multibyte "[\x80-\xc0]") (string-to-multibyte "\xc0"))
=> nil
> This area is full of subtleties and gotchas, and in general the
> current code does what it does because it needs to cater to many
> different practical situations.
> There could still be bugs, of course.
Yeah. I found another suspected bug in this area:
(string-match "[[:unibyte:]]" "\x80")
=> nil
(string-match "[[:unibyte:]]" (string-to-multibyte "\x80"))
=> nil
YAMAMOTO Mitsuharu
mituharu@math.s.chiba-u.ac.jp
next prev parent reply other threads:[~2009-06-27 1:30 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-26 9:56 bug#3687: 23.1.50; inconsistency in multibyte eight-bit regexps YAMAMOTO Mitsuharu
2009-06-26 13:43 ` Eli Zaretskii
2009-06-27 1:30 ` YAMAMOTO Mitsuharu [this message]
2009-06-27 9:36 ` Eli Zaretskii
2009-06-29 3:02 ` YAMAMOTO Mitsuharu
2009-06-29 8:47 ` Stefan Monnier
2009-07-24 1:08 ` YAMAMOTO Mitsuharu
2019-06-28 12:41 ` bug#3687: 23.1.50; inconsistency in multibyte eight-bit regexps [PATCH] Mattias Engdegård
2019-06-28 13:03 ` Eli Zaretskii
2019-06-28 14:05 ` Mattias Engdegård
2019-06-28 14:40 ` Eli Zaretskii
2019-06-28 15:00 ` Mattias Engdegård
2019-06-28 16:20 ` Eli Zaretskii
2019-06-28 16:47 ` Mattias Engdegård
2019-06-28 14:56 ` Eli Zaretskii
2019-06-28 15:18 ` Stefan Monnier
2019-06-28 15:34 ` Mattias Engdegård
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=wlskhmxy3h.wl%mituharu@math.s.chiba-u.ac.jp \
--to=mituharu@math.s.chiba-u.ac.jp \
--cc=3687@emacsbugs.donarmstrong.com \
--cc=eliz@gnu.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.