rem: for (cp = str, arg_need = popcount = 0; *cp != '\0'; cp++) { if (*cp == '%') { switch (*++cp) { case '%': cp++; break; case 'i': if (popcount < 2) popcount = 2; break; case 'p': cp++; if (isdigit(cp[1]) && popcount < cp[1] - '0') popcount = cp[1] - '0'; break; case 'd': case 's': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '.': case '+': arg_need++; break; default: break; } }
add: for (cp = str, arg_need = 0; *cp != '\0'; cp++) if (*cp == '%') switch (*++cp) { case 'd': case '2': case '3': case '.': case '+': arg_need++; break; case '%': case '>': case 'i': case 'r': case 'n': case 'B': case 'D': break; default:  fprintf(stderr, erresc, *cp, cap); }   switch (arg_need) { case 0: (void)tputs(str, 1, outc); break; case 1: arg_cols = 0;  if (*++argv == NULL || *argv[0] == '\0') fprintf(stderr, errfew); arg_rows = atoi(*argv);  (void)tputs(tgoto(str, arg_cols, arg_rows), 1, outc); break; case 2: if (*++argv == NULL || *argv[0] == '\0') fprintf(stderr, errfew); arg_rows = atoi(*argv);  if (*++argv == NULL || *argv[0] == '\0') fprintf(stderr, errfew); arg_cols = atoi(*argv);  (void) tputs(tgoto(str, arg_cols, arg_rows), arg_rows, outc); break;  default: fprintf(stderr, errmany);
context: process(char *cap, char *str, char **argv){	char *cp, *s, *nargv[9];	int arg_need, popcount, i;	/* Count how many values we need for this capability. */	for (cp = str, arg_need = popcount = 0; *cp != '\0'; cp++) {		if (*cp == '%') {			switch (*++cp) {			case '%':			   	cp++;				break;			case 'i':				if (popcount < 2)					popcount = 2;				break;			case 'p':				cp++;				if (isdigit(cp[1]) && popcount < cp[1] - '0')					popcount = cp[1] - '0';				break;			case 'd':			case 's':			case '0':			case '1':			case '2':			case '3':			case '4':			case '5':			case '6':			case '7':			case '8':			case '9':			case '.':			case '+':				arg_need++;				break;			default:				break;			}		}	}	arg_need = MAX(arg_need, popcount);	if (arg_need > 9)		fprintf(stderr, "too many arguments (%d) for capability `%s'",		    arg_need, cap);		for (i = 0; i < arg_need; i++) {		long l;		if (argv[i] == NULL)			fprintf(stderr, "not enough arguments (%d) for capability `%s'",			    arg_need, cap);		/* convert ascii representation of numbers to longs */		if (isdigit(argv[i][0]) && (l = strtol(argv[i], &cp, 10)) >= 0		    && l < LONG_MAX && *cp == '\0')			nargv[i] = (char *)l;		else			nargv[i] = argv[i];	}	s = tparm(str, nargv[0], nargv[1], nargv[2], nargv[3],	    nargv[4], nargv[5], nargv[6], nargv[7], nargv[8]);	putp(s);	fflush(stdout);	return (argv + arg_need);}