sbase

suckless unix tools
git clone git://git.2f30.org/sbase.git
Log | Files | Refs | README | LICENSE

commit b606ef5dbc614ba58d7bb994bc1cce6a6b443c17
parent 841838bc43f9eddcf6c801e2c34bb6b9aa42aceb
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu Jan  7 11:37:56 +0100

Fix rematch()

Rematch() was incremnenting the last match always, even in the
cases when it was not matching anything. This patch detects
this situation and it updates it only when there is a match.

Diffstat:
ed.c | 9+++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/ed.c b/ed.c @@ -404,8 +404,13 @@ match(int num) static int rematch(int num) { - lastmatch += matchs[0].rm_eo; - return !regexec(pattern, lastmatch, 10, matchs, 0); + regoff_t off = matchs[0].rm_eo; + + if (!regexec(pattern, lastmatch + off, 10, matchs, 0)) { + lastmatch += off; + return 1; + } + return 0; } static int