if (strlen(old) >= (unsigned)maxstr) { strncpy(edit->buffer, old, maxstr); edit->buffer[maxstr] = '\0'; StrLen = maxstr; } else { strcpy(edit->buffer, old); }
LYstrncpy(edit->buffer, old, maxstr); StrLen = strlen(edit->buffer);
PUBLIC void LYSetupEdit ARGS4(	EDREC *,	edit,	char *, 	old,	int,		maxstr,	int,		maxdsp){    /*     *	Initialize edit record     */    LYGetYX(edit->sy, edit->sx);    edit->pad	= ' ';    edit->dirty = TRUE;    edit->panon = FALSE;    StrLen  = strlen(old);    MaxLen  = maxstr;    DspWdth = maxdsp;    Margin  = 0;    Pos = strlen(old);    DspStart = 0;    if (maxstr > maxdsp) {  /* Need panning? */	if (DspWdth > 4)    /* Else "{}" take up precious screen space */	    edit->panon = TRUE;	/*	 *  Figure out margins.  If too big, we do a lot of unnecessary	 *  scrolling.	If too small, user doesn't have sufficient	 *  look-ahead.  Let's say 25% for each margin, upper bound is	 *  10 columns.	 */	Margin = DspWdth/4;	if (Margin > 10)	    Margin = 10;    }    /*     *	We expect the called function to pass us a default (old) value     *	with a length that is less than or equal to maxstr, and to     *	handle any messaging associated with actions to achieve that     *	requirement.  However, in case the calling function screwed     *	up, we'll check it here, and ensure that no buffer overrun can     *	occur by loading only as much of the head as fits. - FM     */    if (strlen(old) >= (unsigned)maxstr) {	strncpy(edit->buffer, old, maxstr);	edit->buffer[maxstr] = '\0';	StrLen = maxstr;    } else {	strcpy(edit->buffer, old);    }}