[liblouis-liblouisxml] Re: [patch] Correct input to output position mapping for removed repeated text

Jamie,

Thanks for the patch. I will apply it to my development copy. 
Unfortunately, it is not the same as the copy in cood.google. I've been
experimenting and testing. I just fixed the problem with dots 7-8 in
tables like en-us-comp8.ctb. now, if your table does not contain the
capsign opcode but does define dot 7 for capital letters, it will be
preserved. You will have to obtain the new liblouis and liblouisxml from
www.jjb-software.com . Sorry to be out of phrase with the Google site.

I'm putting the finishing touches on the next release. You will receive 
a message on the list when it is available.

John

On Wed, Sep 17, 2008 at 01:04:16PM +1000, James Teh wrote:
> Hi all,
> 
> Attached is a patch to do the following:
> * liblouis/lou_translateString.c: When handling input which is removed 
> due to a "repeated" opcode, correctly update the mapping from input to 
> output positions; i.e. the outputPos array and the returned cursorPos.
> 
> The test case is a string such as:
> "a  "
> Translating this with en-us-g2.ctb yields:
> "a "
> Observe that the second space has been eliminated due to the "repeated" 
> opcode for spaces. Previously, the mapping from input to output 
> positions was:
> [0, 1, 0]
> This is incorrect; this indicates that position 2 of the input maps to 
> position 0 of the output.
> It should be:
>  [0, 1, 1]
> indicating that both position 1 and 2 of the input map to position 1 of 
> the output. Similar issues exist with cursorPos. This patch fixes both.
> 
> Note that the patch passes a string to for_updatePositions, but passes 
> the output length as being 0, so the string is unnecessary. However, 
> passing memcpy a NULL src is undefined according to the spec (though 
> most implementations don't complain).
> 
> I have already committed this to the svn for the liblouis Google Code 
> project.
> 
> Jamie
> 
> -- 
> James Teh
> Email: jamie@xxxxxxxxxxx
> WWW: http://www.jantrid.net/
> MSN Messenger: jamie@xxxxxxxxxxx
> Jabber: jteh@xxxxxxxxxx
> Yahoo: jcs_teh

> Index: liblouis/lou_translateString.c
> ===================================================================
> --- liblouis/lou_translateString.c    (revision 34)
> +++ liblouis/lou_translateString.c    (revision 35)
> @@ -1891,6 +1891,7 @@
>                  && compareChars (&transRule->charsdots[0],
>                                   &currentInput[src], transCharslen, 0))
>             {
> +             for_updatePositions(transRule->charsdots[0], transCharslen, 0);
>               src += transCharslen;
>             }
>           break;


-- 
My websites:
http://www.godtouches.org
http://www.jjb-software.com
Location: Madison, WI, USA

For a description of the software and to download it go to
http://www.jjb-software.com

Other related posts: