Package: netpbm
Version: 2:10.0-10.1
Severity: normal
Tags: patch

In a file with multiple images, white space between the images is not
ignored. This means that instead of...

P1
2 2
01
10
P1
2 2
00
00
[eol]

The file must look like...

P1
2 2
01
10P1
2 2
00
00
[noeol]

... which is rather unexpected. In particular the requirement for no
final end-of-line is rather nasty. The following patch skips
white-space between images. Another possible improvement, in my mind,
would be to skip comments beginning with a # between images as well.

Cheers,
Shaun

--- netpbm-free-10.0.orig/pbm/libpm.c
+++ netpbm-free-10.0/pbm/libpm.c
@@ -20,6 +20,7 @@
  #include "shhopt.h"
 #include "pm.h"

+#include <ctype.h>
 #include <stdarg.h>
 #include <string.h>
 #include <errno.h>
@@ -829,8 +830,9 @@
  pm_nextimage(FILE * const file, int * const eofP) {

     int c;
-
-    c = getc(file);
+    do {
+        c = getc(file);
+    } while (isspace(c));
     if (c == EOF) {
         if (feof(file))
             *eofP = TRUE;

Reply via email to