tdf#99589 - tolower / toupper - dangerous to Turks ...

Change-Id: I8b0fe9354232a7b60f3605fa6f90f6741f7bf683
Reviewed-on: https://gerrit.libreoffice.org/26537
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: jan iversen <jani@documentfoundation.org>
diff --git a/basic/source/sbx/sbxvar.cxx b/basic/source/sbx/sbxvar.cxx
index 0977c74..8ed87ae 100644
--- a/basic/source/sbx/sbxvar.cxx
+++ b/basic/source/sbx/sbxvar.cxx
@@ -30,6 +30,7 @@
#include "sbunoobj.hxx"
#include <math.h>
#include <ctype.h>
#include <rtl/character.hxx>

#include <com/sun/star/uno/XInterface.hpp>
using namespace com::sun::star::uno;
@@ -350,7 +351,7 @@ sal_uInt16 SbxVariable::MakeHashCode( const OUString& rName )
        {
            return 0;
        }
        n = sal::static_int_cast< sal_uInt16 >( ( n << 3 ) + toupper( c ) );
        n = sal::static_int_cast< sal_uInt16 >( ( n << 3 ) + rtl::toAsciiUpperCase( c ) );
    }
    return n;
}
diff --git a/filter/source/t602/t602filter.cxx b/filter/source/t602/t602filter.cxx
index 3a4b3ea..ade1e60 100644
--- a/filter/source/t602/t602filter.cxx
+++ b/filter/source/t602/t602filter.cxx
@@ -38,6 +38,7 @@
#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
#include <comphelper/oslfile2streamwrap.hxx>
#include <rtl/ref.hxx>
#include <rtl/character.hxx>

using namespace ::cppu;
using namespace ::osl;
@@ -679,14 +680,14 @@ tnode T602ImportFilter::PointCmd602(unsigned char *ch)
    char pcmd[2];

    // warning: uChar -> char
    pcmd[0] = (char) toupper(*ch); inschr(*ch);
    pcmd[0] = (char) rtl::toAsciiUpperCase(*ch); inschr(*ch);
    *ch = Readchar602();
    if (!*ch) return tnode::EEND;
    if (*ch=='\n') return tnode::EOL;
    if (!isalpha(*ch)) return (*ch<32) ? tnode::SETCH : tnode::WRITE;

    // warning: uChar -> char
    pcmd[1] = (char) toupper(*ch); inschr(*ch);
    pcmd[1] = (char) rtl::toAsciiUpperCase(*ch); inschr(*ch);

         if (pcmd[0]=='P' && pcmd[1]=='A') { if (pst.pars) pst.willbeeop = true; }
    else if (pcmd[0]=='C' && pcmd[1]=='P') { if (pst.pars) pst.willbeeop = true; }
@@ -761,12 +762,12 @@ void T602ImportFilter::Read602()

        case tnode::EXPCMD: ch = Readchar602();
            if(ch == 0) {inschr('@'); node = tnode::EEND; }
            else if(isupper(ch)) {
            else if(rtl::isAsciiUpperCase(ch)) {
                cmd602[0] = ch;
                ch = Readchar602();
                cmd602[1] = ch;
                cmd602[2] = '\0';
                if(isupper(ch))
                if(rtl::isAsciiUpperCase(ch))
                    node = tnode::SETCMD;   //nedodelano
                else {
                    inschr('@');
diff --git a/helpcompiler/inc/HelpCompiler.hxx b/helpcompiler/inc/HelpCompiler.hxx
index 78f98a2..1acce8f 100644
--- a/helpcompiler/inc/HelpCompiler.hxx
+++ b/helpcompiler/inc/HelpCompiler.hxx
@@ -39,6 +39,7 @@
#include <libxml/catalog.h>

#include <rtl/ustring.hxx>
#include <rtl/character.hxx>
#include <osl/thread.h>
#include <osl/process.h>
#include <osl/file.hxx>
@@ -249,7 +250,7 @@ private:

inline char tocharlower(char c)
{
    return static_cast<char>(tolower(c));
    return static_cast<char>(rtl::toAsciiLowerCase(c));
}

#endif
diff --git a/hwpfilter/source/hbox.cxx b/hwpfilter/source/hbox.cxx
index e501949..bd30edc 100644
--- a/hwpfilter/source/hbox.cxx
+++ b/hwpfilter/source/hbox.cxx
@@ -31,6 +31,8 @@
#include "drawdef.h"
#include "hcode.h"

#include <rtl/character.hxx>

int HBox::boxCount = 0;

HBox::HBox(hchar hch)
@@ -586,7 +588,7 @@ static void getOutlineNumStr(int style, int level, int num, hchar * hstr)
            ptr = buf;
            while (*ptr)
            {
                *ptr = sal::static_int_cast<char>(toupper(*ptr));
                *ptr = sal::static_int_cast<char>(rtl::toAsciiUpperCase(*ptr));
                ptr++;
            }
        }
@@ -688,7 +690,7 @@ hchar_string Outline::GetUnicode() const
                                char *ptr = dest;
                                while( *ptr )
                                {
                                    *ptr = sal::static_int_cast<char>(toupper(*ptr));
                                    *ptr = sal::static_int_cast<char>(rtl::toAsciiUpperCase(*ptr));
                                    ptr++;
                                }
                            }
diff --git a/hwpfilter/source/hwpeq.cxx b/hwpfilter/source/hwpeq.cxx
index dd46110..b87574c 100644
--- a/hwpfilter/source/hwpeq.cxx
+++ b/hwpfilter/source/hwpeq.cxx
@@ -32,6 +32,8 @@ using namespace std;
#include <sal/types.h>
#include <sal/macros.h>

#include <rtl/character.hxx>

/* @Man: change the hwp formula to LaTeX */
#ifdef _WIN32
# define ENDL  "\r\n"
@@ -416,15 +418,15 @@ void make_keyword( char *keyword, const char *token)
    memcpy(keyword, token, len);
    keyword[len] = 0;

    if( (token[0] & 0x80) || islower(token[0]) || strlen(token) < 2 )
    if( (token[0] & 0x80) || rtl::isAsciiLowerCase(token[0]) || strlen(token) < 2 )
        return;

    int capital = isupper(keyword[1]);
    int capital = rtl::isAsciiUpperCase(keyword[1]);
    for( ptr = keyword + 2; *ptr && result; ptr++ )
    {
        if( (*ptr & 0x80) ||
            (!capital && isupper(*ptr)) ||
            (capital && islower(*ptr)) )
            (!capital && rtl::isAsciiUpperCase(*ptr)) ||
            (capital && rtl::isAsciiLowerCase(*ptr)) )
        {
            result = false;
        }
@@ -435,8 +437,8 @@ void make_keyword( char *keyword, const char *token)
        ptr = keyword;
        while( *ptr )
        {
            if( isupper(*ptr) )
                *ptr = sal::static_int_cast<char>(tolower(*ptr));
            if( rtl::isAsciiUpperCase(*ptr) )
                *ptr = sal::static_int_cast<char>(rtl::toAsciiLowerCase(*ptr));
            ptr++;
        }
    }
@@ -687,8 +689,8 @@ static char eq2ltxconv(MzString& sstr, istream *strm, const char *sentinel)
        key[0] = '\\';
        strcpy(key + 1, eq->key);
      }
      if( (eq->flag & EQ_CASE) && isupper(token[0]) )
        key[1] = sal::static_int_cast<char>(toupper(key[1]));
      if( (eq->flag & EQ_CASE) && rtl::isAsciiUpperCase(token[0]) )
        key[1] = sal::static_int_cast<char>(rtl::toAsciiUpperCase(key[1]));
      token = key;
    }

diff --git a/l10ntools/source/gL10nMem.cxx b/l10ntools/source/gL10nMem.cxx
index 2662121..0a533dc 100644
--- a/l10ntools/source/gL10nMem.cxx
+++ b/l10ntools/source/gL10nMem.cxx
@@ -21,7 +21,7 @@
#include <iostream>
#include <fstream>
#include <sstream>
#include<rtl/character.hxx>
#include <rtl/character.hxx>
using namespace std;

#include "gL10nMem.hxx"
@@ -871,7 +871,7 @@ bool l10nMem::locateKey(int                iLineNo,
        if (ch == ' ' || ch == '*' || ch == '+' || ch == '%')
            sUpperKey[i] = '_';
        else
            sUpperKey[i] = toupper(sUpperKey[i]);
            sUpperKey[i] = rtl::toAsciiUpperCase(sUpperKey[i]);
    }

    // Fast check, to see if next key is the one (normal with load and source without change)
diff --git a/sal/osl/w32/file_dirvol.cxx b/sal/osl/w32/file_dirvol.cxx
index 04a62d1..33ef6e3 100644
--- a/sal/osl/w32/file_dirvol.cxx
+++ b/sal/osl/w32/file_dirvol.cxx
@@ -33,6 +33,7 @@
#include "osl/time.h"
#include "rtl/alloc.h"
#include "rtl/ustring.hxx"
#include <rtl/character.hxx>

#include <tchar.h>
#ifdef __MINGW32__
@@ -1054,7 +1055,7 @@ oslFileError SAL_CALL osl_getDirectoryItem(rtl_uString *strFilePath, oslDirector
                osl_acquireDirectoryItem( (oslDirectoryItem)pItemImpl );

                _tcscpy( pItemImpl->cDriveString, strSysFilePath->buffer );
                pItemImpl->cDriveString[0] = toupper( pItemImpl->cDriveString[0] );
                pItemImpl->cDriveString[0] = rtl::toAsciiUpperCase( pItemImpl->cDriveString[0] );

                if ( pItemImpl->cDriveString[_tcslen(pItemImpl->cDriveString) - 1] != '\\' )
                    _tcscat( pItemImpl->cDriveString, TEXT( "\\" ) );
diff --git a/sdext/source/pdfimport/wrapper/wrapper.cxx b/sdext/source/pdfimport/wrapper/wrapper.cxx
index 48e3924..4db5b31 100644
--- a/sdext/source/pdfimport/wrapper/wrapper.cxx
+++ b/sdext/source/pdfimport/wrapper/wrapper.cxx
@@ -69,6 +69,8 @@

#include "rtl/bootstrap.h"

#include <rtl/character.hxx>

using namespace com::sun::star;

namespace pdfi
@@ -469,8 +471,8 @@ sal_Int32 Parser::parseFontCheckForString(
    if (nCopyLen < nAttribLen)
        return 0;
    for (sal_Int32 i = 0; i < nAttribLen; ++i)
        if (tolower(pCopy[i]) != pAttrib[i]
            && toupper(pCopy[i]) != pAttrib[i])
        if (rtl::toAsciiLowerCase(pCopy[i]) != rtl::toAsciiLowerCase(pAttrib[i])
            && rtl::toAsciiUpperCase(pCopy[i]) != rtl::toAsciiLowerCase(pAttrib[i]))
            return 0;
    rResult.isItalic |= bItalic;
    rResult.isBold |= bBold;
diff --git a/soltools/mkdepend/collectdircontent.cxx b/soltools/mkdepend/collectdircontent.cxx
index 0041857..c001ee0 100644
--- a/soltools/mkdepend/collectdircontent.cxx
+++ b/soltools/mkdepend/collectdircontent.cxx
@@ -1,5 +1,6 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
#include "collectdircontent.hxx"
#include <rtl/character.hxx>

using namespace std;

@@ -29,7 +30,7 @@ void IncludesCollection::add_to_collection(const string& dirPath) {
    }
    do {
        string winFileName(FindFileData.cFileName);
        transform(winFileName.begin(), winFileName.end(), winFileName.begin(), ::tolower);
        transform(winFileName.begin(), winFileName.end(), winFileName.begin(), rtl::toAsciiLowerCase);
        dirContent.insert(winFileName);
    } while (FindNextFile(hFind, &FindFileData));
#else
@@ -51,7 +52,7 @@ void IncludesCollection::add_to_collection(const string& dirPath) {

bool IncludesCollection::exists(string filePath) {
#if defined(_WIN32)
    transform(filePath.begin(), filePath.end(), filePath.begin(), ::tolower);
    transform(filePath.begin(), filePath.end(), filePath.begin(), rtl::toAsciiLowerCase);
#endif // defined( WNT )
    PathFilePair dirFile = split_path(filePath);
    string dirPath = dirFile.first;
diff --git a/tools/source/ref/globname.cxx b/tools/source/ref/globname.cxx
index 807af17..8ba0b21 100644
--- a/tools/source/ref/globname.cxx
+++ b/tools/source/ref/globname.cxx
@@ -22,6 +22,7 @@
#include <string.h>

#include <rtl/strbuf.hxx>
#include <rtl/character.hxx>

#include <tools/stream.hxx>
#include <tools/globname.hxx>
@@ -181,7 +182,7 @@ bool SvGlobalName::MakeId( const OUString & rIdStr )
                if( isdigit( *pStr ) )
                    nFirst = nFirst * 16 + (*pStr - '0');
                else
                    nFirst = nFirst * 16 + (toupper( *pStr ) - 'A' + 10 );
                    nFirst = nFirst * 16 + (rtl::toAsciiUpperCase( *pStr ) - 'A' + 10 );
            else
                return false;
            pStr++;
@@ -195,7 +196,7 @@ bool SvGlobalName::MakeId( const OUString & rIdStr )
                if( isdigit( *pStr ) )
                    nSec = nSec * 16 + (*pStr - '0');
                else
                    nSec = nSec * 16 + (sal_uInt16)(toupper( *pStr ) - 'A' + 10 );
                    nSec = nSec * 16 + (sal_uInt16)(rtl::toAsciiUpperCase( *pStr ) - 'A' + 10 );
            else
                return false;
            pStr++;
@@ -209,7 +210,7 @@ bool SvGlobalName::MakeId( const OUString & rIdStr )
                if( isdigit( *pStr ) )
                    nThird = nThird * 16 + (*pStr - '0');
                else
                    nThird = nThird * 16 + (sal_uInt16)(toupper( *pStr ) - 'A' + 10 );
                    nThird = nThird * 16 + (sal_uInt16)(rtl::toAsciiUpperCase( *pStr ) - 'A' + 10 );
            else
                return false;
            pStr++;
@@ -224,7 +225,7 @@ bool SvGlobalName::MakeId( const OUString & rIdStr )
                if( isdigit( *pStr ) )
                    szRemain[i/2] = szRemain[i/2] * 16 + (*pStr - '0');
                else
                    szRemain[i/2] = szRemain[i/2] * 16 + (sal_Int8)(toupper( *pStr ) - 'A' + 10 );
                    szRemain[i/2] = szRemain[i/2] * 16 + (sal_Int8)(rtl::toAsciiUpperCase( *pStr ) - 'A' + 10 );
            else
                return false;
            pStr++;