nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nano-devel] Updated FIX for undo/redo (multibyte characters)


From: Benno Schulenberg
Subject: Re: [Nano-devel] Updated FIX for undo/redo (multibyte characters)
Date: Wed, 21 May 2014 23:09:47 +0200

On Wed, May 21, 2014, at 22:24, Mark Majeres wrote:
> The trickier situation occurs when the index is subtracted by one, such
> was the case with undo/redo ADD.  The function mbleft() can be useful
> for this case, but it requires iterating from the start of the string,
> so beware of the extra processing.

Yeah, some weeks ago I looked at that function and was... appalled,
and tempted to rewrite it.  For UTF-8 the start of the preceding char
can be found much quicker: any byte from 80 to BF is part of a multibyte
sequence that starts earlier, and only bytes from C0 to FF are sequence
starters.  So, stepping back through the string, one has to check at most
four bytes to find the start of the preceding character.  And if one does
not find a valid starter byte by then, then the file contains crap, and the
step should be -1 byte, so the user gets a chance to delete it.  But this
is only for UTF-8 -- maybe there are other multibyte encodings around
that *do* need to be checked from string start.  So I let it be.

> I have attached an updated patch with this feature.

Oww... but that is against a very old revision, and doesn't apply: all
hunks fail.

Benno

-- 
http://www.fastmail.fm - Accessible with your email software
                          or over the web




reply via email to

[Prev in Thread] Current Thread [Next in Thread]