From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 24655 invoked from network); 30 May 2022 05:18:47 -0000 Received: from 9front.inri.net (168.235.81.73) by inbox.vuxu.org with ESMTPUTF8; 30 May 2022 05:18:47 -0000 Received: from mimir.eigenstate.org ([206.124.132.107]) by 9front; Mon May 30 01:15:30 -0400 2022 Received: from abbatoir.myfiosgateway.com (pool-74-108-56-225.nycmny.fios.verizon.net [74.108.56.225]) by mimir.eigenstate.org (OpenSMTPD) with ESMTPSA id 52d8a877 (TLSv1.2:ECDHE-RSA-AES256-SHA:256:NO) for <9front@9front.org>; Sun, 29 May 2022 22:15:21 -0700 (PDT) Message-ID: To: 9front@9front.org Date: Mon, 30 May 2022 01:15:20 -0400 From: ori@eigenstate.org In-Reply-To: <20220522180436.6c17d808@spruce.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: stateless deep-learning cache hosting Subject: Re: [9front] [PATCH] silence drawterm runestrchr while(assign) warning Reply-To: 9front@9front.org Precedence: bulk Quoth Amavect : > Hi, > > I want to shut up drawterm compile warnings without resorting to -Wno. > I'll rationalize this with reducing function sizes by bytes, > "improving readability", and micro optimizations for kencc. > > Here are some basic transformations on strchr and runestrchr. > It reduces 9front function byte sizes on the arches I tested > (amd64 0x4f->0x43, arm 0x50->0x40, power 0x68->0x5c). > It shuts up a gcc warning about runestrchr while(c1 = *s++) > (when compiled without -Wno-parentheses) > Attached are patches for 9front and drawterm. > Below are the full functions for criticism. Looks fine to me, thanks. Committed locally, will push tomorrow after I take a second, well rested look. Will also toss your unit tests into the regress test repo. > Thanks, > Amavect > > > char* > strchr(char *s, int c) > { > char r; > > if(c == 0) > while(*s++) > ; > else > while((r = *s++) != c) > if(r == 0) > return 0; > return s-1; > } > > > Rune* > runestrchr(Rune *s, Rune c) > { > Rune r; > > if(c == 0) > while(*s++) > ; > else > while((r = *s++) != c) > if(r == 0) > return 0; > return s-1; > } > > > unit test: > > #include > #include > > void > main(void) > { > char *v = "foo bar ss"; > char *e; > Rune *c = L"foo βαρ ß"; > Rune *t; > > e = strchr(v, L'z'); > assert(e == nil); > e = strchr(v, L'a'); > assert(e == v+5); > e = strchr(v, 0); > assert(e == v+10); > > t = runestrchr(c, L'z'); > assert(t == nil); > t = runestrchr(c, L'α'); > assert(t == c+5); > t = runestrchr(c, 0); > assert(t == c+9); > } >