fix problem with empty string in -firstNeedsNoncompliantFEN
authorH.G. Muller <h.g.muller@hccnet.nl>
Sat, 28 Nov 2009 21:33:52 +0000 (13:33 -0800)
committerArun Persaud <arun@nubati.net>
Sat, 28 Nov 2009 21:33:52 +0000 (13:33 -0800)
This fixes a bug in the use of the -firstNeedsNoncompliantFEN option with
an empty string as argument. (Which led to truncation of the FEN.)

backend.c

index c2dea7c..339da00 100755 (executable)
--- a/backend.c
+++ b/backend.c
@@ -13683,7 +13683,7 @@ PositionToFEN(move, overrideCastling)
     *p++ = ' ';
 
   if(q = overrideCastling) { // [HGM] FRC: override castling & e.p fields for non-compliant engines
-    while(*p++ = *q++); if(q != overrideCastling+1) p[-1] = ' ';
+    while(*p++ = *q++); if(q != overrideCastling+1) p[-1] = ' '; else --p;
   } else {
   if(nrCastlingRights) {
      q = p;