diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2023-06-28 17:29:32 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2023-06-28 17:29:32 +0000 |
commit | 23ce26f64c34e30951ad9ade2151552ed77e7357 (patch) | |
tree | d73b31a0c2f7c7be4a69f8a8e84e00dd39c432b5 /converter/pbm/xbmtopbm.c | |
parent | 1b6e51a266008348ad93ed8b6ac9ec91b5024fea (diff) | |
download | netpbm-mirror-23ce26f64c34e30951ad9ade2151552ed77e7357.tar.gz netpbm-mirror-23ce26f64c34e30951ad9ade2151552ed77e7357.tar.xz netpbm-mirror-23ce26f64c34e30951ad9ade2151552ed77e7357.zip |
promote Advanced to Stable
git-svn-id: http://svn.code.sf.net/p/netpbm/code/stable@4558 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter/pbm/xbmtopbm.c')
-rw-r--r-- | converter/pbm/xbmtopbm.c | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/converter/pbm/xbmtopbm.c b/converter/pbm/xbmtopbm.c index bbf4e395..1f5384ed 100644 --- a/converter/pbm/xbmtopbm.c +++ b/converter/pbm/xbmtopbm.c @@ -109,25 +109,35 @@ parseDeclaration(const char * const line, -----------------------------------------------------------------------------*/ char nameAndType[MAX_LINE]; int rc; - + rc = sscanf(line, "static short %s = {", nameAndType); if (rc == 1) { *version10P = TRUE; *isDeclarationP = TRUE; } else { int rc; - rc = sscanf(line, "static char %s = {", nameAndType); + rc = sscanf(line, "static unsigned short %s = {", nameAndType); if (rc == 1) { - *version10P = FALSE; + /* This is apparently not legal X10 XBM; we recognize it as an + extension. Many non-Netpbm programs won't. + */ + *version10P = TRUE; *isDeclarationP = TRUE; } else { int rc; - rc = sscanf(line, "static unsigned char %s = {", nameAndType); + rc = sscanf(line, "static char %s = {", nameAndType); if (rc == 1) { *version10P = FALSE; *isDeclarationP = TRUE; - } else - *isDeclarationP = FALSE; + } else { + int rc; + rc = sscanf(line, "static unsigned char %s = {", nameAndType); + if (rc == 1) { + *version10P = FALSE; + *isDeclarationP = TRUE; + } else + *isDeclarationP = FALSE; + } } } } @@ -178,7 +188,7 @@ getXbmHeader(FILE * const ifP, } } - if (!foundDeclaration) + if (!foundDeclaration) pm_error("Unable to find a line in the file containing the start " "of C array declaration (\"static char\" or whatever)"); @@ -208,7 +218,7 @@ getHexByte(FILE * const ifP, assert(c1 >= 0); assert(c1 < 256); assert(c2 >= 0); assert(c2 < 256); - + value = (hexTable[c1] << 4) + hexTable[c2]; if (value >= 256) pm_error("Invalid XBM input. What should be a two digit " @@ -218,7 +228,7 @@ getHexByte(FILE * const ifP, } - + static void readX10Raster(FILE * const ifP, unsigned int const rasterLength, @@ -301,7 +311,7 @@ readBitmapFile(FILE * const ifP, mustPad = (width % 16 >= 1 && width % 16 <= 8 && version10); bytesPerLine = (width + 7) / 8 + (mustPad ? 1 : 0); - + rasterLength = bytesPerLine * height; MALLOCARRAY(data, rasterLength); @@ -331,7 +341,7 @@ main(int argc, const char * inputFileName; unsigned char * p; /* Cursor in raster data data[] */ - + initHexTable(); pbm_init(&argc, argv); @@ -339,7 +349,7 @@ main(int argc, if (argc-1 > 1) pm_error("The only possible argument is the input file name. " "You specified %u arguments", argc-1); - + if (argc-1 > 0) inputFileName = argv[1]; else @@ -359,7 +369,7 @@ main(int argc, for (row = 0; row < rows; ++row) { unsigned int const bytesPerRow = pbm_packed_bytes(cols); unsigned int i; - + for (i = 0; i < bytesPerRow; ++i) bitrow[i] = bitreverse[*p++]; |