V10/libc/stdio/snprintf.c

Compare this file to the similar file:
Show the results in this format:

/*
 * pANS stdio -- sprintf
 */
#include "iolib.h"
int snprintf(char *buf, int len, const char *fmt, ...){
	int n;
	va_list args;
	char *v;
#ifdef V10
	FILE _strbuf;
	_strbuf._flag = _IOWRT+_IOSTRG;
	_strbuf._ptr = (unsigned char *) buf;
	_strbuf._cnt = len;
#define f &_strbuf
#define sclose(x) buf[n] = 0
#else
	FILE *f=sopenw();
	if(f==NULL)
		return 0;
	setvbuf(f, buf, _IOFBF, len);
#endif
	va_start(args, fmt);
	n=vfprintf(f, fmt, args);
	va_end(args);
	sclose(f);
	return n;
}