From: Alan Mackenzie <acm@muc.de>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: Questionable code in handling of wordend in the regexp engine in regex-emacs.c
Date: Mon, 25 Feb 2019 18:56:56 +0000 [thread overview]
Message-ID: <20190225185656.GA3605@ACM> (raw)
In-Reply-To: <jwv1s3y85lm.fsf-monnier+emacs@gnu.org>
Hello, Stefan.
Sorry about the delay in replying.
On Sat, Feb 23, 2019 at 18:15:55 -0500, Stefan Monnier wrote:
> > Primarily, there is an
> > UPDATE_SYNTAX_TABLE (charpos);
> > before determining the syntax of the previous character, which seems OK.
> > Later on, before determining the syntax of the next character, we have:
> > UPDATE_SYNTAX_TABLE_FORWARD (charpos);
> > . Between these two calls, charpos hasn't been changed.
> Good spotting.
Thanks!
> > Surely the argument to the second occurrence should be (charpos + 1)?
> I believe it's instead the other one that needs to use "charpos - 1"
> because the UPDATE_SYNTAX_TABLE is called just before reading the char
> *before* charpos (see patch below).
I don't think this is right. offset is calculated from d, and then
decremented, before calculating charpos.
> > Also, probably less importantly, there is
> > GET_CHAR_AFTER (c2, d, dummy);
> > , whereas at the same place in the handler for case symend: we have
> > instead
> > c2 = RE_STRING_CHAR (d, target_multibyte);
> > . Is the effect of these macros identical, or is one of them up to
> > date, and the other one really needs updating as well, for correct
> > functionality?
> According to my reading of the code, they're identical in multibyte
> buffers not in unibyte buffers where RE_STRING_CHAR just returns a value
> between 0 and 255 (i.e. ASCII or Latin-1 more or less), whereas
> GET_CHAR_AFTER will return either an ASCII char (0..127) or a raw-byte
> char (4194176..4194303).
OK.
> I think it's more correct to return a raw-byte char (4194176..4194303),
> so I'd tend to think that GET_CHAR_AFTER is the better choice, but
> please don't quote me on this.
I won't say a word!
> > I came across these whilst investigating bug #34525. Making the
> > indicated changes to regex-emacs.c sadly doesn't help solve the symptoms
> > of that bug. :-(
> Does the patch below help?
Unfortunately not, not for bug #34525. I did try it out, though. In the
mean time, I've advanced somewhat in the debugging.
> Stefan
> diff --git a/src/regex-emacs.c b/src/regex-emacs.c
> index b667a43a37..72fb5ec561 100644
> --- a/src/regex-emacs.c
> +++ b/src/regex-emacs.c
> @@ -4813,7 +4813,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1,
> int dummy;
ptrdiff_t offset = PTR_TO_OFFSET (d) - 1;
> ptrdiff_t charpos = SYNTAX_TABLE_BYTE_TO_CHAR (offset);
> - UPDATE_SYNTAX_TABLE (charpos);
> + UPDATE_SYNTAX_TABLE (charpos - 1);
> GET_CHAR_BEFORE_2 (c1, d, string1, end1, string2, end2);
> s1 = SYNTAX (c1);
--
Alan Mackenzie (Nuremberg, Germany).
next prev parent reply other threads:[~2019-02-25 18:56 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-22 16:45 Questionable code in handling of wordend in the regexp engine in regex-emacs.c Alan Mackenzie
2019-02-23 23:15 ` Stefan Monnier
2019-02-25 18:56 ` Alan Mackenzie [this message]
2019-02-25 19:18 ` Stefan Monnier
2019-03-01 11:10 ` Alan Mackenzie
2019-03-01 13:41 ` Stefan Monnier
2019-03-01 13:46 ` Eli Zaretskii
2019-03-01 14:14 ` Alan Mackenzie
2019-03-01 14:43 ` Eli Zaretskii
2019-03-01 14:58 ` Alan Mackenzie
2019-03-01 16:22 ` Eli Zaretskii
2019-03-01 16:38 ` Alan Mackenzie
2019-03-01 19:16 ` Alan Mackenzie
2019-03-01 19:31 ` Eli Zaretskii
2019-03-02 11:16 ` Alan Mackenzie
2019-03-02 12:18 ` Eli Zaretskii
2019-03-02 13:18 ` Alan Mackenzie
2019-03-02 13:37 ` Eli Zaretskii
2019-03-04 17:25 ` Eli Zaretskii
2019-03-05 10:51 ` Alan Mackenzie
2019-03-05 16:26 ` Eli Zaretskii
2019-03-02 12:21 ` Eli Zaretskii
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=20190225185656.GA3605@ACM \
--to=acm@muc.de \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/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.