xforms: fix incorrect comparison against empty strings

In XSL a string variable can be nul, the empty string or a non-empty
string. While `$var != ''` ensures that `var` is a non-empty string,
`$var = ''` is true only when `var` holds the empty string. In other words,
`$var = ''` and `$var != ''` can be both false if `var` evaluates to nul.

As a result, the config.h/config.mk generating scripts does not use the
given default value if the explicit value is nul.

This patch fixes the incorrect comparison in the XSL scripts that handles
default values, so that the default value behaves as expected.

Tracked-On: #6355
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
This commit is contained in:
Junjie Mao 2022-01-29 17:42:09 +08:00 committed by acrnsi-robot
parent 5118d67508
commit 1ea67378f1
3 changed files with 4 additions and 3 deletions

View File

@ -49,7 +49,8 @@
<xsl:value-of select="$value" />
<xsl:text>&#xa;</xsl:text>
</xsl:when>
<xsl:when test="($value = '') and ($default != '')">
<xsl:when test="$default != ''">
<xsl:text> </xsl:text>
<xsl:value-of select="$default" />
<xsl:text>&#xa;</xsl:text>
</xsl:when>

View File

@ -43,7 +43,7 @@
<xsl:value-of select="$value" />
<xsl:text>&#xa;</xsl:text>
</xsl:when>
<xsl:when test="($value = '') and ($default != '')">
<xsl:when test="$default != ''">
<xsl:value-of select="$default" />
<xsl:text>&#xa;</xsl:text>
</xsl:when>

View File

@ -329,7 +329,7 @@
<xsl:with-param name="value" select="concat($value, $integer-suffix)" />
</xsl:call-template>
</xsl:when>
<xsl:when test="($value = '') and ($default != '')">
<xsl:when test="$default != ''">
<xsl:call-template name="entry-by-key-value">
<xsl:with-param name="prefix" select="$prefix" />
<xsl:with-param name="key" select="$key" />