retiring gets(3)

mcdonald at uxe.cso.uiuc.edu mcdonald at uxe.cso.uiuc.edu
Sat Nov 12 06:34:00 AEST 1988



>gets() is deliberately required for ANSI C standard conformance because
>a LOT of existing code relies on it.  Any vendor who omits this function
>will not be standard conforming and will not sell its compiler to those
>(expected to be MANY customers) who specify standard conformance.

How about fixing this, and the scanf and strcpy problems as well,
by a little outside-the-standard kludge? (Okay, I realize that every
time I suggest something like this, somebody tries to roast me,
but I am flameproof.) That is

#pragma _MAX_STRING_LENGTH=256  /*or some other suitable number*/

and the compiler would call special versions of gets, strcpy,
and cohorts, that stopped at such a maximum. Now I am not sure whether
the result of overrun would have to be a fatal error or whether
it could just stop copying, but that would at least prevent 
old bugs from biting too bad.



More information about the Comp.lang.c mailing list