From f792803d80ba58f12c9e94e9f569ab793ee4fa79 Mon Sep 17 00:00:00 2001 From: lum Date: Sat, 10 Oct 2015 09:13:14 +0000 Subject: [PATCH] Make functions that accept multiple iterations via C-u N, honour 0. Except C-k which has a defined behaviour. In mg, C-t doesn't complete n iterations if requested, but probably should, hence it has been included in this diff. --- usr.bin/mg/basic.c | 8 +++++++- usr.bin/mg/paragraph.c | 14 +++++++++++++- usr.bin/mg/util.c | 5 ++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/usr.bin/mg/basic.c b/usr.bin/mg/basic.c index 56cc517d3ef..85d9f70fce6 100644 --- a/usr.bin/mg/basic.c +++ b/usr.bin/mg/basic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: basic.c,v 1.46 2015/09/26 21:51:58 jasper Exp $ */ +/* $OpenBSD: basic.c,v 1.47 2015/10/10 09:13:14 lum Exp $ */ /* This file is in the public domain */ @@ -28,6 +28,9 @@ int gotobol(int f, int n) { + if (n == 0) + return (TRUE); + curwp->w_doto = 0; return (TRUE); } @@ -72,6 +75,9 @@ backchar(int f, int n) int gotoeol(int f, int n) { + if (n == 0) + return (TRUE); + curwp->w_doto = llength(curwp->w_dotp); return (TRUE); } diff --git a/usr.bin/mg/paragraph.c b/usr.bin/mg/paragraph.c index 14d695143fc..ed94b2261f0 100644 --- a/usr.bin/mg/paragraph.c +++ b/usr.bin/mg/paragraph.c @@ -1,4 +1,4 @@ -/* $OpenBSD: paragraph.c,v 1.40 2015/09/26 15:03:15 lum Exp $ */ +/* $OpenBSD: paragraph.c,v 1.41 2015/10/10 09:13:14 lum Exp $ */ /* This file is in the public domain. */ @@ -142,6 +142,9 @@ fillpara(int f, int n) struct line *eopline; /* pointer to line just past EOP */ char wbuf[MAXWORD]; /* buffer for current word */ + if (n == 0) + return (TRUE); + undo_boundary_enable(FFRAND, 0); /* record the pointer to the line just past the EOP */ @@ -267,6 +270,9 @@ killpara(int f, int n) { int lineno, status; + if (n == 0) + return (TRUE); + if (findpara() == FALSE) return (TRUE); @@ -298,6 +304,9 @@ markpara(int f, int n) { int i = 0; + if (n == 0) + return (TRUE); + clearmark(FFARG, 0); if (findpara() == FALSE) @@ -326,6 +335,9 @@ transposepara(int f, int n) int i = 0, status; char flg; + if (n == 0) + return (TRUE); + /* find a paragraph, set mark, then goto the end */ gotobop(FFRAND, 1); curwp->w_markp = curwp->w_dotp; diff --git a/usr.bin/mg/util.c b/usr.bin/mg/util.c index d5b5a06af14..64e9d7659e4 100644 --- a/usr.bin/mg/util.c +++ b/usr.bin/mg/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.36 2015/09/29 03:19:24 guenther Exp $ */ +/* $OpenBSD: util.c,v 1.37 2015/10/10 09:13:14 lum Exp $ */ /* This file is in the public domain. */ @@ -117,6 +117,9 @@ twiddle(int f, int n) struct line *dotp; int doto, cr; + if (n == 0) + return (TRUE); + dotp = curwp->w_dotp; doto = curwp->w_doto; -- 2.20.1