diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2025-01-29 23:28:28 +0500 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2025-01-29 21:19:55 +0100 |
commit | 94636bc76489f27087eb4a5433693082631f3334 (patch) | |
tree | 294da2076179516aa59ad8d54dbf1863624dae8e /connectivity/source/parse | |
parent | b5967157b37904219865fd847b20938b3ccfbd72 (diff) |
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.kaganski@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'connectivity/source/parse')
-rw-r--r-- | connectivity/source/parse/sqlnode.cxx | 23 |
1 files changed, 22 insertions, 1 deletions
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: |