Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Bart Newsgroups: comp.lang.c Subject: Re: Command line globber/tokenizer library for C? Date: Wed, 18 Sep 2024 10:49:38 +0100 Organization: A noiseless patient Spider Lines: 41 Message-ID: References: <20240912181625.00006e68@yahoo.com> <20240912223828.00005c10@yahoo.com> <861q1nfsjz.fsf@linuxsc.com> <20240915122211.000058b1@yahoo.com> <20240918024611.000002f3@yahoo.com> <20240918114305.00002317@yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 18 Sep 2024 11:49:38 +0200 (CEST) Injection-Info: dont-email.me; posting-host="521c9b697fde59071240119733a6c915"; logging-data="30124"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+v1UibUdSyWzLrzUdWmVYb" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:bXnrJQoLks3X6RrlfEs8SsTIll8= Content-Language: en-GB In-Reply-To: <20240918114305.00002317@yahoo.com> Bytes: 2871 On 18/09/2024 09:43, Michael S wrote: > On Wed, 18 Sep 2024 01:07:17 +0100 > Bart wrote: >> I find such a coding style pretty much impossible to grasp and >> unpleasant to look at. I had to refactor it like this: >> >> --------------- >> >> static_Bool collect_word(char *s, char *r, _Bool w, Gopher go ) { >> char c = *s; >> #if 1 >> if (c == 0) { >> go->f(go, r, s); >> return w; >> } >> if (is_space(c) && w) { >> go->f(go, r, s); >> return words_do(s, go); >> } >> return collect_word(s+1, r, (w ^ c) == '"', go); > > That's not how it was written in original. Should be: > return collect_word(s+1, r, w ^ c == '"', go); > Not the same thing at all. So, what you are saying is that it means 'w ^ (c == '"')'? Because there could be some ambiguity, I put in the brackets. I had to to guess the precedence and chose the one that seemed more plausible, but I guessed wrong. Mine version then should be: return collect_word(s+1, r, w ^ (c == '"'), go); > The same here. I'm surprised there weren't more typos, but that's not what my post was about which was presentation and layout.