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: Thu, 12 Sep 2024 17:28:27 +0100 Organization: A noiseless patient Spider Lines: 32 Message-ID: References: <20240912181625.00006e68@yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 12 Sep 2024 18:28:26 +0200 (CEST) Injection-Info: dont-email.me; posting-host="3a3e703b62fd17d38a4df729837e6247"; logging-data="361023"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19qbuWI/5A4GSbXyxSStSES" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:b/vpnpvn6nIygPHmob4f+AcvCKM= Content-Language: en-GB In-Reply-To: <20240912181625.00006e68@yahoo.com> Bytes: 2719 On 12/09/2024 16:16, Michael S wrote: > On Thu, 12 Sep 2024 14:44:03 +0100 > Bart wrote: > Apart from unnecessary ilen limit, of unnecessary goto into block (I > have nothing against forward gotos out of blocks, but gotos into blocks > make me nervous) and of variable 'length' that serves no purpose, your > code simply does not fulfill requirements of OP. > I can immediately see two gotchas: no handling of escaped double > quotation marks \" and no handling of single quotation marks. Quite > possibly there are additional omissions. BM's C++ version doesn't handle embedded quotes or single quotes either. Neither expand wildcards into sequences of filename arguments. But you're right about 'length' which in the end was not used. It makes the C version even smaller without it. I wasn't trying to match the OP's requirements, as I don't know what they are. If this has to exactly match how the OS parses the command line into separate parameters, then that's likely to be a significantly more complex program, especially if it is to run on Linux. There's probably no point in trying to create such program; you'd need to find a way of utilising the OS to do the work. Note that I wasn't posting to solve the OP's problem, but as a counter-example to that C++ code which literally hurt my eyes to look at.