src/chess/pgn.c

changeset 59
3fa1de896666
parent 55
54ea19938d57
child 60
0c50aac49e55
--- a/src/chess/pgn.c	Tue Aug 28 14:03:09 2018 +0200
+++ b/src/chess/pgn.c	Tue Aug 28 14:16:30 2018 +0200
@@ -49,7 +49,7 @@
             break;
         }
         if (c != '[') {
-            return EXIT_FAILURE;
+            return 1;
         }
         while (isspace(c = fgetc(stream)));
         i = 0;
@@ -59,18 +59,18 @@
         tagkey[i] = '\0';
         while (isspace(c = fgetc(stream)));
         if (c != '"') {
-            return EXIT_FAILURE;
+            return 1;
         }
         i = 0;
         while ((c = fgetc(stream)) != '"') {
             if (c == '\n') {
-                return EXIT_FAILURE;
+                return 1;
             }
             tagvalue[i++] = c;
         }
         tagvalue[i] = '\0';
         if (fgetc(stream) != ']') {
-            return EXIT_FAILURE;
+            return 1;
         }
 
         if (strcmp("Result", tagkey) == 0) {
@@ -80,7 +80,7 @@
     
     // read moves
     if (fgetc(stream) != '.') {
-        return EXIT_FAILURE;
+        return 1;
     }
     
     char movestr[10];
@@ -94,16 +94,16 @@
         do {
             movestr[i++] = c;
             if (i >= 10) {
-                return EXIT_FAILURE;
+                return 1;
             }
         } while (!isspace(c = fgetc(stream)));
         movestr[i] = '\0';
         if (eval_move(gamestate, movestr, &move, curcol)
                 != VALID_MOVE_SYNTAX) {
-            return EXIT_FAILURE;
+            return 1;
         }
         if (validate_move(gamestate, &move) != VALID_MOVE_SEMANTICS) {
-            return EXIT_FAILURE;
+            return 1;
         }
         apply_move(gamestate, &move);
         
@@ -135,13 +135,13 @@
         if (curcol == BLACK) {
             while (isdigit(c = fgetc(stream)));
             if (c != '.') {
-                return EXIT_FAILURE;
+                return 1;
             }
         }
         curcol = opponent_color(curcol);
     }
     
-    return EXIT_SUCCESS;
+    return 0;
 }
 
 size_t write_pgn(FILE* stream, GameState *gamestate, GameInfo *gameinfo) {

mercurial