diff options
Diffstat (limited to 'converter/pbm')
-rw-r--r-- | converter/pbm/g3topbm.c | 1 | ||||
-rw-r--r-- | converter/pbm/pbmtoascii.c | 49 | ||||
-rw-r--r-- | converter/pbm/pbmtoepson.c | 1 | ||||
-rw-r--r-- | converter/pbm/pbmtonokia.c | 1 | ||||
-rw-r--r-- | converter/pbm/pbmtopk.c | 1 | ||||
-rw-r--r-- | converter/pbm/pbmtoppa/pbmtoppa.c | 1 | ||||
-rw-r--r-- | converter/pbm/pbmtoxbm.c | 1 |
7 files changed, 34 insertions, 21 deletions
diff --git a/converter/pbm/g3topbm.c b/converter/pbm/g3topbm.c index b0d08f9e..83479b91 100644 --- a/converter/pbm/g3topbm.c +++ b/converter/pbm/g3topbm.c @@ -18,6 +18,7 @@ contributing their work to the public domain. ===========================================================================*/ +#define _DEFAULT_SOURCE /* New name for SVID & BSD source defines */ #define _BSD_SOURCE /* Make nstring.h define strcaseeq() */ #include "pm_c_util.h" diff --git a/converter/pbm/pbmtoascii.c b/converter/pbm/pbmtoascii.c index fd590aa6..0305a47b 100644 --- a/converter/pbm/pbmtoascii.c +++ b/converter/pbm/pbmtoascii.c @@ -83,15 +83,15 @@ BSQ,D04, D04,D05, D04,'L', D05,'[', '<','Z', '/','Z', 'c','k',D06,'R',/*D0-DF*/ static void -makeRowOfSigs(FILE * const ifP, - unsigned int const cols, - unsigned int const rows, - int const format, - unsigned int const cellWidth, - unsigned int const cellHeight, - unsigned int const row, - unsigned int * const sig, - unsigned int const ccols) { +makeRowOfSignatures(FILE * const ifP, + unsigned int const cols, + unsigned int const rows, + int const format, + unsigned int const cellWidth, + unsigned int const cellHeight, + unsigned int const row, + unsigned int * const sig, + unsigned int const ccols) { /*---------------------------------------------------------------------------- Compute the signatures for every cell in a row. @@ -183,23 +183,30 @@ pbmtoascii(FILE * const ifP, unsigned int const cellHeight, const char * const carr) { - int cols, rows, format; + int format; + int cols, rows; + /* Dimensions of the input in pixels */ unsigned int ccols; + /* Width of the output in characters */ char * line; /* malloc'ed array */ unsigned int row; - unsigned int * sig; /* malloc'ed array */ - /* This describes in a single integer the pixels of a cell, - as described above. + unsigned int * signatureRow; /* malloc'ed array */ + /* This is the cell signatures of a row of cells. + signatureRow[0] is the signature for the first (leftmost) cell + in the row, signatureRow[1] is the signature for the next one, + etc. A signature is an encoding of the pixels of a cell as + an integer, as described above. */ - assert(cellWidth * cellHeight <= sizeof(sig[0]*8)); + assert(cellWidth * cellHeight <= sizeof(signatureRow[0])*8); pbm_readpbminit(ifP, &cols, &rows, &format); ccols = (cols + cellWidth - 1) / cellWidth; - MALLOCARRAY(sig, ccols); - if (sig == NULL) + MALLOCARRAY(signatureRow, ccols); + if (signatureRow == NULL) pm_error("No memory for %u columns", ccols); + MALLOCARRAY_NOFAIL(line, ccols+1); if (line == NULL) pm_error("No memory for %u columns", ccols); @@ -207,16 +214,16 @@ pbmtoascii(FILE * const ifP, for (row = 0; row < rows; row += cellHeight) { unsigned int endCol; - makeRowOfSigs(ifP, cols, rows, format, cellWidth, cellHeight, - row, sig, ccols); + makeRowOfSignatures(ifP, cols, rows, format, cellWidth, cellHeight, + row, signatureRow, ccols); - findRightMargin(sig, ccols, carr, &endCol); + findRightMargin(signatureRow, ccols, carr, &endCol); - assembleCellRow(sig, endCol, carr, line); + assembleCellRow(signatureRow, endCol, carr, line); puts(line); } - free(sig); + free(signatureRow); free(line); } diff --git a/converter/pbm/pbmtoepson.c b/converter/pbm/pbmtoepson.c index bb36791d..122a438f 100644 --- a/converter/pbm/pbmtoepson.c +++ b/converter/pbm/pbmtoepson.c @@ -11,6 +11,7 @@ ** implied warranty. */ +#define _DEFAULT_SOURCE /* New name for SVID & BSD source defines */ #define _BSD_SOURCE /* Make sure strcaseeq() is in nstring.h */ #include <stdio.h> diff --git a/converter/pbm/pbmtonokia.c b/converter/pbm/pbmtonokia.c index e803e413..73b62b96 100644 --- a/converter/pbm/pbmtonokia.c +++ b/converter/pbm/pbmtonokia.c @@ -4,6 +4,7 @@ Copyright information is at end of file. */ +#define _DEFAULT_SOURCE /* New name for SVID & BSD source defines */ #define _XOPEN_SOURCE 500 /* Make sure strdup() is in string.h */ #define _BSD_SOURCE /* Make sure strcaseeq() is in nstring.h */ #include <string.h> diff --git a/converter/pbm/pbmtopk.c b/converter/pbm/pbmtopk.c index 3948ae0d..2f05d449 100644 --- a/converter/pbm/pbmtopk.c +++ b/converter/pbm/pbmtopk.c @@ -9,6 +9,7 @@ https://www.tug.org/TUGboat/tb06-1/tb11gf.pdf */ +#define _DEFAULT_SOURCE 1 /* New name for SVID & BSD source defines */ #define _BSD_SOURCE 1 /* Make sure strdup() is in string.h */ #define _XOPEN_SOURCE 500 /* Make sure strdup() is in string.h */ diff --git a/converter/pbm/pbmtoppa/pbmtoppa.c b/converter/pbm/pbmtoppa/pbmtoppa.c index f43c08a8..ff4a599e 100644 --- a/converter/pbm/pbmtoppa/pbmtoppa.c +++ b/converter/pbm/pbmtoppa/pbmtoppa.c @@ -4,6 +4,7 @@ * 2-24-98 */ +#define _DEFAULT_SOURCE /* New name for SVID & BSD source defines */ #define _BSD_SOURCE /* This makes sure strcasecmp() is in string.h */ #include <stdio.h> diff --git a/converter/pbm/pbmtoxbm.c b/converter/pbm/pbmtoxbm.c index 14c6b85e..ecb72b30 100644 --- a/converter/pbm/pbmtoxbm.c +++ b/converter/pbm/pbmtoxbm.c @@ -20,6 +20,7 @@ */ +#define _DEFAULT_SOURCE 1 /* New name for SVID & BSD source defines */ #define _BSD_SOURCE 1 /* Make sure strdup() is in string.h */ #define _XOPEN_SOURCE 500 /* Make sure strdup() is in string.h */ |