From ffb639d42d46ce6694f4b557b4954e9921fe93e0 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 7 Apr 2023 10:19:02 -0700 Subject: [PATCH] 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. --- 1994/schnitzi/Makefile | 1 + 1994/schnitzi/README.md | 26 +++++++++++--------------- 1994/schnitzi/schnitzi.alt.c | 2 +- 1994/schnitzi/schnitzi.c | 2 +- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/1994/schnitzi/Makefile b/1994/schnitzi/Makefile index cf2666d21..0dcaaad8a 100644 --- a/1994/schnitzi/Makefile +++ b/1994/schnitzi/Makefile @@ -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 diff --git a/1994/schnitzi/README.md b/1994/schnitzi/README.md index a528218cb..c75f5b73c 100644 --- a/1994/schnitzi/README.md +++ b/1994/schnitzi/README.md @@ -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: diff --git a/1994/schnitzi/schnitzi.alt.c b/1994/schnitzi/schnitzi.alt.c index 45a5365e4..a28d79ee9 100644 --- a/1994/schnitzi/schnitzi.alt.c +++ b/1994/schnitzi/schnitzi.alt.c @@ -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 diff --git a/1994/schnitzi/schnitzi.c b/1994/schnitzi/schnitzi.c index a28d79ee9..45a5365e4 100644 --- a/1994/schnitzi/schnitzi.c +++ b/1994/schnitzi/schnitzi.c @@ -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