- while ((ss >> token) && !isspace(token))
- if (!set_castling_rights(token))
- goto incorrect_fen;
-
- // 4. En passant square
- char col, row;
- if ( ((ss >> col) && (col >= 'a' && col <= 'h'))
- && ((ss >> row) && (row == '3' || row == '6')))
+ ss >> token >> std::noskipws;
+ while (token != '-' && !isspace(token))
+ {
+ set_castling_rights(token);
+ ss >> token;
+ }
+
+ // 4. En passant square. Ignore if no pawn capture is possible
+ ss >> std::skipws >> ep;
+ if (ep.size() == 2)