From: David Lawrence Ramsey Date: Wed, 8 Jun 2005 21:17:32 +0000 (+0000) Subject: in parse_colors(), properly parse a background color without a X-Git-Tag: v1.3.8~185 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=7c78b45e7689962b1ff190b38cb0cc57a52aa4a2;p=nano.git in parse_colors(), properly parse a background color without a foreground color git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2618 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index d29abe6f..d742efa8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -136,6 +136,10 @@ CVS code - (DLR) - Don't set current_len until after it's been asserted that both current and current->data aren't NULL. (DLR) +- rcfile.c: + parse_colors() + - Properly parse a background color without a foreground color. + (DLR) - search.c: do_gotoline() - Properly show an error message if we try to go to line 0, @@ -197,6 +201,10 @@ CVS code - - doc/faq.html: - Update the question about the FAQ to mention the current maintainer. (DLR) +- doc/nanorc.sample: + - In the "nanorc" regexes, tweak the "color" regex to properly + color a line that specifies a background color without a + foreground color, and update the associated comments. (DLR) - doc/man/fr/Makefile.am: - Set mandir to @mandir@/fr, so French manpages get installed where they belong (Jordi). diff --git a/doc/nanorc.sample b/doc/nanorc.sample index d1596b39..de77e5cf 100644 --- a/doc/nanorc.sample +++ b/doc/nanorc.sample @@ -133,9 +133,10 @@ ## ## To use multi-line regexes use the start="regex" end="regex" format. ## -## If your system supports transparency, not specifying a background -## color will use a transparent color. If you don't want this, be sure -## to set the background color to black or white. +## Not specifying a foreground color will use the default foreground +## color. If your system supports transparency, not specifying a +## background color will use a transparent color. If you don't want the +## latter, be sure to set the background color to black or white. ## # syntax "c-file" "\.(c|C|cc|cpp|h|H|hh|hpp)$" # color red "\<[A-Z_]{2,}\>" @@ -264,7 +265,7 @@ # color cyan "^ *(set|unset) +(view|whitespace)" # color green "^ *(set|unset|syntax)\>" ## colors -# color yellow "^ *color +(bright)?(white|black|red|blue|green|yellow|magenta|cyan)(,(white|black|red|blue|green|yellow|magenta|cyan))?\>" +# color yellow "^ *color *(bright)?(white|black|red|blue|green|yellow|magenta|cyan)(,(white|black|red|blue|green|yellow|magenta|cyan))?\>" # color magenta "^ *color\>" "\<(start|end)=" ## strings # color white "\"(\\.|[^\"])*\"" diff --git a/src/rcfile.c b/src/rcfile.c index a6285124..3e5bd78c 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -353,7 +353,7 @@ void parse_syntax(char *ptr) void parse_colors(char *ptr) { int fg, bg; - bool bright = FALSE; + bool bright = FALSE, no_fgcolor = FALSE; char *fgstr; assert(ptr != NULL); @@ -368,8 +368,15 @@ void parse_colors(char *ptr) if (strchr(fgstr, ',') != NULL) { char *bgcolorname; + strtok(fgstr, ","); bgcolorname = strtok(NULL, ","); + if (bgcolorname == NULL) { + /* If we have a background color without a foreground color, + * parse it properly. */ + bgcolorname = fgstr + 1; + no_fgcolor = TRUE; + } if (strncasecmp(bgcolorname, "bright", 6) == 0) { rcfile_error( N_("Background color %s cannot be bright"), @@ -380,11 +387,14 @@ void parse_colors(char *ptr) } else bg = -1; - fg = color_to_int(fgstr, &bright); + if (!no_fgcolor) { + fg = color_to_int(fgstr, &bright); - /* Don't try to parse screwed-up foreground colors. */ - if (fg == -1) - return; + /* Don't try to parse screwed-up foreground colors. */ + if (fg == -1) + return; + } else + fg = -1; if (syntaxes == NULL) { rcfile_error(