[education/rkward] rkward/rbackend: Fixup

Thomas Friedrichsmeier null at kde.org
Thu Apr 18 17:40:15 BST 2024


Git commit 18ddf513fd83d036c14f21e80a4e1e38f41e9f71 by Thomas Friedrichsmeier.
Committed on 18/04/2024 at 16:38.
Pushed by tfry into branch 'master'.

Fixup

M  +3    -3    rkward/rbackend/rkrbackend.cpp
M  +2    -2    rkward/rbackend/rpackages/rkward/R/rk.filename-functions.R
M  +2    -0    rkward/rbackend/rpackages/rkward/R/rk.print-functions.R

https://invent.kde.org/education/rkward/-/commit/18ddf513fd83d036c14f21e80a4e1e38f41e9f71

diff --git a/rkward/rbackend/rkrbackend.cpp b/rkward/rbackend/rkrbackend.cpp
index 2f2fd609c..fee3c769f 100644
--- a/rkward/rbackend/rkrbackend.cpp
+++ b/rkward/rbackend/rkrbackend.cpp
@@ -504,10 +504,10 @@ void RWriteConsoleEx (const char *buf, int buflen, int type) {
 		while (pos < buflen) {
 			int start = str.indexOf(winutf8start, pos);
 			if (start < 0) {
-				utf8.append (RKRBackend::toUtf8 (str.mid(pos).constData()));
+				utf8.append(RKTextCode::fromNative(str.mid(pos)));
 				break;
 			}
-			utf8.append (RKRBackend::toUtf8 (str.left(start).constData()));
+			utf8.append(RKTextCode::fromNative(str.left(start)));
 			start += winutf8start.length();
 			if (start >= buflen) break;
 			int end = str.indexOf(winutf8stop, start);
@@ -515,7 +515,7 @@ void RWriteConsoleEx (const char *buf, int buflen, int type) {
 				utf8.append(QString::fromUtf8(str.mid(start, end - start)));
 				pos = end + winutf8stop.length();
 			} else {
-				utf8.append(QString::fromUtf8(str.mid(start).constData()));
+				utf8.append(QString::fromUtf8(str.mid(start)));
 				break;
 			}
 		}
diff --git a/rkward/rbackend/rpackages/rkward/R/rk.filename-functions.R b/rkward/rbackend/rpackages/rkward/R/rk.filename-functions.R
index 1edee5b88..9a1804fd8 100644
--- a/rkward/rbackend/rpackages/rkward/R/rk.filename-functions.R
+++ b/rkward/rbackend/rpackages/rkward/R/rk.filename-functions.R
@@ -128,10 +128,10 @@
 	if (!file.exists (x)) {
 		encoding.name <- function() {
 			li <- l10n_info();
-			if(isTrue(li$'UTF-8')) return("UTF-8")  # hopefully the most common case, these days
+			if(isTRUE(li$'UTF-8')) return("UTF-8")  # hopefully the most common case, these days
 			if(!is.null(li$codeset)) return(li$codeset)
 			if(!is.null(li$codepage)) return(paste0("windows-", li$codepage))
-			return(tail(strsplit(Sys.getlocale("LC_CTYPE", ".") ,1)))
+			return(tail(strsplit(Sys.getlocale("LC_CTYPE"), ".") ,1))
 		}
 		.rk.cat.output (paste ("<?xml version=\"1.0\" encoding=\"", encoding.name(), "\"?>\n", sep=""))
 		.rk.cat.output ("<html><head>\n<title>RKWard Output</title>\n")
diff --git a/rkward/rbackend/rpackages/rkward/R/rk.print-functions.R b/rkward/rbackend/rpackages/rkward/R/rk.print-functions.R
index 8c34debac..151abe6cf 100644
--- a/rkward/rbackend/rpackages/rkward/R/rk.print-functions.R
+++ b/rkward/rbackend/rpackages/rkward/R/rk.print-functions.R
@@ -112,6 +112,8 @@
 		htmlfile <- rk.get.output.html.file()
 		if(requireNamespace ("R2HTML", quietly = TRUE)) {
 			R2HTML::HTML(x, file=htmlfile, ...)
+		} else {
+			.rk.cat.output("Please install package R2HTML to enable output!")
 		}
 	}
 }



More information about the rkward-tracker mailing list