summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Friesenhahn <bfriesen@simple.dallas.tx.us>2020-12-28 14:07:41 +0000
committerBob Friesenhahn <bfriesen@simple.dallas.tx.us>2020-12-28 14:07:41 +0000
commit0763ef4d4e49a1b45c590bdf2e62f564f3b8c88f (patch)
tree5236f77d5034027173cb5ab30780550a65088abd
parentec8bddedf094a29ef84de80d477fb231850ee8a6 (diff)
parentf2435ace6ce29e025cb728dc2c62613bdd26f71f (diff)
downloadlibtiff-git-0763ef4d4e49a1b45c590bdf2e62f564f3b8c88f.tar.gz
Merge branch 'tools-reduce-initialized-data' into 'master'
Reduce initialized data by making more data const and simplifying usage() implementation. See merge request libtiff/libtiff!180
-rw-r--r--tools/fax2ps.c30
-rw-r--r--tools/fax2tiff.c74
-rw-r--r--tools/pal2rgb.c48
-rw-r--r--tools/ppm2tiff.c51
-rw-r--r--tools/raw2tiff.c123
-rw-r--r--tools/thumbnail.c4
-rw-r--r--tools/tiff2bw.c53
-rw-r--r--tools/tiff2pdf.c64
-rw-r--r--tools/tiff2ps.c83
-rw-r--r--tools/tiff2rgba.c51
-rw-r--r--tools/tiffcmp.c19
-rw-r--r--tools/tiffcp.c143
-rw-r--r--tools/tiffcrop.c293
-rw-r--r--tools/tiffdither.c53
-rw-r--r--tools/tiffdump.c74
-rw-r--r--tools/tiffinfo.c39
-rw-r--r--tools/tiffmedian.c69
-rw-r--r--tools/tiffset.c25
18 files changed, 627 insertions, 669 deletions
diff --git a/tools/fax2ps.c b/tools/fax2ps.c
index f59f4921..613b1016 100644
--- a/tools/fax2ps.c
+++ b/tools/fax2ps.c
@@ -375,6 +375,7 @@ main(int argc, char** argv)
break;
case 'h':
usage(EXIT_SUCCESS);
+ break;
case '?':
usage(EXIT_FAILURE);
}
@@ -433,29 +434,26 @@ main(int argc, char** argv)
return (EXIT_SUCCESS);
}
-const char* stuff[] = {
-"usage: fax2ps [options] [input.tif ...]",
-"where options are:",
-" -w suppress warning messages",
-" -l chars set maximum output line length for generated PostScript",
-" -p page# select page to print (can use multiple times)",
-" -x xres set default horizontal resolution of input data (dpi)",
-" -y yres set default vertical resolution of input data (lpi)",
-" -S scale output to page size",
-" -W width set output page width (inches), default is 8.5",
-" -H height set output page height (inches), default is 11",
-NULL
-};
+static const char usage_info[] =
+"usage: fax2ps [options] [input.tif ...]\n"
+"where options are:\n"
+" -w suppress warning messages\n"
+" -l chars set maximum output line length for generated PostScript\n"
+" -p page# select page to print (can use multiple times)\n"
+" -x xres set default horizontal resolution of input data (dpi)\n"
+" -y yres set default vertical resolution of input data (lpi)\n"
+" -S scale output to page size\n"
+" -W width set output page width (inches), default is 8.5\n"
+" -H height set output page height (inches), default is 11\n"
+;
static void
usage(int code)
{
- int i;
FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr;
fprintf(out, "%s\n\n", TIFFGetVersion());
- for (i = 0; stuff[i] != NULL; i++)
- fprintf(out, "%s\n", stuff[i]);
+ fprintf(out, "%s", usage_info);
exit(code);
}
diff --git a/tools/fax2tiff.c b/tools/fax2tiff.c
index 6b93f9ef..005bc02a 100644
--- a/tools/fax2tiff.c
+++ b/tools/fax2tiff.c
@@ -222,6 +222,7 @@ main(int argc, char* argv[])
break;
case 'h':
usage(EXIT_SUCCESS);
+ break;
case '?':
usage(EXIT_FAILURE);
/*NOTREACHED*/
@@ -432,55 +433,52 @@ copyFaxFile(TIFF* tifin, TIFF* tifout)
return (row);
}
-const char* usage_info[] = {
-"usage: fax2tiff [options] input.raw...",
-"where options are:",
-" -3 input data is G3-encoded [default]",
-" -4 input data is G4-encoded",
-" -U input data is uncompressed (G3 or G4)",
-" -1 input data is 1D-encoded (G3 only) [default]",
-" -2 input data is 2D-encoded (G3 only)",
-" -P input is not EOL-aligned (G3 only) [default]",
-" -A input is EOL-aligned (G3 only)",
-" -M input data has MSB2LSB bit order",
-" -L input data has LSB2MSB bit order [default]",
-" -B input data has min 0 means black",
-" -W input data has min 0 means white [default]",
-" -R # input data has # resolution (lines/inch) [default is 196]",
-" -X # input data has # width [default is 1728]",
-"",
-" -o out.tif write output to out.tif",
+static const char usage_info[] =
+"usage: fax2tiff [options] input.raw...\n"
+"where options are:\n"
+" -3 input data is G3-encoded [default]\n"
+" -4 input data is G4-encoded\n"
+" -U input data is uncompressed (G3 or G4)\n"
+" -1 input data is 1D-encoded (G3 only) [default]\n"
+" -2 input data is 2D-encoded (G3 only)\n"
+" -P input is not EOL-aligned (G3 only) [default]\n"
+" -A input is EOL-aligned (G3 only)\n"
+" -M input data has MSB2LSB bit order\n"
+" -L input data has LSB2MSB bit order [default]\n"
+" -B input data has min 0 means black\n"
+" -W input data has min 0 means white [default]\n"
+" -R # input data has # resolution (lines/inch) [default is 196]\n"
+" -X # input data has # width [default is 1728]\n"
+"\n"
+" -o out.tif write output to out.tif\n"
#ifdef CCITT_SUPPORT
-" -7 generate G3-encoded output [default]",
-" -8 generate G4-encoded output",
-" -u generate uncompressed output (G3 or G4)",
-" -5 generate 1D-encoded output (G3 only)",
-" -6 generate 2D-encoded output (G3 only) [default]",
-" -p generate not EOL-aligned output (G3 only)",
-" -a generate EOL-aligned output (G3 only) [default]",
+" -7 generate G3-encoded output [default]\n"
+" -8 generate G4-encoded output\n"
+" -u generate uncompressed output (G3 or G4)\n"
+" -5 generate 1D-encoded output (G3 only)\n"
+" -6 generate 2D-encoded output (G3 only) [default]\n"
+" -p generate not EOL-aligned output (G3 only)\n"
+" -a generate EOL-aligned output (G3 only) [default]\n"
#endif
-" -c generate \"classic\" TIFF format",
-" -f generate TIFF Class F (TIFF/F) format [default]",
-" -m output fill order is MSB2LSB",
-" -l output fill order is LSB2MSB [default]",
-" -r # make each strip have no more than # rows",
-" -s stretch image by duplicating scanlines",
-" -v print information about conversion work",
+" -c generate \"classic\" TIFF format\n"
+" -f generate TIFF Class F (TIFF/F) format [default]\n"
+" -m output fill order is MSB2LSB\n"
+" -l output fill order is LSB2MSB [default]\n"
+" -r # make each strip have no more than # rows\n"
+" -s stretch image by duplicating scanlines\n"
+" -v print information about conversion work\n"
#ifdef LZW_SUPPORT
-" -z generate LZW compressed output",
+" -z generate LZW compressed output\n"
#endif
-NULL
-};
+;
static void
usage(int code)
{
- int i;
FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr;
fprintf(out, "%s\n\n", TIFFGetVersion());
- for (i = 0; usage_info[i] != NULL; i++)
- fprintf(out, "%s\n", usage_info[i]);
+ fprintf(out, "%s", usage_info);
exit(code);
}
diff --git a/tools/pal2rgb.c b/tools/pal2rgb.c
index 51830779..f73d2470 100644
--- a/tools/pal2rgb.c
+++ b/tools/pal2rgb.c
@@ -118,6 +118,7 @@ main(int argc, char* argv[])
break;
case 'h':
usage(EXIT_SUCCESS);
+ break;
case '?':
usage(EXIT_FAILURE);
/*NOTREACHED*/
@@ -364,7 +365,7 @@ cpTag(TIFF* in, TIFF* out, uint16 tag, uint16 count, TIFFDataType type)
#undef CopyField2
#undef CopyField
-static struct cpTag {
+static const struct cpTag {
uint16 tag;
uint16 count;
TIFFDataType type;
@@ -418,7 +419,7 @@ static struct cpTag {
static void
cpTags(TIFF* in, TIFF* out)
{
- struct cpTag *p;
+ const struct cpTag *p;
for (p = tags; p < &tags[NTAGS]; p++)
{
if( p->tag == TIFFTAG_GROUP3OPTIONS )
@@ -440,44 +441,41 @@ cpTags(TIFF* in, TIFF* out)
}
#undef NTAGS
-const char* usage_info[] = {
-"usage: pal2rgb [options] input.tif output.tif",
-"where options are:",
-" -p contig pack samples contiguously (e.g. RGBRGB...)",
-" -p separate store samples separately (e.g. RRR...GGG...BBB...)",
-" -r # make each strip have no more than # rows",
-" -C 8 assume 8-bit colormap values (instead of 16-bit)",
-" -C 16 assume 16-bit colormap values",
-"",
+static const char usage_info[] =
+"usage: pal2rgb [options] input.tif output.tif\n"
+"where options are:\n"
+" -p contig pack samples contiguously (e.g. RGBRGB...)\n"
+" -p separate store samples separately (e.g. RRR...GGG...BBB...)\n"
+" -r # make each strip have no more than # rows\n"
+" -C 8 assume 8-bit colormap values (instead of 16-bit)\n"
+" -C 16 assume 16-bit colormap values\n"
+"\n"
#ifdef LZW_SUPPORT
-" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding",
-/* " LZW options:", */
-" # set predictor value",
-" For example, -c lzw:2 to get LZW-encoded data with horizontal differencing",
+" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding\n"
+/* " LZW options:\n" */
+" # set predictor value\n"
+" For example, -c lzw:2 to get LZW-encoded data with horizontal differencing\n"
#endif
#ifdef ZIP_SUPPORT
-" -c zip[:opts] compress output with deflate encoding",
-/* " Deflate (ZIP) options:", */
-" # set predictor value",
+" -c zip[:opts] compress output with deflate encoding\n"
+/* " Deflate (ZIP) options:\n" */
+" # set predictor value\n"
#endif
#ifdef PACKBITS_SUPPORT
-" -c packbits compress output with packbits encoding",
+" -c packbits compress output with packbits encoding\n"
#endif
#if defined(LZW_SUPPORT) || defined(ZIP_SUPPORT) || defined(PACKBITS_SUPPORT)
-" -c none use no compression algorithm on output",
+" -c none use no compression algorithm on output\n"
#endif
-NULL
-};
+;
static void
usage(int code)
{
- int i;
FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr;
fprintf(out, "%s\n\n", TIFFGetVersion());
- for (i = 0; usage_info[i] != NULL; i++)
- fprintf(out, "%s\n", usage_info[i]);
+ fprintf(out, "%s", usage_info);
exit(code);
}
diff --git a/tools/ppm2tiff.c b/tools/ppm2tiff.c
index 7f50bdd6..9d27c671 100644
--- a/tools/ppm2tiff.c
+++ b/tools/ppm2tiff.c
@@ -225,6 +225,7 @@ main(int argc, char* argv[])
break;
case 'h':
usage(EXIT_SUCCESS);
+ break;
case '?':
usage(EXIT_FAILURE);
/*NOTREACHED*/
@@ -489,52 +490,48 @@ processCompressOptions(char* opt)
return (1);
}
-const char* usage_info[] = {
-"usage: ppm2tiff [options] input.ppm output.tif",
-"where options are:",
-" -r # make each strip have no more than # rows",
-" -R # set x&y resolution (dpi)",
-"",
+static const char usage_info[] =
+"usage: ppm2tiff [options] input.ppm output.tif\n"
+"where options are:\n"
+" -r # make each strip have no more than # rows\n"
+" -R # set x&y resolution (dpi)\n"
+"\n"
#ifdef JPEG_SUPPORT
-" -c jpeg[:opts] compress output with JPEG encoding",
-/* "JPEG options:", */
-" # set compression quality level (0-100, default 75)",
-" r output color image as RGB rather than YCbCr",
+" -c jpeg[:opts] compress output with JPEG encoding\n"
+/* "JPEG options:\n" */
+" # set compression quality level (0-100, default 75)\n"
+" r output color image as RGB rather than YCbCr\n"
#endif
#ifdef LZW_SUPPORT
-" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding",
-/* " LZW options:", */
-" # set predictor value",
-" For example, -c lzw:2 for LZW-encoded data with horizontal differencing",
+" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding\n"
+/* " LZW options:\n" */
+" # set predictor value\n"
+" For example, -c lzw:2 for LZW-encoded data with horizontal differencing\n"
#endif
#ifdef ZIP_SUPPORT
-" -c zip[:opts] compress output with deflate encoding",
-/* " Deflate (ZIP) options:", */
-" # set predictor value",
+" -c zip[:opts] compress output with deflate encoding\n"
+/* " Deflate (ZIP) options:\n" */
+" # set predictor value\n"
#endif
#ifdef PACKBITS_SUPPORT
-" -c packbits compress output with packbits encoding (the default)",
+" -c packbits compress output with packbits encoding (the default)\n"
#endif
#ifdef CCITT_SUPPORT
-" -c g3[:opts] compress output with CCITT Group 3 encoding",
-" -c g4 compress output with CCITT Group 4 encoding",
+" -c g3[:opts] compress output with CCITT Group 3 encoding\n"
+" -c g4 compress output with CCITT Group 4 encoding\n"
#endif
#if defined(JPEG_SUPPORT) || defined(LZW_SUPPORT) || defined(ZIP_SUPPORT) || defined(PACKBITS_SUPPORT) || defined(CCITT_SUPPORT)
-" -c none use no compression algorithm on output",
+" -c none use no compression algorithm on output\n"
#endif
-"",
-NULL
-};
+;
static void
usage(int code)
{
- int i;
FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr;
fprintf(out, "%s\n\n", TIFFGetVersion());
- for (i = 0; usage_info[i] != NULL; i++)
- fprintf(out, "%s\n", usage_info[i]);
+ fprintf(out, "%s", usage_info);
exit(code);
}
diff --git a/tools/raw2tiff.c b/tools/raw2tiff.c
index 718c230f..77ac070d 100644
--- a/tools/raw2tiff.c
+++ b/tools/raw2tiff.c
@@ -624,86 +624,83 @@ processCompressOptions(char* opt)
return (1);
}
-static const char* usage_info[] = {
-"raw2tiff --- tool for converting raw byte sequences in TIFF images",
-"usage: raw2tiff [options] input.raw output.tif",
-"where options are:",
-" -L input data has LSB2MSB bit order (default)",
-" -M input data has MSB2LSB bit order",
-" -r # make each strip have no more than # rows",
-" -H # size of input image file header in bytes (0 by default)",
-" -w # width of input image in pixels",
-" -l # length of input image in lines",
-" -b # number of bands in input image (1 by default)",
-"",
-" -d data_type type of samples in input image",
-"where data_type may be:",
-" byte 8-bit unsigned integer (default)",
-" short 16-bit unsigned integer",
-" long 32-bit unsigned integer",
-" sbyte 8-bit signed integer",
-" sshort 16-bit signed integer",
-" slong 32-bit signed integer",
-" float 32-bit IEEE floating point",
-" double 64-bit IEEE floating point",
-"",
-" -p photo photometric interpretation (color space) of the input image",
-"where photo may be:",
-" miniswhite white color represented with 0 value",
-" minisblack black color represented with 0 value (default)",
-" rgb image has RGB color model",
-" cmyk image has CMYK (separated) color model",
-" ycbcr image has YCbCr color model",
-" cielab image has CIE L*a*b color model",
-" icclab image has ICC L*a*b color model",
-" itulab image has ITU L*a*b color model",
-"",
-" -s swap bytes fetched from input file",
-"",
-" -i config type of samples interleaving in input image",
-"where config may be:",
-" pixel pixel interleaved data (default)",
-" band band interleaved data",
-"",
+static const char usage_info[] =
+"raw2tiff --- tool for converting raw byte sequences in TIFF images\n"
+"usage: raw2tiff [options] input.raw output.tif\n"
+"where options are:\n"
+" -L input data has LSB2MSB bit order (default)\n"
+" -M input data has MSB2LSB bit order\n"
+" -r # make each strip have no more than # rows\n"
+" -H # size of input image file header in bytes (0 by default)\n"
+" -w # width of input image in pixels\n"
+" -l # length of input image in lines\n"
+" -b # number of bands in input image (1 by default)\n"
+"\n"
+" -d data_type type of samples in input image\n"
+"where data_type may be:\n"
+" byte 8-bit unsigned integer (default)\n"
+" short 16-bit unsigned integer\n"
+" long 32-bit unsigned integer\n"
+" sbyte 8-bit signed integer\n"
+" sshort 16-bit signed integer\n"
+" slong 32-bit signed integer\n"
+" float 32-bit IEEE floating point\n"
+" double 64-bit IEEE floating point\n"
+"\n"
+" -p photo photometric interpretation (color space) of the input image\n"
+"where photo may be:\n"
+" miniswhite white color represented with 0 value\n"
+" minisblack black color represented with 0 value (default)\n"
+" rgb image has RGB color model\n"
+" cmyk image has CMYK (separated) color model\n"
+" ycbcr image has YCbCr color model\n"
+" cielab image has CIE L*a*b color model\n"
+" icclab image has ICC L*a*b color model\n"
+" itulab image has ITU L*a*b color model\n"
+"\n"
+" -s swap bytes fetched from input file\n"
+"\n"
+" -i config type of samples interleaving in input image\n"
+"where config may be:\n"
+" pixel pixel interleaved data (default)\n"
+" band band interleaved data\n"
+"\n"
#ifdef LZW_SUPPORT
-" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding",
-/* " LZW options:", */
-" # set predictor value",
-" For example, -c lzw:2 for LZW-encoded data with horizontal differencing",
+" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding\n"
+/* " LZW options:\n" */
+" # set predictor value\n"
+" For example, -c lzw:2 for LZW-encoded data with horizontal differencing\n"
#endif
#ifdef ZIP_SUPPORT
-" -c zip[:opts] compress output with deflate encoding",
-/* " Deflate (ZIP) options:", */
-" # set predictor value",
+" -c zip[:opts] compress output with deflate encoding\n"
+/* " Deflate (ZIP) options:\n" */
+" # set predictor value\n"
#endif
#ifdef JPEG_SUPPORT
-" -c jpeg[:opts] compress output with JPEG encoding",
-/* " JPEG options:", */
-" # set compression quality level (0-100, default 75)",
-" r output color image as RGB rather than YCbCr",
-" For example, -c jpeg:r:50 for JPEG-encoded RGB data with 50% comp. quality",
+" -c jpeg[:opts] compress output with JPEG encoding\n"
+/* " JPEG options:\n" */
+" # set compression quality level (0-100, default 75)\n"
+" r output color image as RGB rather than YCbCr\n"
+" For example, -c jpeg:r:50 for JPEG-encoded RGB data with 50% comp. quality\n"
#endif
#ifdef PACKBITS_SUPPORT
-" -c packbits compress output with packbits encoding",
+" -c packbits compress output with packbits encoding\n"
#endif
#if defined(LZW_SUPPORT) || defined(ZIP_SUPPORT) || defined(JPEG_SUPPORT) || defined(PACKBITS_SUPPORT)
-" -c none use no compression algorithm on output",
+" -c none use no compression algorithm on output\n"
#endif
-"",
-" -o out.tif write output to out.tif",
-" -h this help message",
-NULL
-};
+"\n"
+" -o out.tif write output to out.tif\n"
+" -h this help message\n"
+;
static void
usage(int code)
{
- int i;
FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr;
fprintf(out, "%s\n\n", TIFFGetVersion());
- for (i = 0; usage_info[i] != NULL; i++)
- fprintf(out, "%s\n", usage_info[i]);
+ fprintf(out, "%s", usage_info);
exit(code);
}
diff --git a/tools/thumbnail.c b/tools/thumbnail.c
index edb69983..737780d8 100644
--- a/tools/thumbnail.c
+++ b/tools/thumbnail.c
@@ -221,7 +221,7 @@ cpTag(TIFF* in, TIFF* out, uint16 tag, uint16 count, TIFFDataType type)
#undef CopyField2
#undef CopyField
-static struct cpTag {
+static const struct cpTag {
uint16 tag;
uint16 count;
TIFFDataType type;
@@ -279,7 +279,7 @@ static struct cpTag {
static void
cpTags(TIFF* in, TIFF* out)
{
- struct cpTag *p;
+ const struct cpTag *p;
for (p = tags; p < &tags[NTAGS]; p++)
{
/* Horrible: but TIFFGetField() expects 2 arguments to be passed */
diff --git a/tools/tiff2bw.c b/tools/tiff2bw.c
index ff1487d4..f9491f6d 100644
--- a/tools/tiff2bw.c
+++ b/tools/tiff2bw.c
@@ -439,7 +439,7 @@ cpTag(TIFF* in, TIFF* out, uint16 tag, uint16 count, TIFFDataType type)
#undef CopyField2
#undef CopyField
-static struct cpTag {
+static const struct cpTag {
uint16 tag;
uint16 count;
TIFFDataType type;
@@ -483,7 +483,7 @@ static struct cpTag {
static void
cpTags(TIFF* in, TIFF* out)
{
- struct cpTag *p;
+ const struct cpTag *p;
for (p = tags; p < &tags[NTAGS]; p++)
{
if( p->tag == TIFFTAG_GROUP3OPTIONS )
@@ -505,49 +505,46 @@ cpTags(TIFF* in, TIFF* out)
}
#undef NTAGS
-const char* usage_info[] = {
-"usage: tiff2bw [options] input.tif output.tif",
-"where options are:",
-" -R % use #% from red channel",
-" -G % use #% from green channel",
-" -B % use #% from blue channel",
-"",
-" -r # make each strip have no more than # rows",
-"",
+static const char usage_info[] =
+"usage: tiff2bw [options] input.tif output.tif\n"
+"where options are:\n"
+" -R % use #% from red channel\n"
+" -G % use #% from green channel\n"
+" -B % use #% from blue channel\n"
+"\n"
+" -r # make each strip have no more than # rows\n"
+"\n"
#ifdef LZW_SUPPORT
-" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding",
-/* " LZW options:", */
-" # set predictor value",
-" For example, -c lzw:2 for LZW-encoded data with horizontal differencing",
+" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding\n"
+/* " LZW options:\n" */
+" # set predictor value\n"
+" For example, -c lzw:2 for LZW-encoded data with horizontal differencing\n"
#endif
#ifdef ZIP_SUPPORT
-" -c zip[:opts] compress output with deflate encoding",
-/* " Deflate (ZIP) options:", */
-" # set predictor value",
+" -c zip[:opts] compress output with deflate encoding\n"
+/* " Deflate (ZIP) options:\n" */
+" # set predictor value\n"
#endif
#ifdef PACKBITS_SUPPORT
-" -c packbits compress output with packbits encoding",
+" -c packbits compress output with packbits encoding\n"
#endif
#ifdef CCITT_SUPPORT
-" -c g3[:opts] compress output with CCITT Group 3 encoding",
-" -c g4 compress output with CCITT Group 4 encoding",
+" -c g3[:opts] compress output with CCITT Group 3 encoding\n"
+" -c g4 compress output with CCITT Group 4 encoding\n"
#endif
#if defined(LZW_SUPPORT) || defined(ZIP_SUPPORT) || defined(PACKBITS_SUPPORT) || defined(CCITT_SUPPORT)
-" -c none use no compression algorithm on output",
+" -c none use no compression algorithm on output\n"
#endif
-"",
-NULL
-};
+"\n"
+;
static void
usage(int code)
{
- int i;
FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr;
fprintf(out, "%s\n\n", TIFFGetVersion());
- for (i = 0; usage_info[i] != NULL; i++)
- fprintf(out, "%s\n", usage_info[i]);
+ fprintf(out, "%s", usage_info);
exit(code);
}
diff --git a/tools/tiff2pdf.c b/tools/tiff2pdf.c
index 54b3e651..86c3b6ae 100644
--- a/tools/tiff2pdf.c
+++ b/tools/tiff2pdf.c
@@ -850,49 +850,45 @@ success:
}
static void usage_info(int code) {
- static const char* lines[]={
- "usage: tiff2pdf [options] input.tiff",
- "where options are:",
- " -o: output to file name",
+ static const char lines[]=
+ "usage: tiff2pdf [options] input.tiff\n"
+ "where options are:\n"
+ " -o: output to file name\n"
#ifdef JPEG_SUPPORT
- " -j: compress with JPEG",
+ " -j: compress with JPEG\n"
#endif
#ifdef ZIP_SUPPORT
- " -z: compress with Zip/Deflate",
+ " -z: compress with Zip/Deflate\n"
#endif
#if defined(JPEG_SUPPORT) || defined(ZIP_SUPPORT)
- " -q: compression quality",
- " -n: no compressed data passthrough",
- " -d: do not compress (decompress)",
+ " -q: compression quality\n"
+ " -n: no compressed data passthrough\n"
+ " -d: do not compress (decompress)\n"
#endif
- " -i: invert colors",
- " -u: set distance unit, 'i' for inch, 'm' for centimeter",
- " -x: set x resolution default in dots per unit",
- " -y: set y resolution default in dots per unit",
- " -w: width in units",
- " -l: length in units",
- " -r: 'd' for resolution default, 'o' for resolution override",
- " -p: paper size, eg \"letter\", \"legal\", \"A4\"",
- " -F: make the tiff fill the PDF page",
- " -f: set PDF \"Fit Window\" user preference",
- " -e: date, overrides image or current date/time default, YYYYMMDDHHMMSS",
- " -c: sets document creator, overrides image software default",
- " -a: sets document author, overrides image artist default",
- " -t: sets document title, overrides image document name default",
- " -s: sets document subject, overrides image image description default",
- " -k: sets document keywords",
- " -b: set PDF \"Interpolate\" user preference",
- " -m: set memory allocation limit (in MiB). set to 0 to disable limit",
- " -h: usage",
- NULL
- };
- int i=0;
+ " -i: invert colors\n"
+ " -u: set distance unit, 'i' for inch, 'm' for centimeter\n"
+ " -x: set x resolution default in dots per unit\n"
+ " -y: set y resolution default in dots per unit\n"
+ " -w: width in units\n"
+ " -l: length in units\n"
+ " -r: 'd' for resolution default, 'o' for resolution override\n"
+ " -p: paper size, eg \"letter\", \"legal\", \"A4\"\n"
+ " -F: make the tiff fill the PDF page\n"
+ " -f: set PDF \"Fit Window\" user preference\n"
+ " -e: date, overrides image or current date/time default, YYYYMMDDHHMMSS\n"
+ " -c: sets document creator, overrides image software default\n"
+ " -a: sets document author, overrides image artist default\n"
+ " -t: sets document title, overrides image document name default\n"
+ " -s: sets document subject, overrides image image description default\n"
+ " -k: sets document keywords\n"
+ " -b: set PDF \"Interpolate\" user preference\n"
+ " -m: set memory allocation limit (in MiB). set to 0 to disable limit\n"
+ " -h: usage\n"
+ ;
FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr;
fprintf(out, "%s\n\n", TIFFGetVersion());
- for (i=0;lines[i]!=NULL;i++){
- fprintf(out, "%s\n", lines[i]);
- }
+ fprintf(out, "%s", lines);
return;
}
diff --git a/tools/tiff2ps.c b/tools/tiff2ps.c
index 4ed5eba2..b9762883 100644
--- a/tools/tiff2ps.c
+++ b/tools/tiff2ps.c
@@ -605,7 +605,7 @@ checkImage(TIFF* tif)
#define PS_UNIT_SIZE 72.0F
#define PSUNITS(npix,res) ((npix) * (PS_UNIT_SIZE / (res)))
-static char RGBcolorimage[] = "\
+static const char RGBcolorimage[] = "\
/bwproc {\n\
rgbproc\n\
dup length 3 idiv string 0 3 0\n\
@@ -1653,7 +1653,7 @@ int TIFF2PS(FILE* fd, TIFF* tif, double pgwidth, double pgheight, double lm, dou
return(npages);
}
-static char DuplexPreamble[] = "\
+static const char DuplexPreamble[] = "\
%%BeginFeature: *Duplex True\n\
systemdict begin\n\
/languagelevel where { pop languagelevel } { 1 } ifelse\n\
@@ -1664,7 +1664,7 @@ end\n\
%%EndFeature\n\
";
-static char TumblePreamble[] = "\
+static const char TumblePreamble[] = "\
%%BeginFeature: *Tumble True\n\
systemdict begin\n\
/languagelevel where { pop languagelevel } { 1 } ifelse\n\
@@ -1675,7 +1675,7 @@ end\n\
%%EndFeature\n\
";
-static char AvoidDeadZonePreamble[] = "\
+static const char AvoidDeadZonePreamble[] = "\
gsave newpath clippath pathbbox grestore\n\
4 2 roll 2 copy translate\n\
exch 3 1 roll sub 3 1 roll sub exch\n\
@@ -3087,52 +3087,49 @@ tsize_t Ascii85EncodeBlock( uint8 * ascii85_p, unsigned f_eod, const uint8 * raw
#endif /* EXP_ASCII85ENCODER */
-const char* stuff[] = {
-"usage: tiff2ps [options] input.tif ...",
-"where options are:",
-" -1 generate PostScript Level 1 (default)",
-" -2 generate PostScript Level 2",
-" -3 generate PostScript Level 3",
-" -8 disable use of ASCII85 encoding with PostScript Level 2/3",
-" -a convert all directories in file (default is first), Not EPS",
-" -b # set the bottom margin to # inches",
-" -c center image (-b and -l still add to this)",
-" -C name set postscript document creator name",
-" -d # set initial directory to # counting from zero",
-" -D enable duplex printing (two pages per sheet of paper)",
-" -e generate Encapsulated PostScript (EPS) (implies -z)",
-" -h # set printed page height to # inches (no default)",
-" -w # set printed page width to # inches (no default)",
-" -H # split image if height is more than # inches",
-" -W # split image if width is more than # inches",
-" -L # overLap split images by # inches",
-" -i # enable/disable (Nz/0) pixel interpolation (default: enable)",
-" -l # set the left margin to # inches",
-" -m use \"imagemask\" operator instead of \"image\"",
-" -M size set the memory allocation limit in MiB. 0 to disable limit",
-" -o # convert directory at file offset # bytes",
-" -O file write PostScript to file instead of standard output",
-" -p generate regular (non-encapsulated) PostScript",
-" -P L or P set optional PageOrientation DSC comment to Landscape or Portrait",
-" -r # or auto rotate by 90, 180, 270 degrees or auto",
-" -s generate PostScript for a single image",
-" -t name set postscript document title. Otherwise the filename is used",
-" -T print pages for top edge binding",
-" -x override resolution units as centimeters",
-" -y override resolution units as inches",
-" -z enable printing in the deadzone (only for PostScript Level 2/3)",
-NULL
-};
+static const char usage_info[] =
+"usage: tiff2ps [options] input.tif ...\n"
+"where options are:\n"
+" -1 generate PostScript Level 1 (default)\n"
+" -2 generate PostScript Level 2\n"
+" -3 generate PostScript Level 3\n"
+" -8 disable use of ASCII85 encoding with PostScript Level 2/3\n"
+" -a convert all directories in file (default is first), Not EPS\n"
+" -b # set the bottom margin to # inches\n"
+" -c center image (-b and -l still add to this)\n"
+" -C name set postscript document creator name\n"
+" -d # set initial directory to # counting from zero\n"
+" -D enable duplex printing (two pages per sheet of paper)\n"
+" -e generate Encapsulated PostScript (EPS) (implies -z)\n"
+" -h # set printed page height to # inches (no default)\n"
+" -w # set printed page width to # inches (no default)\n"
+" -H # split image if height is more than # inches\n"
+" -W # split image if width is more than # inches\n"
+" -L # overLap split images by # inches\n"
+" -i # enable/disable (Nz/0) pixel interpolation (default: enable)\n"
+" -l # set the left margin to # inches\n"
+" -m use \"imagemask\" operator instead of \"image\"\n"
+" -M size set the memory allocation limit in MiB. 0 to disable limit\n"
+" -o # convert directory at file offset # bytes\n"
+" -O file write PostScript to file instead of standard output\n"
+" -p generate regular (non-encapsulated) PostScript\n"
+" -P L or P set optional PageOrientation DSC comment to Landscape or Portrait\n"
+" -r # or auto rotate by 90, 180, 270 degrees or auto\n"
+" -s generate PostScript for a single image\n"
+" -t name set postscript document title. Otherwise the filename is used\n"
+" -T print pages for top edge binding\n"
+" -x override resolution units as centimeters\n"
+" -y override resolution units as inches\n"
+" -z enable printing in the deadzone (only for PostScript Level 2/3)\n"
+;
static void
usage(int code)
{
- int i;
FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr;
fprintf(out, "%s\n\n", TIFFGetVersion());
- for (i = 0; stuff[i] != NULL; i++)
- fprintf(out, "%s\n", stuff[i]);
+ fprintf(out, "%s", usage_info);
exit(code);
}
diff --git a/tools/tiff2rgba.c b/tools/tiff2rgba.c
index 675c557b..f179c0a7 100644
--- a/tools/tiff2rgba.c
+++ b/tools/tiff2rgba.c
@@ -59,11 +59,11 @@ extern int getopt(int argc, char * const argv[], const char *optstring);
#endif
#define roundup(x, y) (howmany(x,y)*((uint32)(y)))
-uint16 compression = COMPRESSION_PACKBITS;
-uint32 rowsperstrip = (uint32) -1;
-int process_by_block = 0; /* default is whole image at once */
-int no_alpha = 0;
-int bigtiff_output = 0;
+static uint16 compression = COMPRESSION_PACKBITS;
+static uint32 rowsperstrip = (uint32) -1;
+static int process_by_block = 0; /* default is whole image at once */
+static int no_alpha = 0;
+static int bigtiff_output = 0;
#define DEFAULT_MAX_MALLOC (256 * 1024 * 1024)
/* malloc size limit (in bytes)
* disabled when set to 0 */
@@ -562,46 +562,43 @@ tiffcvt(TIFF* in, TIFF* out)
return( cvt_whole_image( in, out ) );
}
-static const char* usage_info[] = {
+static const char usage_info[] =
/* Help information format modified for the sake of consistency with the other tiff tools */
-/* "usage: tiff2rgba [-c comp] [-r rows] [-b] [-n] [-8] [-M size] input... output", */
-/* "where comp is one of the following compression algorithms:", */
-"usage: tiff2rgba [options] input output",
-"where options are:",
+/* "usage: tiff2rgba [-c comp] [-r rows] [-b] [-n] [-8] [-M size] input... output" */
+/* "where comp is one of the following compression algorithms:" */
+"usage: tiff2rgba [options] input output\n"
+"where options are:\n"
#ifdef JPEG_SUPPORT
-" -c jpeg JPEG encoding",
+" -c jpeg JPEG encoding\n"
#endif
#ifdef ZIP_SUPPORT
-" -c zip Zip/Deflate encoding",
+" -c zip Zip/Deflate encoding\n"
#endif
#ifdef LZW_SUPPORT
-" -c lzw Lempel-Ziv & Welch encoding",
+" -c lzw Lempel-Ziv & Welch encoding\n"
#endif
#ifdef PACKBITS_SUPPORT
-" -c packbits PackBits encoding",
+" -c packbits PackBits encoding\n"
#endif
#if defined(JPEG_SUPPORT) || defined(ZIP_SUPPORT) || defined(LZW_SUPPORT) || defined(PACKBITS_SUPPORT)
-" -c none no compression",
+" -c none no compression\n"
#endif
-"",
-/* "and the other options are:", */
-" -r rows/strip",
-" -b (progress by block rather than as a whole image)",
-" -n don't emit alpha component.",
-" -8 write BigTIFF file instead of ClassicTIFF",
-" -M set the memory allocation limit in MiB. 0 to disable limit",
-NULL
-};
+"\n"
+/* "and the other options are:\n" */
+" -r rows/strip\n"
+" -b (progress by block rather than as a whole image)\n"
+" -n don't emit alpha component.\n"
+" -8 write BigTIFF file instead of ClassicTIFF\n"
+" -M set the memory allocation limit in MiB. 0 to disable limit\n"
+;
static void
usage(int code)
{
- int i;
FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr;
fprintf(out, "%s\n\n", TIFFGetVersion());
- for (i = 0; usage_info[i] != NULL; i++)
- fprintf(out, "%s\n", usage_info[i]);
+ fprintf(out, "%s", usage_info);
exit(code);
}
diff --git a/tools/tiffcmp.c b/tools/tiffcmp.c
index 041d6a2d..7bfef503 100644
--- a/tools/tiffcmp.c
+++ b/tools/tiffcmp.c
@@ -130,24 +130,21 @@ main(int argc, char* argv[])
return (0);
}
-static const char* stuff[] = {
-"usage: tiffcmp [options] file1 file2",
-"where options are:",
-" -l list each byte of image data that differs between the files",
-" -z # list specified number of bytes that differs between the files",
-" -t ignore any differences in directory tags",
-NULL
-};
+static const char usage_info[] =
+"usage: tiffcmp [options] file1 file2\n"
+"where options are:\n"
+" -l list each byte of image data that differs between the files\n"
+" -z # list specified number of bytes that differs between the files\n"
+" -t ignore any differences in directory tags\n"
+;
static void
usage(int code)
{
- int i;
FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr;
fprintf(out, "%s\n\n", TIFFGetVersion());
- for (i = 0; stuff[i] != NULL; i++)
- fprintf(out, "%s\n", stuff[i]);
+ fprintf(out, "%s", usage_info);
exit(code);
}
diff --git a/tools/tiffcp.c b/tools/tiffcp.c
index cc9bb07b..7ab7cd74 100644
--- a/tools/tiffcp.c
+++ b/tools/tiffcp.c
@@ -443,115 +443,112 @@ processCompressOptions(char* opt)
return (1);
}
-static const char* usage_info[] = {
-"usage: tiffcp [options] input... output",
-"where options are:",
-" -a append to output instead of overwriting",
-" -o offset set initial directory offset",
-" -p contig pack samples contiguously (e.g. RGBRGB...)",
-" -p separate store samples separately (e.g. RRR...GGG...BBB...)",
-" -s write output in strips",
-" -t write output in tiles",
-" -x force the merged tiff pages in sequence",
-" -8 write BigTIFF instead of default ClassicTIFF",
-" -B write big-endian instead of native byte order",
-" -L write little-endian instead of native byte order",
-" -M disable use of memory-mapped files",
-" -C disable strip chopping",
-" -i ignore read errors",
-" -b file[,#] bias (dark) monochrome image to be subtracted from all others",
-" -,=% use % rather than , to separate image #'s (per Note below)",
-" -m size set maximum memory allocation size (MiB). 0 to disable limit.",
-"",
-" -r # make each strip have no more than # rows",
-" -w # set output tile width (pixels)",
-" -l # set output tile length (pixels)",
-"",
-" -f lsb2msb force lsb-to-msb FillOrder for output",
-" -f msb2lsb force msb-to-lsb FillOrder for output",
-"",
+static const char usage_info[] =
+"usage: tiffcp [options] input... output\n"
+"where options are:\n"
+" -a append to output instead of overwriting\n"
+" -o offset set initial directory offset\n"
+" -p contig pack samples contiguously (e.g. RGBRGB...)\n"
+" -p separate store samples separately (e.g. RRR...GGG...BBB...)\n"
+" -s write output in strips\n"
+" -t write output in tiles\n"
+" -x force the merged tiff pages in sequence\n"
+" -8 write BigTIFF instead of default ClassicTIFF\n"
+" -B write big-endian instead of native byte order\n"
+" -L write little-endian instead of native byte order\n"
+" -M disable use of memory-mapped files\n"
+" -C disable strip chopping\n"
+" -i ignore read errors\n"
+" -b file[,#] bias (dark) monochrome image to be subtracted from all others\n"
+" -,=% use % rather than , to separate image #'s (per Note below)\n"
+" -m size set maximum memory allocation size (MiB). 0 to disable limit.\n"
+"\n"
+" -r # make each strip have no more than # rows\n"
+" -w # set output tile width (pixels)\n"
+" -l # set output tile length (pixels)\n"
+"\n"
+" -f lsb2msb force lsb-to-msb FillOrder for output\n"
+" -f msb2lsb force msb-to-lsb FillOrder for output\n"
+"\n"
#ifdef LZW_SUPPORT
-" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding",
-/* " LZW options:", */
-" # set predictor value",
-" p# set compression level (preset)",
-" For example, -c lzw:2 for LZW-encoded data with horizontal differencing",
+" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding\n"
+/* " LZW options:" */
+" # set predictor value\n"
+" p# set compression level (preset)\n"
+" For example, -c lzw:2 for LZW-encoded data with horizontal differencing\n"
#endif
#ifdef ZIP_SUPPORT
-" -c zip[:opts] compress output with deflate encoding",
+" -c zip[:opts] compress output with deflate encoding\n"
/* " Deflate (ZIP) options:", */
-" # set predictor value",
-" p# set compression level (preset)",
-" For example, -c zip:3:p9 for maximum compression level and floating",
-" point predictor.",
+" # set predictor value\n"
+" p# set compression level (preset)\n"
+" For example, -c zip:3:p9 for maximum compression level and floating\n"
+" point predictor.\n"
#endif
#if defined(ZIP_SUPPORT) && defined(LIBDEFLATE_SUPPORT)
-" s# set subcodec: 0=zlib, 1=libdeflate (default 1)",
+" s# set subcodec: 0=zlib, 1=libdeflate (default 1)\n"
/* " (only for Deflate/ZIP)", */
#endif
#ifdef LZMA_SUPPORT
-" -c lzma[:opts] compress output with LZMA2 encoding",
+" -c lzma[:opts] compress output with LZMA2 encoding\n"
/* " LZMA options:", */
-" # set predictor value",
-" p# set compression level (preset)",
+" # set predictor value\n"
+" p# set compression level (preset)\n"
#endif
#ifdef ZSTD_SUPPORT
-" -c zstd[:opts] compress output with ZSTD encoding",
+" -c zstd[:opts] compress output with ZSTD encoding\n"
/* " ZSTD options:", */
-" # set predictor value",
-" p# set compression level (preset)",
+" # set predictor value\n"
+" p# set compression level (preset)\n"
#endif
#ifdef WEBP_SUPPORT
-" -c webp[:opts] compress output with WEBP encoding",
+" -c webp[:opts] compress output with WEBP encoding\n"
/* " WEBP options:", */
-" # set predictor value",
-" p# set compression level (preset)",
+" # set predictor value\n"
+" p# set compression level (preset)\n"
#endif
#ifdef JPEG_SUPPORT
-" -c jpeg[:opts] compress output with JPEG encoding",
+" -c jpeg[:opts] compress output with JPEG encoding\n"
/* " JPEG options:", */
-" # set compression quality level (0-100, default 75)",
-" r output color image as RGB rather than YCbCr",
-" For example, -c jpeg:r:50 for JPEG-encoded RGB with 50% comp. quality",
+" # set compression quality level (0-100, default 75)\n"
+" r output color image as RGB rather than YCbCr\n"
+" For example, -c jpeg:r:50 for JPEG-encoded RGB with 50% comp. quality\n"
#endif
#ifdef JBIG_SUPPORT
-" -c jbig compress output with ISO JBIG encoding",
+" -c jbig compress output with ISO JBIG encoding\n"
#endif
#ifdef PACKBITS_SUPPORT
-" -c packbits compress output with packbits encoding",
+" -c packbits compress output with packbits encoding\n"
#endif
#ifdef CCITT_SUPPORT
-" -c g3[:opts] compress output with CCITT Group 3 encoding",
+" -c g3[:opts] compress output with CCITT Group 3 encoding\n"
/* " CCITT Group 3 options:", */
-" 1d use default CCITT Group 3 1D-encoding",
-" 2d use optional CCITT Group 3 2D-encoding",
-" fill byte-align EOL codes",
-" For example, -c g3:2d:fill for G3-2D-encoded data with byte-aligned EOLs",
-" -c g4 compress output with CCITT Group 4 encoding",
+" 1d use default CCITT Group 3 1D-encoding\n"
+" 2d use optional CCITT Group 3 2D-encoding\n"
+" fill byte-align EOL codes\n"
+" For example, -c g3:2d:fill for G3-2D-encoded data with byte-aligned EOLs\n"
+" -c g4 compress output with CCITT Group 4 encoding\n"
#endif
#ifdef LOGLUV_SUPPORT
-" -c sgilog compress output with SGILOG encoding",
+" -c sgilog compress output with SGILOG encoding\n"
#endif
#if defined(LZW_SUPPORT) || defined(ZIP_SUPPORT) || defined(LZMA_SUPPORT) || defined(ZSTD_SUPPORT) || defined(WEBP_SUPPORT) || defined(JPEG_SUPPORT) || defined(JBIG_SUPPORT) || defined(PACKBITS_SUPPORT) || defined(CCITT_SUPPORT) || defined(LOGLUV_SUPPORT)
-" -c none use no compression algorithm on output",
+" -c none use no compression algorithm on output\n"
#endif
-"",
-"Note that input filenames may be of the form filename,x,y,z",
-"where x, y, and z specify image numbers in the filename to copy.",
-"example: tiffcp -c none -b esp.tif,1 esp.tif,0 test.tif",
-" subtract 2nd image in esp.tif from 1st yielding uncompressed result test.tif",
-NULL
-};
+"\n"
+"Note that input filenames may be of the form filename,x,y,z\n"
+"where x, y, and z specify image numbers in the filename to copy.\n"
+"example: tiffcp -c none -b esp.tif,1 esp.tif,0 test.tif\n"
+" subtract 2nd image in esp.tif from 1st yielding uncompressed result test.tif\n"
+;
static void
usage(int code)
{
- int i;
FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr;
fprintf(out, "%s\n\n", TIFFGetVersion());
- for (i = 0; usage_info[i] != NULL; i++)
- fprintf(out, "%s\n", usage_info[i]);
+ fprintf(out, "%s", usage_info);
exit(code);
}
@@ -619,7 +616,7 @@ cpTag(TIFF* in, TIFF* out, uint16 tag, uint16 count, TIFFDataType type)
}
}
-static struct cpTag {
+static const struct cpTag {
uint16 tag;
uint16 count;
TIFFDataType type;
@@ -675,7 +672,7 @@ tiffcp(TIFF* in, TIFF* out)
uint16 input_compression, input_photometric = PHOTOMETRIC_MINISBLACK;
copyFunc cf;
uint32 width, length;
- struct cpTag* p;
+ const struct cpTag* p;
CopyField(TIFFTAG_IMAGEWIDTH, width);
CopyField(TIFFTAG_IMAGELENGTH, length);
diff --git a/tools/tiffcrop.c b/tools/tiffcrop.c
index 7e53525a..df2707e3 100644
--- a/tools/tiffcrop.c
+++ b/tools/tiffcrop.c
@@ -307,7 +307,7 @@ struct crop_mask {
struct coordpairs corners[MAX_REGIONS]; /* Coordinates of upper left and lower right corner */
};
-#define MAX_PAPERNAMES 49
+#define MAX_PAPERNAMES (sizeof(PaperTable)/sizeof(PaperTable[0])) /* was 49 */
#define MAX_PAPERNAME_LENGTH 15
#define DEFAULT_RESUNIT RESUNIT_INCH
#define DEFAULT_PAGE_HEIGHT 14.0
@@ -340,7 +340,7 @@ struct paperdef {
/* European page sizes corrected from update sent by
* thomas . jarosch @ intra2net . com on 5/7/2010
* Paper Size Width Length Aspect Ratio */
-const struct paperdef PaperTable[MAX_PAPERNAMES] = {
+static const struct paperdef PaperTable[/*MAX_PAPERNAMES*/] = {
{"default", 8.500, 14.000, 0.607},
{"pa4", 8.264, 11.000, 0.751},
{"letter", 8.500, 11.000, 0.773},
@@ -645,152 +645,151 @@ static void* limitMalloc(tmsize_t s)
-static const char* usage_info[] = {
-"usage: tiffcrop [options] source1 ... sourceN destination",
-"where options are:",
-" -h Print this syntax listing",
-" -v Print tiffcrop version identifier and last revision date",
-" ",
-" -a Append to output instead of overwriting",
-" -d offset Set initial directory offset, counting first image as one, not zero",
-" -p contig Pack samples contiguously (e.g. RGBRGB...)",
-" -p separate Store samples separately (e.g. RRR...GGG...BBB...)",
-" -s Write output in strips",
-" -t Write output in tiles",
-" -i Ignore read errors",
-" -k size set the memory allocation limit in MiB. 0 to disable limit",
-" ",
-" -r # Make each strip have no more than # rows",
-" -w # Set output tile width (pixels)",
-" -l # Set output tile length (pixels)",
-" ",
-" -f lsb2msb Force lsb-to-msb FillOrder for output",
-" -f msb2lsb Force msb-to-lsb FillOrder for output",
-"",
+static const char usage_info[] =
+"usage: tiffcrop [options] source1 ... sourceN destination\n"
+"where options are:\n"
+" -h Print this syntax listing\n"
+" -v Print tiffcrop version identifier and last revision date\n"
+" \n"
+" -a Append to output instead of overwriting\n"
+" -d offset Set initial directory offset, counting first image as one, not zero\n"
+" -p contig Pack samples contiguously (e.g. RGBRGB...)\n"
+" -p separate Store samples separately (e.g. RRR...GGG...BBB...)\n"
+" -s Write output in strips\n"
+" -t Write output in tiles\n"
+" -i Ignore read errors\n"
+" -k size set the memory allocation limit in MiB. 0 to disable limit\n"
+" \n"
+" -r # Make each strip have no more than # rows\n"
+" -w # Set output tile width (pixels)\n"
+" -l # Set output tile length (pixels)\n"
+" \n"
+" -f lsb2msb Force lsb-to-msb FillOrder for output\n"
+" -f msb2lsb Force msb-to-lsb FillOrder for output\n"
+"\n"
#ifdef LZW_SUPPORT
-" -c lzw[:opts] Compress output with Lempel-Ziv & Welch encoding",
-/* " LZW options:", */
-" # Set predictor value",
-" For example, -c lzw:2 for LZW-encoded data with horizontal differencing",
+" -c lzw[:opts] Compress output with Lempel-Ziv & Welch encoding\n"
+/* " LZW options:\n" */
+" # Set predictor value\n"
+" For example, -c lzw:2 for LZW-encoded data with horizontal differencing\n"
#endif
#ifdef ZIP_SUPPORT
-" -c zip[:opts] Compress output with deflate encoding",
-/* " Deflate (ZIP) options:", */
-" # Set predictor value",
+" -c zip[:opts] Compress output with deflate encoding\n"
+/* " Deflate (ZIP) options:\n" */
+" # Set predictor value\n"
#endif
#ifdef JPEG_SUPPORT
-" -c jpeg[:opts] Compress output with JPEG encoding",
-/* " JPEG options:", */
-" # Set compression quality level (0-100, default 100)",
-" raw Output color image as raw YCbCr (default)",
-" rgb Output color image as RGB",
-" For example, -c jpeg:rgb:50 for JPEG-encoded RGB with 50% comp. quality",
+" -c jpeg[:opts] Compress output with JPEG encoding\n"
+/* " JPEG options:\n" */
+" # Set compression quality level (0-100, default 100)\n"
+" raw Output color image as raw YCbCr (default)\n"
+" rgb Output color image as RGB\n"
+" For example, -c jpeg:rgb:50 for JPEG-encoded RGB with 50% comp. quality\n"
#endif
#ifdef PACKBITS_SUPPORT
-" -c packbits Compress output with packbits encoding",
+" -c packbits Compress output with packbits encoding\n"
#endif
#ifdef CCITT_SUPPORT
-" -c g3[:opts] Compress output with CCITT Group 3 encoding",
-/* " CCITT Group 3 options:", */
-" 1d Use default CCITT Group 3 1D-encoding",
-" 2d Use optional CCITT Group 3 2D-encoding",
-" fill Byte-align EOL codes",
-" For example, -c g3:2d:fill for G3-2D-encoded data with byte-aligned EOLs",
-" -c g4 Compress output with CCITT Group 4 encoding",
+" -c g3[:opts] Compress output with CCITT Group 3 encoding\n"
+/* " CCITT Group 3 options:\n" */
+" 1d Use default CCITT Group 3 1D-encoding\n"
+" 2d Use optional CCITT Group 3 2D-encoding\n"
+" fill Byte-align EOL codes\n"
+" For example, -c g3:2d:fill for G3-2D-encoded data with byte-aligned EOLs\n"
+" -c g4 Compress output with CCITT Group 4 encoding\n"
#endif
#if defined(LZW_SUPPORT) || defined(ZIP_SUPPORT) || defined(JPEG_SUPPORT) || defined(PACKBITS_SUPPORT) || defined(CCITT_SUPPORT)
-" -c none Use no compression algorithm on output",
+" -c none Use no compression algorithm on output\n"
#endif
-" ",
-"Page and selection options:",
-" -N odd|even|#,#-#,#|last sequences and ranges of images within file to process",
-" The words odd or even may be used to specify all odd or even numbered images.",
-" The word last may be used in place of a number in the sequence to indicate.",
-" The final image in the file without knowing how many images there are.",
-" Numbers are counted from one even though TIFF IFDs are counted from zero.",
-" ",
-" -E t|l|r|b edge to use as origin for width and length of crop region",
-" -U units [in, cm, px ] inches, centimeters or pixels",
-" ",
-" -m #,#,#,# margins from edges for selection: top, left, bottom, right separated by commas",
-" -X # horizontal dimension of region to extract expressed in current units",
-" -Y # vertical dimension of region to extract expressed in current units",
-" -Z #:#,#:# zones of the image designated as position X of Y,",
-" eg 1:3 would be first of three equal portions measured from reference edge",
-" -z x1,y1,x2,y2:...:xN,yN,xN+1,yN+1",
-" regions of the image designated by upper left and lower right coordinates",
-"",
-"Export grouping options:",
-" -e c|d|i|m|s export mode for images and selections from input images.",
-" When exporting a composite image from multiple zones or regions",
-" (combined and image modes), the selections must have equal sizes",
-" for the axis perpendicular to the edge specified with -E.",
-" c|combined All images and selections are written to a single file (default).",
-" with multiple selections from one image combined into a single image.",
-" d|divided All images and selections are written to a single file",
-" with each selection from one image written to a new image.",
-" i|image Each input image is written to a new file (numeric filename sequence)",
-" with multiple selections from the image combined into one image.",
-" m|multiple Each input image is written to a new file (numeric filename sequence)",
-" with each selection from the image written to a new image.",
-" s|separated Individual selections from each image are written to separate files.",
-"",
-"Output options:",
-" -H # Set horizontal resolution of output images to #",
-" -V # Set vertical resolution of output images to #",
-" -J # Set horizontal margin of output page to # expressed in current units",
-" when sectioning image into columns x rows using the -S cols:rows option",
-" -K # Set verticalal margin of output page to # expressed in current units",
-" when sectioning image into columns x rows using the -S cols:rows option",
-" ",
-" -O orient orientation for output image, portrait, landscape, auto",
-" -P page page size for output image segments, eg letter, legal, tabloid, etc",
-" use #.#x#.# to specify a custom page size in the currently defined units",
-" where #.# represents the width and length",
-" -S cols:rows Divide the image into equal sized segments using cols across and rows down.",
-" ",
-" -F hor|vert|both",
-" flip (mirror) image or region horizontally, vertically, or both",
-" -R # [90,180,or 270] degrees clockwise rotation of image or extracted region",
-" -I [black|white|data|both]",
-" invert color space, eg dark to light for bilevel and grayscale images",
-" If argument is white or black, set the PHOTOMETRIC_INTERPRETATION ",
-" tag to MinIsBlack or MinIsWhite without altering the image data",
-" If the argument is data or both, the image data are modified:",
-" both inverts the data and the PHOTOMETRIC_INTERPRETATION tag,",
-" data inverts the data but not the PHOTOMETRIC_INTERPRETATION tag",
-" ",
-"-D opt1:value1,opt2:value2,opt3:value3:opt4:value4",
-" Debug/dump program progress and/or data to non-TIFF files.",
-" Options include the following and must be joined as a comma",
-" separate list. The use of this option is generally limited to",
-" program debugging and development of future options.",
-" ",
-" debug:N Display limited program progress indicators where larger N",
-" increase the level of detail. Note: Tiffcrop may be compiled with",
-" -DDEVELMODE to enable additional very low level debug reporting.",
-"",
-" Format:txt|raw Format any logged data as ASCII text or raw binary ",
-" values. ASCII text dumps include strings of ones and zeroes",
-" representing the binary values in the image data plus identifying headers.",
-" ",
-" level:N Specify the level of detail presented in the dump files.",
-" This can vary from dumps of the entire input or output image data to dumps",
-" of data processed by specific functions. Current range of levels is 1 to 3.",
-" ",
-" input:full-path-to-directory/input-dumpname",
-" ",
-" output:full-path-to-directory/output-dumpnaem",
-" ",
-" When dump files are being written, each image will be written to a separate",
-" file with the name built by adding a numeric sequence value to the dumpname",
-" and an extension of .txt for ASCII dumps or .bin for binary dumps.",
-" ",
-" The four debug/dump options are independent, though it makes little sense to",
-" specify a dump file without specifying a detail level.",
-" ",
-NULL
-};
+"\n"
+"Page and selection options:\n"
+" -N odd|even|#,#-#,#|last sequences and ranges of images within file to process\n"
+" The words odd or even may be used to specify all odd or even numbered images.\n"
+" The word last may be used in place of a number in the sequence to indicate.\n"
+" The final image in the file without knowing how many images there are.\n"
+" Numbers are counted from one even though TIFF IFDs are counted from zero.\n"
+"\n"
+" -E t|l|r|b edge to use as origin for width and length of crop region\n"
+" -U units [in, cm, px ] inches, centimeters or pixels\n"
+" \n"
+" -m #,#,#,# margins from edges for selection: top, left, bottom, right separated by commas\n"
+" -X # horizontal dimension of region to extract expressed in current units\n"
+" -Y # vertical dimension of region to extract expressed in current units\n"
+" -Z #:#,#:# zones of the image designated as position X of Y,\n"
+" eg 1:3 would be first of three equal portions measured from reference edge\n"
+" -z x1,y1,x2,y2:...:xN,yN,xN+1,yN+1\n"
+" regions of the image designated by upper left and lower right coordinates\n"
+"\n"
+"Export grouping options:\n"
+" -e c|d|i|m|s export mode for images and selections from input images.\n"
+" When exporting a composite image from multiple zones or regions\n"
+" (combined and image modes), the selections must have equal sizes\n"
+" for the axis perpendicular to the edge specified with -E.\n"
+" c|combined All images and selections are written to a single file (default).\n"
+" with multiple selections from one image combined into a single image.\n"
+" d|divided All images and selections are written to a single file\n"
+" with each selection from one image written to a new image.\n"
+" i|image Each input image is written to a new file (numeric filename sequence)\n"
+" with multiple selections from the image combined into one image.\n"
+" m|multiple Each input image is written to a new file (numeric filename sequence)\n"
+" with each selection from the image written to a new image.\n"
+" s|separated Individual selections from each image are written to separate files.\n"
+"\n"
+"Output options:\n"
+" -H # Set horizontal resolution of output images to #\n"
+" -V # Set vertical resolution of output images to #\n"
+" -J # Set horizontal margin of output page to # expressed in current units\n"
+" when sectioning image into columns x rows using the -S cols:rows option\n"
+" -K # Set verticalal margin of output page to # expressed in current units\n"
+" when sectioning image into columns x rows using the -S cols:rows option\n"
+" \n"
+" -O orient orientation for output image, portrait, landscape, auto\n"
+" -P page page size for output image segments, eg letter, legal, tabloid, etc\n"
+" use #.#x#.# to specify a custom page size in the currently defined units\n"
+" where #.# represents the width and length\n"
+" -S cols:rows Divide the image into equal sized segments using cols across and rows down.\n"
+"\n"
+" -F hor|vert|both\n"
+" flip (mirror) image or region horizontally, vertically, or both\n"
+" -R # [90,180,or 270] degrees clockwise rotation of image or extracted region\n"
+" -I [black|white|data|both]\n"
+" invert color space, eg dark to light for bilevel and grayscale images\n"
+" If argument is white or black, set the PHOTOMETRIC_INTERPRETATION \n"
+" tag to MinIsBlack or MinIsWhite without altering the image data\n"
+" If the argument is data or both, the image data are modified:\n"
+" both inverts the data and the PHOTOMETRIC_INTERPRETATION tag,\n"
+" data inverts the data but not the PHOTOMETRIC_INTERPRETATION tag\n"
+"\n"
+"-D opt1:value1,opt2:value2,opt3:value3:opt4:value4\n"
+" Debug/dump program progress and/or data to non-TIFF files.\n"
+" Options include the following and must be joined as a comma\n"
+" separate list. The use of this option is generally limited to\n"
+" program debugging and development of future options.\n"
+"\n"
+" debug:N Display limited program progress indicators where larger N\n"
+" increase the level of detail. Note: Tiffcrop may be compiled with\n"
+" -DDEVELMODE to enable additional very low level debug reporting.\n"
+"\n"
+" Format:txt|raw Format any logged data as ASCII text or raw binary \n"
+" values. ASCII text dumps include strings of ones and zeroes\n"
+" representing the binary values in the image data plus identifying headers.\n"
+"\n"
+" level:N Specify the level of detail presented in the dump files.\n"
+" This can vary from dumps of the entire input or output image data to dumps\n"
+" of data processed by specific functions. Current range of levels is 1 to 3.\n"
+"\n"
+" input:full-path-to-directory/input-dumpname\n"
+"\n"
+" output:full-path-to-directory/output-dumpnaem\n"
+"\n"
+" When dump files are being written, each image will be written to a separate\n"
+" file with the name built by adding a numeric sequence value to the dumpname\n"
+" and an extension of .txt for ASCII dumps or .bin for binary dumps.\n"
+"\n"
+" The four debug/dump options are independent, though it makes little sense to\n"
+" specify a dump file without specifying a detail level.\n"
+"\n"
+;
/* This function could be modified to pass starting sample offset
* and number of samples as args to select fewer than spp
@@ -1515,15 +1514,13 @@ processCompressOptions(char* opt)
static void
usage(int code)
- {
- int i;
- FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr;
+{
+ FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr;
- fprintf(out, "\n%s\n", TIFFGetVersion());
- for (i = 0; usage_info[i] != NULL; i++)
- fprintf(out, "%s\n", usage_info[i]);
- exit(code);
- }
+ fprintf(out, "\n%s\n", TIFFGetVersion());
+ fprintf(out, "%s", usage_info);
+ exit(code);
+}
#define CopyField(tag, v) \
if (TIFFGetField(in, tag, &v)) TIFFSetField(out, tag, v)
@@ -1589,7 +1586,7 @@ cpTag(TIFF* in, TIFF* out, uint16 tag, uint16 count, TIFFDataType type)
}
}
-static struct cpTag {
+static const struct cpTag {
uint16 tag;
uint16 count;
TIFFDataType type;
@@ -5013,7 +5010,7 @@ static int
get_page_geometry (char *name, struct pagedef *page)
{
char *ptr;
- int n;
+ unsigned int n;
for (ptr = name; *ptr; ptr++)
*ptr = (char)tolower((int)*ptr);
@@ -7122,7 +7119,7 @@ writeSingleSection(TIFF *in, TIFF *out, struct image_data *image,
uint16 bps, spp;
uint16 input_compression, input_photometric;
uint16 input_planar;
- struct cpTag* p;
+ const struct cpTag* p;
/* Calling this seems to reset the compression mode on the TIFF *in file.
TIFFGetField(in, TIFFTAG_JPEGCOLORMODE, &input_jpeg_colormode);
@@ -7799,7 +7796,7 @@ writeCroppedImage(TIFF *in, TIFF *out, struct image_data *image,
uint16 bps, spp;
uint16 input_compression, input_photometric;
uint16 input_planar;
- struct cpTag* p;
+ const struct cpTag* p;
input_compression = image->compression;
input_photometric = image->photometric;
diff --git a/tools/tiffdither.c b/tools/tiffdither.c
index 9ed761dd..599c7dfa 100644
--- a/tools/tiffdither.c
+++ b/tools/tiffdither.c
@@ -309,51 +309,48 @@ main(int argc, char* argv[])
return (EXIT_SUCCESS);
}
-static const char* usage_info[] = {
-"usage: tiffdither [options] input.tif output.tif",
-"where options are:",
-" -r # make each strip have no more than # rows",
-" -t # set the threshold value for dithering (default 128)",
-" -f lsb2msb force lsb-to-msb FillOrder for output",
-" -f msb2lsb force msb-to-lsb FillOrder for output",
-"",
+static const char usage_info[] =
+"usage: tiffdither [options] input.tif output.tif\n"
+"where options are:\n"
+" -r # make each strip have no more than # rows\n"
+" -t # set the threshold value for dithering (default 128)\n"
+" -f lsb2msb force lsb-to-msb FillOrder for output\n"
+" -f msb2lsb force msb-to-lsb FillOrder for output\n"
+"\n"
#ifdef LZW_SUPPORT
-" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding",
-" # set predictor value",
-" For example, -c lzw:2 for LZW-encoded data with horizontal differencing",
+" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding\n"
+" # set predictor value\n"
+" For example, -c lzw:2 for LZW-encoded data with horizontal differencing\n"
#endif
#ifdef ZIP_SUPPORT
-" -c zip[:opts] compress output with deflate encoding",
-" # set predictor value",
+" -c zip[:opts] compress output with deflate encoding\n"
+" # set predictor value\n"
#endif
#ifdef PACKBITS_SUPPORT
-" -c packbits compress output with packbits encoding",
+" -c packbits compress output with packbits encoding\n"
#endif
#ifdef CCITT_SUPPORT
-" -c g3[:opts] compress output with CCITT Group 3 encoding",
-" Group 3 options:",
-" 1d use default CCITT Group 3 1D-encoding",
-" 2d use optional CCITT Group 3 2D-encoding",
-" fill byte-align EOL codes",
-" For example, -c g3:2d:fill for G3-2D-encoded data with byte-aligned EOLs",
-" -c g4 compress output with CCITT Group 4 encoding",
+" -c g3[:opts] compress output with CCITT Group 3 encoding\n"
+" Group 3 options:\n"
+" 1d use default CCITT Group 3 1D-encoding\n"
+" 2d use optional CCITT Group 3 2D-encoding\n"
+" fill byte-align EOL codes\n"
+" For example, -c g3:2d:fill for G3-2D-encoded data with byte-aligned EOLs\n"
+" -c g4 compress output with CCITT Group 4 encoding\n"
#endif
#if defined(LZW_SUPPORT) || defined(ZIP_SUPPORT) || defined(PACKBITS_SUPPORT) || defined(CCITT_SUPPORT)
-" -c none use no compression algorithm on output",
+" -c none use no compression algorithm on output\n"
#endif
-"",
-NULL
-};
+"\n"
+;
static void
usage(int code)
{
- int i;
FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr;
fprintf(out, "%s\n\n", TIFFGetVersion());
- for (i = 0; usage_info[i] != NULL; i++)
- fprintf(out, "%s\n", usage_info[i]);
+ fprintf(out, "%s", usage_info);
exit(code);
}
diff --git a/tools/tiffdump.c b/tools/tiffdump.c
index 00be9dd4..b0020593 100644
--- a/tools/tiffdump.c
+++ b/tools/tiffdump.c
@@ -73,33 +73,39 @@ static union
TIFFHeaderBig big;
TIFFHeaderCommon common;
} hdr;
-char* appname;
-char* curfile;
-int swabflag;
-int bigendian;
-int bigtiff;
-uint32 maxitems = 24; /* maximum indirect data items to print */
-
-const char* bytefmt = "%s%#02x"; /* BYTE */
-const char* sbytefmt = "%s%d"; /* SBYTE */
-const char* shortfmt = "%s%u"; /* SHORT */
-const char* sshortfmt = "%s%d"; /* SSHORT */
-const char* longfmt = "%s%lu"; /* LONG */
-const char* slongfmt = "%s%ld"; /* SLONG */
-const char* ifdfmt = "%s%#04lx"; /* IFD offset */
+static char* appname;
+static char* curfile;
+static int swabflag;
+static int bigendian;
+static int bigtiff;
+static uint32 maxitems = 24; /* maximum indirect data items to print */
+
+static const char bytefmt[] = "%s%#02x"; /* BYTE */
+static const char sbytefmt[] = "%s%d"; /* SBYTE */
+static const char shortfmtd[] = "%s%u"; /* SHORT */
+static const char shortfmth[] = "%s%#x";
+static const char sshortfmtd[] = "%s%d"; /* SSHORT */
+static const char sshortfmth[] = "%s%#x";
+static const char longfmtd[] = "%s%lu"; /* LONG */
+static const char longfmth[] = "%s%#lx";
+static const char slongfmtd[] = "%s%ld"; /* SLONG */
+static const char slongfmth[] = "%s%#lx";
+static const char ifdfmt[] = "%s%#04lx"; /* IFD offset */
#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
-const char* long8fmt = "%s%I64u"; /* LONG8 */
-const char* slong8fmt = "%s%I64d"; /* SLONG8 */
-const char* ifd8fmt = "%s%#08I64x"; /* IFD offset8*/
+static const char long8fmt[] = "%s%I64u"; /* LONG8 */
+static const char slong8fmt[] = "%s%I64d"; /* SLONG8 */
+static const char ifd8fmt[] = "%s%#08I64x"; /* IFD offset8*/
#else
-const char* long8fmt = "%s%llu"; /* LONG8 */
-const char* slong8fmt = "%s%lld"; /* SLONG8 */
-const char* ifd8fmt = "%s%#08llx"; /* IFD offset8*/
+static const char long8fmt[] = "%s%llu"; /* LONG8 */
+static const char slong8fmt[] = "%s%lld"; /* SLONG8 */
+static const char ifd8fmt[] = "%s%#08llx"; /* IFD offset8 */
#endif
-const char* rationalfmt = "%s%g"; /* RATIONAL */
-const char* srationalfmt = "%s%g"; /* SRATIONAL */
-const char* floatfmt = "%s%g"; /* FLOAT */
-const char* doublefmt = "%s%g"; /* DOUBLE */
+static const char rationalfmt[] = "%s%g"; /* RATIONAL */
+static const char srationalfmt[] = "%s%g"; /* SRATIONAL */
+static const char floatfmt[] = "%s%g"; /* FLOAT */
+static const char doublefmt[] = "%s%g"; /* DOUBLE */
+
+unsigned int hex_mode;
static void dump(int, uint64);
@@ -122,16 +128,14 @@ main(int argc, char* argv[])
int multiplefiles = (argc > 1);
int c;
uint64 diroff = 0;
+ hex_mode=0;
bigendian = (*(char *)&one == 0);
appname = argv[0];
while ((c = getopt(argc, argv, "m:o:h")) != -1) {
switch (c) {
- case 'h': /* print values in hex */
- shortfmt = "%s%#x";
- sshortfmt = "%s%#x";
- longfmt = "%s%#lx";
- slongfmt = "%s%#lx";
+ case 'h': /* print values in hex */
+ hex_mode=1;
break;
case 'o':
diroff = (uint64) strtoul(optarg, NULL, 0);
@@ -740,19 +744,19 @@ PrintData(FILE* fd, uint16 type, uint32 count, unsigned char* data)
case TIFF_SHORT: {
uint16 *wp = (uint16*)data;
while (count-- > 0)
- fprintf(fd, shortfmt, sep, *wp++), sep = " ";
+ fprintf(fd, hex_mode ? shortfmth : shortfmtd, sep, *wp++), sep = " ";
break;
}
case TIFF_SSHORT: {
int16 *wp = (int16*)data;
while (count-- > 0)
- fprintf(fd, sshortfmt, sep, *wp++), sep = " ";
+ fprintf(fd, hex_mode ? sshortfmth : sshortfmtd, sep, *wp++), sep = " ";
break;
}
case TIFF_LONG: {
uint32 *lp = (uint32*)data;
while (count-- > 0) {
- fprintf(fd, longfmt, sep, (unsigned long) *lp++);
+ fprintf(fd, hex_mode ? longfmth : longfmtd, sep, (unsigned long) *lp++);
sep = " ";
}
break;
@@ -760,7 +764,7 @@ PrintData(FILE* fd, uint16 type, uint32 count, unsigned char* data)
case TIFF_SLONG: {
int32 *lp = (int32*)data;
while (count-- > 0)
- fprintf(fd, slongfmt, sep, (long) *lp++), sep = " ";
+ fprintf(fd, hex_mode ? slongfmth : slongfmtd, sep, (long) *lp++), sep = " ";
break;
}
case TIFF_LONG8: {
@@ -769,7 +773,7 @@ PrintData(FILE* fd, uint16 type, uint32 count, unsigned char* data)
uint64 val;
memcpy(&val, llp, sizeof(uint64));
llp ++;
- fprintf(fd, long8fmt, sep, val);
+ fprintf(fd, long8fmt, sep, (unsigned long long) val);
sep = " ";
}
break;
@@ -780,7 +784,7 @@ PrintData(FILE* fd, uint16 type, uint32 count, unsigned char* data)
int64 val;
memcpy(&val, llp, sizeof(int64));
llp ++;
- fprintf(fd, slong8fmt, sep, val);
+ fprintf(fd, slong8fmt, sep, (long long) val);
sep = " ";
}
break;
diff --git a/tools/tiffinfo.c b/tools/tiffinfo.c
index 2271c9d1..438911ae 100644
--- a/tools/tiffinfo.c
+++ b/tools/tiffinfo.c
@@ -172,34 +172,31 @@ main(int argc, char* argv[])
return (status);
}
-static const char* stuff[] = {
-"usage: tiffinfo [options] input...",
-"where options are:",
-" -D read data",
-" -i ignore read errors",
-" -c display data for grey/color response curve or colormap",
-" -d display raw/decoded image data",
-" -f lsb2msb force lsb-to-msb FillOrder for input",
-" -f msb2lsb force msb-to-lsb FillOrder for input",
-" -j show JPEG tables",
-" -o offset set initial directory offset",
-" -r read/display raw image data instead of decoded data",
-" -s display strip offsets and byte counts",
-" -w display raw data in words rather than bytes",
-" -z enable strip chopping",
-" -# set initial directory (first directory is # 0)",
-NULL
-};
+static const char usage_info[] =
+"usage: tiffinfo [options] input...\n"
+"where options are:\n"
+" -D read data\n"
+" -i ignore read errors\n"
+" -c display data for grey/color response curve or colormap\n"
+" -d display raw/decoded image data\n"
+" -f lsb2msb force lsb-to-msb FillOrder for input\n"
+" -f msb2lsb force msb-to-lsb FillOrder for input\n"
+" -j show JPEG tables\n"
+" -o offset set initial directory offset\n"
+" -r read/display raw image data instead of decoded data\n"
+" -s display strip offsets and byte counts\n"
+" -w display raw data in words rather than bytes\n"
+" -z enable strip chopping\n"
+" -# set initial directory (first directory is # 0)\n"
+;
static void
usage(int code)
{
- int i;
FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr;
fprintf(out, "%s\n\n", TIFFGetVersion());
- for (i = 0; stuff[i] != NULL; i++)
- fprintf(out, "%s\n", stuff[i]);
+ fprintf(out, "%s", usage_info);
exit(code);
}
diff --git a/tools/tiffmedian.c b/tools/tiffmedian.c
index f8b529ec..4f55b2e1 100644
--- a/tools/tiffmedian.c
+++ b/tools/tiffmedian.c
@@ -94,20 +94,20 @@ typedef struct {
int entries[MAX_CMAP_SIZE][2];
} C_cell;
-uint16 rm[MAX_CMAP_SIZE], gm[MAX_CMAP_SIZE], bm[MAX_CMAP_SIZE];
-int num_colors;
-uint32 histogram[B_LEN][B_LEN][B_LEN];
-Colorbox *freeboxes;
-Colorbox *usedboxes;
-C_cell **ColorCells;
-TIFF *in, *out;
-uint32 rowsperstrip = (uint32) -1;
-uint16 compression = (uint16) -1;
-uint16 bitspersample = 1;
-uint16 samplesperpixel;
-uint32 imagewidth;
-uint32 imagelength;
-uint16 predictor = 0;
+static uint16 rm[MAX_CMAP_SIZE], gm[MAX_CMAP_SIZE], bm[MAX_CMAP_SIZE];
+static int num_colors;
+static uint32 histogram[B_LEN][B_LEN][B_LEN];
+static Colorbox *freeboxes;
+static Colorbox *usedboxes;
+static C_cell **ColorCells;
+static TIFF *in, *out;
+static uint32 rowsperstrip = (uint32) -1;
+static uint16 compression = (uint16) -1;
+static uint16 bitspersample = 1;
+static uint16 samplesperpixel;
+static uint32 imagewidth;
+static uint32 imagelength;
+static uint16 predictor = 0;
static void get_histogram(TIFF*, Colorbox*);
static void splitbox(Colorbox*);
@@ -329,43 +329,40 @@ processCompressOptions(char* opt)
return (1);
}
-char* usage_info[] = {
-"usage: tiffmedian [options] input.tif output.tif",
-"where options are:",
-" -r # make each strip have no more than # rows",
-" -C # create a colormap with # entries",
-" -f use Floyd-Steinberg dithering",
-"",
+static const char usage_info[] =
+"usage: tiffmedian [options] input.tif output.tif\n"
+"where options are:\n"
+" -r # make each strip have no more than # rows\n"
+" -C # create a colormap with # entries\n"
+" -f use Floyd-Steinberg dithering\n"
+"\n"
#ifdef LZW_SUPPORT
-" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding",
-/* " LZW options:", */
-" # set predictor value",
-" For example, -c lzw:2 to get LZW-encoded data with horizontal differencing",
+" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding\n"
+/* " LZW options:" */
+" # set predictor value\n"
+" For example, -c lzw:2 to get LZW-encoded data with horizontal differencing\n"
#endif
#ifdef ZIP_SUPPORT
-" -c zip[:opts] compress output with deflate encoding",
-/* " Deflate (ZIP) options:", */
-" # set predictor value",
+" -c zip[:opts] compress output with deflate encoding\n"
+/* " Deflate (ZIP) options:" */
+" # set predictor value\n"
#endif
#ifdef PACKBITS_SUPPORT
-" -c packbits compress output with packbits encoding",
+" -c packbits compress output with packbits encoding\n"
#endif
#if defined(LZW_SUPPORT) || defined(ZIP_SUPPORT) || defined(PACKBITS_SUPPORT)
-" -c none use no compression algorithm on output",
+" -c none use no compression algorithm on output\n"
#endif
-"",
-NULL
-};
+"\n"
+;
static void
usage(int code)
{
- int i;
FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr;
fprintf(out, "%s\n\n", TIFFGetVersion());
- for (i = 0; usage_info[i] != NULL; i++)
- fprintf(out, "%s\n", usage_info[i]);
+ fprintf(out, "%s", usage_info);
exit(code);
}
diff --git a/tools/tiffset.c b/tools/tiffset.c
index 75cf45c0..c38c50a9 100644
--- a/tools/tiffset.c
+++ b/tools/tiffset.c
@@ -46,27 +46,24 @@
#define EXIT_FAILURE 1
#endif
-static const char* usageMsg[] = {
-"usage: tiffset [options] filename",
-"where options are:",
-" -s <tagname> [count] <value>... set the tag value",
-" -u <tagname> to unset the tag",
-" -d <dirno> set the directory",
-" -sd <diroff> set the subdirectory",
-" -sf <tagname> <filename> read the tag value from file (for ASCII tags only)",
-" -h this help screen",
-NULL
-};
+static const char usageMsg[] =
+"usage: tiffset [options] filename\n"
+"where options are:\n"
+" -s <tagname> [count] <value>... set the tag value\n"
+" -u <tagname> to unset the tag\n"
+" -d <dirno> set the directory\n"
+" -sd <diroff> set the subdirectory\n"
+" -sf <tagname> <filename> read the tag value from file (for ASCII tags only)\n"
+" -h this help screen\n"
+;
static void
usage(int code)
{
- int i;
FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr;
fprintf(out, "%s\n\n", TIFFGetVersion());
- for (i = 0; usageMsg[i]; i++)
- fprintf(out, "%s\n", usageMsg[i]);
+ fprintf(out, "%s", usageMsg);
exit(code);
}