connectivity/source/parse/sqlnode.cxx | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)
New commits: commit 0a4ef5903b88f851c8b1dda14edab864c268264f Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Wed Jan 29 23:28:28 2025 +0500 Commit: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> CommitDate: Tue Feb 4 17:23:39 2025 +0100 tdf#130672: handle Rule::factor explicitly When representing a signed number, the rule may consist of two subnodes: a punctuation bearing "+" or "-", and then the following digits (see 'factor:' in connectivity/source/parse/sqlbison.y). After punctuation was added to the string buffer, the following number is passed to parseLeaf, where it checks if the buffer is not empty, and then adds a space between the preceding sign and the digits. This change handles the 'factor' rule explicitly. Change-Id: I0c929418ad88c5bf653a4e820f45b7d627b07da7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180917 Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> Tested-by: Jenkins (cherry picked from commit 94636bc76489f27087eb4a5433693082631f3334) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180923 Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index 95d6e88c2215..1192183fc636 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -497,10 +497,31 @@ void OSQLParseNode::impl_parseNodeToString_throw(OUStringBuffer& rString, const } bHandled = true; break; + + case factor: + bSimple = false; + if (nCount == 2 && m_aChildren[0] && m_aChildren[1] + && (SQL_ISPUNCTUATION(m_aChildren[0], "-") || SQL_ISPUNCTUATION(m_aChildren[0], "+")) + && (m_aChildren[1]->getNodeType() == SQLNodeType::IntNum + || m_aChildren[1]->getNodeType() == SQLNodeType::ApproxNum)) + { + // A signed number ("+" or "-" plus either IntNum or ApproxNum) + // The default processing would first add the sign, then process the number, which + // would see that rString is not empty already, and insert a space between the sign + // and the digits. Avoid that unneeded space. + OUStringBuffer aFactorPara; + m_aChildren[1]->impl_parseNodeToString_throw(aFactorPara, rParam, bSimple); + // Insert a space before the signed number, similar to parseLeaf for IntNum / ApproxNum + if (!rString.isEmpty()) + rString.append(" "); + rString.append(m_aChildren[0]->getTokenValue() + aFactorPara); + bHandled = true; + } + break; + case odbc_call_spec: case subquery: case term: - case factor: case window_function: case cast_spec: case num_value_exp: