libtiff: Merge branch 'rectify_some_shadowed_declarations' into 'master'

From 68d62c65a0833b938a18f7a499a82d2444b3db4e Mon Sep 17 00:00:00 2001
From: Su_Laus <[EMAIL REDACTED]>
Date: Fri, 3 Nov 2023 21:59:14 +0100
Subject: [PATCH] Rectify some shadowed declarations and warnings in tools and
 test modules.

---
 contrib/iptcutil/iptcutil.c             | 32 ++++-----
 test/rewrite_tag.c                      |  1 -
 test/test_directory.c                   |  2 +-
 test/test_transferfunction_write_read.c |  4 +-
 test/test_write_read_tags.c             | 22 +++----
 tools/tiffcp.c                          | 11 ++--
 tools/unsupported/tiff2ps.c             | 88 ++++++++++++-------------
 7 files changed, 80 insertions(+), 80 deletions(-)

diff --git a/contrib/iptcutil/iptcutil.c b/contrib/iptcutil/iptcutil.c
index 49d4fcd5..918c6f95 100644
--- a/contrib/iptcutil/iptcutil.c
+++ b/contrib/iptcutil/iptcutil.c
@@ -459,38 +459,38 @@ int main(int argc, char *argv[])
             {
                 if (state == 0)
                 {
-                    int state, next;
+                    int state2, next2;
 
-                    char brkused, quoted;
+                    char brkused2, quoted2;
 
-                    state = 0;
-                    next = 0;
+                    state2 = 0;
+                    next2 = 0;
                     while (tokenizer(0, newstr, inputlen, token, "", "#", "", 0,
-                                     &brkused, &next, &quoted) == 0)
+                                     &brkused2, &next2, &quoted2) == 0)
                     {
-                        if (state == 0)
+                        if (state2 == 0)
                             dataset = (unsigned char)atoi(newstr);
-                        else if (state == 1)
+                        else if (state2 == 1)
                             recnum = (unsigned char)atoi(newstr);
-                        state++;
+                        state2++;
                     }
                 }
                 else if (state == 1)
                 {
-                    int next;
+                    int next2;
 
                     unsigned long len;
 
-                    char brkused, quoted;
+                    char brkused2, quoted2;
 
-                    next = 0;
+                    next2 = 0;
                     len = (unsigned long)strlen(token);
                     while (tokenizer(0, newstr, inputlen, token, "", "&", "", 0,
-                                     &brkused, &next, &quoted) == 0)
+                                     &brkused2, &next2, &quoted2) == 0)
                     {
-                        if (brkused && next > 0)
+                        if (brkused2 && next2 > 0)
                         {
-                            char *s = &token[next - 1];
+                            char *s = &token[next2 - 1];
 
                             len -= convertHTMLcodes(s, (int)strlen(s));
                         }
@@ -511,9 +511,9 @@ int main(int argc, char *argv[])
                         fputc((len >> 8) & 255, ofile);
                         fputc(len & 255, ofile);
                     }
-                    next = 0;
+                    next2 = 0;
                     while (len--)
-                        fputc(token[next++], ofile);
+                        fputc(token[next2++], ofile);
                 }
                 state++;
             }
diff --git a/test/rewrite_tag.c b/test/rewrite_tag.c
index d91b76c2..77332526 100644
--- a/test/rewrite_tag.c
+++ b/test/rewrite_tag.c
@@ -39,7 +39,6 @@
 #include "tiffio.h"
 #include "tiffiop.h"
 
-const uint32_t length = 40;
 const uint32_t rows_per_strip = 1;
 
 int test_packbits()
diff --git a/test/test_directory.c b/test/test_directory.c
index 6cc3baf8..aaf29a2c 100644
--- a/test/test_directory.c
+++ b/test/test_directory.c
@@ -758,7 +758,7 @@ int test_SubIFD_directrory_handling(bool is_big_tiff)
     }
 
     tdir_t numberOfMainIFDs = TIFFNumberOfDirectories(tif);
-    if (numberOfMainIFDs != N_DIRECTORIES - number_of_sub_IFDs)
+    if (numberOfMainIFDs != (tdir_t)N_DIRECTORIES - number_of_sub_IFDs)
     {
         fprintf(stderr,
                 "Unexpected number of directories in %s. Expected %i, "
diff --git a/test/test_transferfunction_write_read.c b/test/test_transferfunction_write_read.c
index 8e4fa1ef..ec0952c7 100644
--- a/test/test_transferfunction_write_read.c
+++ b/test/test_transferfunction_write_read.c
@@ -39,7 +39,6 @@ const uint16_t bps = 8;
 const uint16_t photometric = PHOTOMETRIC_RGB;
 const uint16_t rows_per_strip = 100; /* up to 2**32-1 */
 const uint16_t planarconfig = PLANARCONFIG_CONTIG;
-const char *filename = "test_transferfunction_write_read.tif";
 
 /* Data and pointer to three transfer functions. */
 uint16_t *pTransferFunctionData;
@@ -266,6 +265,9 @@ int write_basic_IFD_data(TIFF **ptif, const char *filename, int wrtTransferFunct
 /*==== main() ====*/
 int main()
 {
+
+    const char *filename = "test_transferfunction_write_read.tif";
+
     if (setup_transfer_functions())
         return 1;
 
diff --git a/test/test_write_read_tags.c b/test/test_write_read_tags.c
index 227f6ba3..0bd5cca5 100644
--- a/test/test_write_read_tags.c
+++ b/test/test_write_read_tags.c
@@ -158,14 +158,14 @@ uint32_t listTagsNotFollowPasscountRules[] = {
 int check_tag_definitions(void);
 int write_test_tiff(TIFF *tif, const char *filenameRead);
 int write_all_tags(TIFF *tif, const TIFFFieldArray *tFieldArray,
-                   uint32_t *listTagsNotToWrite, uint32_t nTagsInList,
+                   uint32_t *plistTagsNotToWrite, uint32_t nTagsInList,
                    uint32_t *iCnt);
 int tagIsInList(uint32_t tTag, uint32_t *list, uint32_t nTagsInList);
 int testPasscountFlag(const char *szMsg, const TIFFFieldArray *tFieldArray,
-                      uint32_t *listTagsNotFollowPasscountRules,
+                      uint32_t *plistTagsNotFollowPasscountRules,
                       uint32_t nTagsInList);
 int read_all_tags(TIFF *tif, const TIFFFieldArray *tFieldArray,
-                  uint32_t *listTagsNotToWrite, uint32_t nTagsNotToWrite,
+                  uint32_t *plistTagsNotToWrite, uint32_t nTagsNotToWrite,
                   uint32_t *iCnt);
 
 /* ==== main() ========================================================
@@ -686,7 +686,7 @@ int write_test_tiff(TIFF *tif, const char *filenameRead)
  *
  */
 int testPasscountFlag(const char *szMsg, const TIFFFieldArray *tFieldArray,
-                      uint32_t *listTagsNotFollowPasscountRules,
+                      uint32_t *plistTagsNotFollowPasscountRules,
                       uint32_t nTagsInList)
 {
     uint32_t t;
@@ -699,7 +699,7 @@ int testPasscountFlag(const char *szMsg, const TIFFFieldArray *tFieldArray,
     for (t = 0; t < nTags; t++)
     {
         if (tagIsInList(tFieldArray->fields[t].field_tag,
-                        listTagsNotFollowPasscountRules, nTagsInList))
+                        plistTagsNotFollowPasscountRules, nTagsInList))
             continue;
 
         if (tFieldArray->fields[t].field_writecount !=
@@ -728,7 +728,7 @@ int testPasscountFlag(const char *szMsg, const TIFFFieldArray *tFieldArray,
     for (t = 0; t < nTags; t++)
     {
         if (tagIsInList(tFieldArray->fields[t].field_tag,
-                        listTagsNotFollowPasscountRules, nTagsInList))
+                        plistTagsNotFollowPasscountRules, nTagsInList))
             continue;
 
         if (tFieldArray->fields[t].field_writecount < 0)
@@ -828,7 +828,7 @@ int testPasscountFlag(const char *szMsg, const TIFFFieldArray *tFieldArray,
     for (t = 0; t < nTags; t++)
     {
         if (tagIsInList(tFieldArray->fields[t].field_tag,
-                        listTagsNotFollowPasscountRules, nTagsInList))
+                        plistTagsNotFollowPasscountRules, nTagsInList))
             continue;
 
         /* TIFF_SETGET_UNDEFINED tags FIELD_IGNORE tags are not written to file.
@@ -935,7 +935,7 @@ int testPasscountFlag(const char *szMsg, const TIFFFieldArray *tFieldArray,
  * iCnt is an index into predefined arrays for the values to write.
  */
 int write_all_tags(TIFF *tif, const TIFFFieldArray *tFieldArray,
-                   uint32_t *listTagsNotToWrite, uint32_t nTagsInList,
+                   uint32_t *plistTagsNotToWrite, uint32_t nTagsInList,
                    uint32_t *iCnt)
 {
 
@@ -950,7 +950,7 @@ int write_all_tags(TIFF *tif, const TIFFFieldArray *tFieldArray,
         uint32_t variableArrayCount = VARIABLE_ARRAY_SIZE;
 
         uint32_t tTag = tFieldArray->fields[t].field_tag;
-        if (tagIsInList(tTag, listTagsNotToWrite, nTagsInList))
+        if (tagIsInList(tTag, plistTagsNotToWrite, nTagsInList))
             continue;
 
         TIFFDataType tType =
@@ -1271,7 +1271,7 @@ int tagIsInList(uint32_t tTag, uint32_t *list, uint32_t nTagsInList)
  * The read values are compared to the written ones.
  */
 int read_all_tags(TIFF *tif, const TIFFFieldArray *tFieldArray,
-                  uint32_t *listTagsNotToWrite, uint32_t nTagsNotToWrite,
+                  uint32_t *plistTagsNotToWrite, uint32_t nTagsNotToWrite,
                   uint32_t *iCnt)
 {
 
@@ -1315,7 +1315,7 @@ int read_all_tags(TIFF *tif, const TIFFFieldArray *tFieldArray,
             tFieldArray->fields[t]
                 .set_field_type; /* e.g. TIFF_SETGET_C0_FLOAT */
         char *tFieldName = tFieldArray->fields[t].field_name;
-        if (tagIsInList(tTag, listTagsNotToWrite, nTagsNotToWrite))
+        if (tagIsInList(tTag, plistTagsNotToWrite, nTagsNotToWrite))
             continue;
 
         /*-- dependent on set_field_type read value --*/
diff --git a/tools/tiffcp.c b/tools/tiffcp.c
index 3f761feb..789b9724 100644
--- a/tools/tiffcp.c
+++ b/tools/tiffcp.c
@@ -1199,11 +1199,11 @@ typedef void biasFn(void *image, void *bias, uint32_t pixels);
     static void subtract##bits(void *i, void *b, uint32_t pixels)              \
     {                                                                          \
         uint##bits##_t *image = i;                                             \
-        uint##bits##_t *bias = b;                                              \
+        uint##bits##_t *biasx = b;                                             \
         while (pixels--)                                                       \
         {                                                                      \
-            *image = *image > *bias ? *image - *bias : 0;                      \
-            image++, bias++;                                                   \
+            *image = *image > *biasx ? *image - *biasx : 0;                    \
+            image++, biasx++;                                                  \
         }                                                                      \
     }
 
@@ -1854,7 +1854,7 @@ DECLAREreadFunc(readSeparateTilesIntoBuffer)
 
 DECLAREwriteFunc(writeBufferToContigStrips)
 {
-    uint32_t row, rowsperstrip;
+    uint32_t row;
     tstrip_t strip = 0;
 
     (void)imagewidth;
@@ -1879,7 +1879,6 @@ DECLAREwriteFunc(writeBufferToContigStrips)
 DECLAREwriteFunc(writeBufferToSeparateStrips)
 {
     uint32_t rowsize = imagewidth * spp;
-    uint32_t rowsperstrip;
     tsize_t stripsize = TIFFStripSize(out);
     tdata_t obuf;
     tstrip_t strip = 0;
@@ -1915,7 +1914,7 @@ DECLAREwriteFunc(writeBufferToSeparateStrips)
             uint32_t nrows = (row + rowsperstrip > imagelength)
                                  ? imagelength - row
                                  : rowsperstrip;
-            tsize_t stripsize = TIFFVStripSize(out, nrows);
+            stripsize = TIFFVStripSize(out, nrows);
 
             cpContigBufToSeparateBuf(obuf, (uint8_t *)buf + row * rowsize + s,
                                      nrows, imagewidth, 0, 0, spp,
diff --git a/tools/unsupported/tiff2ps.c b/tools/unsupported/tiff2ps.c
index 541495d2..e5425bfa 100644
--- a/tools/unsupported/tiff2ps.c
+++ b/tools/unsupported/tiff2ps.c
@@ -181,7 +181,7 @@
  * disabled when set to 0 */
 static tmsize_t maxMalloc = DEFAULT_MAX_MALLOC;
 
-int ascii85 = FALSE;        /* use ASCII85 encoding */
+int ascii85_g = FALSE;      /* use ASCII85 encoding */
 int interpolate = TRUE;     /* interpolate level2 image */
 int level2 = FALSE;         /* generate PostScript level 2 */
 int level3 = FALSE;         /* generate PostScript level 3 */
@@ -195,8 +195,8 @@ double maxPageHeight =
 double maxPageWidth =
     0; /* maximum width  to select from image and print per page */
 double splitOverlap = 0;  /* amount for split pages to overlag */
-int rotation = 0;         /* optional value for rotation angle */
-int auto_rotate = 0;      /* rotate image for best fit on the page */
+int rotation_g = 0;       /* optional value for rotation angle */
+int auto_rotate_g = 0;    /* rotate image for best fit on the page */
 char *filename = NULL;    /* input filename */
 char *title = NULL;       /* optional document title string */
 char *creator = NULL;     /* optional document creator string */
@@ -390,15 +390,15 @@ int main(int argc, char *argv[])
             case 'r':
                 if (strcmp(optarg, "auto") == 0)
                 {
-                    rotation = 0;
-                    auto_rotate = TRUE;
+                    rotation_g = 0;
+                    auto_rotate_g = TRUE;
                 }
                 else
                 {
-                    rotation = atoi(optarg);
-                    auto_rotate = FALSE;
+                    rotation_g = atoi(optarg);
+                    auto_rotate_g = FALSE;
                 }
-                switch (rotation)
+                switch (rotation_g)
                 {
                     case 0:
                     case 90:
@@ -426,18 +426,18 @@ int main(int argc, char *argv[])
             case '1':
                 level2 = FALSE;
                 level3 = FALSE;
-                ascii85 = FALSE;
+                ascii85_g = FALSE;
                 break;
             case '2':
                 level2 = TRUE;
-                ascii85 = TRUE; /* default to yes */
+                ascii85_g = TRUE; /* default to yes */
                 break;
             case '3':
                 level3 = TRUE;
-                ascii85 = TRUE; /* default to yes */
+                ascii85_g = TRUE; /* default to yes */
                 break;
             case '8':
-                ascii85 = FALSE;
+                ascii85_g = FALSE;
                 break;
             case 'x':
                 res_unit = RESUNIT_CENTIMETER;
@@ -467,7 +467,7 @@ int main(int argc, char *argv[])
     }
 
     /* auto rotate requires a specified page width and height */
-    if (auto_rotate == TRUE)
+    if (auto_rotate_g == TRUE)
     {
         /*
       if ((pageWidth == 0) || (pageHeight == 0))
@@ -1438,7 +1438,7 @@ int psMaskImage(FILE *fd, TIFF *tif, int rotation, int center, int *npages,
                 TIFFError("exportMaskedImage", "Invalid image parameters.");
                 return (-1);
             }
-            PSpage(fd, tif, pixwidth, pixheight);
+            PSpage(fd, tif, (uint32_t)pixwidth, (uint32_t)pixheight);
             fprintf(fd, "end\n");
             fprintf(fd, "grestore\n");
             fprintf(fd, "showpage\n");
@@ -1768,7 +1768,7 @@ int TIFF2PS(FILE *fd, TIFF *tif, double pgwidth, double pgheight, double lm,
         view_height = psheight;
 
         if (get_viewport(pgwidth, pgheight, pswidth, psheight, &view_width,
-                         &view_height, rotation))
+                         &view_height, rotation_g))
         {
             TIFFError("get_viewport", "Unable to set image viewport");
             return (1);
@@ -1776,9 +1776,9 @@ int TIFF2PS(FILE *fd, TIFF *tif, double pgwidth, double pgheight, double lm,
 
         /* Write the Postscript file header with Bounding Box and Page Size
          * definitions */
-        if (psStart(fd, npages, auto_rotate, &rotation, &scale, ox, oy, pgwidth,
-                    pgheight, view_width, view_height, pswidth, psheight,
-                    left_offset, bottom_offset))
+        if (psStart(fd, npages, auto_rotate_g, &rotation_g, &scale, ox, oy,
+                    pgwidth, pgheight, view_width, view_height, pswidth,
+                    psheight, left_offset, bottom_offset))
             return (-1);
 
         if (checkImage(tif)) /* Aborts if unsupported image parameters */
@@ -1792,7 +1792,7 @@ int TIFF2PS(FILE *fd, TIFF *tif, double pgwidth, double pgheight, double lm,
                 if ((maxPageHeight) ||
                     (maxPageWidth)) /* used -H or -W  option */
                 {
-                    if (psMaskImage(fd, tif, rotation, center, &npages,
+                    if (psMaskImage(fd, tif, rotation_g, center, &npages,
                                     pixwidth, pixheight, left_offset,
                                     bottom_offset, pgwidth, pgheight, pswidth,
                                     psheight, scale) < 0)
@@ -1812,14 +1812,14 @@ int TIFF2PS(FILE *fd, TIFF *tif, double pgwidth, double pgheight, double lm,
                         if (!generateEPSF && (level2 || level3))
                         {
                             /* Write out the PageSize info for non EPS files */
-                            if (psPageSize(fd, rotation, pgwidth, pgheight,
+                            if (psPageSize(fd, rotation_g, pgwidth, pgheight,
                                            view_width, view_height, pswidth,
                                            psheight))
                                 return (-1);
                         }
                         fprintf(fd, "gsave\n");
                         fprintf(fd, "100 dict begin\n");
-                        if (psScaleImage(fd, scale, rotation, center,
+                        if (psScaleImage(fd, scale, rotation_g, center,
                                          view_width, view_height, pswidth,
                                          psheight, left_offset, bottom_offset))
                             return (-1);
@@ -1839,14 +1839,14 @@ int TIFF2PS(FILE *fd, TIFF *tif, double pgwidth, double pgheight, double lm,
                 if (!generateEPSF && (level2 || level3))
                 {
                     /* Write out the PageSize info for non EPS files */
-                    if (psPageSize(fd, rotation, pgwidth, pgheight, view_width,
-                                   view_height, pswidth, psheight))
+                    if (psPageSize(fd, rotation_g, pgwidth, pgheight,
+                                   view_width, view_height, pswidth, psheight))
                         return (-1);
                 }
                 fprintf(fd, "gsave\n");
                 fprintf(fd, "100 dict begin\n");
-                if (psRotateImage(fd, rotation, pswidth, psheight, left_offset,
-                                  bottom_offset))
+                if (psRotateImage(fd, rotation_g, pswidth, psheight,
+                                  left_offset, bottom_offset))
                     return (-1);
 
                 PSpage(fd, tif, pixwidth, pixheight);
@@ -1857,8 +1857,8 @@ int TIFF2PS(FILE *fd, TIFF *tif, double pgwidth, double pgheight, double lm,
         }
         if (generateEPSF)
             break;
-        if (auto_rotate)
-            rotation = 0.0;
+        if (auto_rotate_g)
+            rotation_g = 0;
         TIFFGetFieldDefaulted(tif, TIFFTAG_SUBFILETYPE, &subfiletype);
     } while (((subfiletype & FILETYPE_PAGE) || printAll) &&
              TIFFReadDirectory(tif));
@@ -2013,7 +2013,7 @@ static void PS_Lvl2colorspace(FILE *fd, TIFF *tif)
 #undef CVT
     }
     fprintf(fd, "[ /Indexed /DeviceRGB %d", num_colors - 1);
-    if (ascii85)
+    if (ascii85_g)
     {
         Ascii85Init();
         fputs("\n<~", fd);
@@ -2023,7 +2023,7 @@ static void PS_Lvl2colorspace(FILE *fd, TIFF *tif)
         fputs(" <", fd);
     for (i = 0; i < num_colors; i++)
     {
-        if (ascii85)
+        if (ascii85_g)
         {
             Ascii85Put((unsigned char)rmap[i], fd);
             Ascii85Put((unsigned char)gmap[i], fd);
@@ -2036,7 +2036,7 @@ static void PS_Lvl2colorspace(FILE *fd, TIFF *tif)
                     gmap[i], bmap[i]);
         }
     }
-    if (ascii85)
+    if (ascii85_g)
         Ascii85Flush(fd);
     else
         fputs(">\n", fd);
@@ -2111,7 +2111,7 @@ static int PS_Lvl2ImageDict(FILE *fd, TIFF *tif, uint32_t w, uint32_t h)
     /*
      * Output filter options and image dictionary.
      */
-    if (ascii85)
+    if (ascii85_g)
         fputs(" /im_stream currentfile /ASCII85Decode filter def\n", fd);
     fputs(" <<\n", fd);
     fputs("  /ImageType 1\n", fd);
@@ -2209,7 +2209,7 @@ static int PS_Lvl2ImageDict(FILE *fd, TIFF *tif, uint32_t w, uint32_t h)
     fputs("  /DataSource", fd);
     if (planarconfiguration == PLANARCONFIG_SEPARATE && samplesperpixel > 1)
         fputs(" [", fd);
-    if (ascii85)
+    if (ascii85_g)
         fputs(" im_stream", fd);
     else
         fputs(" currentfile /ASCIIHexDecode filter", fd);
@@ -2344,7 +2344,7 @@ static int PS_Lvl2ImageDict(FILE *fd, TIFF *tif, uint32_t w, uint32_t h)
     }
 
     fprintf(fd, "\n >> %s\n", imageOp);
-    if (ascii85)
+    if (ascii85_g)
         fputs(" im_stream status { im_stream flushfile } if\n", fd);
     if (repeat_count > 1)
     {
@@ -2463,7 +2463,7 @@ int PS_Lvl2page(FILE *fd, TIFF *tif, uint32_t w, uint32_t h)
     }
 
 #if defined(EXP_ASCII85ENCODER)
-    if (ascii85)
+    if (ascii85_g)
     {
         /*
          * Allocate a buffer to hold the ASCII85 encoded data.  Note
@@ -2489,7 +2489,7 @@ int PS_Lvl2page(FILE *fd, TIFF *tif, uint32_t w, uint32_t h)
     TIFFGetFieldDefaulted(tif, TIFFTAG_FILLORDER, &fillorder);
     for (chunk_no = 0; chunk_no < num_chunks; chunk_no++)
     {
-        if (ascii85)
+        if (ascii85_g)
             Ascii85Init();
         else
             breaklen = MAXLINE;
@@ -2517,7 +2517,7 @@ int PS_Lvl2page(FILE *fd, TIFF *tif, uint32_t w, uint32_t h)
         {
             TIFFError(filename, "Can't read %s %" PRIu32 ".",
                       tiled_image ? "tile" : "strip", chunk_no);
-            if (ascii85)
+            if (ascii85_g)
                 Ascii85Put('\0', fd);
         }
         /*
@@ -2561,7 +2561,7 @@ int PS_Lvl2page(FILE *fd, TIFF *tif, uint32_t w, uint32_t h)
             byte_count -= j;
         }
 
-        if (ascii85)
+        if (ascii85_g)
         {
 #if defined(EXP_ASCII85ENCODER)
             ascii85_l = Ascii85EncodeBlock(ascii85_p, 1, buf_data, byte_count);
@@ -2589,7 +2589,7 @@ int PS_Lvl2page(FILE *fd, TIFF *tif, uint32_t w, uint32_t h)
             }
         }
 
-        if (!ascii85)
+        if (!ascii85_g)
         {
             if (level2 || level3)
                 putc('>', fd);
@@ -2966,7 +2966,7 @@ void PSDataBW(FILE *fd, TIFF *tif, uint32_t w, uint32_t h)
     memset(tf_buf, 0, stripsize);
 
 #if defined(EXP_ASCII85ENCODER)
-    if (ascii85)
+    if (ascii85_g)
     {
         /*
          * Allocate a buffer to hold the ASCII85 encoded data.  Note
@@ -2989,7 +2989,7 @@ void PSDataBW(FILE *fd, TIFF *tif, uint32_t w, uint32_t h)
     }
 #endif
 
-    if (ascii85)
+    if (ascii85_g)
         Ascii85Init();
 
     for (s = 0; s < TIFFNumberOfStrips(tif); s++)
@@ -3015,7 +3015,7 @@ void PSDataBW(FILE *fd, TIFF *tif, uint32_t w, uint32_t h)
         {
             PS_FlipBytes(cp, cc);
         }
-        if (ascii85)
+        if (ascii85_g)
         {
 #if defined(EXP_ASCII85ENCODER)
             if (alpha)
@@ -3072,7 +3072,7 @@ void PSDataBW(FILE *fd, TIFF *tif, uint32_t w, uint32_t h)
         }
     }
 
-    if (!ascii85)
+    if (!ascii85_g)
     {
         if (level2 || level3)
             fputs(">\n", fd);
@@ -3129,7 +3129,7 @@ void PSRawDataBW(FILE *fd, TIFF *tif, uint32_t w, uint32_t h)
     }
 
 #if defined(EXP_ASCII85ENCODER)
-    if (ascii85)
+    if (ascii85_g)
     {
         /*
          * Allocate a buffer to hold the ASCII85 encoded data.  Note
@@ -3162,7 +3162,7 @@ void PSRawDataBW(FILE *fd, TIFF *tif, uint32_t w, uint32_t h)
         }
         if (fillorder == FILLORDER_LSB2MSB)
             TIFFReverseBits(tf_buf, cc);
-        if (!ascii85)
+        if (!ascii85_g)
         {
             for (cp = tf_buf; cc > 0; cc--)
             {