[rkward] rkward/rbackend: Another corner case...

Thomas Friedrichsmeier null at kde.org
Wed Apr 25 10:17:13 UTC 2018


Git commit 9b7a3673968b2be2e086aaef88484cd5d8cae192 by Thomas Friedrichsmeier.
Committed on 25/04/2018 at 10:17.
Pushed by tfry into branch 'master'.

Another corner case...

M  +6    -1    rkward/rbackend/rkrbackend.cpp

https://commits.kde.org/rkward/9b7a3673968b2be2e086aaef88484cd5d8cae192

diff --git a/rkward/rbackend/rkrbackend.cpp b/rkward/rbackend/rkrbackend.cpp
index 78654fc6..3ce1f71f 100644
--- a/rkward/rbackend/rkrbackend.cpp
+++ b/rkward/rbackend/rkrbackend.cpp
@@ -473,7 +473,12 @@ void RWriteConsoleEx (const char *buf, int buflen, int type) {
 	if (win_do_detect_winutf8markers) {
 		QByteArray str(buf, buflen);
 		if (!str.contains('X')) return;  // May happen. We better don't rely on how exactly the output is chunked
-		if (str.indexOf(' ') >= 0) str = str.split(' ').value (1);  // The value may or may not be printed on the same line as the row number
+		// The value may or may not be printed in the same chunk as the row number, and the following value
+		// so split into whatever values have arrived in this chunk, then pick the one with the 'X'
+		QList<QByteArray> candidates = str.split(' ');
+		for (int i = 0; i < candidates.size(); ++i) {
+			if (candidates[i].contains('X')) str = candidates[i];
+		}
 		winutf8start = str.split('X').value(0);
 		winutf8stop = str.split('X').value(1);
 		return;



More information about the rkward-tracker mailing list