moraes@CSRI.TORONTO.EDU (Mark Moraes) (04/06/89)
Sun and Ultrix sscanf()s (possibly other BSD derived Un*x sscanfs as well) attempt to write to the string passed in as argument 1. (It always writes the same character back as was already in the string, so it does not change the contents) This is because sscanf() functions with a parser similar to fscanf(), and invokes functions to push back on the input stream (ungetc()). Such programs, when compiled without -fwritable-strings with gcc, will get a SIGSEGV in ungetc() and die. Since the X toolkit converters for String to Int and String to Short use sscanf(), any X toolkit application which results in one of these converters being invoked will also suffer similarly. The simplest solution requires that you have source - fix ungetc() to not write to the string if the character being pushed back is the same as the one in the string. Alternatives involve making sure sscanf() is not called with constant strings as argument 1, (this is hard for things like toolkit resource initializers), using -fwritable-strings, or finding a public domain sscanf that actually works. (Be warned - sscanf is complex enough that testing it for conformance is a pain) This, and people calling mktemp() with a constant string argument, are common causes of core dumps when you compile programs with gcc. Sigh.