[liblouis-liblouisxml] Re: Calculation of cursorPos

  • From: Michael Whapples <mwhapples@xxxxxxx>
  • To: liblouis-liblouisxml@xxxxxxxxxxxxx
  • Date: Wed, 30 Jan 2013 08:47:28 +0000

I think my question was more, is there a case where a user (I mean other software) of liblouis would want to read cursorPos but not need outputPos? I cannot reason one.


I understand what you were saying, but I guess I was thinking, if the above holds true, should outputPos not be given (outputPos == null) then cursorPos will only be used for input and so will not be changed for output (IE. after the call will still contain what it was given for input).

An alternative, which has already been suggested, liblouis could allocate outputPos if it is null, but then this may mean people who don't want to read cursorPos will still have outputPos allocated and using memory.

Michael Whapples
On 29/01/2013 21:54, John J. Boyer wrote:
Hi Michael,

I'm glad you donn't find a flaw in the reasoning about the calculation
of cursorPos. The code does have to check that outputPos is not NULL .
Otherwise, if it ever is, there would be a segmentation fault or a
totally errroneous value of cursorPos.

John

On Tue, Jan 29, 2013 at 07:27:41PM +0000, Michael Whapples wrote:
I agree about the original question on how to get cursorPos, just
thinking about it I cannot find a case why it might not hold.

As for always needing to give space for outputPos, would anyone use
cursorPos and not want outputPos? I am thinking that cursorPos would
only be used by screen readers and they would probably want outputPos
for routing keys.

Have I missed a use where this might not be the case and cursorPos would
be read but outputPos would not be needed?

Michael Whapples
On 29/01/2013 17:16, John J. Boyer wrote:
It's an interesting idea. However, it would require that space should
always be provided for the outputPos array. A possible solution would be
to use this technique if outputPos is not NULL, but if it is fall back
on the existing code.

John

On Tue, Jan 29, 2013 at 04:16:34PM +0100, Bert Frees wrote:
Hi Jamie,

AFAICS your reasoning is correct. But I may be overlooking something too.

Bert


On 01/29/2013 04:06 PM, James Teh wrote:
outputPos maps input positions to output positions. At the beginning
of the call, cursorPos is the cursor position in the input. Therefore,
unless I'm missing something, the output cursorPos should just be
outputPos[cursorPos]. Is there a reason this isn't the case? This
would simplify the code a great deal and thereby eliminate existing bugs.

Jamie

On 30/01/2013 1:03 AM, John J. Boyer wrote:
I don't understand this question. outputPos is an array. cursorPos is a
single value. What would be the ideal value of cursorPos? There may be
differing opinions on this.

John

On Tue, Jan 29, 2013 at 05:53:28PM +1000, James Teh wrote:
Hi all, especially John,

Currently, there are still some bugs in the calculation of the output
cursor position in lou_translate. I can detail these in a separate
email
if necessary. However, I'm wondering whether it is simpler to just set
cursorPos based on outputPos just before returning the translation,
rather than having separate code for it. Is there any reason cursorPos
is currently determined separately from outputPos? To put it another
way, is there any reason that cursorPos should ever be different to
outputPos[inputCursorPos], where inputCursorPos is the value of
cursorPos when the function was called?

Thanks,
Jamie

--
James Teh
Director, NV Access Limited
Email: jamie@xxxxxxxxxxxx
Web site: http://www.nvaccess.org/
Phone: +61 7 5667 8372
For a description of the software, to download it and links to
project pages go to http://www.abilitiessoft.com
For a description of the software, to download it and links to
project pages go to http://www.abilitiessoft.com
For a description of the software, to download it and links to
project pages go to http://www.abilitiessoft.com

For a description of the software, to download it and links to
project pages go to http://www.abilitiessoft.com

Other related posts: