[liblouis-liblouisxml] [patch] correct inpos where the output length of a rule is larger than its input length
- From: James Teh <jamie@xxxxxxxxxxx>
- To: liblouis/liblouisxml mailing list <liblouis-liblouisxml@xxxxxxxxxxxxx>
- Date: Mon, 22 Sep 2008 16:44:14 +1000
Hi all,Attached is a patch to fix the inpos array values for the case where a rule has an output length which is larger than its input length. For example, using UEBC, given the input "#", the output will be "_?". The array mapping from output to input (inpos) previously specified [0, 1], which is incorrect; there is no character at index 1 in the input. This patch fixes this to be the correct result; i.e. [0, 0].
Note that this was a regression introduced in 1.3.8. However, this is not simply a revert of the problematic code, as that code was necessary to fix a bug relating to 0 length input; e.g. computer braille prefixes and suffixes. This patch takes both cases into account.
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 39) +++ liblouis/lou_translateString.c (working copy) @@ -415,7 +415,7 @@ } for (k = inLength; k < outLength; k++) if (inputPositions != NULL) - inputPositions[dest + k] = src + inLength; + inputPositions[dest + k] = src + (inLength > 0 ? inLength - 1 : 0); } } dest += outLength;
Other related posts:
- » [liblouis-liblouisxml] [patch] correct inpos where the output length of a rule is larger than its input length