55 * (C) Copyright 2001 Albert Ludwigs University Freiburg
66 * Institute of Computer Science
77 *
8- * All rights reserved. Use of this software is permitted for
9- * non-commercial research purposes, and it may be copied only
8+ * All rights reserved. Use of this software is permitted for
9+ * non-commercial research purposes, and it may be copied only
1010 * for that use. All copies must include this copyright message.
1111 * This software is made available AS IS, and neither the authors
1212 * nor the Albert Ludwigs University Freiburg make any warranty
13- * about the software or its performance.
13+ * about the software or its performance.
1414 *********************************************************************/
1515
1616
@@ -34,7 +34,7 @@ typedef unsigned char Bool;
3434/* commands
3535 */
3636char * gdata ;
37- int gn ;
37+ int gn ;
3838
3939
4040
@@ -73,12 +73,18 @@ int main( int argc, char *argv[] )
7373 }
7474 while ( (c = fgetc ( data )) != '\n' );
7575 for ( i = 0 ; i < gn ; i ++ ) {
76- fscanf ( data , " %d" , & (initial [i + 1 ]) );
76+ if (fscanf ( data , " %d" , & (initial [i + 1 ]) ) != 1 ) {
77+ printf ("Error reading initial state\n" );
78+ exit (1 );
79+ }
7780 }
7881 while ( (c = fgetc ( data )) != '\n' );
7982 while ( (c = fgetc ( data )) != '\n' );
8083 for ( i = 0 ; i < gn ; i ++ ) {
81- fscanf ( data , " %d" , & (goal [i + 1 ]) );
84+ if (fscanf ( data , " %d" , & (goal [i + 1 ]) ) != 1 ) {
85+ printf ("Error reading goal state\n" );
86+ exit (1 );
87+ }
8288 }
8389
8490 if ( 0 ) {
@@ -119,8 +125,8 @@ int main( int argc, char *argv[] )
119125 }
120126 }
121127 printf (")\n)\n)\n\n\n" );
122-
123-
128+
129+
124130
125131 exit ( 0 );
126132
0 commit comments