Created `quick-start.md` to hold the FAQ 0.0 content. Used `sgit(1)` to change: * faq.html#enter ==> quick-start.html#enter * faq.html#enter_questions ==> quick-start.html#enter_questions * faq.html#step_0 ==> quick-start.html#step_0 * faq.html#step_1 ==> quick-start.html#step_1 * faq.html#step_2 ==> quick-start.html#step_2 * faq.html#register ==> quick-start.html#register * faq.html#step_3 ==> quick-start.html#step_3 * faq.html#step_4 ==> quick-start.html#step_4 * faq.html#step_5 ==> quick-start.html#step_5 * faq.html#step_6 ==> quick-start.html#step_6 * faq.html#step_7 ==> quick-start.html#step_7 * faq.html#step_submit ==> quick-start.html#step_submit Via: ```sh sgit -e 's/faq\.html#enter/quick-start.html#enter/g' '*.md' '*.hdr' 'inc/*.html' sgit -e 's/faq\.html#enter_questions/quick-start.html#enter_questions/g' '*.md' '*.hdr' 'inc/*.html' sgit -e 's/faq\.html#step_0/quick-start.html#step_0/g' '*.md' '*.hdr' 'inc/*.html' sgit -e 's/faq\.html#step_1/quick-start.html#step_1/g' '*.md' '*.hdr' 'inc/*.html' sgit -e 's/faq\.html#step_2/quick-start.html#step_2/g' '*.md' '*.hdr' 'inc/*.html' sgit -e 's/faq\.html#register/quick-start.html#register/g' '*.md' '*.hdr' 'inc/*.html' sgit -e 's/faq\.html#step_3/quick-start.html#step_3/g' '*.md' '*.hdr' 'inc/*.html' sgit -e 's/faq\.html#step_4/quick-start.html#step_4/g' '*.md' '*.hdr' 'inc/*.html' sgit -e 's/faq\.html#step_5/quick-start.html#step_5/g' '*.md' '*.hdr' 'inc/*.html' sgit -e 's/faq\.html#step_6/quick-start.html#step_6/g' '*.md' '*.hdr' 'inc/*.html' sgit -e 's/faq\.html#step_7/quick-start.html#step_7/g' '*.md' '*.hdr' 'inc/*.html' sgit -e 's/faq\.html#step_submit/quick-start.html#step_submit/g' '*.md' '*.hdr' 'inc/*.html' ``` The former FAQ 0.0 section in `faq.html` now just refers to `quick-start.html`. Modified menu and non-JS menu so that "Enter the IOCCC" refers to `quick-start.html`. Changed `bin/gen-top-html.sh` VERSION from "1.4.10 2024-11-23" to "1.4.11 2025-01-09". Performed `make www` on macOS to complete the above.
To build:
make
Bugs and (Mis)features:
The current status of this entry is:
STATUS: doesn't work with some platforms - please help us fix it
For more detailed information see 2011/richards in bugs.html.
To use:
echo expression | ./richards
Try:
./try.sh
Judges' remarks:
Oh no, yet another
dc-style calculator? (see
2000/dlowe using an embedded Perl interpreter and deemed Worst Abuse of the Rules). Well, this one does it (expression calculation, that is,
not the rule abuse) in a different way. The author claims that his calculator
does just-in-time compilation. What would you do to prove or disprove his claim
without attempting to unravel the source?
Author's remarks:
This is an implementation of the classic UNIX
dc command, the
reverse Polish
calculator. Actually it's a pretty bad implementation, since it only implements
32-bit integers (well, sizeof(int)-sized integers). It only implements the
commands +, -, *, /, p (only for numbers), register stacks, macros and
comparisons. Wow, you'd think I could've done better in 2K of code.
OH! I forgot to mention! It's a JIT.
Wait, don't stop reading! I know what you're thinking, platform-specific code is discouraged in IOCCC. But do you see any platform-specific code? There's no assembler here! This JIT works on a dozen platforms, and the only platform-specific assumptions it makes are that the stack grows down and integers are at least 32-bit.
You will probably get warnings while compiling the code. In particular:
-
If your system requires the inclusion of
alloca.hto use alloca, use the compile flag-DAH. -
If your system cannot use
mmap(), use the compile flag-DNM. -
I don't include any headers I don't strictly need to, so you'll get warnings about (at least)
memcpy(),isdigit(),atoi(),calloc(),malloc()andalloca()if you didn't use-DAH. - NOTE from judges: we added these includes in 2023. -
GCC likes to complain about
while (a = b)(assignments as a condition). -
I don't return from
main(), even though it's declared to returnint.
Platforms on which all known/tested optimization levels work with no additional flags:
- gcc 4.6.2 + x86[_64] + GNU/Linux, Mac OS X or Windows
- clang 2.9-16 + x86[_64] + GNU/Linux or Mac OS X
- tcc 0.9.25
- gcc 4.4.5 + alpha, arm, mips[el], powerpc[64], s390x (IBM zSeries)
- gcc 4.1.3 + vax + NetBSD
Platforms which work but not at all optimization levels or needing special flags:
- owcc 1.9 + x86 + Windows: Needs
-DNM -DAH -fno-stack-check - gcc 4.4.5 + sh4:
-O0works, higher optimization levels don't work for unknown reasons.