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 --- lib/libpbm2.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib/libpbm2.c') 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); } -- cgit 1.4.1