src/main.c

changeset 209
dc4f34426c66
parent 208
e9c3d3e89465
--- a/src/main.c	Tue Sep 01 17:47:07 2026 +0200
+++ b/src/main.c	Wed Sep 02 17:11:56 2026 +0200
@@ -1289,11 +1289,20 @@
     if (settings.continuepgn) {
         FILE *pgnfile = fopen(settings.continuepgn, "r");
         if (pgnfile) {
-            int result = read_pgn(pgnfile, &gamestate);
+            pgn_result result = read_pgn(pgnfile, &gamestate);
             fclose(pgnfile);
-            if (result) {
-                printw("Invalid PGN file content at position %zu:\n%s\n",
-                        pgn_error_position(), pgn_error_str(result));
+            if (result.code) {
+                printw("Invalid PGN content at position %zu", result.position);
+                if (result.move_half_number) {
+                    unsigned hm = result.move_half_number - 1;
+                    printw(" (move %u, %s)", 1+hm/2, hm%2 ? "black":"white");
+                }
+                printw(":\n%s", pgn_error_str(result.code));
+                if (result.code == pgn_error_move) {
+                    addch(' ');
+                    eval_move_failed_msg(result.move_error);
+                }
+                printw("\n");
                 exitcode = EXIT_FAILURE;
             }
             /* clear resignation and remis flags to allow game continuation */

mercurial