cppuhelper : use rtl::isAlphaNumeric instead of recreate the method.

Change-Id: I30bd9e0bf99c2a115b67a59377b2d2ef6fdefef0
Reviewed-on: https://gerrit.libreoffice.org/54194
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Arnaud Versini <arnaud.versini@libreoffice.org>
This commit is contained in:
Arnaud Versini 2018-05-13 16:30:52 +02:00 committed by Arnaud Versini
parent 6ebe8b9068
commit e93c3662b3

View File

@ -27,6 +27,7 @@
#include <rtl/uri.hxx> #include <rtl/uri.hxx>
#include <rtl/ustring.h> #include <rtl/ustring.h>
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
#include <rtl/character.hxx>
#include <sal/types.h> #include <sal/types.h>
#include <map> #include <map>
@ -35,17 +36,6 @@
using cppu::UnoUrl; using cppu::UnoUrl;
using cppu::UnoUrlDescriptor; using cppu::UnoUrlDescriptor;
namespace {
inline bool isAlphanum(sal_Unicode c)
{
return (c >= 0x30 && c <= 0x39) // '0'--'9'
|| (c >= 0x41 && c <= 0x5A) // 'A'--'Z'
|| (c >= 0x61 && c <= 0x7A); // 'a'--'z'
}
}
class UnoUrlDescriptor::Impl class UnoUrlDescriptor::Impl
{ {
public: public:
@ -76,7 +66,7 @@ inline UnoUrlDescriptor::Impl::Impl(rtl::OUString const & rDescriptor)
switch (eState) switch (eState)
{ {
case STATE_NAME0: case STATE_NAME0:
if (bEnd || !isAlphanum(c)) if (bEnd || !rtl::isAsciiAlphanumeric(c))
throw rtl::MalformedUriException( throw rtl::MalformedUriException(
"UNO URL contains bad descriptor name"); "UNO URL contains bad descriptor name");
nStart = i; nStart = i;
@ -90,13 +80,13 @@ inline UnoUrlDescriptor::Impl::Impl(rtl::OUString const & rDescriptor)
= rDescriptor.copy(nStart, i - nStart).toAsciiLowerCase(); = rDescriptor.copy(nStart, i - nStart).toAsciiLowerCase();
eState = STATE_KEY0; eState = STATE_KEY0;
} }
else if (!isAlphanum(c)) else if (!rtl::isAsciiAlphanumeric(c))
throw rtl::MalformedUriException( throw rtl::MalformedUriException(
"UNO URL contains bad descriptor name"); "UNO URL contains bad descriptor name");
break; break;
case STATE_KEY0: case STATE_KEY0:
if (bEnd || !isAlphanum(c)) if (bEnd || !rtl::isAsciiAlphanumeric(c))
throw rtl::MalformedUriException( throw rtl::MalformedUriException(
"UNO URL contains bad parameter key"); "UNO URL contains bad parameter key");
nStart = i; nStart = i;
@ -110,7 +100,7 @@ inline UnoUrlDescriptor::Impl::Impl(rtl::OUString const & rDescriptor)
nStart = i + 1; nStart = i + 1;
eState = STATE_VALUE; eState = STATE_VALUE;
} }
else if (bEnd || !isAlphanum(c)) else if (bEnd || !rtl::isAsciiAlphanumeric(c))
throw rtl::MalformedUriException( throw rtl::MalformedUriException(
"UNO URL contains bad parameter key"); "UNO URL contains bad parameter key");
break; break;
@ -222,7 +212,7 @@ inline UnoUrl::Impl * UnoUrl::Impl::create(rtl::OUString const & rUrl)
for (j = i; j < rUrl.getLength(); ++j) for (j = i; j < rUrl.getLength(); ++j)
{ {
sal_Unicode c = rUrl[j]; sal_Unicode c = rUrl[j];
if (!isAlphanum(c) && c != 0x21 && c != 0x24 // '!', '$' if (!rtl::isAsciiAlphanumeric(c) && c != 0x21 && c != 0x24 // '!', '$'
&& c != 0x26 && c != 0x27 && c != 0x28 // '&', ''', '(' && c != 0x26 && c != 0x27 && c != 0x28 // '&', ''', '('
&& c != 0x29 && c != 0x2A && c != 0x2B // ')', '*', '+' && c != 0x29 && c != 0x2A && c != 0x2B // ')', '*', '+'
&& c != 0x2C && c != 0x2D && c != 0x2E // ',', '-', '.' && c != 0x2C && c != 0x2D && c != 0x2E // ',', '-', '.'