Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Compiler warning after workers/39825
- X-seq: zsh-workers 39866
- From: Sebastian Gniazdowski <psprint@xxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: Compiler warning after workers/39825
- Date: Tue, 08 Nov 2016 00:36:47 -0800
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=mesmtp; bh=kPHesp8ZB4+2e15SSKP6v9AWtc I=; b=JUSRXcZDwfkRZMNRWVJz6t9Rgiie/58HMrb/AtsIJEsXToJy1QmHBYfaev ZMLWTsuaVaER32SoVBoghEqTXGsRyr1JzfLSbPo3YZ7C5VtsB3a3OrCJG5mk8V6u aLtpZ+NQu/FskFviYLpL0W+705EQfuvDeh5Om2OUfcVD79b/I=
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=smtpout; bh=kP Hesp8ZB4+2e15SSKP6v9AWtcI=; b=WWZHUV0CRvssfYm1q8XqsJ0lE1NN0w3/DJ BpnMazxUyPj9Hpw5Ll09qJ7WFEOvzjStqOK1HKlw8Bs6ot6YbpEvQSWujhW8Le2s 2GSy8AwWgQuK4j/DnalLRMpEACw/5YJyx78iYWiERzuWeKIzeZuir5QzrlAeJ7Sb QJBpE7pHw=
- In-reply-to: <161107155001.ZM25685@torch.brasslantern.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
- References: <161107155001.ZM25685@torch.brasslantern.com>
On Mon, Nov 7, 2016, at 03:50 PM, Bart Schaefer wrote:
> ../../zsh-5.0/Src/utils.c: In function `mb_metastrlenend':
> ../../zsh-5.0/Src/utils.c:5344: warning: comparison is always true due to
> limited range of data type
>
> commit 9c68ef08
Attached is patch that should work for both signed and unsigned
integers. Does it emit any warning?
On current system warmup the test results are 2141 ms vs 2337 ms,
slightly less than 10%, but still ~200 ms difference.
--
Sebastian Gniazdowski
psprint@xxxxxxxxxxxx
diff --git a/Src/utils.c b/Src/utils.c
index 733f570..32e7dc6 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -5341,7 +5341,12 @@ mb_metastrlenend(char *ptr, int width, char *eptr)
inchar = *ptr;
ptr++;
- if (complete && (inchar >= 0 && inchar <= 0x7f)) {
+ /*
+ * 0x7f is all ones except for top bit in binary,
+ * this will check if inchar is in range 0 .. 127
+ * inclusive, regardless of char signedness
+ */
+ if (complete && (inchar & 0x7f) == inchar) {
/*
* We rely on 7-bit US-ASCII as a subset, so skip
* multibyte handling if we have such a character.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author