diff options
Diffstat (limited to 'converter/pgm')
-rw-r--r-- | converter/pgm/bioradtopgm.c | 21 | ||||
-rw-r--r-- | converter/pgm/hipstopgm.c | 15 | ||||
-rw-r--r-- | converter/pgm/lispmtopgm.c | 2 | ||||
-rw-r--r-- | converter/pgm/pgmtofs.c | 24 |
4 files changed, 34 insertions, 28 deletions
diff --git a/converter/pgm/bioradtopgm.c b/converter/pgm/bioradtopgm.c index 471709c1..9acdf8a5 100644 --- a/converter/pgm/bioradtopgm.c +++ b/converter/pgm/bioradtopgm.c @@ -23,15 +23,12 @@ #define BYTE_TO_WORD(lsb,msb) (((BYTE) lsb) + (((BYTE) msb) << 8)) int -main( argc, argv ) - int argc; - char* argv[]; - { +main(int argc, char * argv[]) { FILE* ifp; gray* grayrow; - register gray* gP; + gray* gP; int argn, row, i; - register int col, val, val2; + int col, val, val2; int rows=0, cols=0, image_num= -1, image_count, byte_word, check_word; int maxval; BYTE buf[BIORAD_HEADER_LENGTH]; @@ -47,6 +44,18 @@ main( argc, argv ) if ( ISDIGIT( argv[argn][1] )) { image_num = atoi( (argv[argn]+1) ); + + /* TODO atoi() ignores errors. Should be: + + const char * error; + + pm_string_to_int( argv[argn]+1, &image_num, error); + + if (error) + pm_error("Invalid image number. %s", error); + else if (image_num < 0) + pm_error("Internal error: negative image number"); + */ } else pm_usage( usage ); diff --git a/converter/pgm/hipstopgm.c b/converter/pgm/hipstopgm.c index 17048ce7..1517eee1 100644 --- a/converter/pgm/hipstopgm.c +++ b/converter/pgm/hipstopgm.c @@ -53,11 +53,10 @@ read_line(FILE * const fd, static void -read_hips_header( fd, hP ) - FILE* fd; - struct HIPS_Header* hP; -{ - char buf[5000]; +read_hips_header(FILE* const fd, + struct HIPS_Header* const hP) { + + char buf[5000]; /* TODO Check if 5000 is sufficient */ /* Read and toss orig_name. */ read_line( fd, buf, 5000 ); @@ -74,7 +73,7 @@ read_hips_header( fd, hP ) /* Read rows. */ read_line( fd, buf, 5000 ); - hP->rows = atoi( buf ); + hP->rows = atoi( buf ); /* TODO Use pm_string_to_int() instead of atoi() */ /* Read cols. */ read_line( fd, buf, 5000 ); @@ -107,9 +106,9 @@ main(int argc, char * argv[]) { FILE* ifp; gray* grayrow; - register gray* gP; + gray* gP; int argn, row; - register int col; + int col; int maxval; int rows, cols; struct HIPS_Header h; diff --git a/converter/pgm/lispmtopgm.c b/converter/pgm/lispmtopgm.c index 29f280f3..56ae9e2b 100644 --- a/converter/pgm/lispmtopgm.c +++ b/converter/pgm/lispmtopgm.c @@ -138,7 +138,7 @@ getval(FILE * const ifP) { int -main(int argc, const char ** argv) { +main(int argc, const char * argv[]) { FILE * ifP; gray * grayrow; diff --git a/converter/pgm/pgmtofs.c b/converter/pgm/pgmtofs.c index 8780b35a..57ca79cc 100644 --- a/converter/pgm/pgmtofs.c +++ b/converter/pgm/pgmtofs.c @@ -12,25 +12,22 @@ #include "pgm.h" -static void putinit ARGS(( int cols, int rows, int bps )); -static void putitem ARGS(( void )); -static void putgray ARGS(( gray g )); -static void putrest ARGS(( void )); +static void putinit ( int const cols, int const rows, int const bps ); +static void putitem ( void ); +static void putgray ( gray const g ); +static void putrest ( void ); int -main( argc, argv ) - int argc; - char* argv[]; -{ +main(int argc, const char * argv[]) { FILE* ifp; gray** grays; - register gray* gP; + gray* gP; int argn, rows, cols, bps, padright, row, col; gray maxval, nmaxval; const char* const usage = "[pgmfile]"; - pgm_init( &argc, argv ); + pm_proginit(&argc, argv); argn = 1; @@ -87,8 +84,9 @@ main( argc, argv ) static int bitspersample, item, bitsperitem, bitshift, itemsperline, items; static void -putinit( cols, rows, bps ) - int cols, rows, bps; +putinit(int const cols, + int const rows, + int const bps) { printf( "FirstName: \n" ); printf( "LastName: \n" ); @@ -134,7 +132,7 @@ putitem( ) static void -putgray( gray g ) +putgray( gray const g ) { if ( bitsperitem == 8 ) putitem( ); |