[comp.windows.x] sscanf and gcc

moraes@cs.toronto.edu (Mark Moraes) (02/12/90)

mouse@LARRY.MCRCIM.MCGILL.EDU (der Mouse) writes:
>> Reason: puzzle calls sscanf() with a constant string argument.
>> Fix: use gcc -fwritable-strings.
>Proper fix: use a non-broken stdio that doesn't stamp on strings passed
>to sscanf().  (Finding such a stdio may not be entirely trivial, alas.)

For those who have source to their libc (or a BSD4.[23] libc, or SysV
libc, since they seem to be identical in this regard) a simple fix is
to change ungetc to not write the character to the string if the
character is the same as what's in the string (only decrement the
buffer pointer)

We then add something like

        #define BandAidLibraryNeeded YES
        #define BandAidLibrarySources ungetc.c
        #define BandAidLibraryObjects ungetc.o
        #define BandAidLibraryMake()    /* nothing to do here */

to our site.def and put the fixed ungetc.c in mit/lib/X. Seems to work
fine. (We don't compile with -fwritable-strings)