From: David Lawrence Ramsey Date: Thu, 14 Jul 2005 18:33:51 +0000 (+0000) Subject: add minor fixes to the new color code, and merge parts of Brand X-Git-Tag: v1.3.9~188 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=d2361f0761f318ad1cfb41a6ee9d2d158226abaa;p=nano.git 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 --- diff --git a/ChangeLog b/ChangeLog index 99d86738..24138c2b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/src/color.c b/src/color.c index ccd5c9e6..718110df 100644 --- a/src/color.c +++ b/src/color.c @@ -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)); } } diff --git a/src/global.c b/src/global.c index f3c2b6e7..8772e599 100644 --- a/src/global.c +++ b/src/global.c @@ -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); diff --git a/src/nano.h b/src/nano.h index 32341347..a7374b25 100644 --- a/src/nano.h +++ b/src/nano.h @@ -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; diff --git a/src/rcfile.c b/src/rcfile.c index 347d346f..a96744a2 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -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); }