SCCS oddity

Guy Harris guy at rlgvax.UUCP
Sun Nov 11 02:20:16 AEST 1984


> In the course of installing the user-contributed program "bib" on
> 4.2bsd, I found a most puzzling bug....
> 
> Investigation revealed that an intermediate file was being scanned for
> keyword entries by
> 
>     sscanf(line,"%s%s83/03/29D", key, file, &start, &length);
> 
> ...it is immediately obvious :-) that the file was originally maintained
> using SCCS, and that the authors had originally written
> 
>     sscanf(line,"%s%s%D%D", key, file, &start, &length);
> 
> The %D% was then translated by SCCS to the current date!
> 
> ...or that a standard tool like SCCS has been designed so as to be able
> to break a perfectly reasonable piece of code.

SCCS was originally done under a version of UNIX (PWB/UNIX 1.0, if not
an even earlier version) that may only have supported "%ld" for printing
long ints, or which advertised "%ld" as the preferred method.  V7 supported
both, but mentioned "%D" first, which may have induced people to use it.
System III got rid of "%D", supporting only "%ld", because they changed
"%X" to mean "use capital A-F for the digits 10 through 15").  Moral: don't
use "%D", use "%ld" instead - not only will it keep SCCS from breaking your
code (unless another routine uses "%D" in strings), but it will make it
more likely that your code will work under USDL UNIX.  (While you're at it,
don't assume "sprintf" returns a pointer to the buffer it filled in, either.)

> Addendum:
> 
> My investigation of "bib" was sparked off by discovering that "addbib"
> is also completely (but trivially) broken in the 4.2bsd release, since
> it fails to clear the EOF condition after reading an abstract...

I've seen a later version of the 4.2BSD Standard I/O library, in which it
seems they backed the "sticky EOF" change out.  Sort of like Bell backing the
"sorry, only one external declaration" change to the UNIX C implementation
out of System V.

	Guy Harris
	{seismo,ihnp4,allegra}!rlgvax!guy



More information about the Comp.unix.wizards mailing list