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.
This commit is contained in:
Roberto E. Vargas Caballero 2016-01-07 11:37:56 +01:00 committed by sin
parent 78fd6ff239
commit 54ad6d512b

9
ed.c
View File

@ -404,8 +404,13 @@ match(int num)
static int static int
rematch(int num) rematch(int num)
{ {
lastmatch += matchs[0].rm_eo; regoff_t off = matchs[0].rm_eo;
return !regexec(pattern, lastmatch, 10, matchs, 0);
if (!regexec(pattern, lastmatch + off, 10, matchs, 0)) {
lastmatch += off;
return 1;
}
return 0;
} }
static int static int