Fixes in 1998 html files

This includes some notices to those who wish for a greater challenge.

In the 1998/schweikh3 the man page (and its copy to demonstrate the
entry) have been updated slightly but only in comment (move 'or' from
the command suggested to render it in text to its own line before the
next command also in comment).

The bugs file was updated for an entry or two.
This commit is contained in:
Cody Boone Ferguson committed 2024-07-29 08:47:22 -07:00
1 parent e297d4541a
commit 1fad29cd2f
28 files changed
+647 -370

No files matched your search

+30 -27
View File
@@ -5,9 +5,8 @@
```
There is an alternate version of this entry that will work with macOS. See the
[Alternate code](#alternate-code) section below. We recommend you look at it
even if you don't have a Mac, unless you want to figure it out yourself, as it
includes some interesting details about the entry.
[Alternate code](#alternate-code) section below. We recommend you look at the
code at the last, even if you don't have a Mac.
## To use:
@@ -22,9 +21,9 @@ includes some interesting details about the entry.
As noted above this entry will not work as it stands for macOS and there are
some important notes as well as a description of how the fixed version works
(the details of which are relevant to the original entry that no longer works as
well as the fixed version but are described in the context of the macOS
well as the fixed version, but are described in the context of the macOS
adjustments). For details of what had to change, see [macos.html](macos.html).
Unless you wish to figure it out yourself, we recommend that you read this even
**Unless you wish to figure it out yourself**, we recommend that you read this even
if you don't have a Mac as it has some interesting details about the entry.
@@ -66,13 +65,12 @@ crufty internationalization support.
#### Historical note:
Some non-gcc compilers that were not fully ANSI standard did not
compile this entry correctly. Using cc by default was not helpful
most of the time on this entry, because the program had a hardcoded
gcc invocation anyway. Anyone who uses egcs and has no plain gcc
will need to frob the source anyway and can be expected to do the
right thing with `${CC}`. This limitation was removed in 2023 but in the past
one should have used gcc.
Some non-`gcc` compilers that were not fully ANSI standard did not compile this
entry correctly. Using cc by default was not helpful most of the time on this
entry, because the program had a hardcoded `gcc` invocation anyway. Anyone who
uses egcs and has no plain `gcc` will need to frob the source anyway and can be
expected to do the right thing with `${CC}`. This limitation was removed in 2023
but in the past one should have used `gcc`.
## Author's remarks:
@@ -109,12 +107,12 @@ itself. Just load it in your favorite editor.
`gcc` (the GNU C compiler) must be available at runtime. It is assumed that your
C implementation keeps headers as files in the `/usr/include` directory. The
[info](%%REPO_URL%%/1998/schweikh1/info) file must be readable and reside in the current working directory.
The current working directory must be writable in order to create a temporary
file (which is removed upon program termination). In case you don't have gcc at
runtime, not all is lost if your compiler or preprocessor can produce a list of
defined macros in the format output by `gcc -dM`, i.e. lines of the form
`#define MACRO value`.
[info](%%REPO_URL%%/1998/schweikh1/info) file must be readable and reside in the
current working directory. The current working directory must be writable in
order to create a temporary file (which is removed upon program termination). In
case you don't have gcc at runtime, not all is lost if your compiler or
preprocessor can produce a list of defined macros in the format output by `gcc
-dM`, i.e. lines of the form `#define MACRO value`.
Edit the source at line 55 in this case.
@@ -143,6 +141,12 @@ programs that may fail to compile due to syntax errors: supposing that
is expected to compile and meet the assertion. If it does not, your
compiler compiles some other language than ISO C.
### NOTICE to those who wish for a greater challenge:
**If you want a greater challenge, don't read any further**:
just try to understand the program via the source.
If you get stuck, come back and read below for additional hints and information.
### Why I think my program is obfuscated
@@ -271,17 +275,16 @@ To use, try:
```
I have tried, as suggested in the guidelines, to let the code look
like ordinary C code. Apart from a few long lines I think I left
the indentation like I would in RL. You should however not try to
use `indent` on the source. The code is extremely fragile because of the
myriads of `__LINE__` macros -- indenting is a sure way to break
the program. Don't even think of maintaining that beast; I've
had my share of core dumps during development :-) A test suite
was used after every minor change to find out if the program still
I have tried, as suggested in the [guidelines](../guidelines.txt), to let the
code look like ordinary C code. Apart from a few long lines I think I left the
indentation like I would in RL. You should however not try to use `indent` on
the source. The code is extremely fragile because of the myriads of `__LINE__`
macros -- indenting is a sure way to break the program. Don't even think of
maintaining that beast; I've had my share of core dumps during development :-) A
test suite was used after every minor change to find out if the program still
does what it should.
From the goals: "To stress C compilers with unusual code."
From the goals: "`To stress C compilers with unusual code.`"
That describes exactly my modest attempts...
+27 -27
View File
@@ -410,18 +410,17 @@ Location: <a href="../../location.html#DE">DE</a> - <em>Federal Republic of Germ
<h2 id="to-build">To build:</h2>
<pre><code> make all</code></pre>
<p>There is an alternate version of this entry that will work with macOS. See the
<a href="#alternate-code">Alternate code</a> section below. We recommend you look at it
even if you don’t have a Mac, unless you want to figure it out yourself, as it
includes some interesting details about the entry.</p>
<a href="#alternate-code">Alternate code</a> section below. We recommend you look at the
code at the last, even if you don’t have a Mac.</p>
<h2 id="to-use">To use:</h2>
<pre><code> ./schweikh1</code></pre>
<h2 id="alternate-code">Alternate code:</h2>
<p>As noted above this entry will not work as it stands for macOS and there are
some important notes as well as a description of how the fixed version works
(the details of which are relevant to the original entry that no longer works as
well as the fixed version but are described in the context of the macOS
well as the fixed version, but are described in the context of the macOS
adjustments). For details of what had to change, see <a href="macos.html">macos.html</a>.
Unless you wish to figure it out yourself, we recommend that you read this even
<strong>Unless you wish to figure it out yourself</strong>, we recommend that you read this even
if you don’t have a Mac as it has some interesting details about the entry.</p>
<h3 id="alternate-build">Alternate build:</h3>
<pre><code> make alt</code></pre>
@@ -444,13 +443,12 @@ Do not read them if you want to figure this out yourself. “Amendment
One” refers to “NA1”, the add-on to C89 which added some fairly
crufty internationalization support.</p>
<h4 id="historical-note">Historical note:</h4>
<p>Some non-gcc compilers that were not fully ANSI standard did not
compile this entry correctly. Using cc by default was not helpful
most of the time on this entry, because the program had a hardcoded
gcc invocation anyway. Anyone who uses egcs and has no plain gcc
will need to frob the source anyway and can be expected to do the
right thing with <code>${CC}</code>. This limitation was removed in 2023 but in the past
one should have used gcc.</p>
<p>Some non-<code>gcc</code> compilers that were not fully ANSI standard did not compile this
entry correctly. Using cc by default was not helpful most of the time on this
entry, because the program had a hardcoded <code>gcc</code> invocation anyway. Anyone who
uses egcs and has no plain <code>gcc</code> will need to frob the source anyway and can be
expected to do the right thing with <code>${CC}</code>. This limitation was removed in 2023
but in the past one should have used <code>gcc</code>.</p>
<h2 id="authors-remarks">Author’s remarks:</h2>
<p>Important! This program, if it compiles at all, is mis-compiled by many
compilers due to compiler bugs. It could be the “least likely
@@ -474,12 +472,11 @@ itself. Just load it in your favorite editor.</p>
<h3 id="requirements">Requirements</h3>
<p><code>gcc</code> (the GNU C compiler) must be available at runtime. It is assumed that your
C implementation keeps headers as files in the <code>/usr/include</code> directory. The
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1998/schweikh1/info">info</a> file must be readable and reside in the current working directory.
The current working directory must be writable in order to create a temporary
file (which is removed upon program termination). In case you don’t have gcc at
runtime, not all is lost if your compiler or preprocessor can produce a list of
defined macros in the format output by <code>gcc -dM</code>, i.e. lines of the form
<code>#define MACRO value</code>.</p>
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1998/schweikh1/info">info</a> file must be readable and reside in the
current working directory. The current working directory must be writable in
order to create a temporary file (which is removed upon program termination). In
case you don’t have gcc at runtime, not all is lost if your compiler or
preprocessor can produce a list of defined macros in the format output by <code>gcc -dM</code>, i.e. lines of the form <code>#define MACRO value</code>.</p>
<p>Edit the source at line 55 in this case.</p>
<h3 id="background">Background</h3>
<p>ISO C has a very strict idea of visibility of identifiers. All possible
@@ -500,6 +497,10 @@ programs that may fail to compile due to syntax errors: supposing that
}</code></pre>
<p>is expected to compile and meet the assertion. If it does not, your
compiler compiles some other language than ISO C.</p>
<h3 id="notice-to-those-who-wish-for-a-greater-challenge">NOTICE to those who wish for a greater challenge:</h3>
<p><strong>If you want a greater challenge, don’t read any further</strong>:
just try to understand the program via the source.</p>
<p>If you get stuck, come back and read below for additional hints and information.</p>
<h3 id="why-i-think-my-program-is-obfuscated">Why I think my program is obfuscated</h3>
<p>Not only is the program’s purpose a thorough standard conformance
test, the source itself is a beast and has uncovered bugs in many
@@ -590,16 +591,15 @@ The advantages of an independent clean room approach…</p>
print length ($_),&quot;\n&quot;;</code></pre>
<p>To use, try:</p>
<pre><code> perl ./charcount.pl schweikh1.c</code></pre>
<p>I have tried, as suggested in the guidelines, to let the code look
like ordinary C code. Apart from a few long lines I think I left
the indentation like I would in RL. You should however not try to
use <code>indent</code> on the source. The code is extremely fragile because of the
myriads of <code>__LINE__</code> macros – indenting is a sure way to break
the program. Don’t even think of maintaining that beast; I’ve
had my share of core dumps during development :-) A test suite
was used after every minor change to find out if the program still
<p>I have tried, as suggested in the <a href="../guidelines.txt">guidelines</a>, to let the
code look like ordinary C code. Apart from a few long lines I think I left the
indentation like I would in RL. You should however not try to use <code>indent</code> on
the source. The code is extremely fragile because of the myriads of <code>__LINE__</code>
macros – indenting is a sure way to break the program. Don’t even think of
maintaining that beast; I’ve had my share of core dumps during development :-) A
test suite was used after every minor change to find out if the program still
does what it should.</p>
<p>From the goals: “To stress C compilers with unusual code.”
<p>From the goals: “<code>To stress C compilers with unusual code.</code>”
That describes exactly my modest attempts…</p>
<!--
+19 -6
View File
@@ -389,11 +389,18 @@
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<!-- BEFORE: 1st line of markdown file: 1998/schweikh1/macos.md -->
<h1 id="introduction-to-this-document">Introduction to this document:</h1>
<p>This document describes how this was fixed to work with macOS as well as some of
the magic in the entry. Even if you don’t have a Mac it might be worth your time
reading especially as some of it details some important fixes and changes in the
original entry as well.</p>
<h1 id="macos-changes">macOS changes</h1>
<h2 id="notice-to-those-who-wish-for-a-greater-challenge">NOTICE to those who wish for a greater challenge:</h2>
<p><strong>If you want a greater challenge, don’t read any further</strong>:
just try to understand the program via the source.</p>
<p>If you get stuck, come back and read below for additional hints and information.
Of course, if you do not have a Mac the code might make less sense, so you might
just wish to read this in that case, should you wish to understand it.</p>
<h1 id="macos-aside">macOS aside:</h1>
<p>As an aside: if you have a Mac with the Apple chip, some of the header files
will report an unsupported architecture and unsupported compiler (error,
warning). This will not make the program abort, however, but even with an Intel
@@ -401,20 +408,26 @@ CPU though, the original entry will not work in macOS as it stands because
<code>/usr/include</code> is hard-coded in the code and macOS does not have it.</p>
<p>Nevertheless, although some of it would not work in other systems where
<code>/usr/include</code> exists, the <code>#define</code>s would still be found okay, at least until
a file was not found (this limitation was removed in both versions in 2023). see</p>
a file was not found (this limitation was removed in both versions in 2023).</p>
<p>However, as noted, macOS does <strong>not</strong> have <code>/usr/include</code> so this would never
work for macOS without some changes, described next. For macOS you will need the
command line tools installed which can be done like:</p>
<pre><code> sudo xcode-select --install</code></pre>
<h1 id="important-point-about-the-hard-coded-compiler">Important point about the hard-coded compiler:</h1>
<p>An important point is that the original version hard-coded <code>gcc</code> but just like
the entry, the alternate version has also removed this limitation despite <code>gcc</code>
existing (though it’s <code>clang</code>) in macOS.</p>
existing (though it’s <code>clang</code>) in macOS; instead it is <code>cc</code>.</p>
<h1 id="how-this-entry-works-the-magic">How this entry works (the magic):</h1>
<p>Now as far as how this works if you look at the code of
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1998/schweikh1/schweikh1.c">schweikh1.c</a>, on line 55 you’ll see a funny command (this goes for
the alternate version as well but a bit different).</p>
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1998/schweikh1/schweikh1.c">schweikh1.c</a>, on <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1998/schweikh1/schweikh1.c#L55">line
55</a> you’ll see a funny command
(this goes for the <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1998/schweikh1/schweikh1.alt.c">alternate
version</a>, also on <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1998/schweikh1/schweikh1.c#L55">line
55</a>, but the command is necessarily
different).</p>
<p>Now the key is two magic numbers, one (two times) on a different line shortly below the
string and the other a couple lines further below.</p>
<p>In the original the numbers are, respectively, <code>44</code> and <code>46</code>, but with the gcc
<p>In the original the numbers are, respectively, <code>44</code> and <code>46</code>, but with the <code>gcc</code>
limitation removed the numbers now are <code>43</code> and <code>45</code>. But how does this work? Well
the command is:</p>
<pre><code> &quot;0gcc -ansi -E -dM -undef %s /usr/include/%s&gt;r\0 (&quot;</code></pre>
+25 -6
View File
@@ -1,9 +1,20 @@
# Introduction to this document:
This document describes how this was fixed to work with macOS as well as some of
the magic in the entry. Even if you don't have a Mac it might be worth your time
reading especially as some of it details some important fixes and changes in the
original entry as well.
# macOS changes
## NOTICE to those who wish for a greater challenge:
**If you want a greater challenge, don't read any further**:
just try to understand the program via the source.
If you get stuck, come back and read below for additional hints and information.
Of course, if you do not have a Mac the code might make less sense, so you might
just wish to read this in that case, should you wish to understand it.
# macOS aside:
As an aside: if you have a Mac with the Apple chip, some of the header files
will report an unsupported architecture and unsupported compiler (error,
@@ -13,7 +24,7 @@ CPU though, the original entry will not work in macOS as it stands because
Nevertheless, although some of it would not work in other systems where
`/usr/include` exists, the `#define`s would still be found okay, at least until
a file was not found (this limitation was removed in both versions in 2023). see
a file was not found (this limitation was removed in both versions in 2023).
However, as noted, macOS does **not** have `/usr/include` so this would never
work for macOS without some changes, described next. For macOS you will need the
@@ -23,18 +34,26 @@ command line tools installed which can be done like:
sudo xcode-select --install
```
# Important point about the hard-coded compiler:
An important point is that the original version hard-coded `gcc` but just like
the entry, the alternate version has also removed this limitation despite `gcc`
existing (though it's `clang`) in macOS.
existing (though it's `clang`) in macOS; instead it is `cc`.
# How this entry works (the magic):
Now as far as how this works if you look at the code of
[schweikh1.c](%%REPO_URL%%/1998/schweikh1/schweikh1.c), on line 55 you'll see a funny command (this goes for
the alternate version as well but a bit different).
[schweikh1.c](%%REPO_URL%%/1998/schweikh1/schweikh1.c), on [line
55](%%REPO_URL%%/1998/schweikh1/schweikh1.c#L55) you'll see a funny command
(this goes for the [alternate
version](%%REPO_URL%%/1998/schweikh1/schweikh1.alt.c), also on [line
55](%%REPO_URL%%/1998/schweikh1/schweikh1.c#L55), but the command is necessarily
different).
Now the key is two magic numbers, one (two times) on a different line shortly below the
string and the other a couple lines further below.
In the original the numbers are, respectively, `44` and `46`, but with the gcc
In the original the numbers are, respectively, `44` and `46`, but with the `gcc`
limitation removed the numbers now are `43` and `45`. But how does this work? Well
the command is: