Files
ioccc/2001/schweikh
Landon Curt Noll f29b37e49a improve HTML menus, add social.html, prep for IOCCC28 winners
Prepare for the winners of **IOCCC28**.

> However these are not the 2024 droids you are looking for.  :-)

The HTML menu (both JavaScript and non-JavaScript) has been updated.

The `Status -> Rules and guidelines' have been replaced with two
separate menus `Status -> IOCCC rules` and `Status -> IOCCC guidelines`.

Added a new top level `social.html` page: built from a new `social.md`.

Sorted rules for building specific web pages in the top level `Makefile`.
Added `make social` to make the `social.html` page from `social.md`.

The `bin/gen-top-html.sh` now is able to process a argument of **social**
to process the new top level `social.html` page.

Changed `bin/gen-top-html.sh` VERSION from "2.0.0 2025-03-13"
to "2.0.1 2025-07-25".

Below `About -> Home page` a new `About -> IOCCC social media` menu item
as added.

Because the menu change touched every HTML file, we changed the general
copyright date range for HTML files from "1984-2024" to "1984-2025"
due to the extensive changes made for **IOCCC28**.

Those markdown files that were modified in 2025 had their copyright date
range also changed from "1984-2024" to "1984-2025".

Rebuilt tarballs and sitemap due to the extensive HTML rebuilding.

Ran `make update` to perform the above.
2025-07-26 13:06:29 -07:00
..
2024-08-05 09:48:14 -07:00
2023-10-30 05:02:51 -07:00
2023-07-06 21:49:38 -07:00

To build:

    make

Bugs and (Mis)features:

The current status of this entry is:

STATUS: INABIAF - please DO NOT fix

For more detailed information see 2001/schweikh in bugs.html.

To use:

    ./schweikh string string2

This program will very likely crash or do something else if you do not give it two args.

Note also that the glob pattern must match the whole string. See the author's comments for details and a workaround.

There's also no way to escape meta characters.

Try:

    ./try.sh

Judges' remarks:

Do you get the pattern here?

Author's remarks:

This one-liner program is a glob pattern matcher. It understands the glob characters * meaning 'zero or more characters' and ? meaning exactly one character, just like your unix shell.

Run it with two args, the string and the glob pattern. The exit status is 0 (shell true) when the pattern matches, 1 otherwise. The glob pattern must match the whole string, so you may want to use * at the beginning and end of the pattern if you are looking for something in the middle.

You can use it for your shell scripting needs similar to a silent grep (and without stdout redirected to /dev/null):

    if prog "${VARIABLE}" '<glob>'; then
        echo VARIABLE matches
    else
        echo no match
    fi

Bugs

There is no way to escape the meta characters. Dammit Jim, I'm a one-liner, not a regexp lib.

All obfuscation is obviously in the recursive m() function, an 86 character glob pattern evaluator, returning nonzero for a match:

  • Just a single complex return expression.
  • Nested ternary operator ?: to save on if/else verbosity.
  • Short circuiting && and || to save even more on if/else verbosity.
  • Subtraction instead of an equality operator in *t - 42.
  • ASCII codes for * and ?.
  • Careful use of blanks even though this year's rules have extended that resource limit.
  • The source is a complete preprocessed C program. Because it communicates with the world out there by means of argv and the exit status, there is no need for stdio.h bloat. An asm guru could surely squeeze this program in less than a screenful.
  • indent(1) is probably not too helpful.

The recursion wonderfully and magically takes care of iteration and backtracking. I could tell you how it works but then I would have to kill request a NDA from you :-) Run it under a debugger with several inputs, it will be quite helpful and instructive. Handling of ? is straightforward; for * start out with *foo and foo* against foo. How does it deal with sequences of adjacent *? How could this be improved? If all else fails, recode the ?: operators with if/else and try again. For extra credit implement character classes like [a-z].