Fix 2006/sloane for some versions of clang

Unfortunately later versions of clang have an additional defect where
not only are the args of main() required to be specific types but there
can only be 0, 2 or 3 args. This program did not use the second arg so I
removed it originally but this will obviously not work for all systems
so I have brought the second arg back.

The unfortunate problem here is that the author used the letter Z for
the second arg and that's exactly what I have been using for the macro
for usleep() in alt code (Z for sleep of course). So here in order to
make it so that the entry looks as close to the original as possible I
have kept it as Z (changing the type to 'char **') and instead renamed
the Z macro to just S. S was selected as it can also stand for sleep but
also it's kind of (not quite but kind of) a backwards Z. Whether the
other entries should also be changed to be '-DS=...' is something to
consider for consistency but that can be decided another time. It
probably doesn't matter except that it does bother me as I don't like
inconsistent consistencies any more than I like consistent
inconsistencies or inconsistent consistencies.
This commit is contained in:
Cody Boone Ferguson committed 2023-10-22 13:23:55 -07:00
1 parent 19fdd5f944
commit 59de574ffb
5 files changed
+24 -16

No files matched your search

+1 -1
View File
@@ -59,7 +59,7 @@ ARCH=
# Defines that are needed to compile
#
CDEFINE= -DZ=65000
CDEFINE= -DS=65000
# Include files that are needed to compile
#
+3 -3
View File
@@ -25,11 +25,11 @@ see the [original code](#original-code) section.
This alternate version, which we recommend that you use in order to see what is
happening with modern systems, and to not flash too quickly, which can be
problematic for some people, can be configured to different speeds by way of the
value used in `usleep()`. The default is `-DZ=65000` but you can easily change
value used in `usleep()`. The default is `-DS=65000` but you can easily change
it. To do so try:
```sh
make CDEFINE="-DZ=70000" clobber alt
make CDEFINE="-DS=70000" clobber alt
./sloane.alt
```
@@ -37,7 +37,7 @@ If you wish to make it like the original, as if the below [Original
code](#original-code) was being used, you can do:
```sh
make CDEFINE="-DZ=0" clobber alt
make CDEFINE="-DS=0" clobber alt
./sloane.alt
```
+2 -2
View File
@@ -13,7 +13,7 @@ KXw{Y" "RsFwsFwsFw{zaqyaz|FmMpyaoyI\\]cuUw{J"
"~|_."[c(6,"b" "cd\\a[g","^`" "_e"
"]fh")+8], p( "#$%" "&'()*+,-.1"[ c(11
,"_ac[]\\YZi" "jkm", "`bd^efghXWlV" )+13
]-34,a);}main (k ){ float z[1920] ,A=0
]-34,a);}main (k,Z )char**Z;{float z[1920] ,A=0
,B=0 ,i,j; puts("" "\x1b" "[2J");for(;;
) { float e=sin(A ), n= sin(B),g=cos(
A),m =cos(B);for(k =0;k< 1840;k++)y=-k
@@ -27,6 +27,6 @@ A),m =cos(B);for(k =0;k< 1840;k++)y=-k
g)*m-c* d*e-f*g-l*d*n);if(D>z[o] )z[o]
=D,b[o] =" ..,,-++=#$@"[ N>0?N:0
] ; } printf(
"\x1b[" "H" );usleep(Z);for(k =1;1841
"\x1b[" "H" );usleep(S);for(k =1;1841
>k;k++) putchar (k%80?b [k]:10)
; A += 0.053;B +=0.037 ; } }
+1 -1
View File
@@ -13,7 +13,7 @@ KXw{Y" "RsFwsFwsFw{zaqyaz|FmMpyaoyI\\]cuUw{J"
"~|_."[c(6,"b" "cd\\a[g","^`" "_e"
"]fh")+8], p( "#$%" "&'()*+,-.1"[ c(11
,"_ac[]\\YZi" "jkm", "`bd^efghXWlV" )+13
]-34,a);}main (k ){ float z[1920] ,A=0
]-34,a);}main (k,Z )char**Z;{float z[1920] ,A=0
,B=0 ,i,j; puts("" "\x1b" "[2J");for(;;
) { float e=sin(A ), n= sin(B),g=cos(
A),m =cos(B);for(k =0;k< 1840;k++)y=-k
+17 -9
View File
@@ -1859,19 +1859,27 @@ Cody fixed this entry to work with clang which has a defect with the args to
`main()`: it requires specific types: `int` and `char **` for the first and
latter args.
Curiously, although clang requires the types of args to be strictly
correct it allows for only one arg which Cody made it as the second arg was not
used and this allows for a closer match to the original format of the entry.
He also made sure that the Makefile links in `libm` as not all systems do this by default.
Since the author suggested that the lack of certain `#include`s might break the
program in some systems he added `-include ...` to the Makefile as well.
The [alternate version](2006/sloane/sloane.alt.c), which allows one to see what
is going on in modern systems, and which we recommend one use _first_, was
provided by Cody.
Curiously, although clang requires the types of args to be strictly correct,
some versions do allow only one arg. This was done at first because it's not
used but Cody discovered that later versions of clang have an additional defect
where it does not allow only one arg so the second arg to `main()` was added
back. This was an unfortunate problem for the alt code as he has been using Z
for alt code `usleep()` (for sleep) but
in this case unfortunately the original entry used `Z` in `main()` (though
unused) so to make it more like the original Cody renamed the macro `Z` for
`usleep()` to `S` instead which can stand for sleep and also it is kind of like
a backwards `Z`. That way `Z` could be in `main()`.
Cody also made sure that the Makefile links in `libm` as not all systems do this
by default.
Since the author suggested that the lack of certain `#include`s might break the
program in some systems he added `-include ...` to the Makefile as well.
## [2006/toledo2](2006/toledo2/toledo2.c) ([README.md](2006/toledo2/README.md]))