diff options
Diffstat (limited to 'generator/pbmtext.c')
-rw-r--r-- | generator/pbmtext.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/generator/pbmtext.c b/generator/pbmtext.c index 2f4d18c7..e83f1b0c 100644 --- a/generator/pbmtext.c +++ b/generator/pbmtext.c @@ -304,10 +304,8 @@ get_line_dimensions(const char line[], const struct font * const font_p, int full_pixels; /* integer part of accumulated_ics */ accumulated_ics += intercharacter_space; full_pixels = (int) accumulated_ics; - if (full_pixels > 0) { - *bwid_p += full_pixels; - accumulated_ics -= full_pixels; - } + *bwid_p += full_pixels; + accumulated_ics -= full_pixels; } lastGlyphP = glyphP; *bwid_p += glyphP->xadd; @@ -506,13 +504,11 @@ placeCharacterInOutput(char const lastch, cursorP->widthSoFar += fontP->glyph[glyphIndex]->x; } else { /* handle extra intercharacter space (-space option) */ - unsigned int fullPixels; /* integer part of accumulatedIcs */ + int fullPixels; /* integer part of accumulatedIcs */ cursorP->accumulatedIcs += cursorP->intercharacterSpace; fullPixels = (int) cursorP->accumulatedIcs; - if (fullPixels > 0) { - cursorP->widthSoFar += fullPixels; - cursorP->accumulatedIcs -= fullPixels; - } + cursorP->widthSoFar += fullPixels; + cursorP->accumulatedIcs -= fullPixels; } cursorP->widthSoFar += fontP->glyph[glyphIndex]->xadd; } @@ -615,10 +611,8 @@ truncateText(struct text const inputText, int fullPixels; /* integer part of accumulatedIcs */ accumulatedIcs += intercharacterSpace; fullPixels = (int) intercharacterSpace; - if (fullPixels > 0) { - widthSoFar += fullPixels; - accumulatedIcs -= fullPixels; - } + widthSoFar += fullPixels; + accumulatedIcs -= fullPixels; } widthSoFar += fontP->glyph[lastch]->xadd; } @@ -663,6 +657,9 @@ getText(const char cmdline_text[], lineCount = 0; /* initial value */ while (fgets(buf, sizeof(buf), stdin) != NULL) { + if (strlen(buf) + 1 >= sizeof(buf)) + pm_error("A line of input text is longer than %u characters." + "Cannot process.", sizeof(buf)-1); fixControlChars(buf, fontP); if (lineCount >= maxlines) { maxlines *= 2; |