Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!ut-sally!pyramid!decwrl!sun!guy From: guy@sun.uucp (Guy Harris) Newsgroups: net.lang.c Subject: Re: putw return value Message-ID: <7364@sun.uucp> Date: Wed, 17-Sep-86 14:42:41 EDT Article-I.D.: sun.7364 Posted: Wed Sep 17 14:42:41 1986 Date-Received: Fri, 19-Sep-86 23:25:58 EDT References: <102@hcx1.UUCP> Organization: Sun Microsystems, Inc. Lines: 36 > Question: What should "putw" return? > > Our I/O library returns the error code for the "putw" operation, which is > usually 0. In perusing BSD4.2 and ATT5.2.2 source, I see the same > functionality. Which probably means it predates both of them, and worked that way in the V7-vintage standard I/O library. This would indicate it's probably supposed to. > Yet the man pages seem to indicate that "putw" should return the "word" > written. The trouble with returning the value written is that if you write the value -1, this can't be distinguished from EOF (at least on UNIX implementations, and others where EOF is -1), and unless you *know* that you won't be writing that value, you have to call "ferror" on that stream to detect errors. > Is there a discrepancy between the code and the documentation? Well, if there isn't, how do you explain the fact that the code and documentation disagree? More likely, you meant "There is a discrepancy between the code and the documentation; which is correct?" to which the answer is, most likely, "The code, in this case; the code has been that way for a long time, though several variations of UNIX, and 'fixing' it to agree with the documentation would cause other problems." > (The Perennial C test suite makes mention in a "bugs" section that the > VAX 11/750 also returns "0" for putw in the particular test.) Which is a very odd way of putting it; did the people who did that test suite to work differently on a VAX-11/780, for instance? -- Guy Harris {ihnp4, decvax, seismo, decwrl, ...}!sun!guy guy@sun.com (or guy@sun.arpa)