=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mg/Attic/random.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- src/usr.bin/mg/Attic/random.c 2005/11/19 20:16:35 1.16 +++ src/usr.bin/mg/Attic/random.c 2005/11/22 05:02:44 1.17 @@ -1,4 +1,4 @@ -/* $OpenBSD: random.c,v 1.16 2005/11/19 20:16:35 kjell Exp $ */ +/* $OpenBSD: random.c,v 1.17 2005/11/22 05:02:44 kjell Exp $ */ /* This file is in the public domain. */ @@ -335,125 +335,6 @@ s = ldelete((RSIZE)n, (f & FFARG) ? KFORW : KNONE); return (s); -} - -/* - * Kill line. If called without an argument, it kills from dot to the end - * of the line, unless it is at the end of the line, when it kills the - * newline. If called with an argument of 0, it kills from the start of the - * line to dot. If called with a positive argument, it kills from dot - * forward over that number of newlines. If called with a negative argument - * it kills any text before dot on the current line, then it kills back - * abs(arg) lines. - */ -/* ARGSUSED */ -int -killline(int f, int n) -{ - struct line *nextp; - RSIZE chunk; - int i, c; - - /* clear kill buffer if last wasn't a kill */ - if ((lastflag & CFKILL) == 0) - kdelete(); - thisflag |= CFKILL; - if (!(f & FFARG)) { - for (i = curwp->w_doto; i < llength(curwp->w_dotp); ++i) - if ((c = lgetc(curwp->w_dotp, i)) != ' ' && c != '\t') - break; - if (i == llength(curwp->w_dotp)) - chunk = llength(curwp->w_dotp) - curwp->w_doto + 1; - else { - chunk = llength(curwp->w_dotp) - curwp->w_doto; - if (chunk == 0) - chunk = 1; - } - } else if (n > 0) { - chunk = llength(curwp->w_dotp) - curwp->w_doto + 1; - nextp = lforw(curwp->w_dotp); - i = n; - while (--i) { - if (nextp == curbp->b_linep) - break; - chunk += llength(nextp) + 1; - nextp = lforw(nextp); - } - } else { - /* n <= 0 */ - chunk = curwp->w_doto; - curwp->w_doto = 0; - i = n; - while (i++) { - if (lback(curwp->w_dotp) == curbp->b_linep) - break; - curwp->w_dotp = lback(curwp->w_dotp); - curwp->w_flag |= WFMOVE; - chunk += llength(curwp->w_dotp) + 1; - } - } - /* - * KFORW here is a bug. Should be KBACK/KFORW, but we need to - * rewrite the ldelete code (later)? - */ - return (ldelete(chunk, KFORW)); -} - -/* - * Yank text back from the kill buffer. This is really easy. All of the work - * is done by the standard insert routines. All you do is run the loop, and - * check for errors. The blank lines are inserted with a call to "newline" - * instead of a call to "lnewline" so that the magic stuff that happens when - * you type a carriage return also happens when a carriage return is yanked - * back from the kill buffer. An attempt has been made to fix the cosmetic - * bug associated with a yank when dot is on the top line of the window - * (nothing moves, because all of the new text landed off screen). - */ -/* ARGSUSED */ -int -yank(int f, int n) -{ - struct line *lp; - int c, i, nline; - - if (n < 0) - return (FALSE); - - /* newline counting */ - nline = 0; - - undo_add_boundary(); - undo_no_boundary(TRUE); - while (n--) { - /* mark around last yank */ - isetmark(); - i = 0; - while ((c = kremove(i)) >= 0) { - if (c == '\n') { - if (newline(FFRAND, 1) == FALSE) - return (FALSE); - ++nline; - } else { - if (linsert(1, c) == FALSE) - return (FALSE); - } - ++i; - } - } - /* cosmetic adjustment */ - lp = curwp->w_linep; - - /* if offscreen insert */ - if (curwp->w_dotp == lp) { - while (nline-- && lback(lp) != curbp->b_linep) - lp = lback(lp); - /* adjust framing */ - curwp->w_linep = lp; - curwp->w_flag |= WFHARD; - } - undo_no_boundary(FALSE); - undo_add_boundary(); - return (TRUE); } #ifdef NOTAB