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));
}