Second alt version added to 1985/sicherman

Since some versions of clang object to the number of args to main()
(requiring, supposedly, 0, 2 or 3[0] args) and in the case that it is
enforced to not allow 1 I have added a second alt code that will be
compiled IF sicherman.c fails to compile (and it'll compile into
sicherman, not sicherman.alt2 or something like that). This required
another change which also is in sicherman.c.

The macros in the code that were C (which only translated to '/**/') and
V were changed to lower case letters. Then the 'c' in 'subr()' was
changed back to upper case. This also feels better since the 'C' (now
'c') in main() is although used it is not necessary either since it just
is an empty comment. The primary reason for this change is that in the
new version we obviously want the first arg of main() to be 'C' but with
the macro 'C' this would not be possible. The change to 'v' from 'V' is
simply to match case as both were in the original main() args (as ints).

I am not sure I like having to change the macro names to lower case but
at the same time the 'C="..."' in 'subr()' makes more sense to be upper
case as it's about the language and it also allows in the new version
that main() can have upper case C. Of course I could have made that
change in just the new version but it felt better to match style as much
as possible.

[0] The version that objects to this still seems to allow 1 arg even
though it claims that it requires 0, 2 or 3 args.
This commit is contained in:
Cody Boone Ferguson committed 2023-11-25 05:44:42 -08:00
1 parent dadcaf92c4
commit 8fc785aa24
5 files changed
+71 -26

No files matched your search

+3 -4
View File
@@ -132,16 +132,15 @@ all: data ${TARGET}
clean clobber install love haste waste maker easter_egg \
sandwich supernova deep_magic magic charon pluto
${PROG}: ${PROG}.c
${CC} ${CFLAGS} $< -o $@ ${LDFLAGS}
${PROG}: ${PROG}.c ${PROG}.alt2.c
${CC} ${CFLAGS} $< -o $@ ${LDFLAGS} || \
${CC} ${CFLAGS} ${PROG}.alt2.c -o $@ ${LDFLAGS}
# alternative executable
#
alt: data ${ALT_TARGET}
@${TRUE}
${PROG}.alt: ${PROG}.alt.c
${CC} ${CFLAGS} -traditional-cpp $< -o $@ ${LDFLAGS}
# data files
#
+5
View File
@@ -6,6 +6,11 @@ make all
NOTE: there is an [alternate version](#alternate-code) for those who have an old
enough compiler or have a compiler that supports the option `-traditional-cpp`.
There is also an alternate version that is meant to work in the case that your
version of clang fails to compile it due to the wrong number of args to `main()`
should that ever happen (a compiler error of some versions of clang if `main()`
has four args is that `main()` can only have 0, 2 or 3 args but it does
currently accept 1 arg to `main()` nonetheless).
## To use:
+26
View File
@@ -0,0 +1,26 @@
#define C_C_(_)~' '&_
#define _C_C(_)('\b'b'\b'>=C_C>'\t'b'\n')
#define C_C _|_
#define b *
#define c /**/
#define v _C_C(
char _,__;
main(
/* C program. (If you don't
* understand it look it
* up.) (In the */C, Manual)
char **Manual;
{
char _,__;
while (read(0,&__,1) & write((_=(_=C_C_(__),
v))?__:__-_+'\b'b'\b'|((_-52)%('\b'b'\b'+~
' '&'\t'b'\n')+1),1),&_,1))_=c-v+subr(&v));
}
subr(C)
char *C;
{
C="Lint says \"argument Manual isn't used.\" What's that\
mean?"; while (write((read(('"'-'/*"'))?__:__-_+
'\b'b'\b'|((_-52)%('\b'b'\b'+C_C_('\t'b'\n'))+1),1),&_,1));
}
+8 -8
View File
@@ -2,24 +2,24 @@
#define _C_C(_)('\b'b'\b'>=C_C>'\t'b'\n')
#define C_C _|_
#define b *
#define C /**/
#define V _C_C(
#define c /**/
#define v _C_C(
char _,__;
main(
/* C program. (If you don't
* understand it look it
* up.) (In the C*/ Manual)
* up.) (In the C*/Manual)
{
char _,__;
while (read(0,&__,1) & write((_=(_=C_C_(__),
V))?__:__-_+'\b'b'\b'|((_-52)%('\b'b'\b'+~
' '&'\t'b'\n')+1),1),&_,1))_=C-V+subr(&V));
v))?__:__-_+'\b'b'\b'|((_-52)%('\b'b'\b'+~
' '&'\t'b'\n')+1),1),&_,1))_=c-v+subr(&v));
}
subr(c)
char *c;
subr(C)
char *C;
{
c="Lint says \"argument Manual isn't used.\" What's that\
C="Lint says \"argument Manual isn't used.\" What's that\
mean?"; while (write((read(('"'-'/*"'))?__:__-_+
'\b'b'\b'|((_-52)%('\b'b'\b'+C_C_('\t'b'\n'))+1),1),&_,1));
}
+29 -14
View File
@@ -56,7 +56,7 @@ Scovell](https://web.archive.org/web/20070120220721/https://thomasscovell.com/ta
## [1984/decot](1984/decot/decot.c) ([README.md](1984/decot/README.md]))
Cody fixed this to not require `-traditional-cpp` which some compilers like
clang do not support. Fixing `-traditional-cpp` is, as noted earlier, very
clang do not support. Fixing `-traditional-cpp` is, as noted later on, very
complicated, but we encourage you to look at the alternate code (which is the
original code with a minor modification made by the judges) and the fixed
code, to see what had to be done.
@@ -215,7 +215,7 @@ the default).
## [1985/sicherman](1985/sicherman/sicherman.c) ([README.md](1985/sicherman/README.md]))
Cody fixed this _very twisted entry_ to not require `-traditional-cpp`. Fixing
`-traditional-cpp` is, as noted earlier, very complicated, but Cody would like
`-traditional-cpp` is, as noted later on, very complicated, but Cody would like
to refer you to the original file
[sicherman.orig.c](1985/sicherman/sicherman.orig.c) and he suggests that you
then compare it to [sicherman.c](1985/sicherman/sicherman.c) for some good old
@@ -248,6 +248,19 @@ were actually not what they appear: the only arg that existed in `main()` was
{
```
- The macros `C` and `V` were changed to lower case. This is because it felt
like the `C=" ..`' part in `subr()` would be better to be upper case as it talks
about the language. Also in the second alternate version (the first being the
original code) which is in case a new version of clang ever objects to only one
arg in `main()` (which is not out of the realm of possibility), `main()` can
have `C` as `argc` to `main()` so it would read like it once did: `C manual`
albeit with a `,` separating the two. The second alternate version is compiled
in case the first does not. Originally the macros were kept the same and the
`C` in `subr()` was `c`. It feels better (in some ways) to make it so that the
`C` for the language is upper case though, and since it actually translated to
`/**/` it can just be `c`, not `C`. The `V` was changed to `v` to be the same
case as `c`.
- The code:
```c
@@ -259,7 +272,7 @@ were actually not what they appear: the only arg that existed in `main()` was
had to be changed to:
```c
c="Lint says \"argument Manual isn't used.\" What's that\
C="Lint says \"argument Manual isn't used.\" What's that\
mean?"; while (write((read(('"'-'/*"'))?__:__-_+
'\b'b'\b'|((_-52)%('\b'b'\b'+C_C_('\t'b'\n'))+1),1),&_,1));
```
@@ -273,11 +286,12 @@ were actually not what they appear: the only arg that existed in `main()` was
before and actually that there aren't that many changes in the function at
all!
Notice also that the parameter `C` had to be changed to `c` due to the macro.
Notice also that the parameter `C` remained the same due to the macro `C`
rename to `c`.
The `char`s `_` and `__` were made file scope so the `subr()` could actually
compile but this does not affect the ones in `main()`. Why is this? You tell
us!
The `char`s `_` and `__` in `main()` were copied to file scope so that
`subr()` could actually compile but this does not affect the ones in
`main()`. Why is this? You tell us!
- The code in `main()` is where there are significant changes, changing from:
@@ -291,14 +305,15 @@ were actually not what they appear: the only arg that existed in `main()` was
```c
while (read(0,&__,1) & write((_=(_=C_C_(__),
V))?__:__-_+'\b'b'\b'|((_-52)%('\b'b'\b'+~
' '&'\t'b'\n')+1),1),&_,1))_=C-V+subr(&V));
' '&'\t'b'\n')+1),1),&_,1))_=c-v+subr(&v));
```
Note how numerous of the macros can still be used but some cannot be. Can
you figure out why? Why too is it that the `subr()` function is called but
it appears that some of the code in that function is also in `main()` in the
`while` condition? What happens if you remove it from `main()`? What happens
if you remove it from `subr()` or don't even bother calling `subr()`?
Note how numerous of the macros (though two changed in case) can still be
used but some cannot be. Can you figure out why? Why too is it that the
`subr()` function is called but it appears that some of the code in that
function is also in `main()` in the `while` condition? What happens if you
remove it from `main()`? What happens if you remove it from `subr()` or
don't even bother calling `subr()`?
# <a name="1986"></a>1986
@@ -523,7 +538,7 @@ unlikely(?) but nevertheless suggested case that `putchar()` is not available.
Cody fixed this twisted entry (as we called it :-) ) for modern compilers,
including making it no longer require `-traditional-cpp`. Fixing
`-traditional-cpp` is, as noted earlier, very complicated, but we encourage you
`-traditional-cpp` is, as noted later on, very complicated, but we encourage you
to compare the fix from the original entry. There was another problem to resolve
as well, however.