about summary refs log tree commit diff
path: root/editor
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2024-03-30 18:31:01 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2024-03-30 18:31:01 +0000
commit81c59f730dacf62c927eb57dcadeecffe8b8daea (patch)
treea67cc5906891e0965c3a9d8cea80deacbc7f1930 /editor
parent19387d1be30e80e8c4e865bfe053aed1094ca8af (diff)
downloadnetpbm-mirror-81c59f730dacf62c927eb57dcadeecffe8b8daea.tar.gz
netpbm-mirror-81c59f730dacf62c927eb57dcadeecffe8b8daea.tar.xz
netpbm-mirror-81c59f730dacf62c927eb57dcadeecffe8b8daea.zip
promote Development to Advanced
git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@4897 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'editor')
-rw-r--r--editor/pambackground.c2
-rw-r--r--editor/pamcut.c259
-rw-r--r--editor/pamditherbw.c97
-rw-r--r--editor/pammasksharpen.c2
-rw-r--r--editor/pamscale.c5
5 files changed, 203 insertions, 162 deletions
diff --git a/editor/pambackground.c b/editor/pambackground.c
index 218f5b7e..2aed88c1 100644
--- a/editor/pambackground.c
+++ b/editor/pambackground.c
@@ -22,7 +22,7 @@ parseCommandLine(int argc, const char ** const argv,
    was passed to us as the argv array.
 -----------------------------------------------------------------------------*/
     optEntry *option_def;
-        /* Instructions to OptParseOptions2 on how to parse our options.
+        /* Instructions to OptParseOptions3 on how to parse our options.
          */
     optStruct3 opt;
 
diff --git a/editor/pamcut.c b/editor/pamcut.c
index 7870fd70..b6190098 100644
--- a/editor/pamcut.c
+++ b/editor/pamcut.c
@@ -74,6 +74,7 @@ struct CmdlineInfo {
     unsigned int heightSpec;
     unsigned int height;
     unsigned int pad;
+    unsigned int reportonly;
     unsigned int verbose;
 };
 
@@ -185,6 +186,8 @@ parseCommandLine(int argc, const char ** const argv,
     OPTENT3(0,   "height",     OPT_UINT,   &cmdlineP->height,
             &cmdlineP->heightSpec,      0);
     OPTENT3(0,   "pad",        OPT_FLAG,   NULL, &cmdlineP->pad,           0);
+    OPTENT3(0,   "reportonly", OPT_FLAG,   NULL,
+            &cmdlineP->reportonly, 0);
     OPTENT3(0,   "verbose",    OPT_FLAG,   NULL, &cmdlineP->verbose,       0);
 
     opt.opt_table = option_def;
@@ -318,6 +321,55 @@ near(Location     const loc,
 
 
 static void
+computeCutBoundsOneDim(unsigned int const origSz,
+                       Location     const nearArg,
+                       Location     const farArg,
+                       bool         const dimSpec,
+                       unsigned int const dimArg,
+                       int *        const nearLocP,
+                       int *        const farLocP) {
+/*----------------------------------------------------------------------------
+   Do one dimension (vertical or horizontal) of the function of
+   'computeCutBounds'.
+-----------------------------------------------------------------------------*/
+    if (dimSpec)
+        assert(dimArg > 0);
+
+    if (nearArg.locType == LOCTYPE_NONE) {
+        if (farArg.locType == LOCTYPE_NONE) {
+            *nearLocP = 0;
+            if (dimSpec)
+                *farLocP = 0 + (int)dimArg - 1;
+            else
+                *farLocP = (int)origSz - 1;
+        } else {
+            *farLocP = near(farArg, origSz);
+            if (dimSpec)
+                *nearLocP = near(farArg, origSz) - (int)dimArg + 1;
+            else
+                *nearLocP = 0;
+        }
+    } else {
+        *nearLocP = near(nearArg, origSz);
+        if (farArg.locType == LOCTYPE_NONE) {
+            if (dimSpec)
+                *farLocP = near(nearArg, origSz) + (int)dimArg - 1;
+            else
+                *farLocP = (int)origSz - 1;
+        } else {
+            if (dimSpec) {
+                pm_error("You may not specify left, right, and width "
+                         "or top, bottom, and height.  "
+                         "Choose at most two of each of these sets.");
+            } else
+                *farLocP = near(farArg, origSz);
+        }
+    }
+}
+
+
+
+static void
 computeCutBounds(unsigned int const cols,
                  unsigned int const rows,
                  Location     const leftArg,
@@ -341,75 +393,11 @@ computeCutBounds(unsigned int const cols,
    *botrowP.  Any of these can be outside the image, including by being
    negative.
 -----------------------------------------------------------------------------*/
-    /* Find left and right bounds */
+    computeCutBoundsOneDim(cols, leftArg, rghtArg, widthSpec,  widthArg,
+                           leftColP, rghtColP);
 
-    if (widthSpec)
-        assert(widthArg > 0);
-
-    if (leftArg.locType == LOCTYPE_NONE) {
-        if (rghtArg.locType == LOCTYPE_NONE) {
-            *leftColP = 0;
-            if (widthSpec)
-                *rghtColP = 0 + (int)widthArg - 1;
-            else
-                *rghtColP = (int)cols - 1;
-        } else {
-            *rghtColP = near(rghtArg, cols);
-            if (widthSpec)
-                *leftColP = near(rghtArg, cols) - (int)widthArg + 1;
-            else
-                *leftColP = 0;
-        }
-    } else {
-        *leftColP = near(leftArg, cols);
-        if (rghtArg.locType == LOCTYPE_NONE) {
-            if (widthSpec)
-                *rghtColP = near(leftArg, cols) + (int)widthArg - 1;
-            else
-                *rghtColP = (int)cols - 1;
-        } else {
-            if (widthSpec) {
-                pm_error("You may not specify left, right, and width.  "
-                         "Choose at most two of these.");
-            } else
-                *rghtColP = near(rghtArg, cols);
-        }
-    }
-
-    /* Find top and bottom bounds */
-
-    if (heightSpec)
-        assert(heightArg > 0);
-
-    if (topArg.locType == LOCTYPE_NONE) {
-        if (botArg.locType == LOCTYPE_NONE) {
-            *topRowP = 0;
-            if (heightSpec)
-                *botRowP = 0 + (int)heightArg - 1;
-            else
-                *botRowP = (int)rows - 1;
-        } else {
-            *botRowP = near(botArg, rows);
-            if (heightSpec)
-                *topRowP = near(botArg, rows) - (int)heightArg + 1;
-            else
-                *topRowP = 0;
-        }
-    } else {
-        *topRowP = near(topArg, rows);
-        if (botArg.locType == LOCTYPE_NONE) {
-            if (heightSpec)
-                *botRowP = near(topArg, rows) + (int)heightArg - 1;
-            else
-                *botRowP = (int)rows - 1;
-        } else {
-            if (heightSpec) {
-                pm_error("You may not specify top, bottom, and height.  "
-                         "Choose at most two of these.");
-            } else
-                *botRowP = near(botArg, rows);
-        }
-    }
+    computeCutBoundsOneDim(rows, topArg,  botArg,  heightSpec, heightArg,
+                           topRowP,  botRowP);
 }
 
 
@@ -466,6 +454,46 @@ rejectOutOfBounds(unsigned int const cols,
 
 
 static void
+reportCuts(int          const leftCol,
+           int          const rghtCol,
+           int          const topRow,
+           int          const botRow,
+           unsigned int const oldWidth,
+           unsigned int const oldHeight) {
+
+    /* N.B. column and row numbers can be outside the input image, even
+       negative, which implies padding is required.
+    */
+
+    unsigned int const newWidth  = rghtCol - leftCol + 1;
+    unsigned int const newHeight = botRow  - topRow  + 1;
+
+    assert (rghtCol >= leftCol);
+    assert (botRow  >= topRow );
+
+    printf("%d %d %d %d %u %u %u %u\n",
+           leftCol, rghtCol, topRow, botRow,
+           oldWidth, oldHeight, newWidth, newHeight);
+}
+
+
+
+static void
+drainRaster(const struct pam * const inpamP) {
+/*----------------------------------------------------------------------------
+   Read through the input image described by *inpamP, which is positioned
+   to the raster, so the input stream is properly positioned for whatever
+   is next.
+-----------------------------------------------------------------------------*/
+    unsigned int row;
+
+    for (row = 0; row < inpamP->height; ++row)
+        pnm_readpamrow(inpamP, NULL);
+}
+
+
+
+static void
 writeBlackRows(const struct pam * const outpamP,
                int                const rows) {
 /*----------------------------------------------------------------------------
@@ -495,7 +523,7 @@ writeBlackRows(const struct pam * const outpamP,
 
 
 
-struct rowCutter {
+typedef struct {
 /*----------------------------------------------------------------------------
    This is an object that gives you pointers you can use to effect the
    horizontal cutting and padding of a row just by doing one
@@ -537,7 +565,7 @@ struct rowCutter {
     tuple * copyTuples;
     tuple blackTuple;
     tuple discardTuple;
-};
+} RowCutter;
 
 
 
@@ -554,13 +582,13 @@ struct rowCutter {
 
 
 static void
-createRowCutter(const struct pam *  const inpamP,
-                const struct pam *  const outpamP,
-                int                 const leftcol,
-                int                 const rightcol,
-                struct rowCutter ** const rowCutterPP) {
+createRowCutter(const struct pam * const inpamP,
+                const struct pam * const outpamP,
+                int                const leftcol,
+                int                const rightcol,
+                RowCutter **       const rowCutterPP) {
 
-    struct rowCutter * rowCutterP;
+    RowCutter * rowCutterP;
     tuple * inputPointers;
     tuple * outputPointers;
     tuple * copyTuples;
@@ -624,7 +652,7 @@ createRowCutter(const struct pam *  const inpamP,
 
 
 static void
-destroyRowCutter(struct rowCutter * const rowCutterP) {
+destroyRowCutter(RowCutter * const rowCutterP) {
 
     pnm_freepamrow(rowCutterP->copyTuples);
     pnm_freepamtuple(rowCutterP->blackTuple);
@@ -645,12 +673,12 @@ extractRowsGen(const struct pam * const inpamP,
                int                const toprow,
                int                const bottomrow) {
 
-    struct rowCutter * rowCutterP;
+    RowCutter * rowCutterP;
     int row;
 
     /* Write out top padding */
-    if (0 - toprow > 0)
-        writeBlackRows(outpamP, 0 - toprow);
+    if (toprow < 0)
+        writeBlackRows(outpamP, MIN(0, bottomrow+1) - toprow);
 
     createRowCutter(inpamP, outpamP, leftcol, rightcol, &rowCutterP);
 
@@ -671,14 +699,15 @@ extractRowsGen(const struct pam * const inpamP,
     destroyRowCutter(rowCutterP);
 
     /* Write out bottom padding */
-    if ((bottomrow - (inpamP->height-1)) > 0)
-        writeBlackRows(outpamP, bottomrow - (inpamP->height-1));
+    if (bottomrow >= inpamP->height)
+        writeBlackRows(outpamP, bottomrow - MAX(inpamP->height, toprow) + 1);
+
 }
 
 
 
 static void
-makeBlackPBMRow(unsigned char * const bitrow,
+makeBlackPbmRow(unsigned char * const bitrow,
                 unsigned int    const cols) {
 
     unsigned int const colByteCnt = pbm_packed_bytes(cols);
@@ -695,14 +724,14 @@ makeBlackPBMRow(unsigned char * const bitrow,
 
 
 static void
-extractRowsPBM(const struct pam * const inpamP,
+extractRowsPbm(const struct pam * const inpamP,
                const struct pam * const outpamP,
                int                const leftcol,
                int                const rightcol,
                int                const toprow,
                int                const bottomrow) {
 
-    unsigned char * bitrow;
+    unsigned char * bitrow;   /* read/write buffer */
     int             readOffset, writeOffset;
     int             row;
     unsigned int    totalWidth;
@@ -730,17 +759,16 @@ extractRowsPBM(const struct pam * const inpamP,
     }
 
     bitrow = pbm_allocrow_packed(totalWidth);
+      /* Initialize row buffer to all black for top and side padding */
 
-    if (toprow < 0 || leftcol < 0 || rightcol >= inpamP->width){
-        makeBlackPBMRow(bitrow, totalWidth);
-        if (toprow < 0) {
-            int row;
-            for (row=0; row < 0 - toprow; ++row)
-                pbm_writepbmrow_packed(outpamP->file, bitrow,
-                                       outpamP->width, 0);
-        }
+    /* Write out top padding */
+    if (toprow < 0) {
+        makeBlackPbmRow(bitrow, outpamP->width);
+        for (row = toprow; row < MIN(0, bottomrow+1); ++row)
+            pbm_writepbmrow_packed(outpamP->file, bitrow, outpamP->width, 0);
     }
 
+    makeBlackPbmRow(bitrow, totalWidth);
     for (row = 0; row < inpamP->height; ++row){
         if (row >= toprow && row <= bottomrow) {
             pbm_readpbmrow_bitoffset(inpamP->file, bitrow, inpamP->width,
@@ -757,12 +785,13 @@ extractRowsPBM(const struct pam * const inpamP,
             pnm_readpamrow(inpamP, NULL);    /* read and discard */
     }
 
-    if (bottomrow - (inpamP->height-1) > 0) {
-        int row;
-        makeBlackPBMRow(bitrow, outpamP->width);
-        for (row = 0; row < bottomrow - (inpamP->height-1); ++row)
-            pbm_writepbmrow_packed(outpamP->file, bitrow, outpamP->width, 0);
+    /* Write out bottom padding */
+    if (bottomrow >= inpamP->height) {
+        makeBlackPbmRow(bitrow, outpamP->width);
+        for (row = MAX(inpamP->height, toprow); row < bottomrow+1; ++row)
+             pbm_writepbmrow_packed(outpamP->file, bitrow, outpamP->width, 0);
     }
+
     pbm_freerow_packed(bitrow);
 }
 
@@ -797,23 +826,31 @@ cutOneImage(FILE *             const ifP,
                    toprow, leftcol, bottomrow, rightcol);
     }
 
-    outpam = inpam;    /* Initial value -- most fields should be same */
-    outpam.file   = ofP;
-    outpam.width  = rightcol - leftcol + 1;
-    outpam.height = bottomrow - toprow + 1;
-
-    pnm_writepaminit(&outpam);
-
-    if (PNM_FORMAT_TYPE(outpam.format) == PBM_TYPE)
-        extractRowsPBM(&inpam, &outpam, leftcol, rightcol, toprow, bottomrow);
-    else
-        extractRowsGen(&inpam, &outpam, leftcol, rightcol, toprow, bottomrow);
+    if (cmdline.reportonly) {
+        reportCuts(leftcol, rightcol, toprow, bottomrow,
+                   inpam.width, inpam.height);
+        drainRaster(&inpam);
+    } else {
+        outpam = inpam;    /* Initial value -- most fields should be same */
+        outpam.file   = ofP;
+        outpam.width  = rightcol - leftcol + 1;
+        outpam.height = bottomrow - toprow + 1;
+
+        pnm_writepaminit(&outpam);
+
+        if (PNM_FORMAT_TYPE(outpam.format) == PBM_TYPE)
+            extractRowsPbm(&inpam, &outpam,
+                           leftcol, rightcol, toprow, bottomrow);
+        else
+            extractRowsGen(&inpam, &outpam,
+                           leftcol, rightcol, toprow, bottomrow);
+    }
 }
 
 
 
 int
-main(int argc, const char *argv[]) {
+main(int argc, const char ** const argv) {
 
     FILE * const ofP = stdout;
 
@@ -838,3 +875,5 @@ main(int argc, const char *argv[]) {
 
     return 0;
 }
+
+
diff --git a/editor/pamditherbw.c b/editor/pamditherbw.c
index 694b2c21..4de14b43 100644
--- a/editor/pamditherbw.c
+++ b/editor/pamditherbw.c
@@ -22,26 +22,26 @@
 #include "pm_gamma.h"
 
 
-enum halftone {QT_FS,
+enum Halftone {QT_FS,
                QT_ATKINSON,
                QT_THRESH,
                QT_DITHER8,
                QT_CLUSTER,
                QT_HILBERT};
 
-enum ditherType {DT_REGULAR, DT_CLUSTER};
+enum DitherType {DT_REGULAR, DT_CLUSTER};
 
 static sample blackSample = (sample) PAM_BLACK;
 static sample whiteSample = (sample) PAM_BW_WHITE;
 static tuple  const blackTuple = &blackSample;
 static tuple  const whiteTuple = &whiteSample;
 
-struct cmdlineInfo {
+struct CmdlineInfo {
     /* All the information the user supplied in the command line,
        in a form easy for the program to use.
     */
-    const char *  inputFilespec;
-    enum halftone halftone;
+    const char *  inputFileNm;
+    enum Halftone halftone;
     unsigned int  clumpSize;
         /* Defined only for halftone == QT_HILBERT */
     unsigned int  clusterRadius;
@@ -55,13 +55,13 @@ struct cmdlineInfo {
 
 
 static void
-parseCommandLine(int argc, char ** argv,
-                 struct cmdlineInfo *cmdlineP) {
+parseCommandLine(int argc, const char ** const argv,
+                 struct CmdlineInfo * const cmdlineP) {
 /*----------------------------------------------------------------------------
    Note that the file spec array we return is stored in the storage that
    was passed to us as the argv array.
 -----------------------------------------------------------------------------*/
-    optEntry *option_def;
+    optEntry * option_def;
         /* Instructions to pm_optParseOptions3 on how to parse our options.
          */
     optStruct3 opt;
@@ -98,7 +98,7 @@ parseCommandLine(int argc, char ** argv,
     opt.short_allowed = FALSE;  /* We have no short (old-fashioned) options */
     opt.allowNegNum = FALSE;  /* We may have parms that are negative numbers */
 
-    pm_optParseOptions3(&argc, argv, opt, sizeof(opt), 0);
+    pm_optParseOptions3(&argc, (char **)argv, opt, sizeof(opt), 0);
         /* Uses and sets argc, argv, and some of *cmdlineP and others. */
 
     free(option_def);
@@ -160,9 +160,9 @@ parseCommandLine(int argc, char ** argv,
                  "non-option argument:  the file name",
                  argc-1);
     else if (argc-1 == 1)
-        cmdlineP->inputFilespec = argv[1];
+        cmdlineP->inputFileNm = argv[1];
     else
-        cmdlineP->inputFilespec = "-";
+        cmdlineP->inputFileNm = "-";
 }
 
 
@@ -173,15 +173,15 @@ makeOutputPam(unsigned int const width,
 
     struct pam outpam;
 
-    outpam.size = sizeof(outpam);
-    outpam.len = PAM_STRUCT_SIZE(tuple_type);
-    outpam.file = stdout;
-    outpam.format = PAM_FORMAT;
-    outpam.plainformat = 0;
-    outpam.height = height;
-    outpam.width = width;
-    outpam.depth = 1;
-    outpam.maxval = 1;
+    outpam.size             = sizeof(outpam);
+    outpam.len              = PAM_STRUCT_SIZE(tuple_type);
+    outpam.file             = stdout;
+    outpam.format           = PAM_FORMAT;
+    outpam.plainformat      = 0;
+    outpam.height           = height;
+    outpam.width            = width;
+    outpam.depth            = 1;
+    outpam.maxval           = 1;
     outpam.bytes_per_sample = 1;
     strcpy(outpam.tuple_type, "BLACKANDWHITE");
 
@@ -471,12 +471,12 @@ doHilbert(FILE *       const ifP,
 
 
 
-struct converter {
-    void (*convertRow)(struct converter * const converterP,
+struct Converter {
+    void (*convertRow)(struct Converter * const converterP,
                        unsigned int       const row,
                        tuplen                   grayrow[],
                        tuple                    bitrow[]);
-    void (*destroy)(struct converter * const converterP);
+    void (*destroy)(struct Converter * const converterP);
     unsigned int cols;
     void * stateP;
 };
@@ -505,7 +505,7 @@ struct fsState {
 
 
 static void
-fsConvertRow(struct converter * const converterP,
+fsConvertRow(struct Converter * const converterP,
              unsigned int       const row,
              tuplen                   grayrow[],
              tuple                    bitrow[]) {
@@ -576,7 +576,7 @@ fsConvertRow(struct converter * const converterP,
 
 
 static void
-fsDestroy(struct converter * const converterP) {
+fsDestroy(struct Converter * const converterP) {
 
     struct fsState * const stateP = converterP->stateP;
 
@@ -588,14 +588,14 @@ fsDestroy(struct converter * const converterP) {
 
 
 
-static struct converter
+static struct Converter
 createFsConverter(struct pam * const graypamP,
                   float        const threshFraction,
                   bool         const randomseedSpec,
                   unsigned int const randomseed) {
 
     struct fsState * stateP;
-    struct converter converter;
+    struct Converter converter;
 
     converter.cols       = graypamP->width;
     converter.convertRow = &fsConvertRow;
@@ -655,7 +655,7 @@ struct atkinsonState {
 
 
 static void
-moveAtkinsonErrorWindowDown(struct converter * const converterP) {
+moveAtkinsonErrorWindowDown(struct Converter * const converterP) {
 
     struct atkinsonState * const stateP = converterP->stateP;
 
@@ -676,7 +676,7 @@ moveAtkinsonErrorWindowDown(struct converter * const converterP) {
 
 
 static void
-atkinsonConvertRow(struct converter * const converterP,
+atkinsonConvertRow(struct Converter * const converterP,
                    unsigned int       const row,
                    tuplen                   grayrow[],
                    tuple                    bitrow[]) {
@@ -721,7 +721,7 @@ atkinsonConvertRow(struct converter * const converterP,
 
 
 static void
-atkinsonDestroy(struct converter * const converterP) {
+atkinsonDestroy(struct Converter * const converterP) {
 
     struct atkinsonState * const stateP = converterP->stateP;
 
@@ -735,14 +735,14 @@ atkinsonDestroy(struct converter * const converterP) {
 
 
 
-static struct converter
+static struct Converter
 createAtkinsonConverter(struct pam * const graypamP,
                         float        const threshFraction,
                         bool         const randomseedSpec,
                         unsigned int const randomseed) {
 
     struct atkinsonState * stateP;
-    struct converter converter;
+    struct Converter converter;
     unsigned int relRow;
 
     converter.cols       = graypamP->width;
@@ -787,7 +787,7 @@ struct threshState {
 
 
 static void
-threshConvertRow(struct converter * const converterP,
+threshConvertRow(struct Converter * const converterP,
                  unsigned int       const row,
                  tuplen                   grayrow[],
                  tuple                    bitrow[]) {
@@ -803,18 +803,18 @@ threshConvertRow(struct converter * const converterP,
 
 
 static void
-threshDestroy(struct converter * const converterP) {
+threshDestroy(struct Converter * const converterP) {
     free(converterP->stateP);
 }
 
 
 
-static struct converter
+static struct Converter
 createThreshConverter(struct pam * const graypamP,
                       float        const threshFraction) {
 
     struct threshState * stateP;
-    struct converter converter;
+    struct Converter converter;
 
     MALLOCVAR_NOFAIL(stateP);
 
@@ -838,7 +838,7 @@ struct clusterState {
 
 
 static void
-clusterConvertRow(struct converter * const converterP,
+clusterConvertRow(struct Converter * const converterP,
                   unsigned int       const row,
                   tuplen                   grayrow[],
                   tuple                    bitrow[]) {
@@ -859,7 +859,7 @@ clusterConvertRow(struct converter * const converterP,
 
 
 static void
-clusterDestroy(struct converter * const converterP) {
+clusterDestroy(struct Converter * const converterP) {
 
     struct clusterState * const stateP = converterP->stateP;
     unsigned int const diameter = 2 * stateP->radius;
@@ -876,9 +876,9 @@ clusterDestroy(struct converter * const converterP) {
 
 
 
-static struct converter
+static struct Converter
 createClusterConverter(struct pam *    const graypamP,
-                       enum ditherType const ditherType,
+                       enum DitherType const ditherType,
                        unsigned int    const radius) {
 
     /* TODO: We create a floating point normalized, gamma-adjusted
@@ -891,7 +891,7 @@ createClusterConverter(struct pam *    const graypamP,
     int const clusterNormalizer = radius * radius * 2;
     unsigned int const diameter = 2 * radius;
 
-    struct converter converter;
+    struct Converter converter;
     struct clusterState * stateP;
     unsigned int row;
 
@@ -946,21 +946,21 @@ createClusterConverter(struct pam *    const graypamP,
 
 
 int
-main(int argc, char *argv[]) {
+main(int argc, const char ** const argv) {
 
-    struct cmdlineInfo cmdline;
-    FILE* ifP;
+    struct CmdlineInfo cmdline;
+    FILE * ifP;
 
-    pgm_init(&argc, argv);
+    pm_proginit(&argc, argv);
 
     parseCommandLine(argc, argv, &cmdline);
 
-    ifP = pm_openr(cmdline.inputFilespec);
+    ifP = pm_openr(cmdline.inputFileNm);
 
     if (cmdline.halftone == QT_HILBERT)
         doHilbert(ifP, cmdline.clumpSize);
     else {
-        struct converter converter;
+        struct Converter converter;
         struct pam graypam;
         struct pam bitpam;
         tuplen * grayrow;
@@ -1022,3 +1022,6 @@ main(int argc, char *argv[]) {
 
     return 0;
 }
+
+
+
diff --git a/editor/pammasksharpen.c b/editor/pammasksharpen.c
index 1e3dee32..51bdedd9 100644
--- a/editor/pammasksharpen.c
+++ b/editor/pammasksharpen.c
@@ -24,7 +24,7 @@ parseCommandLine(int argc, const char ** const argv,
    was passed to us as the argv array.
 -----------------------------------------------------------------------------*/
     optEntry *option_def;
-        /* Instructions to OptParseOptions2 on how to parse our options.
+        /* Instructions to OptParseOptions3 on how to parse our options.
          */
     optStruct3 opt;
 
diff --git a/editor/pamscale.c b/editor/pamscale.c
index 410cd94a..8a51b2be 100644
--- a/editor/pamscale.c
+++ b/editor/pamscale.c
@@ -636,7 +636,6 @@ parseCommandLine(int argc,
 --------------------------------------------------------------------------*/
     optEntry * option_def;
     optStruct3 opt;
-        /* Instructions to pm_optParseOptions3 on how to parse our options. */
 
     unsigned int option_def_index;
     unsigned int xyfit, xyfill;
@@ -675,7 +674,7 @@ parseCommandLine(int argc,
     opt.short_allowed = false;  /* We have no short (old-fashioned) options */
     opt.allowNegNum = false;   /* We have no parms that are negative numbers */
 
-    pm_optParseOptions3(&argc, (char **)argv, opt, sizeof(opt), 0);
+    pm_optParseOptions4(&argc, argv, opt, sizeof(opt), 0);
     /* Uses and sets argc, argv, and some of *cmdlineP and others. */
 
     if (cmdlineP->nomix && filterSpec)
@@ -2251,7 +2250,7 @@ pamscale(FILE *             const ifP,
 
 
 int
-main(int argc, const char **argv ) {
+main(int argc, const char ** const argv) {
 
     struct CmdlineInfo cmdline;
     FILE * ifP;