Commit 66945350 authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

painting: when skipping a zero-length match, skip a character, not a byte

parent 9de376de
Showing with 14 additions and 12 deletions
+14 -12
...@@ -2384,9 +2384,10 @@ void edit_draw(filestruct *fileptr, const char *converted, ...@@ -2384,9 +2384,10 @@ void edit_draw(filestruct *fileptr, const char *converted,
REG_NOMATCH) REG_NOMATCH)
break; break;
/* Skip over a zero-length regex match. */ /* If the match is of length zero, skip it. */
if (startmatch.rm_so == startmatch.rm_eo) { if (startmatch.rm_so == startmatch.rm_eo) {
index += startmatch.rm_eo + 1; index = move_mbright(fileptr->data,
index + startmatch.rm_eo);
continue; continue;
} }
...@@ -2484,10 +2485,11 @@ void edit_draw(filestruct *fileptr, const char *converted, ...@@ -2484,10 +2485,11 @@ void edit_draw(filestruct *fileptr, const char *converted,
/* Begin searching for an end after the start match. */ /* Begin searching for an end after the start match. */
index += startmatch.rm_eo; index += startmatch.rm_eo;
/* If the start match is zero-length, don't get stuck. */ /* If the start match is zero-length, don't get stuck. */
if (startmatch.rm_so == startmatch.rm_eo) if (startmatch.rm_so == startmatch.rm_eo) {
if (++index > linelen) index = move_mbright(start_line->data, index);
if (index > linelen)
break; break;
}
/* If there is no end after this last start, good. */ /* If there is no end after this last start, good. */
if (regexec(varnish->end, start_line->data + index, if (regexec(varnish->end, start_line->data + index,
0, NULL, REG_NOTBOL) == REG_NOMATCH) 0, NULL, REG_NOTBOL) == REG_NOMATCH)
...@@ -2578,13 +2580,13 @@ void edit_draw(filestruct *fileptr, const char *converted, ...@@ -2578,13 +2580,13 @@ void edit_draw(filestruct *fileptr, const char *converted,
#endif #endif
} }
index = endmatch.rm_eo; index = endmatch.rm_eo;
/* Skip over a zero-length match. */ /* If the end match is of length zero, step ahead. */
if (endmatch.rm_so == endmatch.rm_eo) if (endmatch.rm_so == endmatch.rm_eo) {
index += 1; index = move_mbright(fileptr->data, index);
if (index > linelen) if (index > linelen)
break; break;
else }
continue; continue;
} }
/* There is no end on this line. But maybe on later lines? */ /* There is no end on this line. But maybe on later lines? */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment