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;
void
CmdPlot(w, cmd)
MagWindow *w;
TxCommand *cmd;
CmdPlot(
MagWindow *w,
TxCommand *cmd)
{
int option;
const char * const *msg;

View File

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

View File

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

View File

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

View File

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