https://github.com/libsdl-org/libtiff/commit/a072029d933ba6cdfefb54d460405b3b75345fbc
From a072029d933ba6cdfefb54d460405b3b75345fbc Mon Sep 17 00:00:00 2001
From: Andrey Kiselev <[EMAIL REDACTED]>
Date: Fri, 2 Jul 2010 11:03:25 +0000
Subject: [PATCH] Use PrintData() function instead of PrintByte/Short/Long().
Should fix an issue reported at
http://bugzilla.maptools.org/show_bug.cgi?id=2116
---
tools/tiffdump.c | 91 ++++++------------------------------------------
1 file changed, 10 insertions(+), 81 deletions(-)
diff --git a/tools/tiffdump.c b/tools/tiffdump.c
index cce3a087..8f9461ce 100644
--- a/tools/tiffdump.c
+++ b/tools/tiffdump.c
@@ -1,4 +1,4 @@
-/* $Id: tiffdump.c,v 1.13.2.2 2010-06-21 19:18:07 bfriesen Exp $ */
+/* $Id: tiffdump.c,v 1.13.2.3 2010-07-02 11:03:25 dron Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@@ -252,9 +252,6 @@ static int TIFFFetchData(int, TIFFDirEntry*, void*);
static void PrintTag(FILE*, uint16);
static void PrintType(FILE*, uint16);
static void PrintData(FILE*, uint16, uint32, unsigned char*);
-static void PrintByte(FILE*, const char*, TIFFDirEntry*);
-static void PrintShort(FILE*, const char*, TIFFDirEntry*);
-static void PrintLong(FILE*, const char*, TIFFDirEntry*);
/*
* Read the next TIFF directory from a file
@@ -327,36 +324,22 @@ ReadDirectory(int fd, unsigned ix, off_t off)
switch (dp->tdir_type) {
case TIFF_FLOAT:
case TIFF_UNDEFINED:
- case TIFF_ASCII: {
- unsigned char data[4];
- _TIFFmemcpy(data, &dp->tdir_offset, 4);
- if (swabflag)
- TIFFSwabLong((uint32*) data);
- PrintData(stdout,
- dp->tdir_type, dp->tdir_count, data);
- break;
- }
+ case TIFF_ASCII:
case TIFF_BYTE:
- PrintByte(stdout, bytefmt, dp);
- break;
case TIFF_SBYTE:
- PrintByte(stdout, sbytefmt, dp);
- break;
case TIFF_SHORT:
- PrintShort(stdout, shortfmt, dp);
- break;
case TIFF_SSHORT:
- PrintShort(stdout, sshortfmt, dp);
- break;
case TIFF_LONG:
- PrintLong(stdout, longfmt, dp);
- break;
case TIFF_SLONG:
- PrintLong(stdout, slongfmt, dp);
- break;
- case TIFF_IFD:
- PrintLong(stdout, ifdfmt, dp);
+ case TIFF_IFD: {
+ unsigned char data[4];
+ _TIFFmemcpy(data, &dp->tdir_offset, 4);
+ if (swabflag)
+ TIFFSwabLong((uint32*) data);
+ PrintData(stdout,
+ dp->tdir_type, dp->tdir_count, data);
break;
+ }
}
} else {
unsigned char *data = (unsigned char *)_TIFFmalloc(space);
@@ -521,60 +504,6 @@ PrintType(FILE* fd, uint16 type)
}
#undef NTYPES
-static void
-PrintByte(FILE* fd, const char* fmt, TIFFDirEntry* dp)
-{
- char* sep = "";
-
- if (hdr.tiff_magic == TIFF_BIGENDIAN) {
- switch ((int)dp->tdir_count) {
- case 4: fprintf(fd, fmt, sep, dp->tdir_offset&0xff);
- sep = " ";
- case 3: fprintf(fd, fmt, sep, (dp->tdir_offset>>8)&0xff);
- sep = " ";
- case 2: fprintf(fd, fmt, sep, (dp->tdir_offset>>16)&0xff);
- sep = " ";
- case 1: fprintf(fd, fmt, sep, dp->tdir_offset>>24);
- }
- } else {
- switch ((int)dp->tdir_count) {
- case 4: fprintf(fd, fmt, sep, dp->tdir_offset>>24);
- sep = " ";
- case 3: fprintf(fd, fmt, sep, (dp->tdir_offset>>16)&0xff);
- sep = " ";
- case 2: fprintf(fd, fmt, sep, (dp->tdir_offset>>8)&0xff);
- sep = " ";
- case 1: fprintf(fd, fmt, sep, dp->tdir_offset&0xff);
- }
- }
-}
-
-static void
-PrintShort(FILE* fd, const char* fmt, TIFFDirEntry* dp)
-{
- char *sep = "";
-
- if (hdr.tiff_magic == TIFF_BIGENDIAN) {
- switch (dp->tdir_count) {
- case 2: fprintf(fd, fmt, sep, dp->tdir_offset&0xffff);
- sep = " ";
- case 1: fprintf(fd, fmt, sep, dp->tdir_offset>>16);
- }
- } else {
- switch (dp->tdir_count) {
- case 2: fprintf(fd, fmt, sep, dp->tdir_offset>>16);
- sep = " ";
- case 1: fprintf(fd, fmt, sep, dp->tdir_offset&0xffff);
- }
- }
-}
-
-static void
-PrintLong(FILE* fd, const char* fmt, TIFFDirEntry* dp)
-{
- fprintf(fd, fmt, "", (long) dp->tdir_offset);
-}
-
#include <ctype.h>
static void