summaryrefslogtreecommitdiff
path: root/i18nutil
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2014-12-17 17:54:18 +0100
committerNoel Grandin <noelgrandin@gmail.com>2014-12-18 06:05:49 +0000
commit652e09f734fefb9b49787e8e565d235d504a1e73 (patch)
tree3c1d9cdc537273d1129f43400396231b903ebf15 /i18nutil
parentd95df6d12c8191f2c97719b59420c49651b5d8ac (diff)
fdo#39440 reduce scope of local variables
This addresses some cppcheck warnings. Change-Id: I7e85aca5a86f993a9906525edffbd44a179dc245 Reviewed-on: https://gerrit.libreoffice.org/13510 Reviewed-by: Noel Grandin <noelgrandin@gmail.com> Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'i18nutil')
-rw-r--r--i18nutil/source/utility/oneToOneMapping.cxx12
-rw-r--r--i18nutil/source/utility/widthfolding.cxx12
2 files changed, 11 insertions, 13 deletions
diff --git a/i18nutil/source/utility/oneToOneMapping.cxx b/i18nutil/source/utility/oneToOneMapping.cxx
index 39c74ded40bf..2ced0f898f41 100644
--- a/i18nutil/source/utility/oneToOneMapping.cxx
+++ b/i18nutil/source/utility/oneToOneMapping.cxx
@@ -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 )
diff --git a/i18nutil/source/utility/widthfolding.cxx b/i18nutil/source/utility/widthfolding.cxx
index 2d3fcb1a93c9..a47152333eda 100644
--- a/i18nutil/source/utility/widthfolding.cxx
+++ b/i18nutil/source/utility/widthfolding.cxx
@@ -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] )
{