diff options
-rw-r--r-- | converter/other/pamtosvg/curve.h | 11 | ||||
-rw-r--r-- | converter/other/pamtosvg/fit.c | 9 | ||||
-rw-r--r-- | converter/ppm/ppmtoarbtxt.c | 82 | ||||
-rw-r--r-- | generator/pbmtextps.c | 95 |
4 files changed, 84 insertions, 113 deletions
diff --git a/converter/other/pamtosvg/curve.h b/converter/other/pamtosvg/curve.h index d251df84..ba5f1833 100644 --- a/converter/other/pamtosvg/curve.h +++ b/converter/other/pamtosvg/curve.h @@ -69,17 +69,6 @@ typedef struct curve * curve_type; ? CURVE_CYCLIC (c) ? (signed int) CURVE_LENGTH (c) + (signed int) (n) - 1 : -1\ : (signed int) (n) - 1) -static __inline__ vector_type -curve_slope_none(void) { - vector_type const retval = {0.0, 0.0, 0.0}; - return retval; -} - -static bool -curve_slope_is_present(vector_type const slope) { - return slope.dx != 0.0 || slope.dy != 0.0; -} - #define PREVIOUS_CURVE(c) ((c)->previous) #define NEXT_CURVE(c) ((c)->next) diff --git a/converter/other/pamtosvg/fit.c b/converter/other/pamtosvg/fit.c index cd659e9c..4b43fbf0 100644 --- a/converter/other/pamtosvg/fit.c +++ b/converter/other/pamtosvg/fit.c @@ -1738,12 +1738,13 @@ divideAndFit(curve * const curveP, -----------------------------------------------------------------------------*/ spline_list_type * retval; curve * leftCurveP; - // The beginning (lower indexes) subcurve + /* The beginning (lower indexes) subcurve */ curve * rghtCurveP; - // The other subcurve + /* The other subcurve */ vector_type joinSlope; - // The slope of the end of the left subcurve and start of the right - // subcurve. + /* The slope of the end of the left subcurve and start of the right + subcurve. + */ spline_list_type * leftSplineListP; assert(subdivisionIndex > 1); diff --git a/converter/ppm/ppmtoarbtxt.c b/converter/ppm/ppmtoarbtxt.c index c13fc981..9817f183 100644 --- a/converter/ppm/ppmtoarbtxt.c +++ b/converter/ppm/ppmtoarbtxt.c @@ -162,60 +162,64 @@ save_bin_data(int const ndat, +static SKL_OBJ * +save_icol_data(SKL_OBJ_TYP const ctyp, + const char * const format, + int const icolmin, + int const icolmax) { /* Save integer color data in Object */ -static SKL_OBJ *save_icol_data (ctyp,format,icolmin,icolmax) -SKL_OBJ_TYP ctyp; -char *format; -int icolmin, icolmax; -{SKL_OBJ *obj; + SKL_OBJ * objP; - obj = (SKL_OBJ *)malloc (sizeof (SKL_OBJ)); - if (obj != NULL) - { - obj->otyp = ctyp; - strcpy (obj->odata.icol_data.icformat,format); - obj->odata.icol_data.icolmin = icolmin; - obj->odata.icol_data.icolmax = icolmax; - } - return (obj); + MALLOCVAR(objP); + + if (objP) { + objP->otyp = ctyp; + strcpy(objP->odata.icol_data.icformat, format); + objP->odata.icol_data.icolmin = icolmin; + objP->odata.icol_data.icolmax = icolmax; + } + return objP; } + +static SKL_OBJ * +save_fcol_data(SKL_OBJ_TYP const ctyp, + const char * const format, + double const fcolmin, + double const fcolmax) { /* Save float color data in Object */ -static SKL_OBJ *save_fcol_data (ctyp,format,fcolmin,fcolmax) -SKL_OBJ_TYP ctyp; -char *format; -double fcolmin, fcolmax; -{SKL_OBJ *obj; + SKL_OBJ * objP; - obj = (SKL_OBJ *)malloc (sizeof (SKL_OBJ)); - if (obj != NULL) - { - obj->otyp = ctyp; - strcpy (obj->odata.fcol_data.fcformat,format); - obj->odata.fcol_data.fcolmin = fcolmin; - obj->odata.fcol_data.fcolmax = fcolmax; - } - return (obj); + MALLOCVAR(objP); + + if (objP) { + objP->otyp = ctyp; + strcpy(objP->odata.fcol_data.fcformat, format); + objP->odata.fcol_data.fcolmin = fcolmin; + objP->odata.fcol_data.fcolmax = fcolmax; + } + return objP; } + +static SKL_OBJ * +save_i_data(SKL_OBJ_TYP const ctyp, + const char * const format) { + /* Save universal data in Object */ -static SKL_OBJ *save_i_data (ctyp,format) -SKL_OBJ_TYP ctyp; -char *format; -{SKL_OBJ *obj; + SKL_OBJ * objP; - obj = (SKL_OBJ *)malloc (sizeof (SKL_OBJ)); - if (obj != NULL) - { - obj->otyp = ctyp; - strcpy (obj->odata.i_data.iformat,format); - } - return (obj); + MALLOCVAR(objP); + if (objP) { + objP->otyp = ctyp; + strcpy(objP->odata.i_data.iformat, format); + } + return objP; } diff --git a/generator/pbmtextps.c b/generator/pbmtextps.c index 42600975..a4c0b51d 100644 --- a/generator/pbmtextps.c +++ b/generator/pbmtextps.c @@ -31,20 +31,6 @@ #define BUFFER_SIZE 2048 -static const char * const gs_exe_path = -#ifdef GHOSTSCRIPT_EXECUTABLE_PATH -GHOSTSCRIPT_EXECUTABLE_PATH; -#else -NULL; -#endif - -static const char * const pnmcrop_exe_path = -#ifdef PNMCROP_EXECUTABLE_PATH -PNMCROP_EXECUTABLE_PATH; -#else -NULL; -#endif - struct cmdlineInfo { /* All the information the user supplied in the command line, in a form easy for the program to use. @@ -199,30 +185,27 @@ construct_postscript(struct cmdlineInfo const cmdline) { static const char * -gs_executable_name() { +gsExecutableName() { - static char buffer[BUFFER_SIZE]; + const char * const which = "which gs"; - if (!gs_exe_path) { - const char * const which = "which gs"; + static char buffer[BUFFER_SIZE]; - FILE * f; + FILE * f; - memset(buffer, 0, BUFFER_SIZE); + memset(buffer, 0, BUFFER_SIZE); - f = popen(which, "r"); - if (!f) - pm_error("Can't find ghostscript"); + f = popen(which, "r"); + if (!f) + pm_error("Can't find ghostscript"); - fread(buffer, 1, BUFFER_SIZE, f); - if (buffer[strlen(buffer) - 1] == '\n') - buffer[strlen(buffer) - 1] = '\0'; - pclose(f); - - if (buffer[0] != '/' && buffer[0] != '.') - pm_error("Can't find ghostscript"); - } else - strcpy(buffer, gs_exe_path); + fread(buffer, 1, BUFFER_SIZE, f); + if (buffer[strlen(buffer) - 1] == '\n') + buffer[strlen(buffer) - 1] = '\0'; + pclose(f); + + if (buffer[0] != '/' && buffer[0] != '.') + pm_error("Can't find ghostscript"); return buffer; } @@ -230,37 +213,31 @@ gs_executable_name() { static const char * -crop_executable_name(void) { +cropExecutableName(void) { + + const char * const which = "which pnmcrop"; static char buffer[BUFFER_SIZE]; const char * retval; - if (!pnmcrop_exe_path) { - const char * const which = "which pnmcrop"; - - FILE * f; + FILE * f; - memset(buffer, 0, BUFFER_SIZE); + memset(buffer, 0, BUFFER_SIZE); - f = popen(which, "r"); - if (!f) - retval = NULL; - else { - fread(buffer, 1, BUFFER_SIZE, f); - if (buffer[strlen(buffer) - 1] == '\n') - buffer[strlen(buffer) - 1] = 0; - pclose(f); + f = popen(which, "r"); + if (!f) + retval = NULL; + else { + fread(buffer, 1, BUFFER_SIZE, f); + if (buffer[strlen(buffer) - 1] == '\n') + buffer[strlen(buffer) - 1] = 0; + pclose(f); - if (buffer[0] != '/' && buffer[0] != '.') { - retval = NULL; - pm_message("Can't find pnmcrop"); - } else - retval = buffer; - } - } else { - strcpy(buffer, pnmcrop_exe_path); - - retval = buffer; + if (buffer[0] != '/' && buffer[0] != '.') { + retval = NULL; + pm_message("Can't find pnmcrop"); + } else + retval = buffer; } return retval; } @@ -297,7 +274,7 @@ gsCommand(const char * const psFname, asprintfN(&retval, "%s -g%dx%d -r%d -sDEVICE=pbm " "-sOutputFile=%s -q -dBATCH -dNOPAUSE %s </dev/null >/dev/null", - gs_executable_name(), (int) x, (int) y, cmdline.res, + gsExecutableName(), (int) x, (int) y, cmdline.res, outputFilename, psFname); return retval; @@ -311,9 +288,9 @@ cropCommand(const char * const inputFileName) { const char * retval; const char * plainOpt = pm_plain_output ? "-plain" : "" ; - if (crop_executable_name()) { + if (cropExecutableName()) { asprintfN(&retval, "%s -top -right %s %s", - crop_executable_name(), plainOpt, inputFileName); + cropExecutableName(), plainOpt, inputFileName); if (retval == strsol) pm_error("Unable to allocate memory"); } else |