From 6bf2d50668a3b969de135d04cbedd4c4b8eb34bd Mon Sep 17 00:00:00 2001 From: giraffedata Date: Thu, 18 Dec 2014 23:59:11 +0000 Subject: improve error message git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@2344 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- doc/HISTORY | 3 +++ lib/libpbm2.c | 10 +++++++--- lib/libpgm1.c | 3 ++- lib/libpnm1.c | 3 ++- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/doc/HISTORY b/doc/HISTORY index 1e0627a4..a078182b 100644 --- a/doc/HISTORY +++ b/doc/HISTORY @@ -25,6 +25,9 @@ not yet BJH Release 10.69.00 anytopnm: convert all images in a multi-image GIF instead of just the first. + + Improve "bad magic number" message from pbmXXX, and pgmXXX, and + pnmXXX programs. Fix bogus message from ppmXXX programs when the input is not (per the magic number) a Netpbm image. Introduced after 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); } -- cgit 1.4.1