[education/rkward] /: Fix object name completion for names starting with a digit.

Thomas Friedrichsmeier null at kde.org
Sun May 29 08:34:47 BST 2022


Git commit af4b9a472d9749d211d930e201d97ba33471d25e by Thomas Friedrichsmeier.
Committed on 29/05/2022 at 07:34.
Pushed by tfry into branch 'master'.

Fix object name completion for names starting with a digit.

M  +1    -0    ChangeLog
M  +12   -2    rkward/core/robject.cpp

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

diff --git a/ChangeLog b/ChangeLog
index ec0aa7a7..6d7d63be 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,4 @@
+- Fix object name completion for (irregular) names starting with a digit
 - 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 f7e2d6eb..e47fdd84 100644
--- a/rkward/core/robject.cpp
+++ b/rkward/core/robject.cpp
@@ -56,8 +56,18 @@ RObject::~RObject () {
 
 bool RObject::irregularShortName (const QString &name) {
 	// no trace
-	static const QRegExp invalidChars ("[^a-zA-z0-9\\._]");
-	return (name.contains (invalidChars));
+	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
+		if(c.isLetter()) continue;
+		if(c == '.') continue;
+		if(c == '_') continue;
+		if(i && c.isDigit()) continue;
+		return true;
+	}
+	return(false);
 }
 
 QString RObject::getFullName (int options) const {


More information about the rkward-tracker mailing list