about summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2014-12-18 23:59:11 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2014-12-18 23:59:11 +0000
commit6bf2d50668a3b969de135d04cbedd4c4b8eb34bd (patch)
tree47f63c57605566d18b3e589f96379458d93b18fe /lib
parent731bf1e2804a640fc0e62091ff654bd0748c52b6 (diff)
downloadnetpbm-mirror-6bf2d50668a3b969de135d04cbedd4c4b8eb34bd.tar.gz
netpbm-mirror-6bf2d50668a3b969de135d04cbedd4c4b8eb34bd.tar.xz
netpbm-mirror-6bf2d50668a3b969de135d04cbedd4c4b8eb34bd.zip
improve error message
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@2344 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'lib')
-rw-r--r--lib/libpbm2.c10
-rw-r--r--lib/libpgm1.c3
-rw-r--r--lib/libpnm1.c3
3 files changed, 11 insertions, 5 deletions
diff --git a/lib/libpbm2.c b/lib/libpbm2.c
index a8e4b0f6..a77fa0ae 100644
--- a/lib/libpbm2.c
+++ b/lib/libpbm2.c
@@ -87,10 +87,13 @@ pbm_readpbminit(FILE * const ifP,
                 int *  const rowsP,
                 int *  const formatP) {
 
-    *formatP = pm_readmagicnumber(ifP);
+    int realFormat;
 
-    switch (PAM_FORMAT_TYPE(*formatP)) {
+    realFormat = pm_readmagicnumber(ifP);
+
+    switch (PAM_FORMAT_TYPE(realFormat)) {
     case PBM_TYPE:
+        *formatP = realFormat;
         pbm_readpbminitrest(ifP, colsP, rowsP);
         break;
 
@@ -110,7 +113,8 @@ pbm_readpbminit(FILE * const ifP,
                  "to PBM with 'pamtopnm'");
         break;
     default:
-        pm_error("bad magic number - not a Netpbm file");
+        pm_error("bad magic number 0x%x - not a PPM, PGM, PBM, or PAM file",
+                 realFormat);
     }
     validateComputableSize(*colsP, *rowsP);
 }
diff --git a/lib/libpgm1.c b/lib/libpgm1.c
index 57344c16..de5aedde 100644
--- a/lib/libpgm1.c
+++ b/lib/libpgm1.c
@@ -167,7 +167,8 @@ pgm_readpgminit(FILE * const fileP,
         break;
 
     default:
-        pm_error("bad magic number - not a Netpbm file");
+        pm_error("bad magic number 0x%x - not a PPM, PGM, PBM, or PAM file",
+                 realFormat);
     }
     validateComputableSize(*colsP, *rowsP);
 }
diff --git a/lib/libpnm1.c b/lib/libpnm1.c
index 29fee13a..045b7afc 100644
--- a/lib/libpnm1.c
+++ b/lib/libpnm1.c
@@ -129,7 +129,8 @@ pnm_readpnminit(FILE *   const fileP,
     break;
 
     default:
-        pm_error("bad magic number - not a ppm, pgm, or pbm file");
+        pm_error("bad magic number 0x%x - not a PPM, PGM, PBM, or PAM file",
+                 realFormat);
     }
     validateComputableSize(*colsP, *rowsP);
 }