[Libreoffice-commits] core.git: connectivity/source
Noel Grandin
noel.grandin at collabora.co.uk
Tue May 30 09:37:49 UTC 2017
connectivity/source/commontools/CommonTools.cxx | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
New commits:
commit 47bbe217607374ccd3a76f1ef6d82e43efd31ba1
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Tue May 30 09:13:44 2017 +0200
untwist the logic in convertName2SQLName
Change-Id: Ib3cfa3a8a2bdc691e3f6db25672a37c8ede1ffd5
Reviewed-on: https://gerrit.libreoffice.org/38180
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/connectivity/source/commontools/CommonTools.cxx b/connectivity/source/commontools/CommonTools.cxx
index 3a9f237ce824..82e497b2e65b 100644
--- a/connectivity/source/commontools/CommonTools.cxx
+++ b/connectivity/source/commontools/CommonTools.cxx
@@ -211,21 +211,19 @@ OUString convertName2SQLName(const OUString& rName,const OUString& _rSpecials)
{
if(isValidSQLName(rName,_rSpecials))
return rName;
- OUString aNewName(rName);
+
const sal_Unicode* pStr = rName.getStr();
+ // if not valid
+ if (*pStr >= 128 || rtl::isAsciiDigit(*pStr))
+ return OUString();
+
+ OUStringBuffer aNewName(rName);
sal_Int32 nLength = rName.getLength();
- bool bValid(*pStr < 128 && !rtl::isAsciiDigit(*pStr));
- for (sal_Int32 i=0; bValid && i < nLength; ++pStr,++i )
+ for (sal_Int32 i=0; i < nLength; ++pStr,++i )
if(!isCharOk(*pStr,_rSpecials))
- {
- aNewName = aNewName.replace(*pStr,'_');
- pStr = aNewName.getStr() + i;
- }
-
- if ( !bValid )
- aNewName.clear();
+ aNewName[i] = '_';
- return aNewName;
+ return aNewName.makeStringAndClear();
}
OUString quoteName(const OUString& _rQuote, const OUString& _rName)
More information about the Libreoffice-commits
mailing list