src/chess/pgn.c

changeset 59
3fa1de896666
parent 55
54ea19938d57
child 60
0c50aac49e55
     1.1 --- a/src/chess/pgn.c	Tue Aug 28 14:03:09 2018 +0200
     1.2 +++ b/src/chess/pgn.c	Tue Aug 28 14:16:30 2018 +0200
     1.3 @@ -49,7 +49,7 @@
     1.4              break;
     1.5          }
     1.6          if (c != '[') {
     1.7 -            return EXIT_FAILURE;
     1.8 +            return 1;
     1.9          }
    1.10          while (isspace(c = fgetc(stream)));
    1.11          i = 0;
    1.12 @@ -59,18 +59,18 @@
    1.13          tagkey[i] = '\0';
    1.14          while (isspace(c = fgetc(stream)));
    1.15          if (c != '"') {
    1.16 -            return EXIT_FAILURE;
    1.17 +            return 1;
    1.18          }
    1.19          i = 0;
    1.20          while ((c = fgetc(stream)) != '"') {
    1.21              if (c == '\n') {
    1.22 -                return EXIT_FAILURE;
    1.23 +                return 1;
    1.24              }
    1.25              tagvalue[i++] = c;
    1.26          }
    1.27          tagvalue[i] = '\0';
    1.28          if (fgetc(stream) != ']') {
    1.29 -            return EXIT_FAILURE;
    1.30 +            return 1;
    1.31          }
    1.32  
    1.33          if (strcmp("Result", tagkey) == 0) {
    1.34 @@ -80,7 +80,7 @@
    1.35      
    1.36      // read moves
    1.37      if (fgetc(stream) != '.') {
    1.38 -        return EXIT_FAILURE;
    1.39 +        return 1;
    1.40      }
    1.41      
    1.42      char movestr[10];
    1.43 @@ -94,16 +94,16 @@
    1.44          do {
    1.45              movestr[i++] = c;
    1.46              if (i >= 10) {
    1.47 -                return EXIT_FAILURE;
    1.48 +                return 1;
    1.49              }
    1.50          } while (!isspace(c = fgetc(stream)));
    1.51          movestr[i] = '\0';
    1.52          if (eval_move(gamestate, movestr, &move, curcol)
    1.53                  != VALID_MOVE_SYNTAX) {
    1.54 -            return EXIT_FAILURE;
    1.55 +            return 1;
    1.56          }
    1.57          if (validate_move(gamestate, &move) != VALID_MOVE_SEMANTICS) {
    1.58 -            return EXIT_FAILURE;
    1.59 +            return 1;
    1.60          }
    1.61          apply_move(gamestate, &move);
    1.62          
    1.63 @@ -135,13 +135,13 @@
    1.64          if (curcol == BLACK) {
    1.65              while (isdigit(c = fgetc(stream)));
    1.66              if (c != '.') {
    1.67 -                return EXIT_FAILURE;
    1.68 +                return 1;
    1.69              }
    1.70          }
    1.71          curcol = opponent_color(curcol);
    1.72      }
    1.73      
    1.74 -    return EXIT_SUCCESS;
    1.75 +    return 0;
    1.76  }
    1.77  
    1.78  size_t write_pgn(FILE* stream, GameState *gamestate, GameInfo *gameinfo) {

mercurial