Fix 2001/herrmann2 for clang
This was done by changing the types of the args in main() to be int and char ** respectively and (where necessary) casting the argv (V) to int which was the previous type. I also noted that prior to and after the fix certain invocations segfaulted though Yusuke Endoh did not have this problem (I linked to his analysis of the entry).
This commit is contained in:
1 parent
bf4eacac7d
commit
f86ab4571f
2 files changed
+45
-2
No files matched your search
@@ -14,12 +14,26 @@
|
||||
make
|
||||
```
|
||||
|
||||
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this to work with
|
||||
clang by changing the args to main() to be `int` and `char **` respectively and
|
||||
changing specific references to the `argv` arg, casting to int which was its old
|
||||
type. Thank you Cody for your assistance!
|
||||
|
||||
|
||||
### To run:
|
||||
|
||||
```sh
|
||||
./herrmann2
|
||||
```
|
||||
|
||||
Cody notes that [Yusuke Endoh](/winners.html#Yusuke_Endoh) does not get a
|
||||
segfault with some of the invocations (without fixing it for clang) but Cody
|
||||
does get a segfault both before fixing it for clang and after. Yusuke provides
|
||||
some interesting thoughts which can be found
|
||||
[here](https://mame-github-io.translate.goog/ioccc-ja-spoilers/2001/herrmann2.html?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=en-US&_x_tr_pto=wapp).
|
||||
Thank you Yusuke for your interesting thoughts!
|
||||
|
||||
|
||||
### Try:
|
||||
|
||||
```sh
|
||||
@@ -27,11 +41,38 @@ make
|
||||
./herrmann2 < herrmann2.cup
|
||||
```
|
||||
|
||||
Try running each command a few times and notice the different output. Can you
|
||||
figure out why each is different?
|
||||
|
||||
|
||||
If you use vi(m) you can see a pattern in `hermmann2.cup` and `herrmann2.ioccc`
|
||||
by say:
|
||||
|
||||
|
||||
/[pon]
|
||||
|
||||
and
|
||||
|
||||
/l
|
||||
|
||||
For additional fun in `herrman2.cup` try:
|
||||
|
||||
|
||||
/[po]
|
||||
/q
|
||||
|
||||
and in `herrmann2.ioccc` try:
|
||||
|
||||
/n
|
||||
|
||||
|
||||
|
||||
## Judges' comments:
|
||||
|
||||
Be careful when staring at the source code - your eyes might cross, but
|
||||
if you concentrate on your focus you will find illumination!
|
||||
|
||||
|
||||
## Author's comments:
|
||||
|
||||
You probably know those "magic eye" 3D pictures - pictures looking
|
||||
@@ -65,9 +106,11 @@ new random character, it will take the next one from the
|
||||
argument. When it arrives at the end of the argument, it will
|
||||
start over at the beginning. Example:
|
||||
|
||||
```sh
|
||||
./herrmann2 "234 84 045 5 6765 7487 65190 84 656 254 12 43931 818 0 6542\
|
||||
341 45 567 76967 7244 606 976567 895 81898 095 68678 1843 4650547\
|
||||
565980691 389 04974" < herrmann2.ioccc
|
||||
```
|
||||
|
||||
### Some hints to get better results
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
char*d,A[9876];char*d,A[9876];char*d,A[9876];char*d,A[9876];char*d,A[9876];char
|
||||
e;b;*ad,a,c; te;b;*ad,a,c; te;*ad,a,c; w,te;*ad,a, w,te;*ad,and, w,te;*ad,
|
||||
r,T; wri; ;*h; r,T; wri; ;*h; r; wri; ;*h;_, r; wri;*h;_, r; wri;*har;_, r; wri
|
||||
;on; ;l ;i(V) ;on; ;l ;i(V) ;o ;l ;mai(V) ;o ;mai(n,V) ;main (n,V)
|
||||
;on;l;i(int V);on;l;i(int V);o;l;mai(int n,int V);o;mai(int n,int V);main(int n,char**V)
|
||||
{-!har ; {-!har ; {har =A; {h =A;ad =A;read
|
||||
(0,&e,o||n -- +(0,&e,o||n -- +(0,&o||n ,o-- +(0,&on ,o-4,- +(0,n ,o-=94,- +(0,n
|
||||
,l=b=8,!( te-*A,l=b=8,!( te-*A,l=b,!( time-*A,l=b, time)|-*A,l= time(0)|-*A,l=
|
||||
@@ -10,7 +10,7 @@ r,T; wri; ;*h; r,T; wri; ;*h; r; wri; ;*h;_, r; wri;*h;_, r; wri;*har;_, r; wri
|
||||
)=+ +95>e?(*& c)=+ +95>e?(*& c) +95>e?(*& _*c) +95>(*& _*c) +95>(*&r= _*c) +95>
|
||||
5,r+e-r +_:2-195,r+e-r +_:2-195+e-r +_:2-1<-95+e-r +_-1<-95+e-r ++?_-1<-95+e-r
|
||||
|(d==d),!n ?*d||(d==d),!n ?*d||(d==d),!n ?*d||(d==d),!n ?*d||(d==d),!n ?*d||(d=
|
||||
*( (char**)+V+ *( (char)+V+ *( (c),har)+V+ (c),har)+ (V+ (c),r)+ (V+ ( c),
|
||||
*( (char**)+(int)V+ *( (char)+(int)V+ *( (c),har)+V+ (c),har)+ (V+ (c),r)+ (V+ ( c),
|
||||
+0,*d-7 ) -r+8)+0,*d-7 -r+8)+0,*d-c:7 -r+80,*d-c:7 -r+7:80,*d-7 -r+7:80,*d++-7
|
||||
+7+! r: and%9- +7+! rand%9-85 +7+! rand%95 +7+!! rand%95 +7+ rand()%95 +7+ r
|
||||
-(r+o):(+w,_+ A-(r+o)+w,_+*( A-(r+o)+w,_+ A-(r=e+o)+w,_+ A-(r+o)+wri,_+ A-(r+o)
|
||||
|
||||
Reference in new issue
Block a user