]> git.wh0rd.org Git - nano.git/commitdiff
add minor fixes to the new color code, and merge parts of Brand
authorDavid Lawrence Ramsey <pooka109@gmail.com>
Thu, 14 Jul 2005 18:33:51 +0000 (18:33 +0000)
committerDavid Lawrence Ramsey <pooka109@gmail.com>
Thu, 14 Jul 2005 18:33:51 +0000 (18:33 +0000)
Huntsman's old patch in where applicable

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2858 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

ChangeLog
src/color.c
src/global.c
src/nano.h
src/rcfile.c

index 99d867389cd5e3bcda39f840d09bc1d409bc9eb1..24138c2b614832d4a321618e13b3b594e26bdebb 100644 (file)
--- 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
index ccd5c9e6ef57c360c25033961e419313d54894b0..718110df2940f211d2a9ba9f443abc936a82aa89 100644 (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));
        }
     }
 
index f3c2b6e7742cef1eea695cee9741101770e2daa8..8772e599b86d70c3633a9e25ab0bbfb29de08e17 100644 (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);
index 323413478c2fdd105caaebff9578080b6b9536ed..a7374b25ea088551db8c3cdc2d327d5fc438a059 100644 (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;
index 347d346f283b3c1d85d2247b6fdb31ff08a9db21..a96744a2a9402494f212c35f47dfff95b594324f 100644 (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);
            }