diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2013-12-15 02:35:34 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2013-12-15 02:35:34 +0000 |
commit | 8fdd7e1f3bb3f57b5cf5ebe246582f0376aa1ded (patch) | |
tree | f6a825d3c581f4395a362e68d9a0154823d6fa48 /editor | |
parent | 32d86d4abad3eefe0f5c300290b4a94247011269 (diff) | |
download | netpbm-mirror-8fdd7e1f3bb3f57b5cf5ebe246582f0376aa1ded.tar.gz netpbm-mirror-8fdd7e1f3bb3f57b5cf5ebe246582f0376aa1ded.tar.xz netpbm-mirror-8fdd7e1f3bb3f57b5cf5ebe246582f0376aa1ded.zip |
cleanup
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@2063 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'editor')
-rw-r--r-- | editor/pnmshear.c | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/editor/pnmshear.c b/editor/pnmshear.c index 657f265d..99fa3026 100644 --- a/editor/pnmshear.c +++ b/editor/pnmshear.c @@ -1,4 +1,4 @@ -/* pnmshear.c - read a portable anymap and shear it by some angle + /* pnmshear.c - read a portable anymap and shear it by some angle ** ** Copyright (C) 1989, 1991 by Jef Poskanzer. ** @@ -17,6 +17,7 @@ #include <string.h> #include "pm_c_util.h" +#include "mallocvar.h" #include "ppm.h" #include "pnm.h" #include "shhopt.h" @@ -24,11 +25,13 @@ #define SCALE 4096 #define HALFSCALE 2048 -struct cmdline_info { + + +struct CmdlineInfo { /* All the information the user supplied in the command line, in a form easy for the program to use. */ - const char * input_filespec; /* Filespec of input file */ + const char * inputFileName; /* Name of input file */ double angle; /* requested shear angle, in radians */ unsigned int noantialias; /* -noantialias option */ const char * background; /* NULL if none */ @@ -37,15 +40,17 @@ struct cmdline_info { static void -parseCommandLine(int argc, char ** argv, - struct cmdline_info *cmdlineP) { +parseCommandLine(int argc, const char ** argv, + struct CmdlineInfo *cmdlineP) { optStruct3 opt; unsigned int option_def_index = 0; - optEntry *option_def = malloc(100*sizeof(optEntry)); + optEntry * option_def; unsigned int backgroundSpec; + MALLOCARRAY(option_def, 100); + OPTENT3(0, "noantialias", OPT_FLAG, NULL, &cmdlineP->noantialias, 0); OPTENT3(0, "background", OPT_STRING, &cmdlineP->background, &backgroundSpec, 0); @@ -54,7 +59,7 @@ parseCommandLine(int argc, char ** argv, opt.short_allowed = FALSE; opt.allowNegNum = TRUE; - pm_optParseOptions3(&argc, argv, opt, sizeof(opt), 0); + pm_optParseOptions3(&argc, (char **)argv, opt, sizeof(opt), 0); if (!backgroundSpec) cmdlineP->background = NULL; @@ -68,15 +73,16 @@ parseCommandLine(int argc, char ** argv, pm_error("Angle argument is not a valid floating point number: " "'%s'", argv[1]); if (argc-1 < 2) - cmdlineP->input_filespec = "-"; + cmdlineP->inputFileName = "-"; else { - cmdlineP->input_filespec = argv[2]; + cmdlineP->inputFileName = argv[2]; if (argc-1 > 2) pm_error("too many arguments (%d). " "The only arguments are shear angle and filespec.", argc-1); } } + free(option_def); } @@ -200,7 +206,7 @@ backgroundColor(const char * const backgroundColorName, int -main(int argc, char * argv[]) { +main(int argc, const char * argv[]) { FILE * ifP; xel * xelrow; @@ -212,13 +218,13 @@ main(int argc, char * argv[]) { xelval maxval, newmaxval; double shearfac; - struct cmdline_info cmdline; + struct CmdlineInfo cmdline; - pnm_init(&argc, argv); + pm_proginit(&argc, argv); parseCommandLine(argc, argv, &cmdline); - ifP = pm_openr(cmdline.input_filespec); + ifP = pm_openr(cmdline.inputFileName); pnm_readpnminit(ifP, &cols, &rows, &maxval, &format); xelrow = pnm_allocrow(cols); @@ -256,7 +262,7 @@ main(int argc, char * argv[]) { shearCols = (rows - row) * shearfac; shearRow(xelrow, cols, newxelrow, newcols, - shearCols, format, bgxel, !cmdline.noantialias); + shearCols, format, bgxel, !cmdline.noantialias); pnm_writepnmrow(stdout, newxelrow, newcols, newmaxval, newformat, 0); } @@ -266,3 +272,6 @@ main(int argc, char * argv[]) { return 0; } + + + |