*BSD News Article 18922


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!agate!toe.CS.Berkeley.EDU!bostic
From: bostic@toe.CS.Berkeley.EDU (Keith Bostic)
Newsgroups: comp.os.386bsd.questions
Subject: Re: Using gets() [ Was Re: nn ]
Date: 27 Jul 1993 12:30:00 GMT
Organization: University of California, Berkeley
Lines: 44
Message-ID: <233748$qa8@agate.berkeley.edu>
References: <CAKu2r.10rt@austin.ibm.com> <CAq222.8E4@sugar.NeoSoft.COM> <22u6tmINN2t6@xs4all.hacktic.nl> <CAsEpH.55o@sugar.NeoSoft.COM>
NNTP-Posting-Host: toe.cs.berkeley.edu

In article <CAsEpH.55o@sugar.NeoSoft.COM> peter@NeoSoft.com (Peter da Silva) writes:
>In article <22u6tmINN2t6@xs4all.hacktic.nl> cor@hacktic.nl (Cor) writes:
>> peter@NeoSoft.com (Peter da Silva) writes:
>> >I agree. gets should work as documented, but it should probably be stuck
>> >in an "obsolete" library, to be linked in as "-lobso" for programs that
>> >use broken functions. Stick strtok in there as well :>.
>
>> Phew, at least *some* people that agree with my original posting.
>
>Not entirely. I think gets() should be made non-functional unless you
>make an explicit choice to pull it in. I just think that this breakage
>should occur at compile time, not run time.

I agree in principle, but it isn't possible.  ANSI C requires the
gets() function in the C library, so requiring the user to specify
that they wish to use it explicitly at compile time isn't possible.

Even if it were possible, some people would simply put in the
#define instead of fixing the code.

The only choice left to the developer is to make it sufficiently
annoying that it won't be used.  Which, ah, we did.  ;-}

Another point is that it's incredibly trivial to fix, the excuse
of not having the resources simply isn't relevant here.

I also agree about strtok(3).  The "programmer" that thought it
would be a good idea to have a string field interface that:

	+ wasn't reentrant
	+ couldn't be used by library code
	+ couldn't detect empty/leading fields

should have their feet held to the fire.  Use strsep(3) from the
4BSD releases instead.


        Keith Bostic                    bostic@cs.berkeley.edu
        CSRG                            +1-510-642-4948
        Department of EECS
        University of California
        Berkeley, CA  94720