The navigation bar for a winning entry now has a "_Original C_" link
(between the ✅ and the Inventory on the right hand side) so that one
may easily view the original C code that was submitted for IOCCC judging.
Ran `make www timestamp` to perform the above.
792 lines
32 KiB
HTML
792 lines
32 KiB
HTML
<!DOCTYPE html>
|
||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||
<!-- START: two lines up starts content from: inc/top.default.html -->
|
||
|
||
<!-- END: this line ends content from: inc/top.default.html -->
|
||
<!-- START: this line starts content from: inc/head.default.html -->
|
||
|
||
<head>
|
||
<link rel="stylesheet" href="../../ioccc.css">
|
||
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@100..900&display=swap" rel="stylesheet">
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
|
||
<title>1998/schweikh1 - CPP abuse</title>
|
||
<link rel="icon" type="image/x-icon" href="../../favicon.ico">
|
||
<meta name="description" content="1998 IOCCC entry schweikh1 - CPP abuse">
|
||
<meta name="keywords" content="IOCCC, 1998, IOCCC 1998, IOCCC entry, schweikh1, CPP abuse">
|
||
</head>
|
||
|
||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
|
||
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
|
||
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
|
||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||
|
||
<!-- END: this line ends content from: inc/head.default.html -->
|
||
|
||
<!-- -->
|
||
<!-- This web page was formed via the tool: bin/readme2index.sh -->
|
||
<!-- The content of main section of this web page came from: 1998/schweikh1/README.md -->
|
||
<!-- -->
|
||
|
||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||
<!-- !!! Do not modify this web page, instead modify the file: 1998/schweikh1/README.md !!! -->
|
||
<!-- !!! Do not modify this web page, instead modify the file: 1998/schweikh1/README.md !!! -->
|
||
<!-- !!! Do not modify this web page, instead modify the file: 1998/schweikh1/README.md !!! -->
|
||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||
|
||
<!-- Markdown content was converted into HTML via the tool: bin/md2html.sh -->
|
||
|
||
<!-- START: this line starts content from: inc/body.default.html -->
|
||
|
||
<body>
|
||
|
||
<!-- END: this line ends content from: inc/body.default.html -->
|
||
<!-- START: this line starts content from: inc/topbar.default.html -->
|
||
|
||
<div class="theader">
|
||
<nav class="topbar">
|
||
<div class="container">
|
||
<div class="logo">
|
||
<a href="../../index.html" class="logo-link">
|
||
IOCCC
|
||
</a>
|
||
</div>
|
||
|
||
<div class="topbar-items">
|
||
<div class="item">
|
||
<span class="item-header">
|
||
Entries
|
||
</span>
|
||
|
||
<div class="sub-item">
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../years.html" class="sub-item-link">
|
||
Winning entries
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../authors.html" class="sub-item-link">
|
||
Winning authors
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../location.html" class="sub-item-link">
|
||
Location of authors
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../bugs.html" class="sub-item-link">
|
||
Bugs and (mis)features
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html#fix_an_entry" class="sub-item-link">
|
||
Fixing entries
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html#fix_author" class="sub-item-link">
|
||
Updating author info
|
||
</a>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<div class="item">
|
||
<span class="item-header">
|
||
Status
|
||
</span>
|
||
|
||
<div class="sub-item">
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../news.html" class="sub-item-link">
|
||
News
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../status.html" class="sub-item-link">
|
||
Contest status
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../next/rules.html" class="sub-item-link">
|
||
IOCCC rules
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../next/guidelines.html" class="sub-item-link">
|
||
IOCCC guidelines
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../markdown.html" class="sub-item-link">
|
||
Markdown guidelines
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../SECURITY.html" class="sub-item-link">
|
||
Security policy
|
||
</a>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<div class="item">
|
||
<span class="item-header">
|
||
FAQ
|
||
</span>
|
||
|
||
<div class="sub-item">
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html" class="sub-item-link">
|
||
Frequently asked questions
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../quick-start.html#enter" class="sub-item-link">
|
||
Enter the IOCCC
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html#compiling" class="sub-item-link">
|
||
Compiling entries
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html#running_entries" class="sub-item-link">
|
||
Running entries
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html#help" class="sub-item-link">
|
||
How to help
|
||
</a>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<div class="item">
|
||
<span class="item-header">
|
||
About
|
||
</span>
|
||
|
||
<div class="sub-item">
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../index.html" class="sub-item-link">
|
||
Home page
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../social.html" class="sub-item-link">
|
||
IOCCC social media
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../about.html" class="sub-item-link">
|
||
About the IOCCC
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../judges.html" class="sub-item-link">
|
||
The judges
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../thanks-for-help.html" class="sub-item-link">
|
||
Thanks for the help
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../contact.html" class="sub-item-link">
|
||
Contact us
|
||
</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</nav>
|
||
|
||
<div class="header-mobile-menu">
|
||
<noscript>
|
||
<a href="../../nojs-menu.html" class="topbar-js-label">
|
||
Please Enable JavaScript
|
||
</a>
|
||
</noscript>
|
||
|
||
<button id="header-open-menu-button" class="topbar-mobile-menu">
|
||
<img
|
||
src="../../png/hamburger-icon-open.png"
|
||
alt="hamburger style menu icon - open state"
|
||
width=48
|
||
height=48>
|
||
</button>
|
||
|
||
<button id="header-close-menu-button" class="hide-content">
|
||
<img
|
||
src="../../png/hamburger-icon-closed.png"
|
||
alt="hamburger style menu icon - closed state"
|
||
width=48
|
||
height=48>
|
||
</button>
|
||
|
||
<div id="mobile-menu-panel" class="hide-content">
|
||
<div class="mobile-menu-container">
|
||
|
||
<div class="mobile-menu-wrapper">
|
||
<div class="mobile-menu-item">
|
||
Entries
|
||
</div>
|
||
<div class="mobile-submenu-wrapper">
|
||
|
||
<a class="mobile-submenu-item" href="../../years.html">
|
||
Winning entries
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../authors.html">
|
||
Winning authors
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../location.html">
|
||
Location of authors
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../bugs.html">
|
||
Bugs and (mis)features
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html#fix_an_entry">
|
||
Fixing entries
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html#fix_author">
|
||
Updating author info
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../thanks-for-help.html">
|
||
Thanks for the help
|
||
</a>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<div class="mobile-menu-wrapper">
|
||
|
||
<div class="mobile-menu-item">
|
||
Status
|
||
</div>
|
||
<div class="mobile-submenu-wrapper">
|
||
|
||
<a class="mobile-submenu-item" href="../../news.html">
|
||
News
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../status.html">
|
||
Contest status
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../next/rules.html">
|
||
IOCCC rules
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../next/guidelines.html">
|
||
IOCCC guidelines
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../markdown.html">
|
||
Markdown guidelines
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../SECURITY.html">
|
||
Security policy
|
||
</a>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<div class="mobile-menu-wrapper">
|
||
<div class="mobile-menu-item">
|
||
FAQ
|
||
</div>
|
||
<div class="mobile-submenu-wrapper">
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html">
|
||
Frequently asked questions
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../quick-start.html#enter">
|
||
Enter the IOCCC
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html#compiling">
|
||
Compiling entries
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html#running_entries">
|
||
Running entries
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html#help">
|
||
How to help
|
||
</a>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<div class="mobile-menu-wrapper">
|
||
<div class="mobile-menu-item">
|
||
About
|
||
</div>
|
||
<div class="mobile-submenu-wrapper">
|
||
|
||
<a class="mobile-submenu-item" href="../../index.html">
|
||
Home page
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../social.html">
|
||
IOCCC social media
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../about.html">
|
||
About the IOCCC
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../judges.html">
|
||
The judges
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../contact.html">
|
||
Contact us
|
||
</a>
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<script>
|
||
var headerOpenMenuButton = document.getElementById("header-open-menu-button");
|
||
var headerCloseMenuButton = document.getElementById("header-close-menu-button");
|
||
var mobileMenuPanel = document.getElementById("mobile-menu-panel");
|
||
|
||
headerOpenMenuButton.addEventListener("click", () => {
|
||
headerOpenMenuButton.classList.remove("topbar-mobile-menu");
|
||
headerOpenMenuButton.classList.add("hide-content");
|
||
|
||
headerCloseMenuButton.classList.remove("hide-content");
|
||
headerCloseMenuButton.classList.add("topbar-mobile-menu");
|
||
|
||
mobileMenuPanel.classList.remove("hide-content");
|
||
mobileMenuPanel.classList.add("topbar-mobile-panel");
|
||
});
|
||
|
||
headerCloseMenuButton.addEventListener("click", () => {
|
||
headerCloseMenuButton.classList.remove("topbar-mobile-menu");
|
||
headerCloseMenuButton.classList.add("hide-content");
|
||
|
||
mobileMenuPanel.classList.add("hide-content");
|
||
mobileMenuPanel.classList.remove("topbar-mobile-panel");
|
||
|
||
headerOpenMenuButton.classList.add("topbar-mobile-menu");
|
||
headerOpenMenuButton.classList.remove("hide-content");
|
||
});
|
||
</script>
|
||
|
||
<!-- END: this line ends content from: inc/topbar.default.html -->
|
||
<!-- START: this line starts content from: inc/header.default.html -->
|
||
|
||
<div class="header">
|
||
<a href="../../2011/zucker/index.html">
|
||
<img src="../../png/ioccc.png"
|
||
alt="IOCCC image by Matt Zucker"
|
||
width=300
|
||
height=110>
|
||
</a>
|
||
<h1>The International Obfuscated C Code Contest</h1>
|
||
<h2>1998/schweikh1 - CPP abuse</h2>
|
||
<h3>Tests to see if your compiler and headers are standard</h3>
|
||
</div>
|
||
|
||
<!-- END: this line ends content from: inc/header.default.html -->
|
||
<!-- START: this line starts content from: inc/navbar.mid.html -->
|
||
|
||
<div class="navbar">
|
||
<a class="Left" href="../schnitzi/index.html">← 1998/schnitzi</a>
|
||
<a class="Left" href="../index.html">↑ 1998 ↑</a>
|
||
<a class="Left" href="../schweikh2/index.html">1998/schweikh2 →</a>
|
||
<a class="Right" href="https://github.com/ioccc-src/winner/blob/master/1998/schweikh1/schweikh1.c">C code</a>
|
||
<a class="Right" href="https://github.com/ioccc-src/winner/blob/master/1998/schweikh1/Makefile">Makefile</a>
|
||
<a class="Right" href="#inventory">Inventory</a>
|
||
<a class="Right" href="https://github.com/ioccc-src/winner/blob/master/1998/schweikh1/schweikh1.orig.c">Original C</a>
|
||
<a class="Right" href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fwww.ioccc.org%2F1998%2Fschweikh1%2Findex.html">✓</a>
|
||
</div>
|
||
|
||
<!-- END: this line ends content from: inc/navbar.mid.html -->
|
||
<!-- START: this line starts content from: inc/before-content.default.html -->
|
||
|
||
<div class="content" id="content">
|
||
|
||
<!-- END: this line ends content from: inc/before-content.default.html -->
|
||
<!-- START: this line starts content for HTML phase 20 by: bin/output-index-author.sh via bin/md2html.sh -->
|
||
|
||
<!-- START: this line starts content generated by: bin/output-index-author.sh -->
|
||
|
||
<h2 id="author">Author:</h2>
|
||
<ul>
|
||
<li>Name: <a href="../../authors.html#Jens_Schweikhardt">Jens Schweikhardt</a><br>
|
||
Location: <a href="../../location.html#DE">DE</a> - <em>Federal Republic of Germany</em> (<em>Germany</em>)</li>
|
||
</ul>
|
||
|
||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||
|
||
<!-- END: this line ends content for HTML phase 20 by: bin/output-index-author.sh via bin/md2html.sh -->
|
||
<!-- 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/README.md -->
|
||
<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 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
|
||
adjustments). For details of what had to change, see <a href="macos.html">macos.html</a>.
|
||
<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>
|
||
<h3 id="alternate-build-1">Alternate build:</h3>
|
||
<p>Use <code>schweikh1.alt</code> as you would <code>schweikh1</code> above.</p>
|
||
<h3 id="alternate-try">Alternate try:</h3>
|
||
<p>Bonus exercise: modify the code to provide a different compiler.</p>
|
||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||
<p>What does it do? It seems to print a list of system headers, perhaps
|
||
with words after them. Curiously, if you look at the list of words
|
||
defined in a given standard header, they are never printed directly
|
||
after that header’s name. Aha! It’s a conformance test for the
|
||
standard headers.</p>
|
||
<p>This code is a wonder; it’s a wonder that it compiles. I wonder
|
||
whether or not it should. The innovative realization that you can
|
||
use special characters, such as <code>'\n'</code>, in <code>#file</code> directives alone
|
||
merits some recognition.</p>
|
||
<p>I’ve included most of the author’s remarks; they’re fairly thorough.
|
||
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-<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
|
||
to compile and execute” in conjunction with preprocessor abuse.
|
||
When run, it is likely to uncover bugs in your system headers.</p>
|
||
<p>The program is run without arguments. If your compiler is buggy,
|
||
the most likely result is no output and/or an exit status of 1.</p>
|
||
<p>If Amendment One headers are missing you will see something like:</p>
|
||
<pre><code> <iso646.h>:
|
||
gcc: /usr/include/iso646.h: No such file or directory
|
||
gcc: No input files specified
|
||
<wctype.h>:
|
||
gcc: /usr/include/wctype.h: No such file or directory
|
||
gcc: No input files specified
|
||
<wchar.h>:
|
||
gcc: /usr/include/wchar.h: No such file or directory
|
||
gcc: No input files specified</code></pre>
|
||
<p>Bug your vendor for an upgrade.</p>
|
||
<p>The format of the info file is straightforward and described in the file
|
||
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/winner/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
|
||
macros are explicitly enumerated. In a compliant implementation no other
|
||
macros can be defined, because you could write strictly conforming
|
||
programs that may fail to compile due to syntax errors: supposing that
|
||
<code><stdio.h></code> defines <code>PIPE_BUF</code>, then the conforming</p>
|
||
<pre><code> #include <assert.h>
|
||
#include <stdio.h> /* <- or where the bogus macro is defined */
|
||
#include <string.h>
|
||
#define STR(x) #x
|
||
#define XSTR(x) STR(x)
|
||
int main (void)
|
||
{
|
||
int PIPE_BUF = 0;
|
||
assert (strcmp ("PIPE_BUF", XSTR (PIPE_BUF)) == 0);
|
||
return 0;
|
||
}</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
|
||
C compilers.</p>
|
||
<ol type="1">
|
||
<li>The token sequence after <code>#include</code> can consist of pp-tokens and
|
||
“are processed just as in normal text.” [ISO 6.8.2] The result
|
||
must resemble one of the canonical forms, <code>"foo.h"</code> or <code><bar.h></code>.
|
||
This lets us write things like</li>
|
||
</ol>
|
||
<pre><code> #define HEADER "foo.h"
|
||
#include HEADER</code></pre>
|
||
<p>I could not find a compiler rejecting this. However, if we’re
|
||
torturing the preprocessor a little more, by using token pasting,
|
||
at least one compiler falls over.</p>
|
||
<pre><code> #define H(x) <st##x##.h>
|
||
#include H(dio) /* expands to <stdio.h> */</code></pre>
|
||
<p>is rejected by tcc version 4.1.2, the TenDRA compiler:
|
||
<code>"t.c", line 3: Error:<br> [ISO 6.8.3.3]: Invalid result for '##' operator in macro 'H'.</code></p>
|
||
<p>To be honest, I don’t know if the rules for pp-tokens and token
|
||
pasting don’t forbid what I do (and thus tcc is correct in rejecting it).
|
||
In this case, all other compilers I tried are buggy, or the Standard
|
||
itself :-)</p>
|
||
<ol start="2" type="1">
|
||
<li>The <code>#line</code> directive allows to set a line number, and optionally
|
||
a file name, i.e. modify <code>__LINE__</code> and <code>__FILE__</code>. Strange things
|
||
happen if the file name contains a NUL byte – which the Standard
|
||
allows: in <code>#line num "file"</code> the <code>"file"</code> is an s-char-sequence per
|
||
ISO 6.8.4. ISO 6.1.4 defines string literals as s-char-sequences,
|
||
which may include octal escape sequences. Let’s look at</li>
|
||
</ol>
|
||
<pre><code> #include <stdio.h>
|
||
#line 42 "foo\0bar"
|
||
int main (void) {
|
||
printf ("%s %d\n", __FILE__, (int)sizeof __FILE__);
|
||
return 0;
|
||
}</code></pre>
|
||
<p>This is supposed to output <code>'foo 8'</code>. Here’s what happens in RL:</p>
|
||
<pre><code> foo 4 gcc 2.7.2.1, lcc
|
||
foo\0bar 9 tcc 4.1.2, Sunsoft cc turn "\0" into "\\0", ugh!</code></pre>
|
||
<p>(I have written a bug report for gcc. Newer versions and egcs are ok.)</p>
|
||
<ol start="3" type="1">
|
||
<li><p>The <code>%:</code> and <code>%:%:</code> digraphs test for conformance to Amendment One.</p>
|
||
<p>Ask your local guru if C allows the same case label in the same switch
|
||
statement to appear more than once. Ask him/her to think real hard.
|
||
The answer will be “no”. The true guru will cite a constraint in
|
||
ISO 6.6.4.2. Then make fun of the guru’s answer by waving <code>case __LINE__:</code>
|
||
under his/her nose. Easy money from a bet! Make sure your guru has
|
||
no chance to use Standardese weasel words as an escape: can I have</p></li>
|
||
</ol>
|
||
<pre><code> case <some_token>:
|
||
case <some_token>:</code></pre>
|
||
<p>in the same switch? (Note that you need the [invisible] newline. You
|
||
can generously allow the additional constraint that no <code>#undef</code>s or
|
||
<code>#define</code>s are allowed between the two cases.)</p>
|
||
<p>Lots of integer constants and string literals come into the source
|
||
via <code>__LINE__</code> and <code>__FILE__</code> which are redefined at various places.
|
||
Sometimes the <code>__FILE__</code> contains <code>\0</code> bytes; different strings or
|
||
characters are then accessed with offsets, say <code>10+__FILE__</code> or
|
||
<code>__LINE__+__FILE__</code> or <code>2[__FILE__]</code>. One integral constant in octal.
|
||
This makes the source and header input depend on ASCII.</p>
|
||
<p>A few old obfuscations, like one character identifiers, not too
|
||
many macros, a <code>goto O</code>, “needless” assignments to satisfy lint
|
||
with its “function value ignored” warnings. My lint has nothing
|
||
to complain about.</p>
|
||
<p>There’s more whitespace in the Standard than just space, tab and newline. In
|
||
particular, there are vertical tab and form-feed that can be used in certain
|
||
places (outside of preprocessing directives, i.e. they are not allowed from just
|
||
after the <code>#</code> up to the final newline. See 6.8 for details.) On many
|
||
implementations these appear as <code>^L</code> and <code>^K</code>. My source starts with an
|
||
extremely uncommon 32bit word consisting of <code>^L</code>, <code>^K</code>, <code>%</code> and <code>:</code>. I have
|
||
grepped old winning entries for ^K, none of them contains one, so this is
|
||
something new – after 14 years of IOCCC. Be sure to have enough paper in your
|
||
printer when you make a hard copy of the source…</p>
|
||
<p>While I’m at it, the rules state that only space, tab and newline
|
||
are ignored for the count (plus ‘<code>{</code>’, ‘<code>}</code>’, ‘<code>;</code>’ followed by
|
||
whitespace). The <a href="https://github.com/ioccc-src/winner/blob/master/1998/mkentry.c">mkentry.c</a> program, however, uses <code>isspace(3)</code> which
|
||
returns nonzero for <code>\v</code> and <code>\f</code> and other characters as well.
|
||
I could have used a lot more <code>^K</code> and <code>^L</code> probably undetected by your
|
||
counter but decided to err on the side of safety. I use a perl
|
||
script to compute the character count according to the rules.
|
||
The advantages of an independent clean room approach…</p>
|
||
<pre><code> #!/usr/bin/perl -w
|
||
$/ = "\0";
|
||
$_ = <>;
|
||
s/[;{}][ \t\n]/\n/g;
|
||
s/[ \t\n]+//g;
|
||
print length ($_),"\n";</code></pre>
|
||
<p>To use, try:</p>
|
||
<pre><code> perl ./charcount.pl schweikh1.c</code></pre>
|
||
<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: “<code>To stress C compilers with unusual code.</code>”
|
||
That describes exactly my modest attempts…</p>
|
||
<!--
|
||
|
||
Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.
|
||
|
||
You are free to share and adapt this file under the terms of this license:
|
||
|
||
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
||
|
||
For more information, see:
|
||
|
||
https://creativecommons.org/licenses/by-sa/4.0/
|
||
|
||
-->
|
||
<!-- AFTER: last line of markdown file: 1998/schweikh1/README.md -->
|
||
|
||
<!-- END: this line ends content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||
<!-- START: this line starts content for HTML phase 22 by: bin/output-index-inventory.sh via bin/md2html.sh -->
|
||
|
||
<!-- START: this line starts content generated by: bin/output-index-inventory.sh -->
|
||
|
||
<div id="inventory">
|
||
<h1 id="inventory-for-1998schweikh1">Inventory for 1998/schweikh1</h1>
|
||
</div>
|
||
<h2 id="primary-files">Primary files</h2>
|
||
<ul>
|
||
<li><a href="https://github.com/ioccc-src/winner/blob/master/1998/schweikh1/schweikh1.c">schweikh1.c</a> - entry source code</li>
|
||
<li><a href="https://github.com/ioccc-src/winner/blob/master/1998/schweikh1/Makefile">Makefile</a> - entry Makefile</li>
|
||
<li><a href="https://github.com/ioccc-src/winner/blob/master/1998/schweikh1/schweikh1.alt.c">schweikh1.alt.c</a> - alternate source code</li>
|
||
<li><a href="https://github.com/ioccc-src/winner/blob/master/1998/schweikh1/schweikh1.orig.c">schweikh1.orig.c</a> - original source code</li>
|
||
<li><a href="https://github.com/ioccc-src/winner/blob/master/1998/schweikh1/charcount.pl">charcount.pl</a> - character counter in perl</li>
|
||
<li><a href="macos.html">macos.html</a> - explains how this entry was fixed to work with macOS</li>
|
||
<li><a href="https://github.com/ioccc-src/winner/blob/master/1998/schweikh1/info">info</a> - file for C standards conformance test</li>
|
||
</ul>
|
||
<h2 id="secondary-files">Secondary files</h2>
|
||
<ul>
|
||
<li><a href="1998_schweikh1.tar.bz2">1998_schweikh1.tar.bz2</a> - download entry tarball</li>
|
||
<li><a href="https://github.com/ioccc-src/winner/blob/master/1998/schweikh1/README.md">README.md</a> - markdown source for this web page</li>
|
||
<li><a href="https://github.com/ioccc-src/winner/blob/master/1998/schweikh1/.entry.json">.entry.json</a> - entry summary and manifest in JSON</li>
|
||
<li><a href="https://github.com/ioccc-src/winner/blob/master/1998/schweikh1/.gitignore">.gitignore</a> - list of files that should not be committed under git</li>
|
||
<li><a href="https://github.com/ioccc-src/winner/blob/master/1998/schweikh1/macos.md">macos.md</a> - markdown source for macos.html</li>
|
||
<li><a href="https://github.com/ioccc-src/winner/blob/master/1998/schweikh1/.path">.path</a> - directory path from top level directory</li>
|
||
<li><a href="index.html">index.html</a> - this web page</li>
|
||
</ul>
|
||
<hr style="width:10%;text-align:left;margin-left:0">
|
||
<h4>
|
||
Jump to: <a href="#">top</a>
|
||
</h4>
|
||
|
||
<!-- END: next line ends content generated by: bin/output-index-inventory.sh -->
|
||
|
||
<!-- END: this line ends content for HTML phase 22 by: bin/output-index-inventory.sh via bin/md2html.sh -->
|
||
<!-- START: this line starts content from: inc/after-content.default.html -->
|
||
|
||
</div>
|
||
|
||
<!-- END: this line ends content from: inc/after-content.default.html -->
|
||
<!-- START: this line starts content from: inc/footer.inventory.html -->
|
||
|
||
<!--
|
||
|
||
Copyright © 1984-2025 by Landon Curt Noll. All Rights Reserved.
|
||
|
||
You are free to share and adapt this file under the terms of this license:
|
||
|
||
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
||
|
||
For more information, see:
|
||
|
||
https://creativecommons.org/licenses/by-sa/4.0/
|
||
|
||
-->
|
||
|
||
<div class="footer">
|
||
|
||
<div id="copyright"><h3>Copyright © 1984-2025 by Landon Curt Noll:
|
||
<a href="https://creativecommons.org/faq/#what-does-some-rights-reserved-mean"
|
||
target="_blank"
|
||
rel="license noopener noreferrer">Some Rights Reserved</a></h3>
|
||
<p>
|
||
This work is <b>licensed by Landon Curt Noll</b> under
|
||
<b><a href="https://creativecommons.org/licenses/by-sa/4.0/?ref=chooser-v1"
|
||
target="_blank"
|
||
rel="license noopener noreferrer"
|
||
style="display:inline-block;">CC BY-SA 4.0</a></b>.
|
||
<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;"
|
||
src="../../png/cc.png"
|
||
alt="cc inside circle symbol">
|
||
<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;"
|
||
src="../../png/by.png"
|
||
alt="person inside circle symbol">
|
||
<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;"
|
||
src="../../png/sa.png"
|
||
alt="arrow looping back on itself inside circle symbol"><br>
|
||
You should <b>carefully review</b> the
|
||
<b><a href="https://creativecommons.org/licenses/by-sa/4.0/legalcode.en"
|
||
target="_blank"
|
||
rel="license noopener noreferrer">CC BY-SA 4.0 LEGAL CODE</a></b>
|
||
before using the licensed material.<br>
|
||
You may wish to review the
|
||
<b><a href="../../license.html"
|
||
target="_blank"
|
||
rel="license noopener noreferrer">highlights of some of the key features and terms</a></b>
|
||
of <b>CC BY-SA 4.0</b>.<br>
|
||
</p>
|
||
</div>
|
||
|
||
<div id="coda"><h3>Coda</h3>
|
||
<p>
|
||
<a href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fwww.ioccc.org%2F1998%2Fschweikh1%2Findex.html" rel="nofollow">Nu HTML check this web page</a><br>
|
||
<a href="#top">Jump to top</a> <a href="#content">Jump to Content</a> <a href="#inventory">Jump to Inventory</a><br>
|
||
</p>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<!-- END: this line ends content from: inc/footer.inventory.html -->
|
||
<!-- START: this line starts content from: inc/bottom.default.html -->
|
||
|
||
</body>
|
||
</html>
|
||
|
||
<!-- END: this line ends content from: inc/bottom.default.html -->
|