plot: convert K&R function definitions to ANSI C

Convert the old-style (K&R) function definitions in plot/ to ANSI C
prototypes, formatted in the project's convention: the return type on its
own line and each parameter on its own line, indented four spaces, with
the original parameter comments retained.

Builds cleanly under GCC 16 / C23 (with the -std=gnu17 build change).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Andreas Wendleder 2026-06-10 03:49:16 +02:00
parent 0c7d357a6d
commit 60f3fec41c
No known key found for this signature in database
GPG Key ID: 588785BFDFB01ABD
5 changed files with 109 additions and 103 deletions

View File

@ -86,9 +86,9 @@ typedef enum {
HELP } PlotOptions; HELP } PlotOptions;
void void
CmdPlot(w, cmd) CmdPlot(
MagWindow *w; MagWindow *w,
TxCommand *cmd; TxCommand *cmd)
{ {
int option; int option;
const char * const *msg; const char * const *msg;

View File

@ -36,9 +36,11 @@ extern int rasFileByteCount;
*/ */
void void
PlotHPRTLHeader(width, height, density, hpfile) PlotHPRTLHeader(
int width, height, density; int width,
FILE *hpfile; int height,
int density,
FILE *hpfile)
{ {
fprintf(hpfile, "\033*r-3U\n"); /* Simple CMY color space */ fprintf(hpfile, "\033*r-3U\n"); /* Simple CMY color space */
fprintf(hpfile, "\033*r%dS", width); /* Image width in pixels. */ fprintf(hpfile, "\033*r%dS", width); /* Image width in pixels. */
@ -64,9 +66,12 @@ PlotHPRTLHeader(width, height, density, hpfile)
#define THIN_MARGIN 40 /* thin spacer (1mm) in HPGL2 coordinates */ #define THIN_MARGIN 40 /* thin spacer (1mm) in HPGL2 coordinates */
void void
PlotHPGL2Header(width, height, density, scale, hpfile) PlotHPGL2Header(
int width, height, density, scale; int width,
FILE *hpfile; int height,
int density,
int scale,
FILE *hpfile)
{ {
fprintf(hpfile, "\033%%-12345X"); /* Universal Command Language. */ fprintf(hpfile, "\033%%-12345X"); /* Universal Command Language. */
fprintf(hpfile, "@PJL ENTER LANGUAGE=HPGL2\r\n"); fprintf(hpfile, "@PJL ENTER LANGUAGE=HPGL2\r\n");
@ -132,8 +137,8 @@ PlotHPGL2Header(width, height, density, scale, hpfile)
*/ */
void void
PlotHPRTLTrailer(hpfile) PlotHPRTLTrailer(
FILE *hpfile; FILE *hpfile)
{ {
fprintf(hpfile, "\033*r0B\014\n"); /* End raster graphics. */ fprintf(hpfile, "\033*r0B\014\n"); /* End raster graphics. */
} }
@ -147,8 +152,8 @@ PlotHPRTLTrailer(hpfile)
*/ */
void void
PlotHPGL2Trailer(hpfile) PlotHPGL2Trailer(
FILE *hpfile; FILE *hpfile)
{ {
fprintf(hpfile, "\033*rC"); /* End raster graphics. */ fprintf(hpfile, "\033*rC"); /* End raster graphics. */
fprintf(hpfile, "\033%%0B"); /* HPGL2 mode. */ fprintf(hpfile, "\033%%0B"); /* HPGL2 mode. */
@ -204,9 +209,10 @@ PlotHPGL2Trailer(hpfile)
*/ */
int int
PlotRTLCompress(s1, s2, len) PlotRTLCompress(
unsigned char *s1, *s2; unsigned char *s1,
int len; unsigned char *s2,
int len)
{ {
/* /*
* Pack s1 using TIFF packbits encoding into s2 * Pack s1 using TIFF packbits encoding into s2
@ -292,12 +298,12 @@ PlotRTLCompress(s1, s2, len)
*/ */
int int
PlotDumpHPRTL(hpfile, kRaster, cRaster, mRaster, yRaster) PlotDumpHPRTL(
FILE *hpfile; /* File in which to dump it. */ FILE *hpfile, /* File in which to dump it. */
Raster *kRaster; /* Rasters to be dumped. */ Raster *kRaster, /* Rasters to be dumped. */
Raster *cRaster; Raster *cRaster,
Raster *mRaster; Raster *mRaster,
Raster *yRaster; Raster *yRaster)
{ {
int line, count, line_offset = 0; int line, count, line_offset = 0;
int ipl, bpl; int ipl, bpl;

View File

@ -144,9 +144,9 @@ struct plotRTLdata {
}; };
int int
pnmRTLLineFunc(linebuffer, arg) pnmRTLLineFunc(
unsigned char *linebuffer; unsigned char *linebuffer,
struct plotRTLdata *arg; struct plotRTLdata *arg)
{ {
int size; int size;
@ -167,9 +167,9 @@ pnmRTLLineFunc(linebuffer, arg)
*/ */
int int
pnmLineFunc(linebuffer, fp) pnmLineFunc(
unsigned char *linebuffer; unsigned char *linebuffer,
FILE *fp; FILE *fp)
{ {
fwrite(linebuffer, im_x * 3, 1, fp); fwrite(linebuffer, im_x * 3, 1, fp);
return 0; return 0;
@ -192,15 +192,15 @@ pnmLineFunc(linebuffer, fp)
*/ */
void void
pnmRenderRegion(scale, scale_over_2, normal, temp, func, arg) pnmRenderRegion(
float scale; float scale,
int scale_over_2; int scale_over_2,
float normal; /* normalizing factor */ float normal, /* normalizing factor */
float *temp; /* passed so we don't have to allocate it float *temp, /* passed so we don't have to allocate it
* on every call. * on every call.
*/ */
int (*func)(); /* Function to call per line of output */ int (*func)(), /* Function to call per line of output */
ClientData arg; /* Arguments to function */ ClientData arg) /* Arguments to function */
{ {
int i, j; int i, j;
int jmax; int jmax;
@ -311,10 +311,10 @@ pnmRenderRegion(scale, scale_over_2, normal, temp, func, arg)
*/ */
int int
pnmBBOX (tile, dinfo, cxp) pnmBBOX(
Tile *tile; Tile *tile,
TileType dinfo; TileType dinfo,
TreeContext *cxp; TreeContext *cxp)
{ {
Rect targetRect, sourceRect; Rect targetRect, sourceRect;
SearchContext *scx = cxp->tc_scx; SearchContext *scx = cxp->tc_scx;
@ -369,10 +369,10 @@ pnmBBOX (tile, dinfo, cxp)
*/ */
int int
pnmTile (tile, dinfo, cxp) pnmTile(
Tile *tile; Tile *tile,
TileType dinfo; TileType dinfo,
TreeContext *cxp; TreeContext *cxp)
{ {
SearchContext *scx = cxp->tc_scx; SearchContext *scx = cxp->tc_scx;
Rect targetRect, sourceRect, *clipRect; Rect targetRect, sourceRect, *clipRect;
@ -552,12 +552,12 @@ pnmTile (tile, dinfo, cxp)
*/ */
void void
PlotPNM(fileName, scx, layers, xMask, width) PlotPNM(
char *fileName; /* Name of PNM file to write. */ char *fileName, /* Name of PNM file to write. */
SearchContext *scx; /* The use and area and transformation SearchContext *scx, /* The use and area and transformation
* in this describe what to plot. * in this describe what to plot.
*/ */
TileTypeBitMask *layers; /* Tells what layers to plot. Only TileTypeBitMask *layers, /* Tells what layers to plot. Only
* paint layers in this mask, and also * paint layers in this mask, and also
* expanded according to xMask, are * expanded according to xMask, are
* plotted. If L_LABELS is set, then * plotted. If L_LABELS is set, then
@ -568,13 +568,13 @@ PlotPNM(fileName, scx, layers, xMask, width)
* according to xMask are plotted as * according to xMask are plotted as
* bounding boxes. * bounding boxes.
*/ */
int xMask; /* An expansion mask, used to indicate int xMask, /* An expansion mask, used to indicate
* the window whose expansion status * the window whose expansion status
* will be used to determine * will be used to determine
* visibility. Zero means treat * visibility. Zero means treat
* everything as expanded. * everything as expanded.
*/ */
int width; /* Indicates the width of the int width) /* Indicates the width of the
* plot, in pixels. * plot, in pixels.
*/ */
{ {
@ -1010,8 +1010,9 @@ float lanczos_kernel(i, n)
*/ */
pnmcolor pnmcolor
PNMColorBlend(c_have, c_put) PNMColorBlend(
pnmcolor *c_have, *c_put; pnmcolor *c_have,
pnmcolor *c_put)
{ {
pnmcolor loccolor; pnmcolor loccolor;
short r, g, b; short r, g, b;
@ -1030,9 +1031,9 @@ PNMColorBlend(c_have, c_put)
} }
pnmcolor pnmcolor
PNMColorIndexAndBlend(c_have, cidx) PNMColorIndexAndBlend(
pnmcolor *c_have; pnmcolor *c_have,
int cidx; int cidx)
{ {
pnmcolor loccolor, *c_put; pnmcolor loccolor, *c_put;
int ir, ig, ib; int ir, ig, ib;
@ -1129,10 +1130,10 @@ PlotPNMTechInit()
/* ARGSUSED */ /* ARGSUSED */
bool bool
PlotPNMTechLine(sectionName, argc, argv) PlotPNMTechLine(
char *sectionName; /* Name of this section (unused). */ char *sectionName, /* Name of this section (unused). */
int argc; /* Number of arguments on line. */ int argc, /* Number of arguments on line. */
char *argv[]; /* Pointers to fields of line. */ char *argv[]) /* Pointers to fields of line. */
{ {
int i, j, k, style; int i, j, k, style;
void PlotPNMSetDefaults(); /* Forward declaration */ void PlotPNMSetDefaults(); /* Forward declaration */
@ -1351,8 +1352,8 @@ PlotPNMTechFinal()
*/ */
void void
PlotLoadStyles(filename) PlotLoadStyles(
char *filename; char *filename)
{ {
FILE *inp; FILE *inp;
char fullName[256]; char fullName[256];
@ -1453,8 +1454,8 @@ dstyle_err:
*/ */
void void
PlotLoadColormap(filename) PlotLoadColormap(
char *filename; char *filename)
{ {
FILE *inp; FILE *inp;
char fullName[256]; char fullName[256];

View File

@ -237,10 +237,10 @@ PlotPSTechInit()
*/ */
bool bool
PlotPSTechLine(sectionName, argc, argv) PlotPSTechLine(
char *sectionName; /* Name of this section (unused). */ char *sectionName, /* Name of this section (unused). */
int argc; /* Number of arguments on line. */ int argc, /* Number of arguments on line. */
char *argv[]; /* Pointers to fields of line. */ char *argv[]) /* Pointers to fields of line. */
{ {
PSStyle *newstyle; PSStyle *newstyle;
PSColor *newcolor; PSColor *newcolor;
@ -333,8 +333,8 @@ PlotPSTechLine(sectionName, argc, argv)
*/ */
void void
plotPSFlushRect(style) plotPSFlushRect(
int style; int style)
{ {
if (curwidth > 0) if (curwidth > 0)
{ {
@ -389,10 +389,9 @@ plotPSFlushLine()
*/ */
void void
plotPSLine(p1, p2) plotPSLine(
Point *p1, *p2; /* Endpoints of line, given in root Point *p1,
* coordinates. Point *p2)
*/
{ {
int x1, x2, y1, y2, limit, diff; int x1, x2, y1, y2, limit, diff;
bool tmptf; bool tmptf;
@ -472,9 +471,9 @@ plotPSLine(p1, p2)
*/ */
void void
plotPSRect(rect, style) plotPSRect(
Rect *rect; /* Rectangle to be drawn, in root coords. */ Rect *rect, /* Rectangle to be drawn, in root coords. */
int style; int style)
{ {
int x, y, w, h; int x, y, w, h;
@ -513,10 +512,10 @@ plotPSRect(rect, style)
*/ */
int int
plotPSPaint(tile, dinfo, cxp) plotPSPaint(
Tile *tile; /* Tile that's of type to be output. */ Tile *tile, /* Tile that's of type to be output. */
TileType dinfo; /* Split tile information */ TileType dinfo, /* Split tile information */
TreeContext *cxp; /* Describes search in progress. */ TreeContext *cxp) /* Describes search in progress. */
{ {
Rect tileArea, edge, rootArea; Rect tileArea, edge, rootArea;
int xbot, width, ybot, height; int xbot, width, ybot, height;
@ -758,14 +757,14 @@ searchright:
*/ */
int int
plotPSLabelPosition(scx, label, x, y, p) plotPSLabelPosition(
SearchContext *scx; /* Describes state of search when label SearchContext *scx, /* Describes state of search when label
* was found. * was found.
*/ */
Label *label; /* Label that was found. */ Label *label, /* Label that was found. */
int *x; /* returned x position */ int *x, /* returned x position */
int *y; /* returned y position */ int *y, /* returned y position */
int *p; /* returned orientation */ int *p) /* returned orientation */
{ {
Rect rootArea; Rect rootArea;
int pos; int pos;
@ -854,11 +853,11 @@ plotPSLabelPosition(scx, label, x, y, p)
#define CHARHEIGHT 1.4 #define CHARHEIGHT 1.4
int int
plotPSLabelBounds(scx, label) plotPSLabelBounds(
SearchContext *scx; /* Describes state of search when label SearchContext *scx, /* Describes state of search when label
* was found. * was found.
*/ */
Label *label; /* Label that was found. */ Label *label) /* Label that was found. */
{ {
int pspos; int pspos;
int ls, psxsize, psysize; int ls, psxsize, psysize;
@ -939,11 +938,11 @@ plotPSLabelBounds(scx, label)
*/ */
int int
plotPSLabelBox(scx, label) plotPSLabelBox(
SearchContext *scx; /* Describes state of search when label SearchContext *scx, /* Describes state of search when label
* was found. * was found.
*/ */
Label *label; /* Label that was found. */ Label *label) /* Label that was found. */
{ {
Rect rootArea; Rect rootArea;
int x, y; int x, y;
@ -1004,11 +1003,11 @@ plotPSLabelBox(scx, label)
*/ */
int int
plotPSLabel(scx, label) plotPSLabel(
SearchContext *scx; /* Describes state of search when label SearchContext *scx, /* Describes state of search when label
* was found. * was found.
*/ */
Label *label; /* Label that was found. */ Label *label) /* Label that was found. */
{ {
int x, y; int x, y;
int pspos; int pspos;
@ -1047,8 +1046,8 @@ plotPSLabel(scx, label)
*/ */
int int
plotPSCell(scx) plotPSCell(
SearchContext *scx; /* Describes cell whose bbox is to SearchContext *scx) /* Describes cell whose bbox is to
* be plotted. * be plotted.
*/ */
{ {
@ -1123,12 +1122,12 @@ plotPSCell(scx)
*/ */
void void
PlotPS(fileName, scx, layers, xMask) PlotPS(
char *fileName; /* Name of PS file to write. */ char *fileName, /* Name of PS file to write. */
SearchContext *scx; /* The use and area and transformation SearchContext *scx, /* The use and area and transformation
* in this describe what to plot. * in this describe what to plot.
*/ */
TileTypeBitMask *layers; /* Tells what layers to plot. Only TileTypeBitMask *layers, /* Tells what layers to plot. Only
* paint layers in this mask, and also * paint layers in this mask, and also
* expanded according to xMask, are * expanded according to xMask, are
* plotted. If L_LABELS is set, then * plotted. If L_LABELS is set, then
@ -1139,7 +1138,7 @@ PlotPS(fileName, scx, layers, xMask)
* according to xMask are plotted as * according to xMask are plotted as
* bounding boxes. * bounding boxes.
*/ */
int xMask; /* An expansion mask, used to indicate int xMask) /* An expansion mask, used to indicate
* the window whose expansion status * the window whose expansion status
* will be used to determine * will be used to determine
* visibility. Zero means treat * visibility. Zero means treat

View File

@ -36,8 +36,8 @@ extern void CmdPlot();
*/ */
int int
Tclplot_Init(interp) Tclplot_Init(
Tcl_Interp *interp; Tcl_Interp *interp)
{ {
int n; int n;
SectionID invplot; SectionID invplot;