retiring gets(3)

Doug Gwyn gwyn at smoke.BRL.MIL
Thu Nov 10 11:13:02 AEST 1988


In article <1988Nov8.054845.23998 at utstat.uucp> geoff at utstat.uucp (Geoff Collyer) writes:
>We need to get ... the next release from your favourite C vendor to
>delete gets.

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.

I sympathize with the desire to encourage conversion to fgets(), but
attempts to force this down programmers' throats are misguided.  This
is an EDUCATIONAL issue and should be handled as one.  Otherwise you
will be as effective as the Libertarians were with their politics-
before-public-education approach.  Even if your philosophy is right,
you should get others to go along with it BEFORE trying to force them
to conform to it.

By the way, have you removed scanf() from your C library as well?  Or
sprintf()?  Or strcpy()?  They can be misused in the same way as gets().
Let us know how happy your customers are once ALL such routines are gone.

I think the appropriate treatment of gets() is to omit it from the
documentation or to document it with "Unless you have sufficient control
over the data being read to be sure that it will not overflow the buffer,
use fgets".  But leave it in the library.



More information about the Comp.lang.c mailing list