Files
ioccc/1998/tomtorfs/tomtorfs.c
T
Cody Boone Ferguson 3141392cc1 Fixes in 1998/tomtorfs, add try.sh & format fixes
The author stated that the program assumes EOF is -1 but for systems
that do not have this it will fail. This is indeed a valid concern as
the standard mandates that it's a value < 0 but it doesn't require it to
be -1.

The author also stated that the program could fail if 1 is not a return
value that indicates error so this was changed to EXIT_FAILURE as the
suggested was made. It is possible of course that I missed a place where
this should have been updated but I don't believe so. I am unaware of
any system where this would be a problem and I don't know why it matters
anyway but I made the change as the author stated it could be a problem
with portability.

The README.md file has been formatted and typo checked.

Added try.sh script.

This should complete this entry's review.
2023-11-12 05:10:38 -08:00

22 lines
1.1 KiB
C

#include <stdio.h>
#include <stdlib.h>
#define exit(a) return EXIT_FAILURE
int main(int a,char **A){FILE*B;typedef unsigned long C;C b
[8]; if(!(a==7&&(B= fopen(1[A],"rb")))) exit(1); for(7[b]=0
;7[b]<5;7[b]++)b[7[ b]]=strtoul(A[2+7[b ]],0,16-!7[b]*6);5[
b]=3[b] ; while ((6[b]= getc(B)
) !=EOF ){if(2 [b])for (7[b]=0
;7[b]<4 ;7[b]++ )if(((6 [b]>>7[
b])^(6[ b]>>(7-7[b])))&1)6[ b] ^=(1
<<7[b]) ^(1<<(7-7[b]));5[b] ^= 6[b]
<<(0[b] -8);for(7[b]=0;7[b] <8;7[b]
++)if(( 5[b]>>(0[b]- 1))&1)5
[b]=(5[ b]<<1)^ 1[b]; else 5[
b]<<=1; }5[b]&=((((C)1 <<(0[b]
-1))-1) <<1)|1; if(2[b] )for(7[
b]=0;7[ b]<(0[b ]>>1);7 [b] ++)
if(((5[b]>>7[b])^(5 [b]>>(0 [b]-1-7 [b])))&1)5[b]^=((C)
1<<7[b])^((C)1<<(0[ b]-1-7[ b]));5[ b]^=4[b];fclose(B);
printf("%0*lX\n", ( int)(0[ b]+3)>> 2,5[b]); return 0;}