[haiku-bugs] Re: [Haiku] #8447: TextView GetText() doesn't straddle the "Gap" properly

  • From: "Pete" <trac@xxxxxxxxxxxx>
  • Date: Fri, 19 Sep 2014 06:46:43 -0000

#8447: TextView GetText() doesn't straddle the "Gap" properly
----------------------------------+----------------------------
   Reporter:  Pete                |      Owner:  axeld
       Type:  bug                 |     Status:  new
   Priority:  critical            |  Milestone:  R1/alpha5
  Component:  Kits/Interface Kit  |    Version:  R1/Development
 Resolution:                      |   Keywords:
 Blocked By:                      |   Blocking:  11132
Has a Patch:  1                   |   Platform:  All
----------------------------------+----------------------------

Comment (by Pete):

 Replying to [comment:9 jackburton]:
 > It's been a while since I last touched that code, but it seems to me
 that "offset" should be added to the second parameter of the second call
 to memcpy(), like we do for the first.
 > IOW:
 > {{{
 >     memcpy(buffer, fBuffer + offset, beforeLen);
 >     memcpy(buffer + beforeLen, fBuffer + fGapIndex + fGapCount + offset,
 afterLen);
 > }}}
 >
 > Otherwise the code wouldn't work with offset != 0.
 No, because the offset is irrelevant for the second memcpy. The first one
 copies the segment of text from offset up to the gap (pointed to by
 fGapIndex); beforelen is calculated to do this.  The second memcpy has to
 start ''immediately'' after the gap, which is pointed to by fGapIndex +
 fGapCount.  Adding in offset as well would push things too far down.

 FTR I ran a check earlier on a patched libbe.so, using Weaver and two
 connected StreamView elements.  (That was where I noticed the problem in
 the first place, as it uses BTextView's 'GetText'.)
 I ran extensive edits in one StreamView -- including UTF-8 characters --
 and transmitted arbitrary clips to the other.  Seemed flawless under all
 conditions.

--
Ticket URL: <https://dev.haiku-os.org/ticket/8447#comment:10>
Haiku <https://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: