diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2015-01-17 01:18:38 +0100 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2015-01-19 06:19:33 +0000 |
commit | 5f01eb5d7a3927d31b7dd268562a59e3dacdd8e8 (patch) | |
tree | 1d2ef3177ce2e986dba34b4dc04c5c5aedcbf782 /vcl/source/fontsubset | |
parent | 5901827bd44dc3600bf66c83882e6847439d59d6 (diff) |
fdo#39440 vcl: reduce scope of local variables
This addresses some cppcheck warnings.
Change-Id: Ibebfe89ad1874f5fa9e20fb76a534d9c2da01e3f
Reviewed-on: https://gerrit.libreoffice.org/13969
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'vcl/source/fontsubset')
-rw-r--r-- | vcl/source/fontsubset/sft.cxx | 15 | ||||
-rw-r--r-- | vcl/source/fontsubset/ttcr.cxx | 13 |
2 files changed, 12 insertions, 16 deletions
diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx index 1adaf794895a..737a7a716f9b 100644 --- a/vcl/source/fontsubset/sft.cxx +++ b/vcl/source/fontsubset/sft.cxx @@ -904,7 +904,7 @@ static int findname( const sal_uInt8 *name, sal_uInt16 n, sal_uInt16 platformID, { if (n == 0) return -1; - int l = 0, r = n-1, i; + int l = 0, r = n-1; sal_uInt32 t1, t2; sal_uInt32 m1, m2; @@ -912,7 +912,7 @@ static int findname( const sal_uInt8 *name, sal_uInt16 n, sal_uInt16 platformID, m2 = (languageID << 16) | nameID; do { - i = (l + r) >> 1; + const int i = (l + r) >> 1; t1 = GetUInt32(name + 6, i * 12 + 0, 1); t2 = GetUInt32(name + 6, i * 12 + 4, 1); @@ -1044,10 +1044,11 @@ static void GetNames(TrueTypeFont *t) bPSNameOK = false; if( !bPSNameOK ) { - bool bReplace = true; /* check if family is a suitable replacement */ if( t->ufamily && t->family ) { + bool bReplace = true; + for( i = 0; t->ufamily[ i ] != 0 && bReplace; i++ ) if( t->ufamily[ i ] < 33 || t->ufamily[ i ] > 127 ) bReplace = false; @@ -1167,7 +1168,7 @@ static sal_uInt32 getGlyph6(const sal_uInt8 *cmap, sal_uInt32, sal_uInt32 c) { } static sal_uInt16 GEbinsearch(sal_uInt16 *ar, sal_uInt16 length, sal_uInt16 toSearch) { - signed int low, mid, high, lastfound = 0xffff; + signed int low, high, lastfound = 0xffff; sal_uInt16 res; if(length == (sal_uInt16)0 || length == (sal_uInt16)0xFFFF) { return (sal_uInt16)0xFFFF; @@ -1175,7 +1176,7 @@ static sal_uInt16 GEbinsearch(sal_uInt16 *ar, sal_uInt16 length, sal_uInt16 toSe low = 0; high = length - 1; while(high >= low) { - mid = (high + low)/2; + int mid = (high + low)/2; res = Int16FromMOTA(*(ar+mid)); if(res >= toSearch) { lastfound = mid; @@ -1820,7 +1821,7 @@ int CreateT3FromTTGlyphs(TrueTypeFont *ttf, FILE *outf, const char *fname, { ControlPoint *pa; PSPathElement *path; - int i, j, r, n; + int i, j, n; const sal_uInt8* table = getTable(ttf, O_head); TTGlyphMetrics metrics; int UPEm = ttf->unitsPerEm; @@ -1909,7 +1910,7 @@ int CreateT3FromTTGlyphs(TrueTypeFont *ttf, FILE *outf, const char *fname, for (i = 0; i < nGlyphs; i++) { fprintf(outf, h33, i); - r = GetTTGlyphOutline(ttf, glyphArray[i] < ttf->nglyphs ? glyphArray[i] : 0, &pa, &metrics, 0); + int r = GetTTGlyphOutline(ttf, glyphArray[i] < ttf->nglyphs ? glyphArray[i] : 0, &pa, &metrics, 0); if (r > 0) { n = BSplineToPSPath(pa, r, &path); diff --git a/vcl/source/fontsubset/ttcr.cxx b/vcl/source/fontsubset/ttcr.cxx index 1f019cfb064b..e65c7cc3f234 100644 --- a/vcl/source/fontsubset/ttcr.cxx +++ b/vcl/source/fontsubset/ttcr.cxx @@ -482,16 +482,12 @@ static void TrueTypeTableDispose_glyf(TrueTypeTable *_this) static void TrueTypeTableDispose_cmap(TrueTypeTable *_this) { - table_cmap *t; - CmapSubTable *s; - sal_uInt32 i; - if (_this) { - t = (table_cmap *) _this->data; + table_cmap *t = (table_cmap *) _this->data; if (t) { - s = t->s; + CmapSubTable *s = t->s; if (s) { - for (i = 0; i < t->m; i++) { + for (sal_uInt32 i = 0; i < t->m; i++) { if (s[i].xc) free(s[i].xc); if (s[i].xg) free(s[i].xg); } @@ -1195,7 +1191,6 @@ sal_uInt32 glyfAdd(TrueTypeTable *table, GlyphData *glyphdata, TrueTypeFont *fnt list l; sal_uInt32 currentID; int ret, n, ncomponents; - GlyphData *gd; assert(table != 0); assert(table->tag == T_glyf); @@ -1235,7 +1230,7 @@ sal_uInt32 glyfAdd(TrueTypeTable *table, GlyphData *glyphdata, TrueTypeFont *fnt } while (listNext(l)); if (!found) { - gd = GetTTRawGlyphData(fnt, currentID); + GlyphData *gd = GetTTRawGlyphData(fnt, currentID); gd->newID = n++; listAppend(l, gd); } |