Kaydet (Commit) f5c93d41 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Use rtl::isAscii* instead of ctype.h is* (and fix passing plain char)

and add rtl::isAsciiWhiteSpace

Change-Id: Iac71975f718b9360ea9dc94485c069c5e7cb91c7
üst e6297cf0
......@@ -239,6 +239,29 @@ template<typename T> inline bool isAsciiOctalDigit(T code)
{ return isAsciiOctalDigit(sal_uInt32(code)); }
#endif
/** Check for ASCII white space character.
@param code A Unicode code point.
@return True if code is an ASCII white space character as defined by C for
isspace in the "C" locale (ASCII ' ', '\f', '\n', '\r', '\t' '\v').
@since LibreOffice 5.4
*/
inline bool isAsciiWhiteSpace(sal_uInt32 code)
{
assert(isUnicodeCodePoint(code));
return code == ' ' || code == '\f' || code == '\n' || code == '\r'
|| code == '\t' || code == '\v';
}
#if defined LIBO_INTERNAL_ONLY
bool isAsciiWhiteSpace(char) = delete;
bool isAsciiWhiteSpace(signed char) = delete;
template<typename T> inline bool isAsciiWhiteSpace(T code)
{ return isAsciiWhiteSpace(sal_uInt32(code)); }
#endif
/** Convert a character, if ASCII, to upper case.
@param code A Unicode code point.
......
......@@ -13,6 +13,7 @@
#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
#include <filter/msfilter/escherex.hxx>
#include <rtl/character.hxx>
#include <tools/stream.hxx>
#include <dmapper/DomainMapperFactory.hxx>
......@@ -71,11 +72,16 @@ RTFError RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
Strm().ReadChar(ch);
if ('\\' == ch)
bInKeyword = true;
if (!bInKeyword && isalnum(ch))
if (!bInKeyword
&& rtl::isAsciiAlphanumeric(static_cast<unsigned char>(ch)))
aBuf.append(ch);
else if (bInKeyword && isspace(ch))
else if (bInKeyword
&& rtl::isAsciiWhiteSpace(
static_cast<unsigned char>(ch)))
bInKeyword = false;
if (!aBuf.isEmpty() && !isalnum(ch))
if (!aBuf.isEmpty()
&& !rtl::isAsciiAlphanumeric(
static_cast<unsigned char>(ch)))
bFoundCode = true;
}
......
......@@ -166,7 +166,7 @@ RTFError RTFTokenizer::resolveParse()
int RTFTokenizer::asHex(char ch)
{
int ret = 0;
if (isdigit(ch))
if (rtl::isAsciiDigit(static_cast<unsigned char>(ch)))
ret = ch - '0';
else
{
......@@ -203,7 +203,7 @@ RTFError RTFTokenizer::resolveKeyword()
if (Strm().IsEof())
return RTFError::UNEXPECTED_EOF;
if (!isalpha(ch))
if (!rtl::isAsciiAlpha(static_cast<unsigned char>(ch)))
{
aBuf.append(ch);
OString aKeyword = aBuf.makeStringAndClear();
......@@ -211,7 +211,7 @@ RTFError RTFTokenizer::resolveKeyword()
// without doing any SeekRel()
return dispatchKeyword(aKeyword, bParam, nParam);
}
while (isalpha(ch))
while (rtl::isAsciiAlpha(static_cast<unsigned char>(ch)))
{
aBuf.append(ch);
Strm().ReadChar(ch);
......@@ -234,13 +234,13 @@ RTFError RTFTokenizer::resolveKeyword()
if (Strm().IsEof())
return RTFError::UNEXPECTED_EOF;
}
if (isdigit(ch))
if (rtl::isAsciiDigit(static_cast<unsigned char>(ch)))
{
OStringBuffer aParameter;
// we have a parameter
bParam = true;
while (isdigit(ch))
while (rtl::isAsciiDigit(static_cast<unsigned char>(ch)))
{
aParameter.append(ch);
Strm().ReadChar(ch);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment