INTRODUCTION
Having been burned several times by the behaviour of sprintf,
I have just finished testing a new version, called snprintf,
and sxprintf, which have the exact functionality of sprintf,
but do bound checking.

In doing this, I discovered a couple of minor coding glitches in the
_doprnt() routine.  It was written in assembler, and the authors
have my sympathy.   I have the funniest feeling that many of the
sections of the conversion routines were DEC VMS sources.
It uses many of the very baroque VAX instructions...

In the following directory, the file doprnt.s.diff was generated using
diff -e /usr/src/lib/libc/vax/stdio/doprnt.s doprnt.s >doprint.s.diff
It can be regenerated using
ed /usr.....doprnt.s <doprnt.s.diff

COPY the ORGINAL doprnt.s before you do the ed, it gets trompped on.

In addition, note a minor bug fix with sscanf, the IORD flag is not needed.
And will cause REAL problems.
	Patrick Powell,
	U. Waterloo, VLSI Design Group,
	Waterloo Ont.

SUMMARY

snprintf( count, str, format, args )
	int count; char *str, *format, ...;
Exact functionality of sprintf, but will only generate count characters,
including trailing 0.  If it fails, it returns a NULL, otherwise it
returns s.

sxprintf( count, str, format, args )
	int count; char *str, *format, ...;
This has the exact functionality of snprintf, in that it does bound checking.
It does not append a trailing 0, and allows very nice reformatting of
fixed field items.

INSTALLATION
1. copy the snprintf.c,sxprintf.c,sprintf.c to /usr/src/lib/libc/stdio
	NOTE: save the old versions, you might want them.
2. copy doprnt.s to /usr/src/lib/libc/vax/stdio
3. update the lint library, by copying the llib-lc to
	/usr/src/usr.lib/lint/llib-lc, and then making the new lint libs
5. compile the lc library (moan).
	Actually, you can shorten this by using the make file,
	which has a quick "update" entry.  This does an "ar u *.o"
	on the object files and the /usr/lib/llibc

What are the benefits?
1. A bombproof version of the stdio library routines that does bounds
	checking.


Patrick ("I hate sprintf") Powell

