commit ba8f806705909cd028891eb5af136bd6a6f95697
parent c12d1b87d4ea775708178a0534ac99594b4ffaff
Author: Benno Schulenberg <bensberg@justemail.net>
Date: Fri, 4 Dec 2015 20:54:34 +0000
Fusing three functions into a single one.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5477 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Diffstat:
2 files changed, 29 insertions(+), 37 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,5 +1,7 @@
2015-12-03 Benno Schulenberg <bensberg@justemail.net>
* src/proto.h: Avoid a compilation warning.
+ * src/color.c (reset_multis_for_id, reset_multis_before/after):
+ Fuse these three functions into a single one.
2015-12-03 Benno Schulenberg <bensberg@justemail.net>
* src/text.c (discard_until): Move the trimming of the undo stack
diff --git a/src/color.c b/src/color.c
@@ -365,54 +365,44 @@ void color_update(void)
}
}
-/* Reset the multicolor info cache for records for any lines which need
- * to be recalculated. */
-void reset_multis_after(filestruct *fileptr, int mindex)
+/* Reset the multiline coloring cache for one specific regex (given by
+ * index) for lines that need reevaluation. */
+void reset_multis_for_id(filestruct *fileptr, int index)
{
- filestruct *oof;
- for (oof = fileptr->next; oof != NULL; oof = oof->next) {
- alloc_multidata_if_needed(oof);
- if (oof->multidata[mindex] != CNONE)
- oof->multidata[mindex] = -1;
- else
+ filestruct *row;
+
+ /* Reset the cache of earlier lines, as far back as needed. */
+ for (row = fileptr->prev; row != NULL; row = row->prev) {
+ alloc_multidata_if_needed(row);
+ if (row->multidata[index] == CNONE)
break;
+ row->multidata[index] = -1;
}
- for (; oof != NULL; oof = oof->next) {
- alloc_multidata_if_needed(oof);
- if (oof->multidata[mindex] == CNONE)
- oof->multidata[mindex] = -1;
- else
+ for (; row != NULL; row = row->prev) {
+ alloc_multidata_if_needed(row);
+ if (row->multidata[index] != CNONE)
break;
+ row->multidata[index] = -1;
}
- edit_refresh_needed = TRUE;
-}
-void reset_multis_before(filestruct *fileptr, int mindex)
-{
- filestruct *oof;
- for (oof = fileptr->prev; oof != NULL; oof = oof->prev) {
- alloc_multidata_if_needed(oof);
- if (oof->multidata[mindex] != CNONE)
- oof->multidata[mindex] = -1;
- else
+ /* Reset the cache of the current line. */
+ fileptr->multidata[index] = -1;
+
+ /* Reset the cache of later lines, as far ahead as needed. */
+ for (row = fileptr->next; row != NULL; row = row->next) {
+ alloc_multidata_if_needed(row);
+ if (row->multidata[index] == CNONE)
break;
+ row->multidata[index] = -1;
}
- for (; oof != NULL; oof = oof->prev) {
- alloc_multidata_if_needed(oof);
- if (oof->multidata[mindex] == CNONE)
- oof->multidata[mindex] = -1;
- else
+ for (; row != NULL; row = row->next) {
+ alloc_multidata_if_needed(row);
+ if (row->multidata[index] != CNONE)
break;
+ row->multidata[index] = -1;
}
- edit_refresh_needed = TRUE;
-}
-/* Reset one multiline regex info. */
-void reset_multis_for_id(filestruct *fileptr, int num)
-{
- reset_multis_before(fileptr, num);
- reset_multis_after(fileptr, num);
- fileptr->multidata[num] = -1;
+ edit_refresh_needed = TRUE;
}
/* Reset multi-line strings around the filestruct fileptr, trying to be