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
master
David Lawrence Ramsey 2005-07-14 18:33:51 +00:00
parent 43cf7a1be3
commit d2361f0761
5 changed files with 23 additions and 23 deletions

View File

@ -48,7 +48,7 @@ CVS code -
screen when color support is enabled if there's no regex
associated with the current file. Changes to update_color()
(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:
open_file()
- Assert that filename isn't NULL, and don't do anything special

View File

@ -138,20 +138,21 @@ void color_update(void)
}
}
/* tmpcolor->startstr and tmpcolor->endstr have already been checked
* for validity elsewhere. Compile their associated regexes if we
* haven't already. */
/* tmpcolor->start_regex and tmpcolor->end_regex have already been
* checked for validity elsewhere. Compile their associated regexes
* if we haven't already. */
for (tmpcolor = openfile->colorstrings; tmpcolor != NULL;
tmpcolor = tmpcolor->next) {
if (tmpcolor->startstr != NULL) {
if (tmpcolor->start_regex != NULL) {
tmpcolor->start = (regex_t *)nmalloc(sizeof(regex_t));
nregcomp(tmpcolor->start, tmpcolor->startstr,
tmpcolor->icase ? REG_ICASE : 0);
regcomp(tmpcolor->start, tmpcolor->start_regex,
REG_EXTENDED | (tmpcolor->icase ? REG_ICASE : 0));
}
if (tmpcolor->endstr != NULL) {
if (tmpcolor->end_regex != NULL) {
tmpcolor->end = (regex_t *)nmalloc(sizeof(regex_t));
nregcomp(tmpcolor->end, tmpcolor->endstr,
tmpcolor->icase ? REG_ICASE : 0);
regcomp(tmpcolor->end, tmpcolor->end_regex,
REG_EXTENDED | (tmpcolor->icase ? REG_ICASE : 0));
}
}

View File

@ -1225,14 +1225,14 @@ void thanks_for_all_the_fish(void)
colortype *bob = syntaxes->color;
syntaxes->color = bob->next;
if (bob->startstr != NULL)
free(bob->startstr);
if (bob->start_regex != NULL)
free(bob->start_regex);
if (bob->start != NULL) {
regfree(bob->start);
free(bob->start);
}
if (bob->endstr != NULL)
free(bob->endstr);
if (bob->end_regex != NULL)
free(bob->end_regex);
if (bob->end != NULL) {
regfree(bob->end);
free(bob->end);

View File

@ -169,11 +169,11 @@ typedef struct colortype {
* insensitive? */
int pairnum; /* Color pair number used for this
* foreground/background. */
char *startstr; /* Start (or all) of the regex
char *start_regex; /* Start (or all) of the regex
* string. */
regex_t *start; /* Compiled start (or all) of the regex
* 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
* string. */
struct colortype *next;

View File

@ -329,16 +329,15 @@ void parse_syntax(char *ptr)
break;
newext = (exttype *)nmalloc(sizeof(exttype));
if (!nregcomp(&newext->val, fileregptr, REG_NOSUB))
free(newext);
else {
if (nregcomp(&newext->val, fileregptr, REG_NOSUB)) {
if (endext == NULL)
endsyntax->extensions = newext;
else
endext->next = newext;
endext = newext;
endext->next = NULL;
}
} else
free(newext);
}
}
@ -436,7 +435,7 @@ void parse_colors(char *ptr, bool icase)
/* Free this regex, now that we know it's valid, and save
* the original string, so that we can recompile this regex
* later as needed. */
newcolor->startstr = mallocstrcpy(NULL, fgstr);
newcolor->start_regex = mallocstrcpy(NULL, fgstr);
regfree(newcolor->start);
free(newcolor->start);
newcolor->start = NULL;
@ -445,7 +444,7 @@ void parse_colors(char *ptr, bool icase)
newcolor->bg = bg;
newcolor->bright = bright;
newcolor->icase = icase;
newcolor->endstr = NULL;
newcolor->end_regex = NULL;
newcolor->end = NULL;
newcolor->next = NULL;
@ -497,7 +496,7 @@ void parse_colors(char *ptr, bool icase)
/* Free this regex, now that we know it's valid, and
* save the original string, so that we can recompile
* this regex later as needed. */
newcolor->endstr = mallocstrcpy(NULL, fgstr);
newcolor->end_regex = mallocstrcpy(NULL, fgstr);
regfree(newcolor->end);
}