From 6a8d850ace4b9e88917e97bfcdef2f081c838571 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 10 Nov 2015 10:35:06 +0300 Subject: [PATCH] bugfix / regexp space trouble Fix of the bug that I've faced when used it with Stockfish 6 SSE Engine, which spitted at me with errors, when everything were OK, because when it is a last move before gameover, the Engine returns that string without trailing space. --- src/main.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.js b/src/main.js index e9da91f..0c9a6f5 100644 --- a/src/main.js +++ b/src/main.js @@ -203,6 +203,7 @@ Engine.prototype.timeLimitedGoCommand = function (infoHandler, self.engineProcess.stdout.removeListener('data', engineStdoutListener); var moveRegex = /bestmove (\w+)(.*)?/g; var match = moveRegex.exec(lines[i]); + if (!match && lines[i].length==13) match = moveRegex.exec(lines[i]+' '); if (match) { deferred.resolve(utilities.convertToMoveObject(match[1])); } else { @@ -272,6 +273,7 @@ Engine.prototype.stopCommand = function () { self.engineProcess.stdout.removeListener('data', engineStdoutListener); var moveRegex = /bestmove (\w+)(.*)?/g; var match = moveRegex.exec(lines[i]); + if (!match && lines[i].length==13) match = moveRegex.exec(lines[i]+' '); if (match) { deferred.resolve(utilities.convertToMoveObject(match[1])); } else {