Commit 7c78b45e authored by David Lawrence Ramsey's avatar David Lawrence Ramsey
Browse files

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
No related merge requests found
Showing with 28 additions and 9 deletions
+28 -9
...@@ -136,6 +136,10 @@ CVS code - ...@@ -136,6 +136,10 @@ CVS code -
(DLR) (DLR)
- Don't set current_len until after it's been asserted that both - Don't set current_len until after it's been asserted that both
current and current->data aren't NULL. (DLR) current and current->data aren't NULL. (DLR)
- rcfile.c:
parse_colors()
- Properly parse a background color without a foreground color.
(DLR)
- search.c: - search.c:
do_gotoline() do_gotoline()
- Properly show an error message if we try to go to line 0, - Properly show an error message if we try to go to line 0,
...@@ -197,6 +201,10 @@ CVS code - ...@@ -197,6 +201,10 @@ CVS code -
- doc/faq.html: - doc/faq.html:
- Update the question about the FAQ to mention the current - Update the question about the FAQ to mention the current
maintainer. (DLR) 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: - doc/man/fr/Makefile.am:
- Set mandir to @mandir@/fr, so French manpages get installed - Set mandir to @mandir@/fr, so French manpages get installed
where they belong (Jordi). where they belong (Jordi).
......
...@@ -133,9 +133,10 @@ ...@@ -133,9 +133,10 @@
## ##
## To use multi-line regexes use the start="regex" end="regex" format. ## To use multi-line regexes use the start="regex" end="regex" format.
## ##
## If your system supports transparency, not specifying a background ## Not specifying a foreground color will use the default foreground
## color will use a transparent color. If you don't want this, be sure ## color. If your system supports transparency, not specifying a
## to set the background color to black or white. ## 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)$" # syntax "c-file" "\.(c|C|cc|cpp|h|H|hh|hpp)$"
# color red "\<[A-Z_]{2,}\>" # color red "\<[A-Z_]{2,}\>"
...@@ -264,7 +265,7 @@ ...@@ -264,7 +265,7 @@
# color cyan "^ *(set|unset) +(view|whitespace)" # color cyan "^ *(set|unset) +(view|whitespace)"
# color green "^ *(set|unset|syntax)\>" # color green "^ *(set|unset|syntax)\>"
## colors ## 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)=" # color magenta "^ *color\>" "\<(start|end)="
## strings ## strings
# color white "\"(\\.|[^\"])*\"" # color white "\"(\\.|[^\"])*\""
......
...@@ -353,7 +353,7 @@ void parse_syntax(char *ptr) ...@@ -353,7 +353,7 @@ void parse_syntax(char *ptr)
void parse_colors(char *ptr) void parse_colors(char *ptr)
{ {
int fg, bg; int fg, bg;
bool bright = FALSE; bool bright = FALSE, no_fgcolor = FALSE;
char *fgstr; char *fgstr;
assert(ptr != NULL); assert(ptr != NULL);
...@@ -368,8 +368,15 @@ void parse_colors(char *ptr) ...@@ -368,8 +368,15 @@ void parse_colors(char *ptr)
if (strchr(fgstr, ',') != NULL) { if (strchr(fgstr, ',') != NULL) {
char *bgcolorname; char *bgcolorname;
strtok(fgstr, ","); strtok(fgstr, ",");
bgcolorname = strtok(NULL, ","); 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) { if (strncasecmp(bgcolorname, "bright", 6) == 0) {
rcfile_error( rcfile_error(
N_("Background color %s cannot be bright"), N_("Background color %s cannot be bright"),
...@@ -380,11 +387,14 @@ void parse_colors(char *ptr) ...@@ -380,11 +387,14 @@ void parse_colors(char *ptr)
} else } else
bg = -1; 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. */ /* Don't try to parse screwed-up foreground colors. */
if (fg == -1) if (fg == -1)
return; return;
} else
fg = -1;
if (syntaxes == NULL) { if (syntaxes == NULL) {
rcfile_error( rcfile_error(
......
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