Undo buffer size increase in 1994/schnitzi
As part of redefining INABIAF the entry now has an equivalent functionality with the generated output. The bugs.md file still has hints on how to get this to use fgets() (for why this is helpful see that file). As a starting point I have the original buffer size increase in schnitzi.alt.c as it would be useful to see how it works and to maybe get the entry to use fgets(). Unfortunately keeping it using gets() is a potential problem but changing it to fgets() is also a potential problem (this goes for all of the entries that use or used gets()). This entry however still uses gets(). The change is the smaller buffer size which means that the entry can not handle big files. The Makefile and README.md now refer to the small buffer size.
This commit is contained in:
1 parent
ec111eb6b2
commit
ffb639d42d
4 files changed
+14
-17
No files matched your search
@@ -128,6 +128,7 @@ all: data ${TARGET}
|
||||
supernova deep_magic magic charon pluto
|
||||
|
||||
${PROG}: ${PROG}.c
|
||||
@echo "NOTE: the buffer size of this entry is very small at 100."
|
||||
${CC} ${CFLAGS} $< -o $@ ${LIBS}
|
||||
|
||||
# alternative executable
|
||||
|
||||
+11
-15
@@ -18,20 +18,6 @@ make all
|
||||
./schnitzi < textfile
|
||||
```
|
||||
|
||||
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) increased the buffer
|
||||
size from 100 to 10000. Changing it to use `fgets()` instead of `gets()` is more
|
||||
problematic because when feeding the source code to the program the output
|
||||
results in compiler errors and not only that but the gets() is still there in
|
||||
the generated output. Even changing the buffer size can result in compilation
|
||||
errors if not done correctly. The generated output also does not have a changed
|
||||
buffer size. Changing it to use fgets() can happen later, maybe, but bigger
|
||||
files can now be parsed by the original code. An example is the Makefile. Cody
|
||||
gave some tips on how this entry works, in order to make the entry use fgets()
|
||||
and compile successfully too, in the [bugs.md](/bugs.md) file. Thank you Cody!
|
||||
|
||||
For the original source file [schnitzi.alt.c](schnitzi.alt.c) see below.
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
@@ -39,10 +25,19 @@ For the original source file [schnitzi.alt.c](schnitzi.alt.c) see below.
|
||||
./schnitzi < /etc/passwd
|
||||
```
|
||||
|
||||
NOTE: the buffer size is very small at 100. It's easy to fix the buffer size but
|
||||
it is not as easy to change it to `fgets()`. [Cody Boone
|
||||
Ferguson](/winners.html#Cody_Boone_Ferguson) gives some hints in the
|
||||
[bugs.md](/bugs.md) file on how this entry works which might be useful in order
|
||||
to get this to use `fgets()` which would prevent a warning at linking or
|
||||
runtime. The file [schnitzi.alt.c](schnitzi.alt.c) has this to get anyone
|
||||
started, should they wish to tackle it (Cody will in time). The problem with
|
||||
changing the buffer size is that even when it works the generated output (see
|
||||
judges' comments below) will not be 100% correct duplication of the program.
|
||||
|
||||
### Alternate code:
|
||||
|
||||
For the original version with a smaller buffer try:
|
||||
To build the alternative code try:
|
||||
|
||||
```sh
|
||||
make alt
|
||||
@@ -50,6 +45,7 @@ make alt
|
||||
|
||||
Use `schnitzi.alt` as you would `schnitzi`.
|
||||
|
||||
|
||||
## Judges' comments:
|
||||
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ h mh111 de{l) +di (+'( d+% c n+
|
||||
*/ n = 0 ;
|
||||
main ( ) {
|
||||
char v [
|
||||
100 ] , s;
|
||||
10000 ] , s;
|
||||
int t[100 ] ,
|
||||
u[100 ] ; u
|
||||
[ 0
|
||||
|
||||
@@ -20,7 +20,7 @@ h mh111 de{l) +di (+'( d+% c n+
|
||||
*/ n = 0 ;
|
||||
main ( ) {
|
||||
char v [
|
||||
10000 ] , s;
|
||||
100 ] , s;
|
||||
int t[100 ] ,
|
||||
u[100 ] ; u
|
||||
[ 0
|
||||
|
||||
Reference in new issue
Block a user