SVG: fix HMI:Assign widget to properly handle single-letter variable names.
authorEdouard Tisserant <edouard@beremiz.fr>
Wed, 03 Apr 2024 14:17:50 +0200
changeset 3922 ffc8da83fdc2
parent 3921 9bb17341aebb
child 3928 5c662d2e3f72
SVG: fix HMI:Assign widget to properly handle single-letter variable names.
svghmi/gen_index_xhtml.xslt
svghmi/widget_assign.ysl2
--- a/svghmi/gen_index_xhtml.xslt	Thu Mar 28 12:07:24 2024 +0100
+++ b/svghmi/gen_index_xhtml.xslt	Wed Apr 03 14:17:50 2024 +0200
@@ -2907,7 +2907,7 @@
           </xsl:if>
         </xsl:for-each>
       </xsl:variable>
-      <xsl:variable name="isVarName" select="regexp:test($value,'^[a-zA-Z_][a-zA-Z0-9_]+$')"/>
+      <xsl:variable name="isVarName" select="regexp:test($value,'^[a-zA-Z_][a-zA-Z0-9_]*$')"/>
       <xsl:choose>
         <xsl:when test="$isVarName">
           <xsl:text>        const </xsl:text>
--- a/svghmi/widget_assign.ysl2	Thu Mar 28 12:07:24 2024 +0100
+++ b/svghmi/widget_assign.ysl2	Wed Apr 03 14:17:50 2024 +0200
@@ -71,7 +71,7 @@
         const "name","substring-before(@value,'=')";
         const "value","substring-after(@value,'=')";
         const "index" foreach "$paths" if "@assign = $name" value "position()-1";
-        const "isVarName", "regexp:test($value,'^[a-zA-Z_][a-zA-Z0-9_]+$')";
+        const "isVarName", "regexp:test($value,'^[a-zA-Z_][a-zA-Z0-9_]*$')";
         choose {
             when "$isVarName"{
     |         const «$value» = this.assignments["«$value»"];