Kaydet (Commit) 652e09f7 authored tarafından Michael Weghorn's avatar Michael Weghorn Kaydeden (comit) Noel Grandin

fdo#39440 reduce scope of local variables

This addresses some cppcheck warnings.

Change-Id: I7e85aca5a86f993a9906525edffbd44a179dc245
Reviewed-on: https://gerrit.libreoffice.org/13510Reviewed-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
Tested-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
üst d95df6d1
......@@ -395,7 +395,6 @@ void lcl_formatPersianWord( sal_Int32 nNumber, OUString& rsResult )
throw( IllegalArgumentException, RuntimeException )
{
OUStringBuffer aTemp(64);
unsigned int nDigit;
static const sal_Unicode asPersianWord_conjunction_data[] = {0x20,0x0648,0x20,0};
OUString asPersianWord_conjunction( asPersianWord_conjunction_data );
unsigned char nSection = 0;
......@@ -409,6 +408,7 @@ void lcl_formatPersianWord( sal_Int32 nNumber, OUString& rsResult )
aTemp.insert( 0, asPersianWord_conjunction).insert( 0, table_PersianWord_decadeX[nSection-1]);
}
unsigned int nDigit;
if ((nDigit = nPart % 100) < 20)
{
if (!aTemp.isEmpty())
......
......@@ -167,7 +167,7 @@ int WLevDistance::WLD( const sal_Unicode* cString, sal_Int32 nStringLen )
&& nSPMin <= (bSplitCount ? 2 * nLimit : nLimit) )
{
sal_Unicode c;
int nP, nQ, nR, nPij, d1, d2;
int nP, nQ, nR, nPij, d2;
j++;
c = cpPattern[j];
......@@ -193,7 +193,7 @@ int WLevDistance::WLD( const sal_Unicode* cString, sal_Int32 nStringLen )
// for each pattern column run though the string
for ( sal_Int32 i=1; i <= nStringLen; i++ )
{
d1 = d2; // WLD( X(i-1), Y(j-1) )
int d1 = d2; // WLD( X(i-1), Y(j-1) )
d2 = npDistance[i]; // WLD( X(i) , Y(j-1) )
if ( cString[i-1] == c )
{
......
......@@ -92,7 +92,6 @@ TextToPronounce_zh::equals( const OUString & str1, sal_Int32 pos1, sal_Int32 nCo
sal_Int32 realCount;
int i; // loop variable
const sal_Unicode * s1, * s2;
const sal_Unicode *pron1, *pron2;
if (nCount1 + pos1 > str1.getLength())
nCount1 = str1.getLength() - pos1;
......@@ -105,8 +104,8 @@ TextToPronounce_zh::equals( const OUString & str1, sal_Int32 pos1, sal_Int32 nCo
s1 = str1.getStr() + pos1;
s2 = str2.getStr() + pos2;
for (i = 0; i < realCount; i++) {
pron1=getPronounce(*s1++);
pron2=getPronounce(*s2++);
const sal_Unicode *pron1 = getPronounce(*s1++);
const sal_Unicode *pron2 = getPronounce(*s2++);
if (pron1 != pron2) {
nMatch1 = nMatch2 = i;
return sal_False;
......
......@@ -38,10 +38,9 @@ sal_Unicode oneToOneMapping::find(const sal_Unicode nKey) const
// binary search
int bottom = 0;
int top = mnSize - 1;
int current;
for (;;) {
current = (top + bottom) / 2;
const int current = (top + bottom) / 2;
if( nKey < mpTable[current].first )
top = current - 1;
else if( nKey > mpTable[current].first )
......@@ -78,15 +77,15 @@ void oneToOneMappingWithFlag::makeIndex()
{
if( !mbHasIndex && mpTableWF )
{
int i, j, high, low, current = -1;
int i, j, current = -1;
for( i = 0; i < 256; i++ )
mpIndex[i] = NULL;
for( size_t k = 0; k < mnSize; k++ )
{
high = (mpTableWF[k].first >> 8) & 0xFF;
low = (mpTableWF[k].first) & 0xFF;
const int high = (mpTableWF[k].first >> 8) & 0xFF;
const int low = (mpTableWF[k].first) & 0xFF;
if( high != current )
{
current = high;
......@@ -124,10 +123,9 @@ sal_Unicode oneToOneMappingWithFlag::find( const sal_Unicode nKey ) const
// binary search
int bottom = 0;
int top = mnSize - 1;
int current;
for (;;) {
current = (top + bottom) / 2;
const int current = (top + bottom) / 2;
if( nKey < mpTableWF[current].first )
top = current - 1;
else if( nKey > mpTableWF[current].first )
......
......@@ -222,12 +222,12 @@ oneToOneMapping& widthfolding::getfull2halfTableForASC()
//
// See the following page for detail:
// http://wiki.openoffice.org/wiki/Calc/Features/JIS_and_ASC_functions
int i, j, high, low;
int i, j;
int n = sizeof(full2halfASCException) / sizeof(UnicodePairWithFlag);
for( i = 0; i < n; i++ )
{
high = (full2halfASCException[i].first >> 8) & 0xFF;
low = (full2halfASCException[i].first) & 0xFF;
const int high = (full2halfASCException[i].first >> 8) & 0xFF;
const int low = (full2halfASCException[i].first) & 0xFF;
if( !table.mpIndex[high] )
{
......@@ -256,12 +256,12 @@ oneToOneMapping& widthfolding::gethalf2fullTableForJIS()
//
// See the following page for detail:
// http://wiki.openoffice.org/wiki/Calc/Features/JIS_and_ASC_functions
int i, j, high, low;
int i, j;
int n = sizeof(half2fullJISException) / sizeof(UnicodePairWithFlag);
for( i = 0; i < n; i++ )
{
high = (half2fullJISException[i].first >> 8) & 0xFF;
low = (half2fullJISException[i].first) & 0xFF;
const int high = (half2fullJISException[i].first >> 8) & 0xFF;
const int low = (half2fullJISException[i].first) & 0xFF;
if( !table.mpIndex[high] )
{
......
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