improve how markdown code language is commented
We added a space between the markdown triple code mark and language that was enclosed in HTML comments. So a line of the form: ```` ```<!---c---> ```` became: ```` ``` <!---c---> ```` This was done to **help** some code see that the HTML comment string was not a markdown code specifier. Not all code understands this after this changed. For example, `pandoc(1)` still forms HTML classes of the form "<!---c-->" when it encounters the above mentioned change. We also fixed a problem with `2019/dogon/README.md` regarding a markdown code block. We also fixed a problem with `2020/yang/README.md` regarding a markdown code block.
This commit is contained in:
1 parent
c549f6585e
commit
3ddbac9e6b
357 files changed
+2432
-2399
No files matched your search
@@ -1,19 +1,19 @@
|
||||
## To build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./prog "expression"
|
||||
```
|
||||
|
||||
or:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./prog
|
||||
```
|
||||
|
||||
@@ -22,13 +22,13 @@ Type in expressions on standard input.
|
||||
|
||||
## Try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./try.sh
|
||||
```
|
||||
|
||||
Notice how the script reads in from a file. If you type just:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./prog
|
||||
```
|
||||
|
||||
@@ -37,7 +37,7 @@ it will prompt you in the same way. Send ctrl-c to exit.
|
||||
|
||||
Finally, if you wish to read the man page:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
man ./calc.1
|
||||
```
|
||||
|
||||
@@ -51,7 +51,7 @@ author's remarks below.
|
||||
|
||||
### Alternate build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make alt
|
||||
```
|
||||
|
||||
@@ -109,7 +109,7 @@ Yes, this is another calculator program.
|
||||
However, unlike any other calculator source code the author is aware of,
|
||||
this one contains no digits. At all. Anywhere. As in
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
grep '[0-9]' prog.c || echo no digits!
|
||||
```
|
||||
|
||||
@@ -222,7 +222,7 @@ With `-Wall -std=c99`, both are quite noisy, and all can be ignored:
|
||||
If the program name begins with an `e`, it echoes `stdin` to `stdout`.
|
||||
This allows for a convenient test suite:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
ln -sf prog eprog
|
||||
PATH=. eprog < test.in | diff - test.out
|
||||
```
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
## To build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make
|
||||
```
|
||||
|
||||
To change the dimensions you can use the `WIDTH` and `HEIGHT` variables when
|
||||
compiling (default 1024 x 800):
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make clobber WIDTH=640 HEIGHT=480
|
||||
```
|
||||
|
||||
@@ -22,14 +22,14 @@ code](#alternate-code) below.
|
||||
|
||||
## To use:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./prog
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./prog
|
||||
```
|
||||
|
||||
@@ -77,7 +77,7 @@ This alt version does this for you.
|
||||
|
||||
### Alternate build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make alt
|
||||
```
|
||||
|
||||
@@ -174,7 +174,7 @@ important support of up to 32 function keys keyboards without spilling over the
|
||||
size limit, and allows us to use such fun expression for arrow view control as
|
||||
the following:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
*(a&1?&C:&B)-=(.05 -a/2%2*.1)*!(a-1&4092^3920)
|
||||
```
|
||||
|
||||
|
||||
+10
-10
@@ -1,6 +1,6 @@
|
||||
## To build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make
|
||||
```
|
||||
|
||||
@@ -10,14 +10,14 @@ See [Alternate code](#alternate-code) below.
|
||||
|
||||
## To use:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
echo Some text | ./prog
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./try.sh
|
||||
```
|
||||
|
||||
@@ -34,7 +34,7 @@ author in the '[prog.c](prog.c) vs [prog.alt.c](prog.alt.c)' section of their re
|
||||
|
||||
### Alternate build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make alt
|
||||
```
|
||||
|
||||
@@ -84,13 +84,13 @@ been shortened in this file.
|
||||
|
||||
If you have `clang`:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
CC=clang make -e
|
||||
```
|
||||
|
||||
Otherwise (gcc):
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make
|
||||
```
|
||||
|
||||
@@ -116,7 +116,7 @@ needed in this case).
|
||||
|
||||
#### Basic mode:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ echo 'I am testing this thing.' | ./prog
|
||||
[... rendering ...]
|
||||
|
||||
@@ -127,7 +127,7 @@ needed in this case).
|
||||
|
||||
#### Interactive mode:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ ./prog
|
||||
> hello world!!!
|
||||
[... rendering ...]
|
||||
@@ -206,7 +206,7 @@ simple text documents.
|
||||
|
||||
Thus, if you try for example:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ ./prog < prog.c
|
||||
```
|
||||
|
||||
@@ -219,7 +219,7 @@ you are curious. :)
|
||||
Defining an environment variable called `DRAFT` will enable the 'draft-mode'.
|
||||
Try for example:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ echo 'testing the draft mode' | DRAFT=1 ./prog
|
||||
```
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## To build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make
|
||||
```
|
||||
|
||||
@@ -11,7 +11,7 @@ require it](../../faq.html#tcpserver).
|
||||
|
||||
## To use:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
tcpserver -v 127.0.0.1 10333 ./prog ioccc.txt
|
||||
```
|
||||
|
||||
@@ -44,7 +44,7 @@ his work.
|
||||
|
||||
Compile the program as follows:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
cc -O3 -std=c99 \
|
||||
-Wall -Wextra -pedantic -o prog prog.c \
|
||||
-Delta_u="Du*laplacian(u)-u*v*v+F*(1-u)" \
|
||||
@@ -59,7 +59,7 @@ Then, run it with the `tcpserver` command in the
|
||||
[Daniel J. Bernstein](../../authors.html#Daniel_J_Bernstein)'s
|
||||
[1991/brndstd](../../1991/brnstnd/index.html) "Best of Show".
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
tcpserver -v 127.0.0.1 10333 ./prog ioccc.txt
|
||||
```
|
||||
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
## To build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./prog
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./try.sh
|
||||
```
|
||||
|
||||
@@ -31,7 +31,7 @@ At this point you might be wondering, [WTF](http://acronyms.thefreedictionary.co
|
||||
|
||||
How is this code obfuscated? Well look again:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
less prog.c
|
||||
|
||||
more prog.c
|
||||
@@ -49,7 +49,7 @@ If you are still puzzled, look at [prog.c](prog.c) with your favorite text edito
|
||||
|
||||
**Follow these instructions literally!**
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
cat prog.c
|
||||
gcc -w -o prog prog.c
|
||||
./prog
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
## To build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./prog
|
||||
```
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
To see the original [mullender](mullender.c) in action:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./try.sh
|
||||
```
|
||||
|
||||
@@ -26,7 +26,7 @@ like at the end. Send INTR to end the program.
|
||||
|
||||
More generally use:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
cc -o prog prog.c foo.c
|
||||
./prog
|
||||
^C # if necessary, where ^C is ctrl-C, interrrupt
|
||||
@@ -71,7 +71,7 @@ Read it upside down.)
|
||||
|
||||
You got it? This program is supposed to be used in this way:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
wget https://www.ioccc.org/1984/mullender.c
|
||||
clang -o prog prog.c mullender.c
|
||||
./prog
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## To build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make
|
||||
```
|
||||
|
||||
@@ -11,14 +11,14 @@ code](#alternate-code) below for details.
|
||||
|
||||
## To use:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./prog <a number of arguments>
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./try.sh
|
||||
```
|
||||
|
||||
@@ -32,7 +32,7 @@ Dogon](../../authors.html#Gil_Dogon); it is the author's original entry.
|
||||
|
||||
### Alternate build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make alt
|
||||
```
|
||||
|
||||
@@ -54,7 +54,7 @@ experiment with numbers that have more or larger factors?
|
||||
|
||||
Visual factorization 1-liner. Try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
gcc -o prog prog.c
|
||||
./prog @
|
||||
./prog @ @
|
||||
|
||||
+5
-5
@@ -1,6 +1,6 @@
|
||||
## To build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make
|
||||
```
|
||||
|
||||
@@ -18,7 +18,7 @@ For more detailed information see [2015 hou bugs](../../bugs.html#2015_hou).
|
||||
|
||||
## To use:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
echo something | ./prog
|
||||
./prog < file
|
||||
```
|
||||
@@ -26,7 +26,7 @@ For more detailed information see [2015 hou bugs](../../bugs.html#2015_hou).
|
||||
|
||||
## Try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./try.sh
|
||||
```
|
||||
|
||||
@@ -42,7 +42,7 @@ the reference code!
|
||||
|
||||
Some things that make you go, "huh?"
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./prog < prog.c | cut -c-5
|
||||
./prog < Makefile | cut -c-4
|
||||
```
|
||||
@@ -51,7 +51,7 @@ How are those values magically returned?
|
||||
|
||||
What happens with a large file? Something over 256K.
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./prog < large_file
|
||||
```
|
||||
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
## To build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make
|
||||
```
|
||||
|
||||
@@ -10,7 +10,7 @@ below.
|
||||
|
||||
## To use:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./prog file1 file2
|
||||
|
||||
./prog -d file1 file2
|
||||
@@ -19,7 +19,7 @@ below.
|
||||
|
||||
## Try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./try.sh
|
||||
```
|
||||
|
||||
@@ -32,7 +32,7 @@ entry but was changed to be the alt version.
|
||||
|
||||
### Alternate build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make alt
|
||||
```
|
||||
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
## To build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./prog
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./prog
|
||||
```
|
||||
|
||||
@@ -27,13 +27,13 @@ Did you find that mobile application game a bit frustrating?
|
||||
Well you can adjust the Makefile parameters to make life a
|
||||
bit easier for you:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./try.sh
|
||||
```
|
||||
|
||||
which runs:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make clobber all DW=199999 DW=22 DH=16 DA=50 DI=-150
|
||||
./prog
|
||||
```
|
||||
@@ -147,13 +147,13 @@ to make some changes to the `Makefile` to get emojis to work on your system.
|
||||
To help you get started, I've included some example substitutions for emojis
|
||||
sprites and instruction text; for example, type
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make EMOJI=beer LANGUAGE=spanish
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make EMOJI=globe
|
||||
```
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## To build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make
|
||||
```
|
||||
|
||||
@@ -18,14 +18,14 @@ For more detailed information see [2015 mills2 bugs](../../bugs.html#2015_mills2
|
||||
|
||||
## To use:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./prog compressed_file.Z
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./try.sh
|
||||
```
|
||||
|
||||
@@ -39,7 +39,7 @@ for a `compress(1)`-like compressor using a similar idea.
|
||||
|
||||
Why is the sad smiley on line 12 in that particular place?
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
c=0) :( O
|
||||
```
|
||||
|
||||
@@ -66,7 +66,7 @@ on the command line. On the odd chance you don't have `compress(1)` hanging abo
|
||||
on your system, I've provided compressed copies of this year's IOCCC rules
|
||||
and guidelines files. To print them, just do
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./prog ioccc_guidelines.txt.Z
|
||||
./prog ioccc_rules.txt.Z
|
||||
```
|
||||
|
||||
+7
-7
@@ -1,20 +1,20 @@
|
||||
## To build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make -B [MACHINE=your_machine.h] [TAPE=your_tape.h] [X=[0|1|2|3|4|5|6|7|8|9]] [V=[0|1|2]] run
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./try.sh
|
||||
```
|
||||
|
||||
@@ -68,13 +68,13 @@ files for examples.
|
||||
|
||||
Every symbol used (except `_`) must be explicitly declared using
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
#define sym_SYMBOL(sym, _SYMBOL) sym
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
#define sym_1(sym, _1) sym
|
||||
```
|
||||
|
||||
@@ -84,7 +84,7 @@ Example:
|
||||
The initial content of the tape must be defined in the tape header using a
|
||||
triple like:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
#define tape ((((,),...l2), l1), c, (r1, (r2..., (,))))
|
||||
```
|
||||
|
||||
@@ -119,7 +119,7 @@ machine.
|
||||
|
||||
To halt the machine, use the keyword `break` as in
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
#define A_1 (2, break)
|
||||
```
|
||||
|
||||
|
||||
+22
-22
@@ -1,6 +1,6 @@
|
||||
## To build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make
|
||||
```
|
||||
|
||||
@@ -18,7 +18,7 @@ For more detailed information see [2015 schweikhardt bugs](../../bugs.html#2015_
|
||||
|
||||
## To use:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./prog n
|
||||
```
|
||||
|
||||
@@ -30,7 +30,7 @@ doing something else. The author explains this in more details.
|
||||
|
||||
## Try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./try.sh
|
||||
```
|
||||
|
||||
@@ -44,7 +44,7 @@ where zeroes move to the right.
|
||||
This code is clean. When you compile with all warnings enabled,
|
||||
such as with clang:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
cc -Weverything -pedantic -std=c11 -Dtyp=uint64\_t -O3 prog.c -o prog
|
||||
```
|
||||
|
||||
@@ -73,7 +73,7 @@ the [Collatz conjecture](https://en.wikipedia.org/wiki/Collatz_conjecture).
|
||||
|
||||
You may explore this famous conjecture using this entry:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./prog 2410
|
||||
./prog abfff
|
||||
./prog 27f8cebf
|
||||
@@ -158,7 +158,7 @@ prefix) as the first argument. The program prints the given number in
|
||||
zero-padded hex and each iteration along with a line count in decimal.
|
||||
The example above looks like this (compiled with 64 bit word size):
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ ./prog 6
|
||||
0000000000000006
|
||||
0000000000000003 1
|
||||
@@ -175,7 +175,7 @@ The size of `n` is only limited by the argument size limit of your
|
||||
shell/OS (the program implements arbitrary size `bignum`s).
|
||||
To query this on your POSIX system, run
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ getconf ARG_MAX
|
||||
262144
|
||||
```
|
||||
@@ -187,7 +187,7 @@ Fear not,
|
||||
[bc(1)](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html)
|
||||
to the rescue:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ printf 'obase=16;10^100\n' | bc
|
||||
1249AD2594C37CEB0B2784C4CE0BF38ACE408E211A7CAAB24308A82E8F1000000000\
|
||||
0000000000000000
|
||||
@@ -333,7 +333,7 @@ hard, I could use `__LINE__` and `stdio.h` macros `EOF`, `L_tmpnam`,
|
||||
Another identity operation. I've done it for you already. Use this
|
||||
`.indent.pro` with FreeBSD indent:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ cat .indent.pro
|
||||
-bad /* blank line after decls */
|
||||
-bap /* blank line after functions */
|
||||
@@ -383,7 +383,7 @@ Spoilers ahead. Duh!
|
||||
|
||||
Pseudocode, with comments matching those in the C source:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
/* run */
|
||||
if (non-NULL and nonempty argv[1]) {
|
||||
n = convert(argv[1])
|
||||
@@ -404,7 +404,7 @@ Pseudocode, with comments matching those in the C source:
|
||||
|
||||
`Bignum`s are represented as the two member `struct`s:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
typedef struct {
|
||||
size_t places; /* number of places in base 2 to the power of (8*sizeof(type)) */
|
||||
type *number; /* dynamically allocated memory for number */
|
||||
@@ -438,7 +438,7 @@ into a starting number (which is output as the first line), and starts
|
||||
crunching. Nothing stops you from executing
|
||||
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./prog "$(cat prog.c)" # Kind of quine?
|
||||
./prog "$(cat rules guidelines)" # A jackpot? Maybe next year...
|
||||
./prog "$(cat /bin/ls)" # Number cut short at first NUL byte.
|
||||
@@ -473,7 +473,7 @@ The open source static checker [cppcheck](http://cppcheck.sourceforge.net/)
|
||||
checks various problems with respect to style, performance, portability
|
||||
and general fishiness. To enable all checks, run
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
cppcheck --enable=all --force -I/usr/include -Dtyp=uint32_t prog.c
|
||||
```
|
||||
|
||||
@@ -486,7 +486,7 @@ checks various problems with respect to security like buffer overflows,
|
||||
function arguments to known troublemaker functions and more. It doesn't need to
|
||||
pre-process code, so can be run without the `typ` macro being defined:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ flawfinder prog.c
|
||||
Flawfinder version 1.31, (C) 2001-2014 David A. Wheeler.
|
||||
Number of rules (primarily dangerous function names) in C/C++ ruleset: 169
|
||||
@@ -592,7 +592,7 @@ use for checking your C programs and I highly recommend trying it. For a start,
|
||||
paste the well know first program in the form and press "Analyze Code". Note
|
||||
the FlexeLint configuration options in comments (no space between `/*` and `lint`).
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
/*lint -w4 turn on everything */
|
||||
/*lint +esym(534,*) no demonstrator defaults */
|
||||
/*lint -e966 indirectly included header file not used */
|
||||
@@ -705,7 +705,7 @@ expressions other than assignments to `char` objects. A consequence is
|
||||
that printing digits with `'0' + digit` is not allowed (even though
|
||||
`'0'` is technically an `int`!) so I am forced to output hex digits with
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
printf("%c", (met)tyr + 32 + 16 + ((8 + EOF) * ((met)tyr / (8 + 2))));
|
||||
```
|
||||
|
||||
@@ -730,7 +730,7 @@ precedence rules in expressions." This requires parentheses for almost
|
||||
all expressions involving more than one operator, especially those for which
|
||||
a cast is required, leading to hard to understand expressions such as
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
const ser glx = (ser)((asx > (ser)64u) ? (ser)((ser)asx + (ser)8u + (ser)1u) : (ser)asx);
|
||||
not.not[leu] = (and)((and)not.not[leu] | (and)(((and)glx % (and)16u) << (and)lys));
|
||||
```
|
||||
@@ -747,7 +747,7 @@ MISRA 16.10: "If a function returns error information, then that error
|
||||
information shall be tested." A cast to `void` would draw a lint warning, so
|
||||
I use the `printf(3)` result in expressions,
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
lys -= 4 * printf("%c", (met)tyr + 32 + 16 + ((8 + EOF) * ((met)tyr / (8 + 2))));
|
||||
val += printf("\n") / ((__LINE__ * L_tmpnam) + TMP_MAX);
|
||||
val -= (printf(" %d\n", val) > BUFSIZ) ? FILENAME_MAX : EOF;
|
||||
@@ -755,7 +755,7 @@ I use the `printf(3)` result in expressions,
|
||||
|
||||
which are, in the absence of errors, equivalent to
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
lys -= 4;
|
||||
/*nop*/
|
||||
++val;
|
||||
@@ -772,7 +772,7 @@ declared as pointer to `const` if the pointer is not used to modify the
|
||||
addressed object." in conjunction with lint's "Note 952: Parameter could
|
||||
be declared `const`" causes `const`-poisoning for all functions,
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
static void phe(const ala not);
|
||||
static void gly(ala *const not, const and his);
|
||||
met main(met val, const pro *const his[]);
|
||||
@@ -792,13 +792,13 @@ up :-) (humor really helps!)"
|
||||
If your compiler supports a 128 bit wide type (e.g. clang, gcc) then
|
||||
you can use it via the `typ` macro:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
clang -Dtyp=__uint128_t -o prog prog.c
|
||||
```
|
||||
|
||||
Indeed, the program can use (and lints clean for) all of
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
clang -Dtyp=uint8_t -o prog8 prog.c
|
||||
clang -Dtyp=uint16_t -o prog16 prog.c
|
||||
clang -Dtyp=uint32_t -o prog32 prog.c
|
||||
|
||||
+8
-8
@@ -1,20 +1,20 @@
|
||||
## To build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
echo Some text | ./prog
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./try.sh
|
||||
```
|
||||
|
||||
@@ -37,7 +37,7 @@ so you need not worry about this.
|
||||
`Fuuko` is a [sea star](https://en.wikipedia.org/wiki/Starfish) generator. Feed
|
||||
her some input through `stdin` to get lots of sea star patterns on `stdout`.
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
cc -O3 -std=c90 fuuko.c -lm -o fuuko_c90
|
||||
echo IOCCC | ./fuuko_c90 > output_c90.c
|
||||
```
|
||||
@@ -45,7 +45,7 @@ her some input through `stdin` to get lots of sea star patterns on `stdout`.
|
||||
If you compile with a C99 compiler instead of C90, the sea stars will
|
||||
have eyes.
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
cc -O3 -std=c99 fuuko.c -lm -o fuuko_c99
|
||||
echo IOCCC | ./fuuko_c99 > output_c99.c
|
||||
```
|
||||
@@ -53,7 +53,7 @@ have eyes.
|
||||
Don't like [sea stars](https://en.wikipedia.org/wiki/Starfish)? Use a C++98
|
||||
compiler to get a [dango](https://en.wikipedia.org/wiki/Dango) instead.
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
g++ -O3 -std=c++98 fuuko.c -lm -o fuuko_cpp98
|
||||
echo IOCCC | ./fuuko_cpp98 > output_cpp98.c
|
||||
```
|
||||
@@ -63,7 +63,7 @@ compiler to get just [circles](https://en.wikipedia.org/wiki/Circle) (or [Swiss
|
||||
cheese](https://en.wikipedia.org/wiki/Swiss_cheeses_and_dairy_products), if you
|
||||
prefer that).
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
g++ -O3 -std=c++11 fuuko.c -lm -o fuuko_cpp11
|
||||
echo IOCCC | ./fuuko_cpp11 > output_cpp11.c
|
||||
```
|
||||
@@ -71,7 +71,7 @@ prefer that).
|
||||
Don't like any of these patterns? Use a C11 compiler and there will be
|
||||
no extra pattern.
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
cc -O3 -std=c11 fuuko.c -lm -o fuuko_c11
|
||||
echo IOCCC | ./fuuko_c11 > output_c11.c
|
||||
```
|
||||
|
||||
Reference in new issue
Block a user