diff options
Diffstat (limited to 'lib/libpbm2.c')
-rw-r--r-- | lib/libpbm2.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/lib/libpbm2.c b/lib/libpbm2.c index 8fde27fd..a611bec5 100644 --- a/lib/libpbm2.c +++ b/lib/libpbm2.c @@ -18,7 +18,7 @@ #include "fileio.h" #include "pam.h" -static bit +static bit getbit (FILE * const file) { char ch; @@ -28,7 +28,7 @@ getbit (FILE * const file) { if ( ch != '0' && ch != '1' ) pm_error( "junk in file where bits should be" ); - + return ( ch == '1' ) ? 1 : 0; } @@ -72,9 +72,9 @@ validateComputableSize(unsigned int const cols, A common operation is adding 1 or 2 to the highest row or column number in the image, so we make sure that's possible. -----------------------------------------------------------------------------*/ - if (cols > INT_MAX - 2) + if (cols > INT_MAX - 10) pm_error("image width (%u) too large to be processed", cols); - if (rows > INT_MAX - 2) + if (rows > INT_MAX - 10) pm_error("image height (%u) too large to be processed", rows); } @@ -157,9 +157,9 @@ pbm_readpbmrow( FILE * const file, void -pbm_readpbmrow_packed(FILE * const fileP, +pbm_readpbmrow_packed(FILE * const fileP, unsigned char * const packedBits, - int const cols, + int const cols, int const format) { switch(format) { @@ -182,20 +182,20 @@ pbm_readpbmrow_packed(FILE * const fileP, case RPBM_FORMAT: { unsigned int bytesReadCt; bytesReadCt = fread(packedBits, 1, pbm_packed_bytes(cols), fileP); - + if (bytesReadCt < pbm_packed_bytes(cols)) { - if (feof(fileP)) - if (bytesReadCt == 0) + if (feof(fileP)) + if (bytesReadCt == 0) pm_error("Attempt to read a raw PBM image row, but " "no more rows left in file."); else pm_error("EOF in the middle of a raw PBM row."); - else + else pm_error("I/O error reading raw PBM row"); } } break; - + default: pm_error("Internal error in pbm_readpbmrow_packed."); } @@ -205,7 +205,7 @@ pbm_readpbmrow_packed(FILE * const fileP, void pbm_readpbmrow_bitoffset(FILE * const ifP, - unsigned char * const packedBits, + unsigned char * const packedBits, int const cols, int const format, unsigned int const offset) { @@ -242,7 +242,7 @@ pbm_readpbmrow_bitoffset(FILE * const ifP, /* Target slot doesn't start on byte boundary; right-shift. */ unsigned char carryover; unsigned int i; - + carryover = (origHead >> lsh) << lsh; for (i = 0; i <= last; ++i) { @@ -251,7 +251,7 @@ pbm_readpbmrow_bitoffset(FILE * const ifP, carryover = t; } } - + if ((cols + rsh) % 8 > 0) { /* Adjust rightmost char */ unsigned int const trs = (cols + rsh) % 8; |