=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mg/util.c,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- src/usr.bin/mg/util.c 2011/01/17 03:12:06 1.27 +++ src/usr.bin/mg/util.c 2011/01/18 16:25:40 1.28 @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.27 2011/01/17 03:12:06 kjell Exp $ */ +/* $OpenBSD: util.c,v 1.28 2011/01/18 16:25:40 kjell Exp $ */ /* This file is in the public domain. */ @@ -451,5 +451,35 @@ while (curwp->w_doto < llength(curwp->w_dotp) && (isspace(lgetc(curwp->w_dotp, curwp->w_doto)))) ++curwp->w_doto; + return (TRUE); +} + +/* + * Join the current line to the previous, or with arg, the next line + * to the current one. If the former line is not empty, leave exactly + * one space at the joint. Otherwise, leave no whitespace. + */ +int +joinline(int f, int n) +{ + int doto; + + undo_boundary_enable(FFRAND, 0); + if (f & FFARG) { + gotoeol(FFRAND, 1); + forwdel(FFRAND, 1); + } else { + gotobol(FFRAND, 1); + backdel(FFRAND, 1); + } + + delwhite(FFRAND, 1); + + if ((doto = curwp->w_doto) > 0) { + linsert(1, ' '); + curwp->w_doto = doto; + } + undo_boundary_enable(FFRAND, 1); + return (TRUE); }