From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2739 Path: news.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: Re: [PATCH 0/4] Refactor and expand string functions. Date: Tue, 5 Feb 2013 16:05:41 +0100 Message-ID: <20130205150541.GR6181@port70.net> References: <1359936735-31915-1-git-send-email-nwmcsween@gmail.com> <511089D1.1000803@gmail.com> <20130205111910.GQ6181@port70.net> <20130205140535.GE20323@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1360076754 11691 80.91.229.3 (5 Feb 2013 15:05:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 5 Feb 2013 15:05:54 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-2740-gllmg-musl=m.gmane.org@lists.openwall.com Tue Feb 05 16:06:15 2013 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1U2k68-00011n-CX for gllmg-musl@plane.gmane.org; Tue, 05 Feb 2013 16:06:12 +0100 Original-Received: (qmail 28165 invoked by uid 550); 5 Feb 2013 15:05:53 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 28157 invoked from network); 5 Feb 2013 15:05:53 -0000 Content-Disposition: inline In-Reply-To: <20130205140535.GE20323@brightrain.aerifal.cx> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:2739 Archived-At: * Rich Felker [2013-02-05 09:05:35 -0500]: > On Tue, Feb 05, 2013 at 12:19:10PM +0100, Szabolcs Nagy wrote: > > * Nathan McSween [2013-02-04 20:25:53 -0800]: > > > for (; (uintptr_t)cs % sizeof(size_t); cs++, n--) { > > > if (!n) return NULL; > > > if (*cs == c) return (void *)cs; > > > } > > > > > > for (w = (const size_t *)cs; !word_has_char(*w, c); w++, n--) > > > if (!n) return NULL; > > > > w++ but n-- does not seem right > > You mean it should be n -= sizeof(size_t) or whatever? > yes, or n -= sizeof *w if you want to save some chars :) and the if (!n) return NULL; is wrong as well once you go by words > Honestly I would prefer the whole inline function be replaced with > just a single-line macro that could be pasted where needed. IMO this > makes the code more readable because you don't have to go looking at > other functions. > > word_has_char, but it's obvious what it does from the name. (Still, I > prefer the original macro names, but that's just me; dunno what others > think.) > i agree > > i dont see how word_has_char works, the name suggests that > > it tests if w has c in it, but that's not what it does > > That's what it's supposed to do. > then the grouping is wrong - return !!((w - WORD_LSB_ONE) & ((~w & WORD_MSB_ONE)^(WORD_LSB_ONE * c))); + return !!(((w - WORD_LSB_ONE) & ~w & WORD_MSB_ONE) ^ (WORD_LSB_ONE * c)); but yes the original macros were cleaner