[comp.windows.x] Bug fixed in Athena TextWidget

jcc@axis.fr (Jean-Christophe Collet) (06/07/89)

[ I'm quite new at X11R3, so sorry if this had previously been discussed
  on the net ]

    There is a bug in the Text Widget from Athena X Widgets.
    I bumped into it while trying to use a TextWidget to display some
    messages in a subwindow.
    The XtTextInvalidate() function generate a segmentation fault whenever
    it is called.

    It comes from the XtTextSource widget. Its GetLastPos field isn't
    initialized. This field is used in the XtTextInvalidate() function
    to call another function. As it's empty : it crashes.

    This fix worked fine here :

*** lib/Xaw/StringSrc.c.old	Fri Jun  2 16:20:25 1989
--- lib/Xaw/StringSrc.c	Fri Jun  2 16:22:27 1989
***************
*** 162,167 ****
--- 162,173 ----
      ((StringSourceData *) (src->data))->length = lastPos;
  }
  
+ static XtTextPosition StringGetLastPos (src)
+   XtTextSource src;
+ {
+     return (((StringSourceData *) (src->data))->length);
+ }
+ 
  static XtTextPosition StringScan (src, pos, sType, dir, count, include)
    XtTextSource	 src;
    XtTextPosition pos;
***************
*** 260,265 ****
--- 266,272 ----
      src->Read = StringReadText;
      src->Replace = StringReplaceText;
      src->SetLastPos = StringSetLastPos;
+     src->GetLastPos = StringGetLastPos;
      src->Scan = StringScan;
      src->SetSelection = SetSelection;
      src->ConvertSelection = NULL;

-------------------------------------------------------------------------------
jcc@axis.fr             ! "An artificial intelligence is better than none !"
..!mcvax!inria!axis!jcc ! "Artificial intelligence matches natural stupidity !"
Collet jean-christophe  ! "Objets inanimes avez vous donc une ame ?"
-------------------------------------------------------------------------------
	Axis Digital        |
	135 rue d'aguesseau |       <this space left intentionaly blank>
	92100 Boulogne      |
	France              |
 Phone: +33 (1) 46 03 37 75 |
-------------------------------------------------------------------------------