diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-04-01 12:52:05 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-04-01 12:52:05 -0700 |
commit | 103579f030bfead4a1f821734dd6dbaf823c5527 (patch) | |
tree | caec556059b3838deefa7a7999db4958f1399e7f /struct.c | |
parent | 4208f2d0dd928a2e627a2284337302be62b3967a (diff) |
Variable scope reductions as recommended by cppcheck
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'struct.c')
-rw-r--r-- | struct.c | 28 |
1 files changed, 14 insertions, 14 deletions
@@ -243,9 +243,8 @@ makeBitmap(StrikePtr strike, int code, IndexSubTablePtr makeIndexSubTables(StrikePtr strike, CmapPtr cmap) { - IndexSubTablePtr table, first, last; - BitmapPtr bitmap0, bitmap; - int index, n; + IndexSubTablePtr first, last; + int index; first = NULL; last = NULL; @@ -262,6 +261,10 @@ makeIndexSubTables(StrikePtr strike, CmapPtr cmap) index = 0; while(index < 0xFFFF) { int constantMetrics = 1; + int n; + IndexSubTablePtr table; + BitmapPtr bitmap0, bitmap; + bitmap0 = strikeBitmapIndex(strike, cmap, index); if(bitmap0 == NULL) { index++; @@ -318,13 +321,12 @@ int fontIndex(FontPtr font, int code) { StrikePtr strike; - BitmapPtr bitmap; if(code == 0) return 0; strike = font->strikes; while(strike) { - bitmap = STRIKE_BITMAP(strike, code); + BitmapPtr bitmap = STRIKE_BITMAP(strike, code); if(bitmap) return bitmap->index; strike = strike->next; @@ -338,11 +340,12 @@ makeCmap(FontPtr font) CmapPtr cmap_head = NULL; CmapPtr cmap_last = NULL; CmapPtr cmap; - int code, i, index, maxindex = 0; + int code, maxindex = 0; code = 0; while(code < FONT_CODES) { - index = fontIndex(font, code); + int i; + int index = fontIndex(font, code); if(index < 0) { code++; continue; @@ -374,7 +377,7 @@ makeCmap(FontPtr font) cmap_head->inverse = calloc(maxindex + 1, sizeof(int)); cmap = cmap_head; while(cmap) { - for(i = cmap->index; + for(int i = cmap->index; i <= cmap->endCode - cmap->startCode + cmap->index; i++) { cmap_head->inverse[i] = i - cmap->index + cmap->startCode; @@ -428,12 +431,10 @@ strikeBitmapIndex(StrikePtr strike, CmapPtr cmap, int index) int strikeMaxWidth(StrikePtr strike) { - BitmapPtr bitmap; - int i; int width_max = 0; - for(i = 0; i < FONT_CODES; i++) { - bitmap = STRIKE_BITMAP(strike, i); + for(int i = 0; i < FONT_CODES; i++) { + BitmapPtr bitmap = STRIKE_BITMAP(strike, i); if(!bitmap) continue; if(bitmap->advanceWidth > width_max) @@ -450,11 +451,10 @@ glyphMetrics(FontPtr font, int code, int *x_max_return, int *y_max_return) { StrikePtr strike; - BitmapPtr bitmap; strike = font->strikes; while(strike) { - bitmap = STRIKE_BITMAP(strike, code); + BitmapPtr bitmap = STRIKE_BITMAP(strike, code); if(bitmap) { if(width_return) *width_return = |