From 5506ea989dcdb14281ce03d824e3f68240d391e1 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 24 Mar 2023 05:27:09 -0700 Subject: [PATCH 1/6] Fix 1998/schnitzi for linux It segfaulted due to wrong type of a variable. It still crashes under macOS which I will be looking at in the near future but it at least works for linux. I noted in the bugs.md a compiler warning that should not be changed as it's not a bug and in fact 'fixing' it will introduce a bug. --- 1998/schnitzi/Makefile | 2 +- 1998/schnitzi/README.md | 105 ++++++++++++++++++++++----------------- 1998/schnitzi/schnitzi.c | 6 +-- bugs.md | 15 ++++++ 4 files changed, 79 insertions(+), 49 deletions(-) diff --git a/1998/schnitzi/Makefile b/1998/schnitzi/Makefile index cea72b4b8..a1b750e9f 100644 --- a/1998/schnitzi/Makefile +++ b/1998/schnitzi/Makefile @@ -97,7 +97,7 @@ CDEFINE= # Include files that are needed to compile # -CINCLUDE= +CINCLUDE= -include stdlib.h #CINCLUDE= -include stdlib.h #CINCLUDE= -include stdio.h #CINCLUDE= -include stdlib.h -include stdio.h diff --git a/1998/schnitzi/README.md b/1998/schnitzi/README.md index 2a2e5afe2..bc519c570 100644 --- a/1998/schnitzi/README.md +++ b/1998/schnitzi/README.md @@ -16,6 +16,11 @@ ./schnitzi 5 > sort.c make sort + +## Try: + + ./schnitzi 3 > sort.c + make sort echo 123 > data echo 234 >> data echo 413 >> data @@ -23,68 +28,78 @@ echo 324 >> data ./sort < data +[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this to work (it +segfaulted) under linux. He notes that currently it segfaults under macOS but +he'll work on that in the near future. + ## Judges' comments - This is a beautiful program. How can a program with no conditional - behavior at all have output which depends on anything? +This is a beautiful program. How can a program with no conditional +behavior at all have output which depends on anything? + +For hints on deciphering this, see below past the Author's Comments; +they're a nice summary, but they leave the mystery intact. + +BTW: the author notes an incredible lipogram story called +[Gadsby](https://www.gutenberg.org/cache/epub/47342/pg47342.txt) which has no +letter E in the story. He did not note this but it has over 50000 (50 thousand) +(!!) words without the letter E which is one of the most common letters! - For hints on deciphering this, see below past the Author's Comments; - they're a nice summary, but they leave the mystery intact. ## Author's comments - In literary circles, there is a poetic form called a "lipogram", - which is a poem in which a specific letter has been distinctly - avoided. This principle can be applied in other ways. For - instance, in this paragraph, the vowel which immediately follows - 't' in the alphabet is nowhere to be seen. There is even an - entire novel (E. V. Wright's "Gadsby") in which no word contains - the letter 'e'. +In literary circles, there is a poetic form called a "lipogram", +which is a poem in which a specific letter has been distinctly +avoided. This principle can be applied in other ways. For +instance, in this paragraph, the vowel which immediately follows +'t' in the alphabet is nowhere to be seen. There is even an +entire novel (E. V. Wright's "Gadsby") in which no word contains +the letter 'e'. - The IOCCC has been no stranger to this concept. Several winning - entries from years past have accomplished interesting feats while - completely avoiding the use of certain C constructs thought to - be essential (e.g. 1988's robison.c). If you have to ask why they - would do it this way, then this contest just isn't for you. +The IOCCC has been no stranger to this concept. Several winning +entries from years past have accomplished interesting feats while +completely avoiding the use of certain C constructs thought to +be essential (e.g. 1988's robison.c). If you have to ask why they +would do it this way, then this contest just isn't for you. - In continuing with this fine tradition, this program suggests to - the ANSI committee some new practical simplifications for the C - language. For instance, it appears that CONDITIONAL BRANCHING isn't - really necessary. So, we can do away with while, do...while, for, - if/else, switch, ?:, or anything else that might cause any kind of - nondeterministic jump in the code. There's too much uncertainty - in the world anyway. +In continuing with this fine tradition, this program suggests to +the ANSI committee some new practical simplifications for the C +language. For instance, it appears that CONDITIONAL BRANCHING isn't +really necessary. So, we can do away with while, do...while, for, +if/else, switch, ?:, or anything else that might cause any kind of +nondeterministic jump in the code. There's too much uncertainty +in the world anyway. - Function parameters and return types just confuse people anyway, so - get rid of them. Same with local variables. In fact, all you really - need are assignment statements, and maybe one printf() and one goto. +Function parameters and return types just confuse people anyway, so +get rid of them. Same with local variables. In fact, all you really +need are assignment statements, and maybe one printf() and one goto. - This style of programming is also ideal for systems with limited - memory capacity, since the function call stack never goes beyond - a depth of one. +This style of programming is also ideal for systems with limited +memory capacity, since the function call stack never goes beyond +a depth of one. - So what does it do? Give it an integer (1 < n < 27) on the command - line, such as +So what does it do? Give it an integer (1 < n < 27) on the command +line, such as - schnitzi 5 + ./schnitzi 5 - The output will itself be a lipographic program, one which inputs - (in this case) five numbers and prints them out sorted. It sorts - them, however, using only "if/else" statements, without arrays or - looping. To see the resulting program run, redirect the output from - "schnitzi" into another file, like this +The output will itself be a lipographic program, one which inputs +(in this case) five numbers and prints them out sorted. It sorts +them, however, using only "if/else" statements, without arrays or +looping. To see the resulting program run, redirect the output from +"schnitzi" into another file, like this schnitzi 4 > sort.c - and then compile it. +and then compile it. -Spoilers And Hints: +### Spoilers And Hints: - The big key to this program is figuring out what the names of the - functions ought to be; a bit of research may allow you to guess at - a few crucial ones. +The big key to this program is figuring out what the names of the +functions ought to be; a bit of research may allow you to guess at +a few crucial ones. - The only function ever called is "O", but "O" is just set to point to - other functions all the time. Or, almost all the time. +The only function ever called is "O", but "O" is just set to point to +other functions all the time. Or, almost all the time. - So how does 'h' get set, and what to? +So how does 'h' get set, and what to? diff --git a/1998/schnitzi/schnitzi.c b/1998/schnitzi/schnitzi.c index 4a1eab007..b8d12a452 100644 --- a/1998/schnitzi/schnitzi.c +++ b/1998/schnitzi/schnitzi.c @@ -1,8 +1,8 @@ typedef void e(); -e *w,*l,*u,*_o,*j,*t,*O,exit,b,c_,b_,a_,c,a,z_,x_,d,y_,_m; -int q,m,_d,z,k,h,f[99]; -char y[26],_p[40][26],_q,r[2],*_,**s,*i, +e *w,*l,*u,*_o,*j,*t,*O,b,c_,b_,a_,c,a,z_,x_,d,y_,_m; +int q,m,z,k,h,f[99]; +char y[26],_p[40][26],_q,r[2],*_,**s,*i,*_d, *x[]= { "\n", ")", "if (", "}\n", ");\n\n", " ", ",&", "\"", ",", " %%d", ";\n\n scanf(\"%%d", "%%d ", "else ", ",", "<", diff --git a/bugs.md b/bugs.md index 7606a893d..120087143 100644 --- a/bugs.md +++ b/bugs.md @@ -315,6 +315,21 @@ type). # 1998 +## [1998/schnitzi](1998/schnitzi/schnitzi.c) ([README.md](1998/schnitzi/README.md)) + +### Status: INABIAF - please do not fix + +If you get the compiler warning: + + warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] + 11 | void g(){ O=j; printf(_); } + | ^~~~~~ + + +please do NOT change it! Doing so will break the generated output. + +It does not currently work under macOS. This will be investigated in the near +future. # 2000 From f761387081f840891c5df64aad1b5fc53da5799a Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 24 Mar 2023 05:33:46 -0700 Subject: [PATCH 2/6] Update bugs.md for 1998/schnitzi.c There's another warning that should not be addressed as it's not a bug and changing it will introduce a bug (at least at first glance). --- bugs.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bugs.md b/bugs.md index 120087143..cb6ce4e86 100644 --- a/bugs.md +++ b/bugs.md @@ -331,6 +331,15 @@ please do NOT change it! Doing so will break the generated output. It does not currently work under macOS. This will be investigated in the near future. +Another warning to ignore is: + + + warning: assignment to 'char *' from incompatible pointer type 'char **' [-Wincompatible-pointer-types] + 55 | main(int v,char **c){ O=r_; _d=c; + | ^ + +Please do not change this. + # 2000 From 39b1e26947491ac0c653d740c9c6986c8605e862 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 24 Mar 2023 08:14:07 -0700 Subject: [PATCH 3/6] Fix 1998/schnitzi for macOS too It no longer segfaults and works as expected in both linux and macOS! --- 1998/schnitzi/README.md | 5 ++--- 1998/schnitzi/schnitzi.c | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/1998/schnitzi/README.md b/1998/schnitzi/README.md index bc519c570..5f25f72f2 100644 --- a/1998/schnitzi/README.md +++ b/1998/schnitzi/README.md @@ -28,9 +28,8 @@ echo 324 >> data ./sort < data -[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this to work (it -segfaulted) under linux. He notes that currently it segfaults under macOS but -he'll work on that in the near future. +[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed a segfault in +this entry. Thank you Cody for your assistance! ## Judges' comments diff --git a/1998/schnitzi/schnitzi.c b/1998/schnitzi/schnitzi.c index b8d12a452..1104eeb63 100644 --- a/1998/schnitzi/schnitzi.c +++ b/1998/schnitzi/schnitzi.c @@ -1,7 +1,7 @@ typedef void e(); -e *w,*l,*u,*_o,*j,*t,*O,b,c_,b_,a_,c,a,z_,x_,d,y_,_m; -int q,m,z,k,h,f[99]; +e *w,*l,*u,*_o,*j,*t,*O,b,c_,b_,a_,c,a,z_,x_,d,y_,_m,n,*h; +int q,m,z,k,f[99]; char y[26],_p[40][26],_q,r[2],*_,**s,*i,*_d, *x[]= { "\n", ")", "if (", "}\n", ");\n\n", " ", ",&", "\"", @@ -52,5 +52,5 @@ void x_(){ O=g; *r=y[k-2]; _=r; j=o_; } void d (){ O=g; *r=y[k]; _=r; k=k+1; m=k Date: Fri, 24 Mar 2023 08:16:35 -0700 Subject: [PATCH 4/6] Add sort to 1998/schnitzi/.gitignore This because the commands in the try section of the README.md create it. --- 1998/schnitzi/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/1998/schnitzi/.gitignore b/1998/schnitzi/.gitignore index be8b7cc80..932755141 100644 --- a/1998/schnitzi/.gitignore +++ b/1998/schnitzi/.gitignore @@ -1,2 +1,3 @@ data schnitzi +sort From a6f8fd4d53fc9b624ed550515359064070dc83a2 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 24 Mar 2023 08:17:44 -0700 Subject: [PATCH 5/6] Add sort.c to 1998/schnitzi/.gitignore It was not being shown in the git status because earlier updated .git/info/exclude which included the file sort.c. --- 1998/schnitzi/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/1998/schnitzi/.gitignore b/1998/schnitzi/.gitignore index 932755141..f646104a4 100644 --- a/1998/schnitzi/.gitignore +++ b/1998/schnitzi/.gitignore @@ -1,3 +1,4 @@ data schnitzi sort +sort.c From b6635064ea403883a9f3360c0ccff744e6ccc224 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 24 Mar 2023 08:48:53 -0700 Subject: [PATCH 6/6] Update bugs/README for 1998/schnitzi I removed from bugs.md the suggestion that it does not work for macOS as I fixed that. I also slightly reworded the entry in bugs.md (about warnings to ignore). Add to README.md summary of problem. --- 1998/schnitzi/README.md | 3 ++- bugs.md | 5 +---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/1998/schnitzi/README.md b/1998/schnitzi/README.md index 5f25f72f2..686df6d19 100644 --- a/1998/schnitzi/README.md +++ b/1998/schnitzi/README.md @@ -29,7 +29,8 @@ ./sort < data [Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed a segfault in -this entry. Thank you Cody for your assistance! +this entry. The problem was invalid data types. Thank you Cody for your +assistance! ## Judges' comments diff --git a/bugs.md b/bugs.md index cb6ce4e86..27b91591e 100644 --- a/bugs.md +++ b/bugs.md @@ -328,9 +328,6 @@ If you get the compiler warning: please do NOT change it! Doing so will break the generated output. -It does not currently work under macOS. This will be investigated in the near -future. - Another warning to ignore is: @@ -338,7 +335,7 @@ Another warning to ignore is: 55 | main(int v,char **c){ O=r_; _d=c; | ^ -Please do not change this. +Please do not change this either. # 2000