Commit d2361f07 authored by David Lawrence Ramsey's avatar David Lawrence Ramsey
Browse files

add minor fixes to the new color code, and merge parts of Brand

Huntsman's old patch in where applicable


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2858 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 23 additions and 23 deletions
+23 -23
...@@ -48,7 +48,7 @@ CVS code - ...@@ -48,7 +48,7 @@ CVS code -
screen when color support is enabled if there's no regex screen when color support is enabled if there's no regex
associated with the current file. Changes to update_color() associated with the current file. Changes to update_color()
(renamed color_update()), thanks_for_all_the_fish(), (renamed color_update()), thanks_for_all_the_fish(),
do_input(), and do_output(), (DLR) do_input(), and do_output(). (Brand Huntsman and DLR)
- files.c: - files.c:
open_file() open_file()
- Assert that filename isn't NULL, and don't do anything special - Assert that filename isn't NULL, and don't do anything special
......
...@@ -138,20 +138,21 @@ void color_update(void) ...@@ -138,20 +138,21 @@ void color_update(void)
} }
} }
/* tmpcolor->startstr and tmpcolor->endstr have already been checked /* tmpcolor->start_regex and tmpcolor->end_regex have already been
* for validity elsewhere. Compile their associated regexes if we * checked for validity elsewhere. Compile their associated regexes
* haven't already. */ * if we haven't already. */
for (tmpcolor = openfile->colorstrings; tmpcolor != NULL; for (tmpcolor = openfile->colorstrings; tmpcolor != NULL;
tmpcolor = tmpcolor->next) { tmpcolor = tmpcolor->next) {
if (tmpcolor->startstr != NULL) { if (tmpcolor->start_regex != NULL) {
tmpcolor->start = (regex_t *)nmalloc(sizeof(regex_t)); tmpcolor->start = (regex_t *)nmalloc(sizeof(regex_t));
nregcomp(tmpcolor->start, tmpcolor->startstr, regcomp(tmpcolor->start, tmpcolor->start_regex,
tmpcolor->icase ? REG_ICASE : 0); REG_EXTENDED | (tmpcolor->icase ? REG_ICASE : 0));
} }
if (tmpcolor->endstr != NULL) {
if (tmpcolor->end_regex != NULL) {
tmpcolor->end = (regex_t *)nmalloc(sizeof(regex_t)); tmpcolor->end = (regex_t *)nmalloc(sizeof(regex_t));
nregcomp(tmpcolor->end, tmpcolor->endstr, regcomp(tmpcolor->end, tmpcolor->end_regex,
tmpcolor->icase ? REG_ICASE : 0); REG_EXTENDED | (tmpcolor->icase ? REG_ICASE : 0));
} }
} }
......
...@@ -1225,14 +1225,14 @@ void thanks_for_all_the_fish(void) ...@@ -1225,14 +1225,14 @@ void thanks_for_all_the_fish(void)
colortype *bob = syntaxes->color; colortype *bob = syntaxes->color;
syntaxes->color = bob->next; syntaxes->color = bob->next;
if (bob->startstr != NULL) if (bob->start_regex != NULL)
free(bob->startstr); free(bob->start_regex);
if (bob->start != NULL) { if (bob->start != NULL) {
regfree(bob->start); regfree(bob->start);
free(bob->start); free(bob->start);
} }
if (bob->endstr != NULL) if (bob->end_regex != NULL)
free(bob->endstr); free(bob->end_regex);
if (bob->end != NULL) { if (bob->end != NULL) {
regfree(bob->end); regfree(bob->end);
free(bob->end); free(bob->end);
......
...@@ -169,11 +169,11 @@ typedef struct colortype { ...@@ -169,11 +169,11 @@ typedef struct colortype {
* insensitive? */ * insensitive? */
int pairnum; /* Color pair number used for this int pairnum; /* Color pair number used for this
* foreground/background. */ * foreground/background. */
char *startstr; /* Start (or all) of the regex char *start_regex; /* Start (or all) of the regex
* string. */ * string. */
regex_t *start; /* Compiled start (or all) of the regex regex_t *start; /* Compiled start (or all) of the regex
* string. */ * string. */
char *endstr; /* End (if any) of the regex string. */ char *end_regex; /* End (if any) of the regex string. */
regex_t *end; /* Compiled end (if any) of the regex regex_t *end; /* Compiled end (if any) of the regex
* string. */ * string. */
struct colortype *next; struct colortype *next;
......
...@@ -329,16 +329,15 @@ void parse_syntax(char *ptr) ...@@ -329,16 +329,15 @@ void parse_syntax(char *ptr)
break; break;
newext = (exttype *)nmalloc(sizeof(exttype)); newext = (exttype *)nmalloc(sizeof(exttype));
if (!nregcomp(&newext->val, fileregptr, REG_NOSUB)) if (nregcomp(&newext->val, fileregptr, REG_NOSUB)) {
free(newext);
else {
if (endext == NULL) if (endext == NULL)
endsyntax->extensions = newext; endsyntax->extensions = newext;
else else
endext->next = newext; endext->next = newext;
endext = newext; endext = newext;
endext->next = NULL; endext->next = NULL;
} } else
free(newext);
} }
} }
...@@ -436,7 +435,7 @@ void parse_colors(char *ptr, bool icase) ...@@ -436,7 +435,7 @@ void parse_colors(char *ptr, bool icase)
/* Free this regex, now that we know it's valid, and save /* Free this regex, now that we know it's valid, and save
* the original string, so that we can recompile this regex * the original string, so that we can recompile this regex
* later as needed. */ * later as needed. */
newcolor->startstr = mallocstrcpy(NULL, fgstr); newcolor->start_regex = mallocstrcpy(NULL, fgstr);
regfree(newcolor->start); regfree(newcolor->start);
free(newcolor->start); free(newcolor->start);
newcolor->start = NULL; newcolor->start = NULL;
...@@ -445,7 +444,7 @@ void parse_colors(char *ptr, bool icase) ...@@ -445,7 +444,7 @@ void parse_colors(char *ptr, bool icase)
newcolor->bg = bg; newcolor->bg = bg;
newcolor->bright = bright; newcolor->bright = bright;
newcolor->icase = icase; newcolor->icase = icase;
newcolor->endstr = NULL; newcolor->end_regex = NULL;
newcolor->end = NULL; newcolor->end = NULL;
newcolor->next = NULL; newcolor->next = NULL;
...@@ -497,7 +496,7 @@ void parse_colors(char *ptr, bool icase) ...@@ -497,7 +496,7 @@ void parse_colors(char *ptr, bool icase)
/* Free this regex, now that we know it's valid, and /* Free this regex, now that we know it's valid, and
* save the original string, so that we can recompile * save the original string, so that we can recompile
* this regex later as needed. */ * this regex later as needed. */
newcolor->endstr = mallocstrcpy(NULL, fgstr); newcolor->end_regex = mallocstrcpy(NULL, fgstr);
regfree(newcolor->end); regfree(newcolor->end);
} }
......
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