comparison interps/malbolge/malbolge.patch @ 996:859f9b4339e6

<Gregor> tar xf egobot.tar.xz
author HackBot
date Sun, 09 Dec 2012 19:30:08 +0000
parents
children
comparison
equal deleted inserted replaced
995:6883f5911eb7 996:859f9b4339e6
1 --- malbolge.c 2005-04-21 00:30:33.000000000 +0200
2 +++ malbolge-new.c 2005-06-03 21:51:11.775304752 +0200
3 @@ -73,15 +73,13 @@
4 while ( ( x = getc( f ) ) != EOF )
5 {
6 if ( isspace( x ) ) continue;
7 - if ( x < 127 && x > 32 )
8 + if ( x < 33 || x > 126
9 + || strchr( "ji*p</vo", xlat1[( x - 33 + i ) % 94] ) == NULL )
10 {
11 - if ( strchr( "ji*p</vo", xlat1[( x - 33 + i ) % 94] ) == NULL )
12 - {
13 - fputs( "invalid character in source file\n", stderr );
14 - free( mem );
15 - fclose( f );
16 - return ( 1 );
17 - }
18 + fputs( "invalid character in source file\n", stderr );
19 + free( mem );
20 + fclose( f );
21 + return ( 1 );
22 }
23 if ( i == 59049 )
24 {
25 @@ -93,6 +91,8 @@
26 mem[i++] = x;
27 }
28 fclose( f );
29 + if ( i < 1 ) mem[i++] = 68;
30 + if ( i < 2 ) mem[i++] = 67;
31 while ( i < 59049 ) mem[i] = op( mem[i - 1], mem[i - 2] ), i++;
32 exec( mem );
33 free( mem );
34 @@ -108,7 +108,7 @@
35 int x;
36 for (;;)
37 {
38 - if ( mem[c] < 33 || mem[c] > 126 ) continue;
39 + if ( mem[c] < 33 || mem[c] > 126 ) return;
40 switch ( xlat1[( mem[c] - 33 + c ) % 94] )
41 {
42 case 'j': d = mem[d]; break;
43 @@ -130,7 +130,7 @@
44 break;
45 case 'v': return;
46 }
47 - mem[c] = xlat2[mem[c] - 33];
48 + if ( mem[c] >= 33 && mem[c] <= 126 ) mem[c] = xlat2[mem[c] - 33];
49 if ( c == 59048 ) c = 0; else c++;
50 if ( d == 59048 ) d = 0; else d++;
51 }