From bb90be5f15cee8dcf80962ab482b7f07707332cd Mon Sep 17 00:00:00 2001 From: giraffedata Date: Sun, 9 Sep 2007 17:59:48 +0000 Subject: Make pbm_readpbminit() and pgm_readpgminit() recognize other Netpbm formats and issue special error message git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@410 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- lib/libpgm1.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'lib/libpgm1.c') diff --git a/lib/libpgm1.c b/lib/libpgm1.c index f615069d..34cc6392 100644 --- a/lib/libpgm1.c +++ b/lib/libpgm1.c @@ -122,11 +122,6 @@ pgm_readpgminit(FILE * const fileP, /* Check magic number. */ realFormat = pm_readmagicnumber(fileP); switch (PAM_FORMAT_TYPE(realFormat)) { - case PGM_TYPE: - *formatP = realFormat; - pgm_readpgminitrest(fileP, colsP, rowsP, maxvalP); - break; - case PBM_TYPE: *formatP = realFormat; pbm_readpbminitrest(fileP, colsP, rowsP); @@ -150,6 +145,15 @@ pgm_readpgminit(FILE * const fileP, *maxvalP = PGM_MAXMAXVAL; break; + case PGM_TYPE: + *formatP = realFormat; + pgm_readpgminitrest(fileP, colsP, rowsP, maxvalP); + break; + + case PPM_TYPE: + pm_error("Input file is a PPM, which this program cannot process. " + "You may want to convert it to PGM with 'ppmtopgm'"); + case PAM_TYPE: pnm_readpaminitrestaspnm(fileP, colsP, rowsP, maxvalP, formatP); @@ -159,7 +163,7 @@ pgm_readpgminit(FILE * const fileP, break; default: - pm_error("bad magic number - not a pgm or pbm file"); + pm_error("bad magic number - not a Netpbm file"); } validateComputableSize(*colsP, *rowsP); } -- cgit 1.4.1