Fix assumption that EOF==-1 in 2015/schweikhardt
The author stated EOF must be -1 but this is, as the author even noted,
not guaranteed by the standard (it just has to be a value < 0).
But rather than add C pre-processor directives to force EOF to be -1
(preferred over changing EOF to -1 in the code) the Makefile does (after
${CFLAGS}) -UEOF -DEOF=-1 so as to not have to modify the code any.
A few fixes in the README.md file.
This should complete this entry, leaving just (I think) 2015/endoh1.
This commit is contained in:
1 parent
0335c04e15
commit
3a1c9da50a
3 files changed
+15
-3
No files matched your search
@@ -129,7 +129,7 @@ all: data ${TARGET}
|
|||||||
sandwich supernova deep_magic magic charon pluto
|
sandwich supernova deep_magic magic charon pluto
|
||||||
|
|
||||||
${PROG}: ${PROG}.c
|
${PROG}: ${PROG}.c
|
||||||
${CC} ${CFLAGS} $< -o $@ ${LDFLAGS}
|
${CC} ${CFLAGS} -UEOF -DEOF=-1 $< -o $@ ${LDFLAGS}
|
||||||
|
|
||||||
# alternative executable
|
# alternative executable
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -24,6 +24,9 @@ For more detailed information see [2015 schweikhardt in bugs.md](/bugs.md#2015-s
|
|||||||
|
|
||||||
where n is a base 16 number of any size.
|
where n is a base 16 number of any size.
|
||||||
|
|
||||||
|
NOTE: although it's supposed to be a base 16 number nothing will stop you from
|
||||||
|
doing something else. The author explains this in more details.
|
||||||
|
|
||||||
|
|
||||||
### Try:
|
### Try:
|
||||||
|
|
||||||
@@ -31,6 +34,10 @@ where n is a base 16 number of any size.
|
|||||||
./try.sh
|
./try.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
|
After running it once to see what commands are run, you might wish to run it a
|
||||||
|
second time and just hold down space to see a fun scroll of numbers especially
|
||||||
|
where zeroes move to the right.
|
||||||
|
|
||||||
|
|
||||||
## Judges' remarks:
|
## Judges' remarks:
|
||||||
|
|
||||||
@@ -445,7 +452,7 @@ In a certain way, the program is character set and encoding agnostic.
|
|||||||
|
|
||||||
* The `EOF` macro from `<stdio.h>` must expand to `-1` since it is used
|
* The `EOF` macro from `<stdio.h>` must expand to `-1` since it is used
|
||||||
to decrement a pointer and do some other math.
|
to decrement a pointer and do some other math.
|
||||||
None of the tools catches this one. The program self-protects against unusual
|
None of the tools catch this one. The program self-protects against unusual
|
||||||
systems with `#if EOF + __STDC__` followed by `#error goofy!`. In the rare event
|
systems with `#if EOF + __STDC__` followed by `#error goofy!`. In the rare event
|
||||||
your system is goofy, replace all `EOF` tokens with `(-1)` and remove the
|
your system is goofy, replace all `EOF` tokens with `(-1)` and remove the
|
||||||
`#error` directive.
|
`#error` directive.
|
||||||
|
|||||||
+6
-1
@@ -3919,7 +3919,12 @@ past).
|
|||||||
|
|
||||||
## <a name="2015_schweikhardt"></a>[2015/endoh3](/2015/schweikhardt/prog.c) ([README.md](/2015/schweikhardt/README.md]))
|
## <a name="2015_schweikhardt"></a>[2015/endoh3](/2015/schweikhardt/prog.c) ([README.md](/2015/schweikhardt/README.md]))
|
||||||
|
|
||||||
[Cody](#cody) added the [try.sh](2015/schweikhardt/try.sh) script.
|
[Cody](#cody) fixed the build so that `EOF` will be `-1` as the program assumes
|
||||||
|
this. It was decided by Cody to do `-UEOF -DEOF=-1` so as to not have to modify
|
||||||
|
the code any with C preprocessor directives (the preferred way) or changing
|
||||||
|
`EOF` to `-1`.
|
||||||
|
|
||||||
|
Cody also added the [try.sh](2015/schweikhardt/try.sh) script.
|
||||||
|
|
||||||
|
|
||||||
## <a name="2015_yang"></a>[2015/yang](/2015/yang/prog.c) ([README.md](/2015/yang/README.md]))
|
## <a name="2015_yang"></a>[2015/yang](/2015/yang/prog.c) ([README.md](/2015/yang/README.md]))
|
||||||
|
|||||||
Reference in new issue
Block a user