2004.11.03 19:19 "[Tiff] [PATCH] Fixed types in tif_next.c", by Edward Lam

Hi,

I'd like to submit a minor patch to fix tif_next,c's use of u_char and u_long. I'm upgrading from libtiff 3.4 to 3.7 under Windows XP and found that I needed replace these with (unsigned char) and (unsigned long) respectively. This is because I'm compiling with WIN32_AVOID_FILEIO but *not* using cygwin. When that is defined, it makes tiffio.h to not include windows.h from which these types can be found. However, comparing the sources between 3.4 and 3.7, it seems that these types have been removed everywhere already except for tif_next.c. Perhaps we forgot to sweep this file?

I've attached the patch which was generated from CVS head.

Thanks,

-Edward

Index: tif_next.c
===================================================================
RCS file: /cvs/maptools/cvsroot/libtiff/libtiff/tif_next.c,v
retrieving revision 1.4
diff -u -d -p -r1.4 tif_next.c
--- tif_next.c  19 Sep 2004 10:08:38 -0000      1.4
+++ tif_next.c  3 Nov 2004 19:13:15 -0000
@@ -34,7 +34,7 @@

 #define SETPIXEL(op, v) {                      \
        switch (npixels++ & 3) {                \
-       case 0: op[0]  = (u_char) ((v) << 6); break;    \
+       case 0: op[0]  = (unsigned char) ((v) << 6); break;     \
        case 1: op[0] |= (v) << 4; break;       \
        case 2: op[0] |= (v) << 2; break;       \
        case 3: *op++ |= (v);      break;       \
@@ -48,7 +48,7 @@
 static int
 NeXTDecode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s)
 {
-       register u_char *bp, *op;
+       register unsigned char *bp, *op;
        register tsize_t cc;
        register int n;
        tidata_t row;
@@ -63,7 +63,7 @@ NeXTDecode(TIFF* tif, tidata_t buf, tsiz
        for (op = buf, cc = occ; cc-- > 0;)
                *op++ = 0xff;

-       bp = (u_char *)tif->tif_rawcp;
+       bp = (unsigned char *)tif->tif_rawcp;
        cc = tif->tif_rawcc;
        scanline = tif->tif_scanlinesize;
        for (row = buf; (long)occ > 0; occ -= scanline, row += scanline) {
@@ -96,7 +96,7 @@ NeXTDecode(TIFF* tif, tidata_t buf, tsiz
                }
                default: {
                        register int npixels = 0, grey;
-                       u_long imagewidth = tif->tif_dir.td_imagewidth;
+                       unsigned long imagewidth = tif->tif_dir.td_imagewidth;

                        /*
                         * The scanline is composed of a sequence