splitup = !ccl && (vs_sm_cursor(sp, &smp) ? 0 : smp - HMAP) > half;
splitup = !ccl && (vs_sm_cursor(sp, &smp) ? 0 : (smp - HMAP) + 1) >= half;
vs_split(sp, new, ccl)	SCR *sp, *new;	int ccl;		/* Colon-command line split. */{	GS *gp;	SMAP *smp;	size_t half;	int issmallscreen, splitup;	gp = sp->gp;	/* Check to see if it's possible. */	if (sp->rows < 4) {		msgq(sp, M_ERR,		    "222|Screen must be larger than %d lines to split", 4 - 1);		return (1);	}	/* Wait for any messages in the screen. */	vs_resolve(sp, 1);	half = sp->rows / 2;	if (ccl && half > 6)		half = 6;	/* Get a new screen map. */	CALLOC(sp, _HMAP(new), SMAP *, SIZE_HMAP(sp), sizeof(SMAP));	if (_HMAP(new) == NULL)		return (1);	_HMAP(new)->lno = sp->lno;	_HMAP(new)->coff = 0;	_HMAP(new)->soff = 1;	/*	 * Small screens: see vs_refresh.c section 6a.  Set a flag so	 * we know to fix the screen up later.	 */	issmallscreen = IS_SMALL(sp);	/* The columns in the screen don't change. */	new->cols = sp->cols;	/*	 * Split the screen, and link the screens together.  If creating a	 * screen to edit the colon command line or the cursor is in the top	 * half of the current screen, the new screen goes under the current	 * screen.  Else, it goes above the current screen.	 *	 * Recalculate current cursor position based on sp->lno, we're called	 * with the cursor on the colon command line.  Then split the screen	 * in half and update the shared information.	 */	splitup = !ccl && (vs_sm_cursor(sp, &smp) ? 0 : smp - HMAP) > half;	if (splitup) {				/* Old is bottom half. */		new->rows = sp->rows - half;	/* New. */		new->woff = sp->woff;		sp->rows = half;		/* Old. */		sp->woff += new->rows;						/* Link in before old. */		CIRCLEQ_INSERT_BEFORE(&gp->dq, sp, new, q);		/*		 * If the parent is the bottom half of the screen, shift		 * the map down to match on-screen text.		 */		memmove(_HMAP(sp), _HMAP(sp) + new->rows,		    (sp->t_maxrows - new->rows) * sizeof(SMAP));	} else {				/* Old is top half. */		new->rows = half;		/* New. */		sp->rows -= half;		/* Old. */		new->woff = sp->woff + sp->rows;						/* Link in after old. */		CIRCLEQ_INSERT_AFTER(&gp->dq, sp, new, q);	}	/* Adjust maximum text count. */	sp->t_maxrows = IS_ONELINE(sp) ? 1 : sp->rows - 1;	new->t_maxrows = IS_ONELINE(new) ? 1 : new->rows - 1;	/*	 * Small screens: see vs_refresh.c, section 6a.	 *	 * The child may have different screen options sizes than the parent,	 * so use them.  Guarantee that text counts aren't larger than the	 * new screen sizes.	 */	if (issmallscreen) {		/* Fix the text line count for the parent. */		if (splitup)			sp->t_rows -= new->rows;		/* Fix the parent screen. */		if (sp->t_rows > sp->t_maxrows)			sp->t_rows = sp->t_maxrows;		if (sp->t_minrows > sp->t_maxrows)			sp->t_minrows = sp->t_maxrows;		/* Fix the child screen. */		new->t_minrows = new->t_rows = O_VAL(sp, O_WINDOW);		if (new->t_rows > new->t_maxrows)			new->t_rows = new->t_maxrows;		if (new->t_minrows > new->t_maxrows)			new->t_minrows = new->t_maxrows;	} else {		sp->t_minrows = sp->t_rows = IS_ONELINE(sp) ? 1 : sp->rows - 1;		/*		 * The new screen may be a small screen, even if the parent		 * was not.  Don't complain if O_WINDOW is too large, we're		 * splitting the screen so the screen is much smaller than		 * normal.		 */		new->t_minrows = new->t_rows = O_VAL(sp, O_WINDOW);		if (new->t_rows > new->rows - 1)			new->t_minrows = new->t_rows =			    IS_ONELINE(new) ? 1 : new->rows - 1;	}	/* Adjust the ends of the new and old maps. */	_TMAP(sp) = IS_ONELINE(sp) ?	    _HMAP(sp) : _HMAP(sp) + (sp->t_rows - 1);	_TMAP(new) = IS_ONELINE(new) ?	    _HMAP(new) : _HMAP(new) + (new->t_rows - 1);	/* Reset the length of the default scroll. */	if ((sp->defscroll = sp->t_maxrows / 2) == 0)		sp->defscroll = 1;	if ((new->defscroll = new->t_maxrows / 2) == 0)		new->defscroll = 1;	/*	 * Initialize the screen flags:	 *	 * If we're in vi mode in one screen, we don't have to reinitialize.	 * This isn't just a cosmetic fix.  The path goes like this:	 *	 *	return into vi(), SC_SSWITCH set	 *	call vs_refresh() with SC_STATUS set	 *	call vs_resolve to display the status message	 *	call vs_refresh() because the SC_SCR_VI bit isn't set	 *	 * Things go downhill at this point.	 *	 * Draw the new screen from scratch, and add a status line.	 */	F_SET(new,	    SC_SCR_REFORMAT | SC_STATUS |	    F_ISSET(sp, SC_EX | SC_VI | SC_SCR_VI | SC_SCR_EX));	return (0);}