if (O_STR(sp, cnt) != NULL && o_set(sp, cnt, OS_DEF | OS_STRDUP, O_STR(sp, cnt), 0))
if (O_STR(sp, cnt) != NULL && o_set(sp, cnt, OS_DEF | OS_NOFREE | OS_STRDUP, O_STR(sp, cnt), 0))
opts_init(sp, oargs)	SCR *sp;	int *oargs;{	ARGS *argv[2], a, b;	OPTLIST const *op;	u_long v;	int cnt, optindx;	char *s, b1[1024];	a.bp = b1;	b.bp = NULL;	a.len = b.len = 0;	argv[0] = &a;	argv[1] = &b;	/* Set numeric and string default values. */#define	OI(indx, str) {							\	if (str != b1)		/* GCC puts strings in text-space. */	\		(void)strcpy(b1, str);					\	a.len = strlen(b1);						\	if (opts_set(sp, argv, NULL)) {					\		 optindx = indx;					\		goto err;						\	}								\}	/*	 * Indirect global options to global space.  Specifically, set up	 * terminal, lines, columns first, they're used by other options.	 * Note, don't set the flags until we've set up the indirection.	 */	if (o_set(sp, O_TERM, 0, NULL, GO_TERM))		goto err;	F_SET(&sp->opts[O_TERM], OPT_GLOBAL);	if (o_set(sp, O_LINES, 0, NULL, GO_LINES))		goto err;	F_SET(&sp->opts[O_LINES], OPT_GLOBAL);	if (o_set(sp, O_COLUMNS, 0, NULL, GO_COLUMNS))		goto err;	F_SET(&sp->opts[O_COLUMNS], OPT_GLOBAL);	if (o_set(sp, O_SECURE, 0, NULL, GO_SECURE))		goto err;	F_SET(&sp->opts[O_SECURE], OPT_GLOBAL);	/* Initialize string values. */	(void)snprintf(b1, sizeof(b1),	    "cdpath=%s", (s = getenv("CDPATH")) == NULL ? ":" : s);	OI(O_CDPATH, b1);	/*	 * !!!	 * Vi historically stored temporary files in /var/tmp.  We store them	 * in /tmp by default, hoping it's a memory based file system.  There	 * are two ways to change this -- the user can set either the directory	 * option or the TMPDIR environmental variable.	 */	(void)snprintf(b1, sizeof(b1),	    "directory=%s", (s = getenv("TMPDIR")) == NULL ? _PATH_TMP : s);	OI(O_DIRECTORY, b1);	OI(O_ESCAPETIME, "escapetime=1");	OI(O_KEYTIME, "keytime=6");	OI(O_MATCHTIME, "matchtime=7");	(void)snprintf(b1, sizeof(b1), "msgcat=%s", _PATH_MSGCAT);	OI(O_MSGCAT, b1);	OI(O_REPORT, "report=5");	OI(O_PARAGRAPHS, "paragraphs=IPLPPPQPP LIpplpipbp");	(void)snprintf(b1, sizeof(b1), "path=%s", "");	OI(O_PATH, b1);	(void)snprintf(b1, sizeof(b1), "recdir=%s", _PATH_PRESERVE);	OI(O_RECDIR, b1);	OI(O_SECTIONS, "sections=NHSHH HUnhsh");	(void)snprintf(b1, sizeof(b1),	    "shell=%s", (s = getenv("SHELL")) == NULL ? _PATH_BSHELL : s);	OI(O_SHELL, b1);	OI(O_SHELLMETA, "shellmeta=~{[*?$`'\"\\");	OI(O_SHIFTWIDTH, "shiftwidth=8");	OI(O_SIDESCROLL, "sidescroll=16");	OI(O_TABSTOP, "tabstop=8");	(void)snprintf(b1, sizeof(b1), "tags=%s", _PATH_TAGS);	OI(O_TAGS, b1);	/*	 * XXX	 * Initialize O_SCROLL here, after term; initializing term should	 * have created a LINES/COLUMNS value.	 */	if ((v = (O_VAL(sp, O_LINES) - 1) / 2) == 0)		v = 1;	(void)snprintf(b1, sizeof(b1), "scroll=%ld", v);	OI(O_SCROLL, b1);	/*	 * The default window option values are:	 *		8 if baud rate <=  600	 *	       16 if baud rate <= 1200	 *	LINES - 1 if baud rate  > 1200	 *	 * Note, the windows option code will correct any too-large value	 * or when the O_LINES value is 1.	 */	if (sp->gp->scr_baud(sp, &v))		return (1);	if (v <= 600)		v = 8;	else if (v <= 1200)		v = 16;	else		v = O_VAL(sp, O_LINES) - 1;	(void)snprintf(b1, sizeof(b1), "window=%lu", v);	OI(O_WINDOW, b1);	/*	 * Set boolean default values, and copy all settings into the	 * the default information.	 */	for (op = optlist, cnt = 0; op->name != NULL; ++op, ++cnt)		switch (op->type) {		case OPT_0BOOL:			break;		case OPT_1BOOL:			O_SET(sp, cnt);			O_D_SET(sp, cnt);			break;		case OPT_NUM:			o_set(sp, cnt, OS_DEF, NULL, O_VAL(sp, cnt));			break;		case OPT_STR:			if (O_STR(sp, cnt) != NULL && o_set(sp,			    cnt, OS_DEF | OS_STRDUP, O_STR(sp, cnt), 0))				goto err;			break;		default:			abort();		}	/*	 * !!!	 * Some options can be initialized by the command name or the	 * command-line arguments.  They don't set the default values,	 * it's historic practice.	 */	for (; *oargs != -1; ++oargs)		OI(*oargs, optlist[*oargs].name);	return (0);#undef OIerr:	msgq(sp, M_ERR,	    "031|Unable to set default %s option", optlist[optindx].name);	return (1);}