about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2010-04-20 01:56:27 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2010-04-20 01:56:27 +0000
commit02cefc20e87ed0406131c4bf2e9b3648bc8adcf5 (patch)
treebce7b2c94dfc0e402de09756b280ec28a65a5233
parent939ec42422e7db7c56ff5f736c00565f1bf621ff (diff)
downloadnetpbm-mirror-02cefc20e87ed0406131c4bf2e9b3648bc8adcf5.tar.gz
netpbm-mirror-02cefc20e87ed0406131c4bf2e9b3648bc8adcf5.tar.xz
netpbm-mirror-02cefc20e87ed0406131c4bf2e9b3648bc8adcf5.zip
Release 10.47.12
git-svn-id: http://svn.code.sf.net/p/netpbm/code/stable@1194 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--converter/other/pnmtopalm/palmtopnm.c67
-rw-r--r--doc/HISTORY10
-rw-r--r--editor/pamscale.c1
-rw-r--r--lib/libpbmfont.c34
-rw-r--r--version.mk2
5 files changed, 96 insertions, 18 deletions
diff --git a/converter/other/pnmtopalm/palmtopnm.c b/converter/other/pnmtopalm/palmtopnm.c
index d6164680..7e4ca453 100644
--- a/converter/other/pnmtopalm/palmtopnm.c
+++ b/converter/other/pnmtopalm/palmtopnm.c
@@ -789,8 +789,8 @@ readRleRow(FILE *          const ifP,
         if (j + incount > bytesPerRow)
             pm_error("Bytes in RLE compressed row exceed bytes per row.  "
                      "Bytes per row is %u.  A run length of %u bytes "
-                     "pushes the bytes in this row up to %u bytes (and then"
-                     "we gave up.", bytesPerRow, incount, j + incount);
+                     "pushes the bytes in this row up to %u bytes (and then "
+                     "we gave up).", bytesPerRow, incount, j + incount);
         pm_readcharu(ifP, &inval);
         memset(palmrow + j, inval, incount);
         j += incount;
@@ -800,6 +800,52 @@ readRleRow(FILE *          const ifP,
 
 
 static void
+readPackBitsRow16(FILE *          const ifP,
+                  unsigned char * const palmrow,
+                  unsigned int    const bytesPerRow) {
+
+    /*  From the Palm OS Programmer's API Reference:
+  
+        Although the [...] spec is byte-oriented, the 16-bit algorithm is
+        identical [to the 8-bit algorithm]: just substitute "word" for "byte".
+    */
+    unsigned int j;
+
+    for (j = 0;  j < bytesPerRow; ) {
+        char incount;
+        pm_readchar(ifP, &incount);
+        if (incount < 0) { 
+            /* How do we handle incount == -128 ? */
+            unsigned int const runlength = (-incount + 1) * 2;
+            unsigned int k;
+            unsigned short inval;
+            pm_readlittleshortu(ifP, &inval);
+            for (k = 0; (k < runlength) && (j + k + 1 < bytesPerRow); k += 2) {
+                memcpy(palmrow + j + k, &inval, 2);
+            }
+            j += runlength;
+        } else {
+            /* We just read the stream of shorts as a stream of chars */
+            unsigned int const nonrunlength = (incount + 1) * 2;
+            unsigned int k;
+            for (k = 0; (k < nonrunlength) && (j + k < bytesPerRow); ++k) {
+                unsigned char inval;
+                pm_readcharu(ifP, &inval);
+                palmrow[j + k] = inval;
+            }
+            j += nonrunlength;
+        }
+        if (j > bytesPerRow) 
+            pm_error("Bytes in PackBits compressed row exceed bytes per row.  "
+                     "Bytes per row is %u.  "
+                     "The bytes in this row were pushed up to %u bytes "
+                     "(and then we gave up).", bytesPerRow, j);
+    }
+} 
+
+
+
+static void
 readPackBitsRow(FILE *          const ifP,
                 unsigned char * const palmrow,
                 unsigned int    const bytesPerRow) {
@@ -814,12 +860,13 @@ readPackBitsRow(FILE *          const ifP,
             unsigned int const runlength = -incount + 1;
             unsigned char inval;
             pm_readcharu(ifP, &inval);
-            memset(palmrow + j, inval, runlength);
+            if (j + runlength < bytesPerRow) 
+                memset(palmrow + j, inval, runlength);
             j += runlength;
         } else {
             unsigned int const nonrunlength = incount + 1;
             unsigned int k;
-            for (k = 0; k < nonrunlength; ++k) {
+            for (k = 0; k < nonrunlength && j + k < bytesPerRow; ++k) {
                 unsigned char inval;
                 pm_readcharu(ifP, &inval);
                 palmrow[j + k] = inval;
@@ -827,7 +874,10 @@ readPackBitsRow(FILE *          const ifP,
             j += nonrunlength;
         }
         if (j > bytesPerRow) 
-            pm_error("Bytes in PackBits compressed row exceed bytes per row.");
+            pm_error("Bytes in PackBits compressed row exceed bytes per row.  "
+                     "Bytes per row is %u.  "
+                     "The bytes in this row were pushed up to %u bytes "
+                     "(and then we gave up).", bytesPerRow, j);
     }
 } 
 
@@ -853,6 +903,7 @@ readDecompressedRow(FILE *                   const ifP,
                     unsigned char *          const lastrow,
                     enum palmCompressionType const compressionType,
                     unsigned int             const bytesPerRow,
+                    unsigned int             const pixelSize,
                     bool                     const firstRow) {
 /*----------------------------------------------------------------------------
    Read a row from Palm file 'ifP', in uncompressed form (i.e. decompress if
@@ -881,7 +932,10 @@ readDecompressedRow(FILE *                   const ifP,
         readScanlineRow(ifP, palmrow, lastrow, bytesPerRow, firstRow);
         break;
     case COMPRESSION_PACKBITS:
-        readPackBitsRow(ifP, palmrow, bytesPerRow);
+        if (pixelSize != 16)
+            readPackBitsRow(ifP, palmrow, bytesPerRow);
+        else
+            readPackBitsRow16(ifP, palmrow, bytesPerRow);
         break;
     case COMPRESSION_NONE:
         readUncompressedRow(ifP, palmrow, bytesPerRow);
@@ -1032,6 +1086,7 @@ writePnm(FILE *            const ofP,
         readDecompressedRow(ifP, palmrow, lastrow, 
                             palmHeader.compressionType, 
                             palmHeader.bytesPerRow,
+                            palmHeader.pixelSize,
                             row == 0);
 
         if (palmHeader.directColor) {
diff --git a/doc/HISTORY b/doc/HISTORY
index dde1f5b6..060ce00f 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -4,6 +4,16 @@ Netpbm.
 CHANGE HISTORY 
 --------------
 
+10.04.20 BJH  Release 10.47.12
+
+              palmtopnm: fix for pixel size 16.  Thanks Paul Bolle
+              <pebolle@tiscali.nl>.
+
+              pamscale: fix -reduce.  Introduced in 10.27.
+
+              pbmtext: fix crash when BDF font file contains spurious
+              blank line.  Ignore such blank lines.
+
 10.03.17 BJH  Release 10.47.11
 
               ppmtoilbm: fix arithmetic overflow with image dimension
diff --git a/editor/pamscale.c b/editor/pamscale.c
index 69861e0e..ab1e3be7 100644
--- a/editor/pamscale.c
+++ b/editor/pamscale.c
@@ -684,6 +684,7 @@ parseCommandLine(int argc,
     } else if (reduce != -1) {
         cmdlineP->scaleType = SCALE_SEPARATE;
         parseFilespecOnlyParms(argc, argv, cmdlineP);
+        cmdlineP->xsize = cmdlineP->ysize = 0;
         cmdlineP->xscale = cmdlineP->yscale = 
             ((double) 1.0) / ((double) reduce);
         pm_message("reducing by %d gives scale factor of %f.", 
diff --git a/lib/libpbmfont.c b/lib/libpbmfont.c
index 902eaf0d..ff75d0a1 100644
--- a/lib/libpbmfont.c
+++ b/lib/libpbmfont.c
@@ -1102,20 +1102,32 @@ mk_argvn(char *        const s,
 
 
 static int
-readline(FILE *        const fp,
-         char *        const buf,
-         const char ** const arg) {
+readline(FILE *        const ifP,
+         char *        const line,
+         const char ** const wordList) {
+/*----------------------------------------------------------------------------
+   Read a nonblank line from file *ifP.  Return the value of the whole line
+   in *buf (must be at least 1024 bytes long), and parse it into words
+   in *wordList (must have at least 32 entries).
 
-    int retval;
-    char * rc;
+   If there is no nonblank line before EOF, return rc == -1.
+-----------------------------------------------------------------------------*/
+    bool gotLine;
+    bool error;
 
-    rc = fgets(buf, 1024, fp);
-    if (rc == NULL)
-        retval = -1;
-    else
-        retval = mk_argvn(buf, arg, 32);
+    for (gotLine = false, error = false; !gotLine && !error; ) {
+        char * rc;
 
-    return retval;
+        rc = fgets(line, 1024, ifP);
+        if (rc == NULL)
+            error = true;
+        else {
+            mk_argvn(line, wordList, 32);
+            if (wordList[0] != NULL)
+                gotLine = true;
+        }
+    }
+    return error ? -1 : 0;
 }
 
 
diff --git a/version.mk b/version.mk
index bbe4efbd..55b55270 100644
--- a/version.mk
+++ b/version.mk
@@ -1,4 +1,4 @@
 NETPBM_MAJOR_RELEASE = 10
 NETPBM_MINOR_RELEASE = 47
-NETPBM_POINT_RELEASE = 10
+NETPBM_POINT_RELEASE = 12