Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: IS_DASH() warning
- X-seq: zsh-workers 40819
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: IS_DASH() warning
- Date: Fri, 10 Mar 2017 09:46:37 +0000
- Cms-type: 201P
- In-reply-to: <CAH+w=7aLSXE5wHtnR-FvCJRVc19UC3aDWOrf2O+fjUZeR23csw@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Organization: Samsung Cambridge Solution Centre
- References: <CGME20170310072841epcas2p2340dcec5f380c88168d615f3df3de89d@epcas2p2.samsung.com> <CAH+w=7aLSXE5wHtnR-FvCJRVc19UC3aDWOrf2O+fjUZeR23csw@mail.gmail.com>
On Thu, 9 Mar 2017 23:27:36 -0800
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> glob.c:2398:10: warning: comparison of constant -101 with expression of type
> 'unsigned char' is always false
> [-Wtautological-constant-out-of-range-compare]
> if (IS_DASH(c1) && lastch >= 0 && p < str2 && lastch <= (int)c2) {
> ^~~~~~~~~~~
> ./zsh.h:248:39: note: expanded from macro 'IS_DASH'
> #define IS_DASH(x) ((x) == '-' || (x) == Dash)
> ~~~ ^ ~~~~
>
> (It's complaining about the comparison to Dash if proportional font
> misplaces the caret.)
I presume I'm not going to see this warning anyway, but Dash is cast to
char so the only obvious thing to do is cast c1, which is currently
unsigned. Alternatively, IS_DASH could be even more clumsy with casts
to both Dash and the input character to unsigned.
pws
diff --git a/Src/glob.c b/Src/glob.c
index 87127e1..0fcb4e1 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -2395,7 +2395,8 @@ xpandbraces(LinkList list, LinkNode *np)
c2 = ztokens[c2 - STOUC(Pound)];
if ((char) c2 == Meta)
c2 = 32 ^ p[1];
- if (IS_DASH(c1) && lastch >= 0 && p < str2 && lastch <= (int)c2) {
+ if (IS_DASH((char)c1) && lastch >= 0 &&
+ p < str2 && lastch <= (int)c2) {
while (lastch < (int)c2)
ccl[lastch++] = 1;
lastch = -1;
Messages sorted by:
Reverse Date,
Date,
Thread,
Author