Fix loading of (noncompliant) wide PGN v4.9.x
authorH.G.Muller <hgm@hgm-xboard.(none)>
Fri, 10 Oct 2025 13:11:15 +0000 (15:11 +0200)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Sat, 11 Oct 2025 16:46:01 +0000 (18:46 +0200)
The PGN standard limits line length to 255 characters. But rather than
clipping too-long lines, XBoard now tries to split such lines at a space.

parser.c

index 7e71619..99808fb 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -289,6 +289,7 @@ ReadLine ()
     if(fromString) return 0; // parsing string, so the end is a hard end
     if(!inputFile) return 0;
     while((c = fgetc(inputFile)) != EOF) {
+       if(c == ' ' && inPtr - inputBuf > PARSEBUFSIZE/2) break;  // break too-long lines
        *inPtr++ = c;
        if(c == '\n') { *inPtr = NULLCHAR; return 1; }
        if(inPtr - inputBuf > PARSEBUFSIZE-2) inPtr--; //prevent crash on overflow