[education/rkward] /: Also correct handling of names starting with .[digit] or _

Thomas Friedrichsmeier null at kde.org
Sun May 29 09:17:13 BST 2022


Git commit f2c53cb7d6a1f8aaca36d8b8a48e493ac44a7feb by Thomas Friedrichsmeier.
Committed on 29/05/2022 at 08:16.
Pushed by tfry into branch 'master'.

Also correct handling of names starting with .[digit] or _

M  +1    -1    ChangeLog
M  +14   -5    rkward/core/robject.cpp

https://invent.kde.org/education/rkward/commit/f2c53cb7d6a1f8aaca36d8b8a48e493ac44a7feb

diff --git a/ChangeLog b/ChangeLog
index 6d7d63be..401bb184 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,4 @@
-- Fix object name completion for (irregular) names starting with a digit
+- Fix object name completion for (irregular) names starting with numbers or underscores
 - Crosstabs N to N: Simplify labels, add option to control table layout
 - Change mechanism for detection of object changes
   - TODO:
diff --git a/rkward/core/robject.cpp b/rkward/core/robject.cpp
index e47fdd84..1e95990f 100644
--- a/rkward/core/robject.cpp
+++ b/rkward/core/robject.cpp
@@ -59,12 +59,21 @@ bool RObject::irregularShortName (const QString &name) {
 	const int len = name.length();
 	for (int i = 0; i < len; ++i) {
 		const QChar c = name.at(i);
-		// letters, dot, and underscore are allowed anywhere in the name
-		// digits are allowed, too, but not as the first char
+		// letters are allowed anywhere in the name
+		// underscore is allowed, but not as the first character
+		// dot, and digits are allowed, too unless they make the name start with a number (or with ...)
 		if(c.isLetter()) continue;
-		if(c == '.') continue;
-		if(c == '_') continue;
-		if(i && c.isDigit()) continue;
+		if(!i) {
+			if(c.isDigit()) return true;
+			if(c == '.') {
+				if(len > 1 && name[1].isDigit()) return true;
+				if(name == QStringLiteral("...")) return true;
+			}
+		} else {
+			if(c.isDigit()) continue;
+			if(c == '.') continue;
+			if(c == '_') continue;
+		}
 		return true;
 	}
 	return(false);


More information about the rkward-tracker mailing list