ngse18@castle.ed.ac.uk (J R Evans) (08/10/90)
In article <9008100138.AA08292@alphalpha.com> nazgul@alphalpha.com (Kee Hinckley) writes: >A friend sent me this code, saying it core-dumped on his machine. >On mine it just doesn't work. ... What a coincidence! I was about to post the following message, so I'm pleased to find I'm not alone in having this problem - it's taken me three days to find the fix. Here is the text of my prepared file: ---------------------------------------------------------------------- There appears to be a discrepancy between documentation and source for the XmStringGetNextSegment() routine in Motif 1.0. The documentation (Programmer's Guide, p134 and Programmer's Reference Manual, p393) give the calling format as Boolean XmStringGetNextSegment(context, ...) XmStringContext *context; /* doesn't work! */ ... whereas (as I am informed by a colleague at Edinburgh University, and is confirmed by practical experimentation) the source contains Boolean XmStringGetNextSegment(context, ...) XmStringContext context; /* no indirection */ ... This behaviour is a change in functionality from the XUI equivalent, on which Motif is modelled, but that fact is not noted in the Porting Guide. I append below a summary of the circuitous route through which this has been established. Any comments? Russ Evans, British Geological Survey, Edinburgh e_gs18@va.nmh.ac.uk (Internet/BITNET); e_gs18@uk.ac.nmh.va (JANET) ============= Some details ============================================ We experienced problems porting a large application from DECwindows to Motif. Due to time constraints, we have been working with binaries and documentation provided to us by DEC, derived from Motif 1.0 and running under Ultrix for RISC 3.1 and VMS 5.3 i.e. we do not have access to the Motif sources. The problems manifested themselves in the code handling returns from the Motif File Selection Box - XmStringGetNextSegment consistently returned the failure code. We were distracted into looking at the File Selection Box as the likely culprit for a number of reasons, particularly that the Ultrix implementation was producing unaligned access error messages, and because the Motif documentation states firmly that the FSB will not work properly unless the application is linked with libPW.a. As Richard Nuttall and David Brooks have since explained, the documentation is in error, and libPW.a is only required on some systems. David Brooks also explained that the unaligned access error is a product of the recomp/regex routines in Ultrix's libc.a and can be eliminated by replacing these routines. At this point, I was reduced to trying anything; In the absence of a more reasonable strategy, I resorted to changing addressing modes at random. It proved that removing a level of indirection from the context argument of XmStringGetNextSegment() caused the code to function as intended. I asked a colleague at Edinburgh University, who holds a licensed copy of the Motif source to examine it on my behalf, and he confirms that the relevant argument is declared as of type XmStringContext i.e. without indirection, contrary to the documentation and in variance with XUI practice. I recount this tale at some length, since part has already appeared on comp.windows.x.motif (in fact, more than I had intended, due to a mailing error) and this will keep the record straight. It's moral is quite clear, of course - those who have access should use the source (Luke!), and those who don't should beware the Motif 1.0 documentation! Better yet, when are we going to see Motif code taking advantage of ANSI function prototyping? Russ Evans (address above)