From 5d27910d6d1352cdb1d454ce1751758642c9cfe1 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Mon, 7 Dec 2015 15:40:07 +0000 Subject: [PATCH] Quitting the loop when there is no end match. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5488 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 3 +++ src/winio.c | 21 +++++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 48e87232..06a981f3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2015-12-07 Benno Schulenberg + * src/winio.c (edit_draw): Quit the loop when there is no end match. + GNU nano 2.5.0 - 2015.12.05 2015-12-05 Chris Allegretta diff --git a/src/winio.c b/src/winio.c index 42543b79..75960b2a 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2738,20 +2738,21 @@ void edit_draw(filestruct *fileptr, const char *converted, int 0, NULL, 0) == REG_NOMATCH) end_line = end_line->next; - if (end_line != NULL) { - assert(0 <= x_start && x_start < COLS); + /* If there is no end, we're done on this line. */ + if (end_line == NULL) + break; - mvwaddnstr(edit, line, x_start, - converted + index, -1); - fileptr->multidata[tmpcolor->id] = CENDAFTER; + assert(0 <= x_start && x_start < COLS); + + /* Paint the rest of the line. */ + mvwaddnstr(edit, line, x_start, converted + index, -1); + fileptr->multidata[tmpcolor->id] = CENDAFTER; #ifdef DEBUG fprintf(stderr, " Marking for id %i line %i as CENDAFTER\n", tmpcolor->id, line); #endif - /* We painted to the end of the line, so - * don't bother checking any more starts. */ - break; - } - start_col = startmatch.rm_so + 1; + /* We've painted to the end of the line, so don't + * bother checking for any more starts. */ + break; } } } -- 2.39.5