Path: utzoo!utgpu!attcan!uunet!seismo!sundc!pitstop!sun!quintus!ok From: ok@quintus.uucp (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: Re: sprintf(3s) query Message-ID: <878@quintus.UUCP> Date: 16 Dec 88 01:05:22 GMT References: <1102@entropy.ms.washington.edu> <8131@ihlpl.ATT.COM> <865@quintus.UUCP> <9181@smoke.BRL.MIL> Sender: news@quintus.UUCP Reply-To: ok@quintus.UUCP (Richard A. O'Keefe) Organization: Quintus Computer Systems, Inc. Lines: 26 In article <9181@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) writes: >#ifdef vax >char *sprintf(); /* too painful to do right */ >#endif > >Note that Sun MUST have changed this in order for it to apply to >their (definitely non-VAX) machines. In point of fact, at least as of SunOS 3.2, they DIDN'T. So much for "MUST". The effect is that in SunOS, if you wanted the buffer pointer, you had to explicitly declare sprintf() yourself. >I hope by now all the BSD code that depends on the value of >sprintf() being anything in particular has been changed to use >some other method. Usually, something like > buf[0] = '\0'; > (void)sprintf(buf, fmt, args); > if (buf[0] == '\0') > /* error */ >is sufficient (it works with both definitions of sprintf()). Except that it doesn't work with either. Consider sprintf("%.*s", len, ptr); when len happens to be 0. By the way, what _are_ the output error conditions that *printf() can detect other than by crashing?