summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2015-10-16 17:27:54 +0200
committerEike Rathke <erack@redhat.com>2015-10-16 17:32:29 +0200
commitc3ef1d12375a6e02df0988eef942afcf71e4ff81 (patch)
tree6bbee926dc35c988d49eda5162af2f488895a77c
parente0769daf7b4335024733fa43b26cd0ef0b03108f (diff)
don not use libc toupper() because it might yield unexpected results
Change-Id: I6202d14b78d153e74b973f1f9fa523ad92f507a7
-rw-r--r--sc/source/core/tool/address.cxx17
1 files changed, 13 insertions, 4 deletions
diff --git a/sc/source/core/tool/address.cxx b/sc/source/core/tool/address.cxx
index 4bd996409f4b..d301e65457b9 100644
--- a/sc/source/core/tool/address.cxx
+++ b/sc/source/core/tool/address.cxx
@@ -834,6 +834,15 @@ static sal_uInt16 lcl_ScRange_Parse_XL_R1C1( ScRange& r,
return 0;
}
+static inline sal_Unicode lcl_toupper( const sal_Unicode c )
+{
+ // Do not use libc toupper() because that is localized and *might* yield
+ // unexpected results (apparently not encountered yet?), for example
+ // Turkish lower case ASCII 'i' might result in upper case 'İ', which is
+ // U+0130 but 0xDD in ISO-8859-9 and 0xA9 in ISO-8859-3 encodings.
+ return ('a' <= c && c <= 'z') ? c - ('a'-'A') : c;
+}
+
static inline const sal_Unicode* lcl_a1_get_col( const sal_Unicode* p,
ScAddress* pAddr,
sal_uInt16* nFlags )
@@ -846,9 +855,9 @@ static inline const sal_Unicode* lcl_a1_get_col( const sal_Unicode* p,
if( !rtl::isAsciiAlpha( *p ) )
return NULL;
- nCol = sal::static_int_cast<SCCOL>( toupper( char(*p++) ) - 'A' );
+ nCol = sal::static_int_cast<SCCOL>( lcl_toupper( *p++ ) - 'A' );
while (nCol <= MAXCOL && rtl::isAsciiAlpha(*p))
- nCol = sal::static_int_cast<SCCOL>( ((nCol + 1) * 26) + toupper( char(*p++) ) - 'A' );
+ nCol = sal::static_int_cast<SCCOL>( ((nCol + 1) * 26) + lcl_toupper( *p++ ) - 'A' );
if( nCol > MAXCOL || rtl::isAsciiAlpha( *p ) )
return NULL;
@@ -1145,9 +1154,9 @@ static sal_uInt16 lcl_ScAddress_Parse_OOo( const sal_Unicode* p, ScDocument* pDo
if (rtl::isAsciiAlpha( *p ))
{
- nCol = sal::static_int_cast<SCCOL>( toupper( char(*p++) ) - 'A' );
+ nCol = sal::static_int_cast<SCCOL>( lcl_toupper( *p++ ) - 'A' );
while (nCol < MAXCOL && rtl::isAsciiAlpha(*p))
- nCol = sal::static_int_cast<SCCOL>( ((nCol + 1) * 26) + toupper( char(*p++) ) - 'A' );
+ nCol = sal::static_int_cast<SCCOL>( ((nCol + 1) * 26) + lcl_toupper( *p++ ) - 'A' );
}
else
nBits = 0;