about summary refs log tree commit diff
path: root/converter
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2013-11-24 17:32:19 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2013-11-24 17:32:19 +0000
commit52da16976da4d738c8a0bdd35959af91ff5ae0bf (patch)
tree7db7ad0c83e0395cac6d76a04a8d440312d1b617 /converter
parentca5af957777d572bdd9a462ef2e3d38905fd4a3d (diff)
downloadnetpbm-mirror-52da16976da4d738c8a0bdd35959af91ff5ae0bf.tar.gz
netpbm-mirror-52da16976da4d738c8a0bdd35959af91ff5ae0bf.tar.xz
netpbm-mirror-52da16976da4d738c8a0bdd35959af91ff5ae0bf.zip
Fix bug: some ascii85 filter output goes to stdout instead of *ofP
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@2036 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter')
-rw-r--r--converter/other/pnmtops.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/converter/other/pnmtops.c b/converter/other/pnmtops.c
index 115f9d29..5f5fcd7f 100644
--- a/converter/other/pnmtops.c
+++ b/converter/other/pnmtops.c
@@ -384,6 +384,17 @@ writeFile(const unsigned char * const buffer,
 
 
 
+static void
+writeFileChar(const char * const buffer,
+              size_t       const writeCt,
+              const char * const name,
+              FILE *       const ofP) {
+
+    writeFile((const unsigned char *)buffer, writeCt, name, ofP);
+}
+
+
+
 #define MAX_FILTER_CT 10
     /* The maximum number of filters this code is capable of applying */
 
@@ -769,7 +780,8 @@ ascii85Filter(FILE *          const ifP,
             ++count;
 
             if (value == 0 && count == 4) {
-                putchar('z');  /* Ascii85 encoding z exception */
+                writeFileChar("z", 1, "ASCII 85 filter", ofP);
+                    /* Ascii85 encoding z exception */
                 ++outcount;
                 count = 0;
             } else if (count == 4) {
@@ -779,15 +791,14 @@ ascii85Filter(FILE *          const ifP,
                 outbuff[1] = value % 85 + 33;
                 outbuff[0] = value / 85 + 33;
 
-                writeFile((const unsigned char *)outbuff, count + 1,
-                          "ASCII 85 filter", ofP);
+                writeFileChar(outbuff, count + 1, "ASCII 85 filter", ofP);
 
                 count = value = 0;
                 outcount += 5; 
             }
 
             if (outcount > 75) {
-                putchar('\n');
+                writeFileChar("\n", 1, "ASCII 85 filter", ofP);
                 outcount = 0;
             }
         }
@@ -803,8 +814,7 @@ ascii85Filter(FILE *          const ifP,
         outbuff[0] = value / 85 + 33;
         outbuff[count + 1] = '\n';
 
-        writeFile((const unsigned char *)outbuff, count + 2,
-                  "ASCII 85 filter", ofP);
+        writeFileChar(outbuff, count + 2, "ASCII 85 filter", ofP);
     }
 
     fclose(ifP);