Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: IS_DASH() warning



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