[rkward] rkward/rbackend: Another fix to 98206a836248ad73abb3f2f9669c1768867ae06e
Thomas Friedrichsmeier
null at kde.org
Wed Apr 25 09:46:26 UTC 2018
Git commit b0383b8d1359c6c36783c139b5195ff6fa1c3ea0 by Thomas Friedrichsmeier.
Committed on 25/04/2018 at 09:46.
Pushed by tfry into branch 'master'.
Another fix to 98206a836248ad73abb3f2f9669c1768867ae06e
M +6 -4 rkward/rbackend/rkrbackend.cpp
https://commits.kde.org/rkward/b0383b8d1359c6c36783c139b5195ff6fa1c3ea0
diff --git a/rkward/rbackend/rkrbackend.cpp b/rkward/rbackend/rkrbackend.cpp
index 6519e730..49b09b09 100644
--- a/rkward/rbackend/rkrbackend.cpp
+++ b/rkward/rbackend/rkrbackend.cpp
@@ -457,6 +457,7 @@ bool RKRBackend::fetchStdoutStderr (bool forcibly) {
}
#ifdef Q_OS_WIN
+bool win_do_detect_winutf8markers = false;
QByteArray winutf8start, winutf8stop;
#endif
void RWriteConsoleEx (const char *buf, int buflen, int type) {
@@ -469,12 +470,12 @@ void RWriteConsoleEx (const char *buf, int buflen, int type) {
// So here we try to detect the markers (if any) from print("X", print.gap=1, quote=FALSE), i.e. an expected output of the form
// [1] _s_X_e_
// Where _s_ and _e_ are the start and stop markers, respectively.
- if (winutf8start.isNull()) {
+ if (win_do_detect_winutf8markers) {
QByteArray str(buf, buflen);
- if (str.indexOf(' ') >= 0) str = str.split(' ').value (1); // Can row numbers ever be missing? We rather play it safe
+ 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
winutf8start = str.split('X').value(0);
winutf8stop = str.split('X').value(1);
- if (winutf8start.isNull()) winutf8start = ""; // don't try detection, again
return;
}
#endif
@@ -1116,8 +1117,9 @@ bool RKRBackend::startR () {
default_global_context = R_GlobalContext;
#ifdef Q_OS_WIN
// See the corresponding note in RWriteConsoleEx(). For auto-detecting UTF8 markers in console output.
- winutf8start.clear();
+ win_do_detect_winutf8markers = true;
runDirectCommand("print(\"X\", print.gap=1, quote=FALSE)");
+ win_do_detect_winutf8markers = false;
#endif
// get info on R runtime version
More information about the rkward-tracker
mailing list