[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Nano-devel] [PATCH] small addition: understand color name "normal"
From: |
Brand Huntsman |
Subject: |
Re: [Nano-devel] [PATCH] small addition: understand color name "normal" to mean the default color |
Date: |
Fri, 30 Mar 2018 03:34:59 -0600 |
On Fri, 30 Mar 2018 11:00:24 +0200
Benno Schulenberg <address@hidden> wrote:
> Op 29-03-18 om 11:23 schreef Brand Huntsman:
> > On Tue, 27 Mar 2018 13:55:38 +0200
> > Benno Schulenberg <address@hidden> wrote:
> >> + if (*bg == -2)
> >> + *bg = -1;
> >
> > Why is this conditional at the bottom where it will always execute
> > instead of immediately after the call to color_to_short that sets
> > bg to -2?
>
> Yes, that was a silly place to put it. Thanks for reporting.
>
> But... there is something strange. When the background color is
> invalid (say, "onion"), it falls back to the default color, but when
> this name is prefixed with "bright" ("brightonion"), the whole
> command gets rejected.
>
> I think it should handle both cases the same. I think it makes the
> most sense to reject a color command whenever something is wrong with
> it. So I have pushed a change that does that: commit cbf22647.
Ya, I sent a patch a month ago to fix that.
http://lists.gnu.org/archive/html/nano-devel/2018-03/txt3TUQ80c18P.txt
The -2 check should happen before the bright background check. A returned error
should be handled before any return value validations.
And why did you remove the comment on invalid fg check? You are making the code
harder to read by using meaningless error values and then not commenting why
the code returns false for a -2. There should be comments on fg and bg checks
or better yet, replace all -2 instances with an INVALID_COLOR macro.