Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c
Subject: Re: Sort of trivial code challenge - may be interesting to you anyway
Date: Fri, 06 Mar 2026 18:14:04 -0800
Organization: A noiseless patient Spider
Lines: 55
Message-ID: <86wlzo9yj7.fsf@linuxsc.com>
References: <10n80sc$3soe4$1@dont-email.me> <86v7feei2e.fsf@linuxsc.com> <10o53k6$1i0ef$2@dont-email.me> <86ms0peby6.fsf@linuxsc.com> <10ockdh$3qpk6$1@dont-email.me> <10ocrjn$3qpk6$2@dont-email.me> <10od64s$3qpk6$4@dont-email.me> <86ikb9bmtw.fsf@linuxsc.com> <10oem5t$n5hk$1@dont-email.me> <865x78c322.fsf@linuxsc.com> <10ofrud$14kd9$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Sat, 07 Mar 2026 02:14:09 +0000 (UTC)
Injection-Info: dont-email.me; posting-host="fa47ee131b44f7fa0236e5dadd002153"; logging-data="1258134"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18+/1ENx1c5BfRgxJPKU0HkgWb2bLbDlS8="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:SdU3Mu3wRhmpDeiehJ6Ba88Oi5U= sha1:+efn79W8nZnPR3KIUXqdXl7rIv8=
Xref: csiph.com comp.lang.c:396838
DFS writes:
> On 3/6/2026 11:53 AM, Tim Rentsch wrote:
>
>> Lew Pitcher writes:
>>
>>> Thanks for the observations. I look forward to seeing /your/ code :-)
>>
>> I'm eager to post it.
>
> It's time!
>
>
>> I'm still hoping DFS will at least post an attempt.
>
> You're an optimist. You'd make a good lion tamer.
>
> "disallow if, for, while, goto, return, and to forbid functions and
> function calls except for calls to C standard library functions. Also
> no math library."
>
> would probably take me 3 days solid to research and write
>
> I did deliver a "no fors, whiles, gotos, or returns" version.
>
> Then I bowed out.
Have you looked up setjmp()/longjmp() yet in the C standard (or
maybe do an online search)? That could help jog your thinking,
and once you get the main idea things might fall into place
fairly quickly.
I say again that ?: is an important part of the battle here.
Feeling merciful, I am giving one more big hint. The outline of
my program looks like this
...
... a few #include's, macros, typedef's, variable declarations
...
static jmp_buf jb;
int
main( int argc, char *argv[] ){
switch( setjmp( jb ) ){
...
... (inside the switch there are several 'case' arms)
... (however there are no 'break' statements used)
...
}
}
Obviously some longjmp()'s are needed in the body of the switch() to
make this all work. Good luck!