isnum(x) ? sprintf((char *)p, (char *)fmt, (int) getfval(x))
isnum(x) ? (getfval(x) ? sprintf((char *)p, (char *)fmt, (int) getfval(x)) : (*p++ = '\0', len++))
int format(char *buf, int bufsize, char *s, Node *a)	/* printf-like conversions */{	char fmt[RECSIZE];	char *p, *t, *os;	Cell *x;	int flag = 0, n;	os = s;	p = buf;	while (*s) {		if (p - buf >= bufsize)			return -1;		if (*s != '%') {			*p++ = *s++;			continue;		}		if (*(s+1) == '%') {			*p++ = '%';			s += 2;			continue;		}		for (t=fmt; (*t++ = *s) != '\0'; s++) {			if (isalpha(*s) && *s != 'l' && *s != 'h' && *s != 'L')				break;	/* the ansi panoply */			if (*s == '*') {				x = execute(a);				a = a->nnext;				sprintf((char *)t-1, "%d", (int) getfval(x));				t = fmt + strlen(fmt);				tempfree(x);			}		}		*t = '\0';		if (t >= fmt + sizeof(fmt))			ERROR "format item %.30s... too long", os FATAL;		switch (*s) {		case 'f': case 'e': case 'g': case 'E': case 'G':			flag = 1;			break;		case 'd': case 'i':			flag = 2;			if(*(s-1) == 'l') break;			*(t-1) = 'l';			*t = 'd';			*++t = '\0';			break;		case 'o': case 'x': case 'X': case 'u':			flag = *(s-1) == 'l' ? 2 : 3;			break;		case 's':			flag = 4;			break;		case 'c':			flag = 5;			break;		default:			ERROR "weird printf conversion %s", fmt WARNING;			flag = 0;			break;		}		if (a == NULL)			ERROR "not enough args in printf(%s)", os FATAL;		x = execute(a);		a = a->nnext;		switch (flag) {		case 0:	sprintf((char *)p, "%s", fmt);	/* unknown, so dump it too */			p += strlen(p);			sprintf((char *)p, "%s", getsval(x));			break;		case 1:	sprintf((char *)p, (char *)fmt, getfval(x)); break;		case 2:	sprintf((char *)p, (char *)fmt, (long) getfval(x)); break;		case 3:	sprintf((char *)p, (char *)fmt, (int) getfval(x)); break;		case 4:			t = getsval(x);			n = strlen(t);			if (n >= bufsize)				ERROR "huge string (%d chars) in printf %.30s...",					n, t FATAL;			sprintf((char *)p, (char *)fmt, t);			break;		case 5:			isnum(x) ? sprintf((char *)p, (char *)fmt, (int) getfval(x))				 : sprintf((char *)p, (char *)fmt, getsval(x)[0]);			break;		}		tempfree(x);		p += strlen(p);		s++;	}	*p = '\0';	for ( ; a; a = a->nnext)		/* evaluate any remaining args */		execute(a);	return 0;}