Sujet : Re: Command line globber/tokenizer library for C?
De : bc (at) *nospam* freeuk.com (Bart)
Groupes : comp.lang.cDate : 12. Sep 2024, 17:28:27
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vbv4ra$b0hv$2@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10
User-Agent : Mozilla Thunderbird
On 12/09/2024 16:16, Michael S wrote:
On Thu, 12 Sep 2024 14:44:03 +0100
Bart <bc@freeuk.com> 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.