🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #291

Re: Taming The Switch-Statement

#291
From: bart
Date: Mon, 12 Oct 2026 20:57
34 lines
2695 bytes
On 12/10/2026 20:52, Scott Lurndal wrote:
> bart <bc@freeuk.com> writes:
>> On 12/10/2026 18:58, Dan Cross wrote:
>>> In article <11ainqf$3kkvd$1@dont-email.me>, bart  <bc@freeuk.com> wrote:
>>
> 
>> This is my first example expressed in C (note those first three args are
>> passed by reference):
>>
>>      while (pmtype = nextcmdparam(&paramno, &name, &value, "m") {
>>          switch (pmtype)
>>          case pm_option: ...; break;
>>          case pm_sourcefile:
>>              if (passlevel == run_pass || passlevel == runpcl_pass) {
>>                  break;
> 
> Aside from the incorrect syntax, it's really difficult to
> determine your intent from this code fragment.

Really? It's attempting to break out of the while-loop from inside that 
switch statement. What we've been discussing at length.

But it won't work like this because in this context, that 'break' is 
switch-break not loop-break.


> It's likely that folks here could provide more idiomatic
> C if you described the problem you're attempting to solve
> rather than providing an incomplete and incorrect code
> fragment.

I'd be interested in the idiomatic C that doesn't involve rewriting my 
code or adding complexity in order to get around that silly clash.
Technical Details
Message-ID: <11ajhka$3vuli$1@dont-email.me>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <119qf6l$2rmg3$1@dont-email.me> <11agils$2s3tg$1@dont-email.me> <11ahpqi$38ir0$2@dont-email.me> <11ainqf$3kkvd$1@dont-email.me> <11aj73v$c2u$1@reader2.panix.com> <11ajcv8$3u33s$1@dont-email.me> <GTazS.183760$ygUb.176068@fx23.iad>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: bart <bc@freeuk.com>
Newsgroups: comp.lang.c
Subject: Re: Taming The Switch-Statement
Date: Mon, 12 Oct 2026 21:57:46 +0100
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <11ajhka$3vuli$1@dont-email.me>
References: <119qf6l$2rmg3$1@dont-email.me> <11agils$2s3tg$1@dont-email.me>
 <11ahpqi$38ir0$2@dont-email.me> <11ainqf$3kkvd$1@dont-email.me>
 <11aj73v$c2u$1@reader2.panix.com> <11ajcv8$3u33s$1@dont-email.me>
 <GTazS.183760$ygUb.176068@fx23.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 12 Oct 2026 20:57:47 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="4192946"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+FhDGTGG5vmE+w1+lqnW26"; posting-host="77c9fe16ce3505b18aae67dd9ba4b8ee"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:U7urFyi9mKRTLpqRAlSz7XLk4fU= sha256:zOlkTg8wQ0NsQFU8IC1l+jX7wRWNSt7Oo0qMXvfAKJ0=
	sha1:Ehy5zMcTHgxCAPOSAu0ELHxq2g4= sha256:oHcr/34syScS2TdWMdDFHdEOA5nANE22OMxhtmqJnRI=
In-Reply-To: <GTazS.183760$ygUb.176068@fx23.iad>
Content-Language: en-GB