Add make test rule to 2012/zeitak + formatting
The make test rule runs the new test.sh script which checks the return value of the program run on a variety of new files (and the old incorrect.c which was renamed incorrect.paren.c). The new files include 1984/anonymous.c and 1984/anonymous.alt.c as the author explicitly mentioned that entry. The README.md file has been format/typo checked.
This commit is contained in:
1 parent
c23eb2be42
commit
5d8e061438
14 files changed
+251
-22
No files matched your search
@@ -113,7 +113,7 @@ ENTRY= zeitak
|
|||||||
PROG= ${ENTRY}
|
PROG= ${ENTRY}
|
||||||
#
|
#
|
||||||
OBJ= ${PROG}.o
|
OBJ= ${PROG}.o
|
||||||
DATA= incorrect.c
|
DATA= incorrect.paren.c incorrect.brace.c incorrect.bracket.c
|
||||||
TARGET= ${PROG}
|
TARGET= ${PROG}
|
||||||
#
|
#
|
||||||
ALT_OBJ= ${PROG}.alt.o
|
ALT_OBJ= ${PROG}.alt.o
|
||||||
@@ -135,6 +135,10 @@ all: data ${TARGET}
|
|||||||
${PROG}: ${PROG}.c
|
${PROG}: ${PROG}.c
|
||||||
${CC} ${CFLAGS} $< -o $@ ${LDFLAGS}
|
${CC} ${CFLAGS} $< -o $@ ${LDFLAGS}
|
||||||
|
|
||||||
|
test: test.sh
|
||||||
|
./$< || exit 1
|
||||||
|
|
||||||
|
|
||||||
# alternative executable
|
# alternative executable
|
||||||
#
|
#
|
||||||
alt: data ${ALT_TARGET}
|
alt: data ${ALT_TARGET}
|
||||||
|
|||||||
+22
-14
@@ -4,6 +4,9 @@
|
|||||||
make
|
make
|
||||||
```
|
```
|
||||||
|
|
||||||
|
There is an alternate version that is slightly deobfuscated. See [alternate
|
||||||
|
code](#alternate-code) below.
|
||||||
|
|
||||||
|
|
||||||
## To use:
|
## To use:
|
||||||
|
|
||||||
@@ -18,8 +21,7 @@ try [incorrect.c](incorrect.c) and the program itself.
|
|||||||
### Try:
|
### Try:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
./zeitak < zeitak.c
|
make test
|
||||||
./zeitak < incorrect.c
|
|
||||||
```
|
```
|
||||||
|
|
||||||
NOTE: it prints an error and exits on the first nesting error so it will not
|
NOTE: it prints an error and exits on the first nesting error so it will not
|
||||||
@@ -28,17 +30,19 @@ detect multiple issues!
|
|||||||
|
|
||||||
## Alternate code:
|
## Alternate code:
|
||||||
|
|
||||||
An alternate version of this entry, [zeitak.alt.c](zeitak.alt.c), is provided.
|
This version, [zeitak.alt.c](zeitak.alt.c), is a version that has been slightly
|
||||||
The file [zeitak.alt.c](zeitak.alt.c) provides a version that has been slightly
|
deobfuscated. You may find reading it helpful in your attempt to understand
|
||||||
deobfuscated. You may find reading that file helpful in your attempt
|
this extremely subtle entry.
|
||||||
to understand this extremely subtle entry.
|
|
||||||
|
|
||||||
To compile this alternate version:
|
|
||||||
|
### Alternate build:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
make alt
|
make alt
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Alternate use:
|
||||||
|
|
||||||
Use `zeitak.alt` as you would `zeitak` above.
|
Use `zeitak.alt` as you would `zeitak` above.
|
||||||
|
|
||||||
|
|
||||||
@@ -55,8 +59,10 @@ just to understand 18 key characters of this code.
|
|||||||
|
|
||||||
## Author's remarks:
|
## Author's remarks:
|
||||||
|
|
||||||
|
|
||||||
### Nesting Errors Detector
|
### Nesting Errors Detector
|
||||||
|
|
||||||
|
|
||||||
#### What does it do
|
#### What does it do
|
||||||
|
|
||||||
As you have probably understood by looking at the source\*, this program has
|
As you have probably understood by looking at the source\*, this program has
|
||||||
@@ -69,7 +75,8 @@ If an error is detected, an error message will be printed. If the problem
|
|||||||
is a superfluous closing bracket, it will even print a few characters
|
is a superfluous closing bracket, it will even print a few characters
|
||||||
around it's position.
|
around it's position.
|
||||||
|
|
||||||
* Make sure you view the source with 4 spaces tab width.
|
\* Make sure you view the source with 4 spaces tab width.
|
||||||
|
|
||||||
|
|
||||||
#### Features
|
#### Features
|
||||||
|
|
||||||
@@ -99,7 +106,7 @@ even more limited source, that is:
|
|||||||
|
|
||||||
* Without any digits.
|
* Without any digits.
|
||||||
* Without any character constants.
|
* Without any character constants.
|
||||||
* Without using functions from headers other than stdio.
|
* Without using functions from headers other than `stdio`.
|
||||||
* Without any control-flow keywords (not even the `?:` operator).
|
* Without any control-flow keywords (not even the `?:` operator).
|
||||||
* Without any arithmetic or logic operators!
|
* Without any arithmetic or logic operators!
|
||||||
|
|
||||||
@@ -107,7 +114,8 @@ So, what's left? Parenthesis, and lots of them, as looking at the source will
|
|||||||
reveal immediately. The main obfuscation is building the whole algorithm using
|
reveal immediately. The main obfuscation is building the whole algorithm using
|
||||||
only function calls, typecasts, array lookups and pointer operators.
|
only function calls, typecasts, array lookups and pointer operators.
|
||||||
|
|
||||||
##### Additional obfuscations include:
|
|
||||||
|
#### Additional obfuscations include:
|
||||||
|
|
||||||
* Extensive reuse of identifiers: Macros share names with variables, inner
|
* Extensive reuse of identifiers: Macros share names with variables, inner
|
||||||
curly braces scopes contain variables with names identical to those in the
|
curly braces scopes contain variables with names identical to those in the
|
||||||
@@ -117,16 +125,16 @@ only function calls, typecasts, array lookups and pointer operators.
|
|||||||
* Mostly one-letter identifiers.
|
* Mostly one-letter identifiers.
|
||||||
* Complex recursion: A function might call itself once, twice, or not at all.
|
* Complex recursion: A function might call itself once, twice, or not at all.
|
||||||
|
|
||||||
|
|
||||||
#### Compilation/Portability/Running Notes
|
#### Compilation/Portability/Running Notes
|
||||||
|
|
||||||
* The program requires `char` to be one byte and pointers to be
|
* The program requires `char` to be one byte and pointers to be
|
||||||
at least two bytes long.
|
at least two bytes long.
|
||||||
|
|
||||||
* The program was tested on the following platforms:
|
* The program was tested on the following platforms:
|
||||||
|
- Ubuntu 9.04 32-bit with GCC
|
||||||
- Ubuntu 9.04 32-bit with GCC
|
- Windows 7 32-bit with GCC
|
||||||
- Windows 7 32-bit with GCC
|
- Windows 7 32-bit with OpenWatcom
|
||||||
- Windows 7 32-bit with OpenWatcom
|
|
||||||
|
|
||||||
|
|
||||||
## Copyright and CC BY-SA 4.0 License:
|
## Copyright and CC BY-SA 4.0 License:
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
int i;main(){for(;i["]<i;++i){--i;}"];read('-'-'-',i+++"hell\
|
||||||
|
o, world!\n",'/'/'/'));}read(j,i,p){write(j/p+p,i---j,i/i);}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
int i;main(){for(;i["]<i;++i){--i;}"];read('-'-'-',i+++"hell\
|
||||||
|
o, world!\n",'/'/'/'));}read(j,i,p)void*i;{write(j/p+p,i---j,(int)i/(int)i);}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int i=40;
|
||||||
|
printf(");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int i=40;
|
||||||
|
printf(""");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main() {}}
|
||||||
|
int i=40;
|
||||||
|
printf("%c",(char)(i)));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main() ]] }}
|
||||||
|
int i=40;
|
||||||
|
printf("%c",(char)(i)));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
int i=40;
|
int i=40;
|
||||||
printf("%c",(char)(i)));
|
printf("%c",(char)(i)));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int i=40;
|
||||||
|
printf("\"");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int i=40;
|
||||||
|
printf(');
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
"
|
||||||
Executable
+161
@@ -0,0 +1,161 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# try.sh - demonstrate IOCCC winner 2012/zeitak
|
||||||
|
#
|
||||||
|
|
||||||
|
# make sure CC is set so that when we do make CC="$CC" it isn't empty. Doing it
|
||||||
|
# this way allows us to have the user specify a different compiler in an easy
|
||||||
|
# way.
|
||||||
|
if [[ -z "$CC" ]]; then
|
||||||
|
CC="cc"
|
||||||
|
fi
|
||||||
|
|
||||||
|
make CC="$CC" all >/dev/null || exit 1
|
||||||
|
|
||||||
|
# clear screen after compilation so that only the entry is shown
|
||||||
|
clear
|
||||||
|
|
||||||
|
# assume no error: set ERROR to 0
|
||||||
|
ERROR=0
|
||||||
|
|
||||||
|
read -r -n 1 -p "Press any key to test zeitak.c for nesting errors: "
|
||||||
|
echo 1>&2
|
||||||
|
./zeitak < zeitak.c
|
||||||
|
EXIT_CODE="$?"
|
||||||
|
if [[ "$EXIT_CODE" -ne 3 ]]; then
|
||||||
|
echo "Error: did not get exit code 3: $EXIT_CODE" 1>&2
|
||||||
|
ERROR=1
|
||||||
|
fi
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
echo "$ cat anonymous.c" 1>&2
|
||||||
|
cat anonymous.c
|
||||||
|
echo 1>&2
|
||||||
|
read -r -n 1 -p "Press any key to test anonymous.c for nesting errors: "
|
||||||
|
echo 1>&2
|
||||||
|
./zeitak < anonymous.c
|
||||||
|
EXIT_CODE="$?"
|
||||||
|
if [[ "$EXIT_CODE" -ne 3 ]]; then
|
||||||
|
echo "Error: did not get exit code 3: $EXIT_CODE" 1>&2
|
||||||
|
ERROR=1
|
||||||
|
fi
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
echo "$ cat anonymous.alt.c" 1>&2
|
||||||
|
cat anonymous.alt.c
|
||||||
|
echo 1>&2
|
||||||
|
read -r -n 1 -p "Press any key to test anonymous.alt.c for nesting errors: "
|
||||||
|
echo 1>&2
|
||||||
|
./zeitak < anonymous.alt.c
|
||||||
|
EXIT_CODE="$?"
|
||||||
|
if [[ "$EXIT_CODE" -ne 3 ]]; then
|
||||||
|
echo "Error: did not get exit code 3: $EXIT_CODE" 1>&2
|
||||||
|
ERROR=1
|
||||||
|
fi
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
echo "$ cat incorrect.brace.c" 1>&2
|
||||||
|
cat incorrect.brace.c
|
||||||
|
echo 1>&2
|
||||||
|
read -r -n 1 -p "Press any key to test incorrect.brace.c: "
|
||||||
|
echo 1>&2
|
||||||
|
./zeitak < incorrect.brace.c
|
||||||
|
EXIT_CODE="$?"
|
||||||
|
if [[ "$EXIT_CODE" -ne 10 ]]; then
|
||||||
|
echo "Error: did not get exit code 10: $EXIT_CODE" 1>&2
|
||||||
|
ERROR=1
|
||||||
|
fi
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
echo "$ cat incorrect.bracket.c" 1>&2
|
||||||
|
cat incorrect.bracket.c
|
||||||
|
echo 1>&2
|
||||||
|
read -r -n 1 -p "Press any key to test incorrect.bracket.c: "
|
||||||
|
echo 1>&2
|
||||||
|
./zeitak < incorrect.bracket.c
|
||||||
|
EXIT_CODE="$?"
|
||||||
|
if [[ "$EXIT_CODE" -ne 10 ]]; then
|
||||||
|
echo "Error: did not get exit code 10: $EXIT_CODE" 1>&2
|
||||||
|
ERROR=1
|
||||||
|
fi
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
echo "$ cat incorrect.paren.c" 1>&2
|
||||||
|
cat incorrect.paren.c
|
||||||
|
echo 1>&2
|
||||||
|
read -r -n 1 -p "Press any key to test incorrect.paren.c: "
|
||||||
|
echo 1>&2
|
||||||
|
./zeitak < incorrect.paren.c
|
||||||
|
EXIT_CODE="$?"
|
||||||
|
if [[ "$EXIT_CODE" -ne 10 ]]; then
|
||||||
|
echo "Error: did not get exit code 10: $EXIT_CODE" 1>&2
|
||||||
|
ERROR=1
|
||||||
|
fi
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
echo "$ cat incorrect.quote-esc.c" 1>&2
|
||||||
|
cat incorrect.quote-esc.c
|
||||||
|
echo 1>&2
|
||||||
|
read -r -n 1 -p "Press any key to test incorrect.quote-esc.c: "
|
||||||
|
echo 1>&2
|
||||||
|
./zeitak < incorrect.quote-esc.c
|
||||||
|
EXIT_CODE="$?"
|
||||||
|
if [[ "$EXIT_CODE" -ne 10 ]]; then
|
||||||
|
echo "Error: did not get exit code 10: $EXIT_CODE" 1>&2
|
||||||
|
ERROR=1
|
||||||
|
fi
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
echo "$ cat incorrect.3.quotes.c" 1>&2
|
||||||
|
cat incorrect.3.quotes.c
|
||||||
|
echo 1>&2
|
||||||
|
read -r -n 1 -p "Press any key to test incorrect.3.quotes.c: "
|
||||||
|
echo 1>&2
|
||||||
|
./zeitak < incorrect.3.quotes.c
|
||||||
|
EXIT_CODE="$?"
|
||||||
|
if [[ "$EXIT_CODE" -ne 10 ]]; then
|
||||||
|
echo "Error: did not get exit code 10: $EXIT_CODE" 1>&2
|
||||||
|
ERROR=1
|
||||||
|
fi
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
echo "$ cat incorrect.single.quote.c" 1>&2
|
||||||
|
cat incorrect.single.quote.c
|
||||||
|
echo 1>&2
|
||||||
|
read -r -n 1 -p "Press any key to test incorrect.single.quote.c: "
|
||||||
|
echo 1>&2
|
||||||
|
./zeitak < incorrect.single.quote.c
|
||||||
|
EXIT_CODE="$?"
|
||||||
|
if [[ "$EXIT_CODE" -ne 10 ]]; then
|
||||||
|
echo "Error: did not get exit code 10: $EXIT_CODE" 1>&2
|
||||||
|
ERROR=1
|
||||||
|
fi
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
echo "$ cat incorrect.1.quote.c" 1>&2
|
||||||
|
cat incorrect.1.quote.c
|
||||||
|
echo 1>&2
|
||||||
|
read -r -n 1 -p "Press any key to test incorrect.1.quote.c: "
|
||||||
|
echo 1>&2
|
||||||
|
./zeitak < incorrect.1.quote.c
|
||||||
|
EXIT_CODE="$?"
|
||||||
|
if [[ "$EXIT_CODE" -ne 10 ]]; then
|
||||||
|
echo "Error: did not get exit code 10: $EXIT_CODE" 1>&2
|
||||||
|
ERROR=1
|
||||||
|
fi
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
echo "$ cat incorrect.txt" 1>&2
|
||||||
|
cat incorrect.txt
|
||||||
|
echo 1>&2
|
||||||
|
read -r -n 1 -p "Press any key to test incorrect.txt: "
|
||||||
|
echo 1>&2
|
||||||
|
./zeitak < incorrect.txt
|
||||||
|
EXIT_CODE="$?"
|
||||||
|
if [[ "$EXIT_CODE" -ne 10 ]]; then
|
||||||
|
echo "Error: did not get exit code 10: $EXIT_CODE" 1>&2
|
||||||
|
ERROR=1
|
||||||
|
fi
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
exit "$ERROR"
|
||||||
@@ -3382,6 +3382,15 @@ We're not sure whether we want to thank Cody or not for this :-) and he's not
|
|||||||
sure if he wants to be thanked either :-) but we appreciate it nonetheless.
|
sure if he wants to be thanked either :-) but we appreciate it nonetheless.
|
||||||
|
|
||||||
|
|
||||||
|
## [2012/zeitak](2012/zeitak/zeitak.c) ([README.md](2012/zeitak/README.md]))
|
||||||
|
|
||||||
|
Cody added the `make test` rule and the [test.sh](2012/zeitak/test.sh) along
|
||||||
|
with a number of files that will be correctly be flagged as incorrect (including
|
||||||
|
a text file to show that it's not that it parses C but rather just matching
|
||||||
|
pairs though that should be obvious) and also some that are correct including
|
||||||
|
1984/anonymous (as the author explicitly mentioned it).
|
||||||
|
|
||||||
|
|
||||||
# <a name="2013"></a>2013
|
# <a name="2013"></a>2013
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user