Subject: bug#18777: [PATCH] dfa: improvement for checking of multibyte character boundary

From: Norihiro Tanaka <[email-masked]>
Date: Thu, 18 Dec 2014 08:50:19 +0900

On Wed, 17 Dec 2014 09:46:09 -0800
Paul Eggert <[email-masked]> wrote:

> Yes, and that's the point: we don't want this if-statement to be pruned
> if WCP != NULL.  We want the code to return P right away in the typical
> case where P is at a character boundary.  If MBP is way less than P,
> this will save the work of the following loop.

We must set a wide character for not next but previous character to WCP
in a case to return P.

For example, I assume following sequence in Shift_JIS locale.  A pair of
0x95 0x5c is a multibyte character in Shift_JIS locale.  I assume to
input MBP = position (a) and P = position (d) into skip_remains_mb().

      0x41 0x95 0x5c 0x0a
    (a)  (b)  (c)  (d)

If WCP == NULL, we can return P right away.  On the other hands, if
WCP != NULL, we must set a wide character for 0x95 0x5c to WCP before
return P.

Do you have any ideas to utilize always_character_boundary for the case?