memmove(bp, p, len);
memcpy(bp, p, len);
ex_move(sp, cmdp)	SCR *sp;	EXCMD *cmdp;{	LMARK *lmp;	MARK fm1, fm2;	recno_t cnt, diff, fl, tl, mfl, mtl;	size_t blen, len;	int mark_reset;	char *bp, *p;	NEEDFILE(sp, cmdp);	/*	 * It's not possible to move things into the area that's being	 * moved.	 */	fm1 = cmdp->addr1;	fm2 = cmdp->addr2;	if (cmdp->lineno >= fm1.lno && cmdp->lineno <= fm2.lno) {		msgq(sp, M_ERR, "139|Destination line is inside move range");		return (1);	}	/*	 * Log the positions of any marks in the to-be-deleted lines.  This	 * has to work with the logging code.  What happens is that we log	 * the old mark positions, make the changes, then log the new mark	 * positions.  Then the marks end up in the right positions no matter	 * which way the log is traversed.	 *	 * XXX	 * Reset the MARK_USERSET flag so that the log can undo the mark.	 * This isn't very clean, and should probably be fixed.	 */	fl = fm1.lno;	tl = cmdp->lineno;	/* Log the old positions of the marks. */	mark_reset = 0;	for (lmp = sp->ep->marks.lh_first; lmp != NULL; lmp = lmp->q.le_next)		if (lmp->name != ABSMARK1 &&		    lmp->lno >= fl && lmp->lno <= tl) {			mark_reset = 1;			F_CLR(lmp, MARK_USERSET);			(void)log_mark(sp, lmp);		}	/* Get memory for the copy. */	GET_SPACE_RET(sp, bp, blen, 256);	/* Move the lines. */	diff = (fm2.lno - fm1.lno) + 1;	if (tl > fl) {				/* Destination > source. */		mfl = tl - diff;		mtl = tl;		for (cnt = diff; cnt--;) {			if (db_get(sp, fl, DBG_FATAL, &p, &len))				return (1);			BINC_RET(sp, bp, blen, len);			memmove(bp, p, len);			if (db_append(sp, 1, tl, bp, len))				return (1);			if (mark_reset)				for (lmp = sp->ep->marks.lh_first;				    lmp != NULL; lmp = lmp->q.le_next)					if (lmp->name != ABSMARK1 &&					    lmp->lno == fl)						lmp->lno = tl + 1;			if (db_delete(sp, fl))				return (1);		}	} else {				/* Destination < source. */		mfl = tl;		mtl = tl + diff;		for (cnt = diff; cnt--;) {			if (db_get(sp, fl, DBG_FATAL, &p, &len))				return (1);			BINC_RET(sp, bp, blen, len);			memmove(bp, p, len);			if (db_append(sp, 1, tl++, bp, len))				return (1);			if (mark_reset)				for (lmp = sp->ep->marks.lh_first;				    lmp != NULL; lmp = lmp->q.le_next)					if (lmp->name != ABSMARK1 &&					    lmp->lno == fl)						lmp->lno = tl;			++fl;			if (db_delete(sp, fl))				return (1);		}	}	FREE_SPACE(sp, bp, blen);	sp->lno = tl;				/* Last line moved. */	sp->cno = 0;	/* Log the new positions of the marks. */	if (mark_reset)		for (lmp = sp->ep->marks.lh_first;		    lmp != NULL; lmp = lmp->q.le_next)			if (lmp->name != ABSMARK1 &&			    lmp->lno >= mfl && lmp->lno <= mtl)				(void)log_mark(sp, lmp);	sp->rptlines[L_MOVED] += diff;	return (0);}