rem: if ((str = tigetstr(p)) && str != (char *)-1) argv = process(p, str, argv); else if ((n = tigetnum(p)) != -2) (void)printf("%d\n", n); else if ((n = tigetflag(p)) != -1) exitval = !n;  else if ((str = tgetstr(p, NULL))) argv = process(p, str, argv);
add: cptr = buf; if (tgetstr(p, &cptr)) argv = process(p, buf, argv);
context: main(int argc, char *argv[]){	int ch, exitval, n, Sflag, Vflag;	char *p, *term, *str;	char **oargv;	oargv = argv;	term = NULL;	Sflag = Vflag = exitval = 0;	while ((ch = getopt(argc, argv, "VST:")) != -1)		switch(ch) {		case 'T':			term = optarg;			break;		case 'S':			Sflag = 1;			break;		/*<Jan-Rixt> 25/09/2003 version of ncursus*/			case 'V':			Vflag = 1;			break;		case '?':		default:			usage();		}	argc -= optind;	argv += optind;	if (Sflag && argc > 0)		usage();	if (!term && !(term = getenv("TERM")))		fprintf(stderr, "No value for $TERM and no -T specified");	/*	 * NOTE: tgetent() will call setupterm() and set ospeed for us	 * (this is ncurses-specific behavior)	 */	if (tgetent(NULL, term) != 1)		fprintf(stderr, "Unknown terminal type `%s'", term);	if (strcmp(__progname, "clear") == 0) {		if (Sflag)			usage();		argv = oargv;		*argv = __progname;		*(argv+1) = NULL;	}	if (Sflag) {		char **av;		/* Build new argv based on stdin */		argc = n = 0;		av = NULL;		str = malloc(1024);		while (fgets(str,1024,stdin) && (str[0] != '!')) {			if (str[strlen(str)-1] != '\n')				fprintf(stderr, "premature EOF");			str[strlen(str)-1] = '\0';			/* grow av as needed */			if (argc + 1 >= n) {				n += 64;				av = (char **)realloc(av, sizeof(char *) * n);				if (av == NULL)					fprintf(stderr, "out of memory 1");			}			/*<Jan-Rixt> 25/09/2003 adaption needed for OpenBeOs*/			p = strtok(str," ");			while (p != NULL) {				if (*p != '\0' && (av[argc++] = strdup(p)) == NULL)					fprintf(stderr, "out of memory 2");				p = strtok(NULL, " \t");			}		}		if (argc > 0) {		av[argc] = NULL;			argv = av;		}	}	if(Vflag)	{		printf("%s\n",curses_version());	}	while ((p = *argv++)) {		switch (*p) {		case 'i':			if (!strcmp(p, "init")) {				init();				continue;			}			break;		case 'l':			if (!strcmp(p, "longname")) {				puts(longname());				continue;			}			break;		case 'r':			if (!strcmp(p, "reset")) {				reset();				continue;			}			break;		}		/* First try as terminfo */		if ((str = tigetstr(p)) && str != (char *)-1)			argv = process(p, str, argv);		else if ((n = tigetnum(p)) != -2)			(void)printf("%d\n", n);		else if ((n = tigetflag(p)) != -1)			exitval = !n;		/* Then fall back on termcap */		else if ((str = tgetstr(p, NULL)))			argv = process(p, str, argv);		else if ((n = tgetnum(p)) != -1)			(void)printf("%d\n", n);		else if ((exitval = tgetflag(p)) != 0)			exitval = !exitval;		else {			(void)printf("Unknown terminfo capability `%s'\n", p);			exitval = 4;		}	}	exit(exitval);}