Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!pt.cs.cmu.edu!o.gp.cs.cmu.edu!NEEK.FAC.CS.CMU.EDU!neek From: neek@NEEK.FAC.CS.CMU.EDU (Craig Marcus) Newsgroups: comp.windows.x.motif Subject: Re: Has anyone used XmStringGetSegment? Message-ID: <1990Aug10.140636.20447@cs.cmu.edu> Date: 10 Aug 90 14:06:36 GMT References: <9008100138.AA08292@alphalpha.com> Sender: netnews@cs.cmu.edu (USENET News Group Software) Reply-To: neek@NEEK.FAC.CS.CMU.EDU (Craig Marcus) Distribution: inet Organization: Carnegie Mellon University Lines: 42 Keywords !> A friend sent me this code, saying it core-dumped on his machine. |> On mine it just doesn't work. I mucked with it a little to no avail. |> |> Note that if you take out the concat and just do it with the first |> Label it went into an infinite loop printing out null strings. .... 7 |> { 8 |> XmString Label, s1, s2; 9 |> XmStringContext Context; 10 |> char *LabelChars; 11 |> XmStringCharSet CharSet; 12 |> XmStringDirection Direction; 13 |> Boolean Separator; 14 |> 15 |> Label =XmStringCreateLtoR("Death",XmSTRING_DEFAULT_CHARSET); 16 |> s1 = XmStringCreateLtoR("andTaxes",XmSTRING_DEFAULT_CHARSET); 17 |> Label = XmStringConcat(Label, s1); 18 |> if (XmStringInitContext(&Context, Label) == False) 19 |> { 20 |> printf("XmStringInitContext Failed\n"); 21 |> exit(0); 22 |> } 23 |> 24 |> while (XmStringGetNextSegment(&Context, &LabelChars, &CharSet, &Dire ction, &Separator)) { 25 |> printf("LabelChars='%s'\n", LabelChars); 26 |> } The problem with this code is that the "Context" variable is one level of indirection off, ie Context is a pointer to a structure as populated by XmStringInitContext. Therefore, in line 24 above, change the first parameter from "&Context" to "Context" and the code should run fine. Neek Carnegie Mellon University Pittsburgh