about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2012-12-14 04:01:27 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2012-12-14 04:01:27 +0000
commit3ba9c81c29daf07cf339060bde7efc670e93cb8e (patch)
treebc19648e287afa1e6b08038c1a67b4d6fdd82553
parent7f5a12073d3a2b4b649f9ad6f7ef26998b9e8034 (diff)
downloadnetpbm-mirror-3ba9c81c29daf07cf339060bde7efc670e93cb8e.tar.gz
netpbm-mirror-3ba9c81c29daf07cf339060bde7efc670e93cb8e.tar.xz
netpbm-mirror-3ba9c81c29daf07cf339060bde7efc670e93cb8e.zip
Fix wrong string comparison: looks at only first 4 bytes of tuple type, making GRAYSCALE_ALPHA look like GRAYSCALE
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1810 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--doc/HISTORY7
-rw-r--r--lib/libpam.c12
2 files changed, 12 insertions, 7 deletions
diff --git a/doc/HISTORY b/doc/HISTORY
index daf78cd9..9577c850 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -15,10 +15,15 @@ not yet  BJH  Release 10.61.00
               metadata, small images do require loss of quality in order to
               get down to a compression ratio of 1.
 
+              libpam, pamcomp: fix bug: treats tuple type GRAYSCALE_ALPHA like
+              GRAYSCALE on 32-bit machine.  Actually, looks only at first 4
+              characters (8 characters on machine with 64 bit addressess) of
+              the tuple type.  Broken since 10.56 (September 2011).
+
               pngtopam -alphapam with grayscale input: fix bug: generates
               invalid output: tuple type GRAYSCALE_ALPHA, but depth 1.  Depth
               should be 2.  Always broken (pngtopam was created in 
-              Netpbm 10.44 (September 2008).
+              Netpbm 10.44 (September 2008)).
               
               pamtotiff: fix bug: XRESOLUTION, YRESOLUTION, and RESOLUTIONUNIT
               not allowed in -tags.  Broken at least since 10.35.
diff --git a/lib/libpam.c b/lib/libpam.c
index 545b928f..b4aaeb95 100644
--- a/lib/libpam.c
+++ b/lib/libpam.c
@@ -805,7 +805,7 @@ interpretTupleType(struct pam * const pamP) {
 
     switch (PAM_FORMAT_TYPE(pamP->format)) {
     case PAM_TYPE: {
-        if (STRSEQ(tupleType, "BLACKANDWHITE")) {
+        if (streq(tupleType, "BLACKANDWHITE")) {
             visual = true;
             colorDepth = 1;
             haveOpacity = false;
@@ -813,22 +813,22 @@ interpretTupleType(struct pam * const pamP) {
                 pm_error("maxval %u is not consistent with tuple type "
                          "BLACKANDWHITE (should be 1)",
                          (unsigned)pamP->maxval);
-        } else if (STRSEQ(tupleType, "GRAYSCALE")) {
+        } else if (streq(tupleType, "GRAYSCALE")) {
             visual = true;
             colorDepth = 1;
             haveOpacity = false;
-        } else if (STRSEQ(tupleType, "GRAYSCALE_ALPHA")) {
+        } else if (streq(tupleType, "GRAYSCALE_ALPHA")) {
             visual = true;
             colorDepth = 1;
             haveOpacity = true;
             opacityPlane = PAM_GRAY_TRN_PLANE;
             validateMinDepth(pamP, 2);
-        } else if (STRSEQ(tupleType, "RGB")) {
+        } else if (streq(tupleType, "RGB")) {
             visual = true;
             colorDepth = 3;
             haveOpacity = false;
             validateMinDepth(pamP, 3);
-        } else if (STRSEQ(tupleType, "RGB_ALPHA")) {
+        } else if (streq(tupleType, "RGB_ALPHA")) {
             visual = true;
             colorDepth = 3;
             haveOpacity = true;
@@ -1294,7 +1294,7 @@ pnm_getopacity(const struct pam * const pamP,
                bool *             const haveOpacityP,
                unsigned int *     const opacityPlaneP) {
 
-    /* Usage note: this is obsolete since we added 'haveOpacity', etc.
+    /* Usage note: this is obsolete since we added 'have_opacity', etc.
        to struct pam.
     */
     if (streq(pamP->tuple_type, "RGB_ALPHA")) {