diff -r c8f2c280cff7 -r 5427beba96d1 src/chess/pgn.c --- a/src/chess/pgn.c Tue Sep 18 15:02:08 2018 +0200 +++ b/src/chess/pgn.c Tue Aug 13 00:33:59 2019 +0200 @@ -35,6 +35,7 @@ enum { pgn_error_missing_quote = 1, pgn_error_missing_bracket, + pgn_error_missing_brace, pgn_error_missing_dot, pgn_error_move_syntax, pgn_error_move_semantics @@ -43,6 +44,7 @@ static const char* pgn_error_strings[] = { "No Error.", "Tag values must be enclosed in double-quotes.", + "Missing closing brace '}' for comment.", "Tags must be enclosed in square brackets: '[Key \"Value\"]'.", "Move numbers must be terminated with a dot (e.g. '13.' - not '13').", "Move is syntactically incorrect.", @@ -128,7 +130,21 @@ } apply_move(gamestate, &move); - // TODO: parse comments + /* skip spaces */ + while (isspace(c = fgetc(stream))); + + /* parse possible comment */ + if (c == '{') { + // TODO: interpret comment (may contain clock info) + do { + c = fgetc(stream); + } while (c != '}' && c != EOF); + if (c == EOF) { + return pgn_error_missing_brace; + } + } + + /* skip spaces */ while (isspace(c = fgetc(stream))); /* end of game data encountered */