From 67a3677763dc57a1a5db1b7c74b9d75f1d2a1f01 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Tue, 21 Mar 2023 09:43:02 -0700 Subject: [PATCH] Fixes in 1990/jaw The example commands in the judges' comments had some problems that gave an error message when running them. I have also figured out the apparent problem with macOS in the command under the try section being: echo "Quartz glyph jocks vend, fix, BMW." | compress | ./btoa | ./jaw But it's not actually a problem. It uses perror() and under macOS with errno == 0 it shows: Undefined error: 0 whereas linux shows 'Success'. So it's not actually a problem with the entry at all. In fact the condition that triggers that call is the same in both linux and macOS. I've updated bugs.md to note this and I also updated the README.md to note it (and to refer to the bugs.md file for more details). The thank you to me is because I missed it earlier on when I fixed the scripts, simple though the fixes were. --- 1990/jaw/.gitignore | 3 +++ 1990/jaw/README.md | 37 +++++++++++++++++++++++-------------- 1990/jaw/shark.sh | 4 ++-- bugs.md | 42 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 16 deletions(-) diff --git a/1990/jaw/.gitignore b/1990/jaw/.gitignore index b52d4cb82..a11ebfac1 100644 --- a/1990/jaw/.gitignore +++ b/1990/jaw/.gitignore @@ -1,3 +1,6 @@ atob jaw zcat +receive +unshark +unshark.c diff --git a/1990/jaw/README.md b/1990/jaw/README.md index 71f20aa7b..f8dd6a85b 100644 --- a/1990/jaw/README.md +++ b/1990/jaw/README.md @@ -21,17 +21,33 @@ ## To build: - make all + make all + + +[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed the script to +work properly in modern environments (to do with PATH not having '.' in it). He +notes that with an invocation in the try section below you will with macOS get +what appears to be an error message but is actually okay. He gives more +information in the [bugs.md](/bugs.md) file. Thank you Cody for the help and +notes! NOTE: as `btoa` is not common we used a ruby script from [Yusuke Endoh](/winners.html#Yusuke_Endoh). Thank you Yusuke for your implementation of `btoa`! + ### Try: +To test the official C entry, one might try: + echo "Quartz glyph jocks vend, fix, BMW." | compress | ./btoa | ./jaw -NOTE: part of this entry does not work under macOS. +which should apply the identity transformation to a minimal +holoalphabetic sentence. + +NOTE: Cody notes the above will not work under macOS. The `sh shark.sh jaw.* +README.md > receive` and following commands below do work with macOS after the +fixes he made. ## Judges' comments: @@ -42,30 +58,23 @@ The program, in its base form, implements two useful utilities: atob - ascii to binary conversion zcat - decompression filter -To test the official C entry, one might try: - - echo "Quartz glyph jocks vend, fix, BMW." | compress | ./btoa | ./jaw - -which should apply the identity transformation to a minimal -holoalphabetic sentence. - Included with this entry is a shell script (with comments edited down to reduce it to 1530 bytes) which implements the complete shark utility. The script, shark.sh, contains a 'jaw.c' embedded within it! -The sender must have 'compress' and 'btoa'. To send, try: +The sender must have `compress` and `btoa`. To send, try: - sh shark.sh jaw.* > receive + sh shark.sh jaw.* README.md > receive The resulting file, 'receive', unpacks the input files -even if the receiver lacks 'uncompress' and 'btoa': +even if the receiver lacks `uncompress` and `btoa`: - mkdir test + mkdir -p test cd test sh ../receive cmp ../jaw.c jaw.c - cmp ../jaw.hint jaw.hint + cmp ../README.md README.md ## Authors' comments: diff --git a/1990/jaw/shark.sh b/1990/jaw/shark.sh index 5a8a30146..72190b1c3 100755 --- a/1990/jaw/shark.sh +++ b/1990/jaw/shark.sh @@ -10,7 +10,7 @@ for i in "${@?${usage?$0 file...}}";do<"$i"||exit;done # "Cleverly he dialed from within." -- D. Van Vliet, "Trout Mask Replica" # PATH=$PATH:. a=atob m=unshark z=zcat -r="rm -f $a $m* $z" v="cc -o $z $m.c" +r="rm -f $a $m* $z" v="cc -Wno-implicit-function-declaration -o $z $m.c" trap "$r;exit 1" 1 2 13 15 echo decoding... (:|compress|./btoa|$a|$z)2>$m>&2||(sed '1,9s/./#define & / @@ -43,5 +43,5 @@ Z,h@=w;n=8;f=Q+e;i=o=HIo<0)X,1;P(i)WH+1){Iw==Q&e){Z;m=n=8;f=QIH<0)X} c=wIw>=f)U++=i,w=oWw>=Q)U++=h@,w=t@;P(i=h@)Wp>D+Q)P(*--p) I(w=f)<1l<$m-&&$z<$m->$m&&tar xvf $m&&$r +($v)&&ln $z $a)&&$a<<\w>$m-&&$z<$m->$m&&tar xvf $m&&$r Z diff --git a/bugs.md b/bugs.md index 1de17f7b7..a08d45387 100644 --- a/bugs.md +++ b/bugs.md @@ -20,6 +20,7 @@ you have one if you like). ## Known bugs that are OK to fix + ### [1995/cdua](1995/cdua/cdua.c) ([README.md](1995/cdua/README.md)) This did not compile under macOS and after it did it crashed. @@ -103,6 +104,47 @@ Vax-11 or pdp-11. In 1984 machine dependent code was allowed. This entry is known to segfault after printing its output. It was documented by the judges and needn't be fixed. +### [1990/jaw](1990/jaw/jaw.c) ([README.md](1990/jaw/README.md)) + +[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed the scripts to +work in modern systems. He notes however that the command in the try section, +the one to test the official C entry, appear to not work with macOS, giving: + + + $ echo "Quartz glyph jocks vend, fix, BMW." | compress | ./btoa | ./jaw + oops: Undefined error: 0 + oops: Undefined error: 0 + + +However this is because the entry uses `perror()` and it just so happens that +the default `errno` gives that result. For instance if you run the following C +program under macOS you will get undefined error but if you do it under linux +you'll likely get success. + + +```c +#include +#include +#include +int main() +{ + errno = 0; + printf("%d, %s\n", errno, strerror(errno)); +} +``` + +In fact the condition which is in the `a()` function on line 18 of the entry +namely: + + I k>16) + +is true on both linux and macOS, with `k` being equal to 22. + +Should the entry use `perror()`? Perhaps not but we're not sure of its purpose +so it can stay for now with this note. + + + ### [1996/westley](1996/westley/westley.c) ([README.md](1996/westley/README.md)) This entry will possibly segfault even when showing the proper output in the