diff --git a/src/color.c b/src/color.c index 2211ceb86112da19d3b6f8b37f3b6109b429c591..25c9603a16eb6fa9f39da3a6cf55ac70c1910e2c 100644 --- a/src/color.c +++ b/src/color.c @@ -260,9 +260,10 @@ void reset_multis_after(filestruct *fileptr, int mindex) { filestruct *oof; for (oof = fileptr->next; oof != NULL; oof = oof->next) { + alloc_multidata_if_needed(oof); if (oof->multidata == NULL) continue; - if (oof->multidata[mindex] != 0) + if (oof->multidata[mindex] != CNONE) oof->multidata[mindex] = -1; else break; @@ -273,9 +274,10 @@ 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 == NULL) continue; - if (oof->multidata[mindex] != 0) + if (oof->multidata[mindex] != CNONE) oof->multidata[mindex] = -1; else break; @@ -299,6 +301,7 @@ void reset_multis(filestruct *fileptr) if (tmpcolor->end == NULL) continue; + alloc_multidata_if_needed(fileptr); /* Figure out where the first begin and end are to determine if things changed drastically for the precalculated multi values */ nobegin = regexec(tmpcolor->start, fileptr->data, 1, &startmatch, 0); diff --git a/src/nano.h b/src/nano.h index e4beb8dc686ec96ccfd4182137d57d2bbbf168d1..0d725de57a8a4056cf74fc216ec57a2302d0c352 100644 --- a/src/nano.h +++ b/src/nano.h @@ -224,17 +224,17 @@ typedef struct syntaxtype { /* Next syntax. */ } syntaxtype; -#define CNONE (1<<0) +#define CNONE (1<<1) /* Yay, regex doesn't apply to this line at all! */ -#define CBEGINBEFORE (1<<1) +#define CBEGINBEFORE (1<<2) /* regex starts on an earlier line, ends on this one */ -#define CENDAFTER (1<<2) +#define CENDAFTER (1<<3) /* regex sraers on this line and ends on a later one */ -#define CWHOLELINE (1<<3) +#define CWHOLELINE (1<<4) /* whole line engulfed by the regex start < me, end > me */ -#define CSTARTENDHERE (1<<4) +#define CSTARTENDHERE (1<<5) /* regex starts and ends within this line */ -#define CWTF (1<<5) +#define CWTF (1<<6) /* Something else */ #endif /* ENABLE_COLOR */ diff --git a/src/proto.h b/src/proto.h index 0e9622759d3d714ce22911a774cb9a3340e77d2e..2328cc13af7d1d4cb178506af9b972aa5d7b1d54 100644 --- a/src/proto.h +++ b/src/proto.h @@ -544,6 +544,7 @@ void parse_include(char *ptr); short color_to_short(const char *colorname, bool *bright); void parse_colors(char *ptr, bool icase); void reset_multis(filestruct *fileptr); +void alloc_multidata_if_needed(filestruct *fileptr); #endif void parse_rcfile(FILE *rcstream #ifdef ENABLE_COLOR diff --git a/src/winio.c b/src/winio.c index 39a89811c35042e27973734d8b01a917f64df5ea..759b69e6899d6e856caa502714d18ad994b2c027 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2551,7 +2551,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int } k = startmatch.rm_eo; } - } else if (fileptr->multidata != NULL && fileptr->multidata[tmpcolor->id] != 0) { + } else if (fileptr->multidata != NULL && fileptr->multidata[tmpcolor->id] != CNONE) { /* This is a multi-line regex. There are two steps. * First, we have to see if the beginning of the line is * colored by a start on an earlier line, and an end on @@ -2571,7 +2571,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int short md = fileptr->multidata[tmpcolor->id]; if (md == -1) - fileptr->multidata[tmpcolor->id] = 0; /* until we find out otherwise */ + fileptr->multidata[tmpcolor->id] = CNONE; /* until we find out otherwise */ else if (md == CNONE) continue; else if (md == CWHOLELINE) {