summaryrefslogtreecommitdiff
path: root/hwpfilter
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2014-12-16 22:18:32 +0100
committerNoel Grandin <noelgrandin@gmail.com>2014-12-17 07:32:56 +0000
commite31657a1eaad12de1ad89aec5b50f8116f67fa3e (patch)
tree435fe84175e5a597d671a86befdf23e91b1fc975 /hwpfilter
parent28d9983e2c561528c27c0dd40c2c0ea5b46a270f (diff)
fdo#39440 reduce scope of local variables
This addresses some cppcheck warnings. Change-Id: I9812658e8a96dd35d686c7ae7a8b829267c5c8bc Reviewed-on: https://gerrit.libreoffice.org/13499 Reviewed-by: Noel Grandin <noelgrandin@gmail.com> Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'hwpfilter')
-rw-r--r--hwpfilter/source/formula.cxx7
-rw-r--r--hwpfilter/source/hcode.cxx11
-rw-r--r--hwpfilter/source/hwpeq.cxx9
-rw-r--r--hwpfilter/source/hwpfile.cxx16
-rw-r--r--hwpfilter/source/hwpreader.cxx4
-rw-r--r--hwpfilter/source/solver.cxx6
6 files changed, 22 insertions, 31 deletions
diff --git a/hwpfilter/source/formula.cxx b/hwpfilter/source/formula.cxx
index 00114a9534dd..ba29996d3723 100644
--- a/hwpfilter/source/formula.cxx
+++ b/hwpfilter/source/formula.cxx
@@ -638,12 +638,11 @@ int Formula::parse()
if( res ){
makeMathML( res );
}
- Node *tmpNode;
int count = nodelist.size();
for( int i = 0 ; i < count ; i++ ){
- tmpNode = nodelist.front();
- nodelist.pop_front();
- delete tmpNode;
+ const Node *tmpNode = nodelist.front();
+ nodelist.pop_front();
+ delete tmpNode;
}
return 0;
diff --git a/hwpfilter/source/hcode.cxx b/hwpfilter/source/hcode.cxx
index 42b7205824b2..b674d5cbcd92 100644
--- a/hwpfilter/source/hcode.cxx
+++ b/hwpfilter/source/hcode.cxx
@@ -498,7 +498,6 @@ static hchar lineCharConv(hchar ch)
static int KsSearch(hchar c)
{
int lo, hi, mid;
- hchar c2;
lo = mid = 0;
hi = 2350 - 1;
@@ -506,7 +505,7 @@ static int KsSearch(hchar c)
while (lo <= hi)
{
mid = (lo + hi) >> 1;
- c2 = ksTbl[mid];
+ hchar c2 = ksTbl[mid];
if (c == c2)
break;
if (c < c2)
@@ -1187,11 +1186,11 @@ hchar_string hstr2ucsstr(hchar const* hstr)
::std::string hstr2ksstr(hchar const* hstr)
{
::std::string ret;
- int res, j;
+ int j;
hchar dest[3];
for( ; *hstr ; )
{
- res = hcharconv(*hstr++, dest, KS);
+ int res = hcharconv(*hstr++, dest, KS);
for( j = 0 ; j < res ; j++ ){
int c = dest[j];
if( c < 32 )
@@ -1397,7 +1396,7 @@ char* base64_encode_string( const uchar *buf, unsigned int len )
char * out;
int inPos = 0;
int outPos = 0;
- int c1, c2, c3;
+ int c1, c2;
unsigned int i;
out=(char *)malloc( (len*4/3)+8 );
@@ -1407,7 +1406,7 @@ char* base64_encode_string( const uchar *buf, unsigned int len )
{
c1 = buf[inPos++] & 0xFF;
c2 = buf[inPos++] & 0xFF;
- c3 = buf[inPos++] & 0xFF;
+ int c3 = buf[inPos++] & 0xFF;
out[outPos++] = basis_64[(c1 & 0xFC) >> 2];
out[outPos++] = basis_64[((c1 & 0x03) << 4) | ((c2 & 0xF0) >> 4)];
out[outPos++] = basis_64[((c2 & 0x0F) << 2) | ((c3 & 0xC0) >> 6)];
diff --git a/hwpfilter/source/hwpeq.cxx b/hwpfilter/source/hwpeq.cxx
index 2cc6ec276485..baf3cf518543 100644
--- a/hwpfilter/source/hwpeq.cxx
+++ b/hwpfilter/source/hwpeq.cxx
@@ -383,12 +383,12 @@ static const hwpeq eq_tbl[] = {
static const hwpeq *lookup_eqn(char *str)
{
static const int eqCount = SAL_N_ELEMENTS(eq_tbl);
- int m, k, l = 0, r = eqCount;
+ int l = 0, r = eqCount;
const hwpeq *result = 0;
while( l < r ) {
- m = (l + r) / 2;
- k = strcmp(eq_tbl[m].key, str);
+ const int m = (l + r) / 2;
+ const int k = strcmp(eq_tbl[m].key, str);
if( k == 0 ) {
result = eq_tbl + m;
break;
@@ -613,9 +613,8 @@ static int eq_word(MzString& outs, istream *strm, int status)
if( 0 != (eq = lookup_eqn(keyword)) ) {
int nargs = eq->nargs;
- int ch;
while( nargs-- ) {
- ch = read_white_space(state, strm);
+ const int ch = read_white_space(state, strm);
if( ch != '{' ) state << '{';
eq_word(state, strm, script_status);
if( ch != '{' ) state << '}';
diff --git a/hwpfilter/source/hwpfile.cxx b/hwpfilter/source/hwpfile.cxx
index c4a0bfc63430..e248a3f46f99 100644
--- a/hwpfilter/source/hwpfile.cxx
+++ b/hwpfilter/source/hwpfile.cxx
@@ -270,13 +270,10 @@ bool HWPFile::ReadParaList(std::list < HWPPara* > &aplist, unsigned char flag)
bool HWPFile::TagsRead(void)
{
- ulong tag;
- long size;
-
while (true)
{
- tag = Read4b();
- size = Read4b();
+ ulong tag = Read4b();
+ long size = Read4b();
if (size <= 0 && tag > 0){
continue;
}
@@ -374,11 +371,10 @@ ColumnDef *HWPFile::GetColumnDef(int num)
int HWPFile::GetPageMasterNum(int page)
{
std::list<ColumnInfo*>::iterator it = columnlist.begin();
- ColumnInfo *now = 0;
int i;
for( i = 1 ; it != columnlist.end() ; ++it, i++){
- now = *it;
+ ColumnInfo *now = *it;
if( page < now->start_page )
return i-1;
}
@@ -619,10 +615,9 @@ int HWPFile::compareCharShape(CharShape *shape)
int count = cslist.size();
if( count > 0 )
{
- CharShape *cshape=0;
for(int i = 0; i< count; i++)
{
- cshape = getCharShape(i);
+ CharShape *cshape = getCharShape(i);
if( shape->size == cshape->size &&
shape->font[0] == cshape->font[0] &&
@@ -646,10 +641,9 @@ int HWPFile::compareParaShape(ParaShape *shape)
int count = pslist.size();
if( count > 0 )
{
- ParaShape *pshape=0;
for(int i = 0; i< count; i++)
{
- pshape = getParaShape(i);
+ ParaShape *pshape = getParaShape(i);
if( shape->left_margin == pshape->left_margin &&
shape->right_margin == pshape->right_margin &&
shape->pspacing_prev == pshape->pspacing_prev &&
diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index fbb09ca1902f..28733fa61477 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -3962,14 +3962,14 @@ void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox)
{
int x = hbox->pgx;
int y = hbox->pgy;
- int a, b;
bool bIsRotate = false;
while (drawobj)
{
padd("draw:style-name", sXML_CDATA,
ascii(Int2Str(drawobj->index, "Draw%d", buf)));
- a = 0; b = 0;
+ int a = 0;
+ int b = 0;
switch (hbox->style.anchor_type)
{
diff --git a/hwpfilter/source/solver.cxx b/hwpfilter/source/solver.cxx
index 334f61c2227f..5ee767c168d5 100644
--- a/hwpfilter/source/solver.cxx
+++ b/hwpfilter/source/solver.cxx
@@ -81,14 +81,14 @@ int mgcLinearSystemD::Solve (int n, double** a, double* b)
int i, j, k;
int irow = 0;
int icol = 0;
- double big, pivinv, save;
+ double save;
for (j = 0; j < n; j++)
ipiv[j] = 0;
for (i = 0; i < n; i++)
{
- big = 0;
+ double big = 0;
for (j = 0; j < n; j++)
{
if ( ipiv[j] != 1 )
@@ -137,7 +137,7 @@ int mgcLinearSystemD::Solve (int n, double** a, double* b)
return 0;
}
- pivinv = 1/a[icol][icol];
+ double pivinv = 1/a[icol][icol];
a[icol][icol] = 1;
for (k = 0; k < n; k++)
a[icol][k] *= pivinv;