K&R sim/*.c: bulk function implementation conversion

K&R obsolete syntax removal for C23 compatibility series
This commit is contained in:
Darryl L. Miles 2025-01-31 19:41:36 +00:00 committed by R. Timothy Edwards
parent b3384f9104
commit 1fbba4408f
4 changed files with 145 additions and 137 deletions

View File

@ -83,9 +83,9 @@ static char bestName[256];
*/ */
int int
SimConnectFunc(tile, cx) SimConnectFunc(
Tile *tile; /* Tile found. */ Tile *tile, /* Tile found. */
TreeContext *cx; /* Describes context of search. The client TreeContext *cx) /* Describes context of search. The client
* data is a pointer to the list head of * data is a pointer to the list head of
* the conSrArg2's describing the areas * the conSrArg2's describing the areas
* left to check. * left to check.
@ -318,8 +318,8 @@ SimConnectFunc(tile, cx)
#define MAXPATHNAME 256 #define MAXPATHNAME 256
void void
SimTreeCopyConnect(scx, mask, xMask, connect, area, destUse, Node_Name) SimTreeCopyConnect(
SearchContext *scx; /* Describes starting area. The SearchContext *scx, /* Describes starting area. The
* scx_use field gives the root of * scx_use field gives the root of
* the hierarchy to search, and the * the hierarchy to search, and the
* scx_area field gives the starting * scx_area field gives the starting
@ -327,26 +327,26 @@ SimTreeCopyConnect(scx, mask, xMask, connect, area, destUse, Node_Name)
* this area. The transform is from * this area. The transform is from
* coords of scx_use to destUse. * coords of scx_use to destUse.
*/ */
TileTypeBitMask *mask; /* Tile types to start from in area. */ TileTypeBitMask *mask, /* Tile types to start from in area. */
int xMask; /* Information must be expanded in all int xMask, /* Information must be expanded in all
* of the windows indicated by this * of the windows indicated by this
* mask. Use 0 to consider all info * mask. Use 0 to consider all info
* regardless of expansion. * regardless of expansion.
*/ */
TileTypeBitMask *connect; /* Points to table that defines what TileTypeBitMask *connect, /* Points to table that defines what
* each tile type is considered to * each tile type is considered to
* connect to. Use DBConnectTbl as * connect to. Use DBConnectTbl as
* a default. * a default.
*/ */
Rect *area; /* The resulting information is Rect *area, /* The resulting information is
* clipped to this area. Pass * clipped to this area. Pass
* TiPlaneRect to get everything. * TiPlaneRect to get everything.
*/ */
CellUse *destUse; /* Result use in which to place CellUse *destUse, /* Result use in which to place
* anything connected to material of * anything connected to material of
* type mask in area of rootUse. * type mask in area of rootUse.
*/ */
char *Node_Name; /* Name of node returned. char *Node_Name) /* Name of node returned.
* NOTE: Don't call this "NodeName", * NOTE: Don't call this "NodeName",
* because that conflicts with reserved * because that conflicts with reserved
* words in some compilers. * words in some compilers.
@ -438,8 +438,9 @@ SimTreeCopyConnect(scx, mask, xMask, connect, area, destUse, Node_Name)
*/ */
bool bool
efPreferredName(name1, name2) efPreferredName(
char *name1, *name2; char *name1,
char *name2)
{ {
int nslashes1, nslashes2; int nslashes1, nslashes2;
char *np1, *np2; char *np1, *np2;
@ -550,32 +551,31 @@ efPreferredName(name1, name2)
*/ */
int int
SimSrConnect(def, startArea, mask, connect, bounds, func, clientData) SimSrConnect(
CellDef *def; /* Cell definition in which to carry out CellDef *def, /* Cell definition in which to carry out
* the connectivity search. Only paint * the connectivity search. Only paint
* in this definition is considered. * in this definition is considered.
*/ */
Rect *startArea; /* Area to search for an initial tile. Only Rect *startArea, /* Area to search for an initial tile. Only
* tiles OVERLAPPING the area are considered. * tiles OVERLAPPING the area are considered.
* This area should have positive x and y * This area should have positive x and y
* dimensions. * dimensions.
*/ */
TileTypeBitMask *mask; /* Only tiles of one of these types are used TileTypeBitMask *mask, /* Only tiles of one of these types are used
* as initial tiles. * as initial tiles.
*/ */
TileTypeBitMask *connect; /* Pointer to a table indicating what tile TileTypeBitMask *connect, /* Pointer to a table indicating what tile
* types connect to what other tile types. * types connect to what other tile types.
* Each entry gives a mask of types that * Each entry gives a mask of types that
* connect to tiles of a given type. * connect to tiles of a given type.
*/ */
Rect *bounds; /* Area, in coords of scx->scx_use->cu_def, Rect *bounds, /* Area, in coords of scx->scx_use->cu_def,
* that limits the search: only tiles * that limits the search: only tiles
* overalapping this area will be returned. * overalapping this area will be returned.
* Use TiPlaneRect to search everywhere. * Use TiPlaneRect to search everywhere.
*/ */
int (*func)(); /* Function to apply at each connected tile. */ int (*func)(), /* Function to apply at each connected tile. */
ClientData clientData; /* Client data for above function. */ ClientData clientData) /* Client data for above function. */
{ {
struct conSrArg csa; struct conSrArg csa;
int startPlane, result; int startPlane, result;
@ -661,26 +661,26 @@ SimSrConnect(def, startArea, mask, connect, bounds, func, clientData)
*/ */
int int
SimTreeSrTiles(scx, mask, xMask, tpath, func, cdarg) SimTreeSrTiles(
SearchContext *scx; /* Pointer to search context specifying SearchContext *scx, /* Pointer to search context specifying
* a cell use to search, an area in the * a cell use to search, an area in the
* coordinates of the cell's def, and a * coordinates of the cell's def, and a
* transform back to "root" coordinates. * transform back to "root" coordinates.
*/ */
TileTypeBitMask *mask; /* Only tiles with a type for which TileTypeBitMask *mask, /* Only tiles with a type for which
* a bit in this mask is on are processed. * a bit in this mask is on are processed.
*/ */
int xMask; /* All subcells are visited recursively int xMask, /* All subcells are visited recursively
* until we encounter uses whose flags, * until we encounter uses whose flags,
* when anded with xMask, are not * when anded with xMask, are not
* equal to xMask. * equal to xMask.
*/ */
TerminalPath *tpath; /* Pointer to a structure describing a TerminalPath *tpath, /* Pointer to a structure describing a
* partially filled-in terminal pathname. * partially filled-in terminal pathname.
* Add new components as encountered. * Add new components as encountered.
*/ */
int (*func)(); /* Function to apply at each qualifying tile */ int (*func)(), /* Function to apply at each qualifying tile */
ClientData cdarg; /* Client data for above function */ ClientData cdarg) /* Client data for above function */
{ {
int SimCellTileSrFunc(); int SimCellTileSrFunc();
TreeFilter filter; TreeFilter filter;
@ -703,29 +703,29 @@ SimTreeSrTiles(scx, mask, xMask, tpath, func, cdarg)
*/ */
int int
SimTreeSrNMTiles(scx, dinfo, mask, xMask, tpath, func, cdarg) SimTreeSrNMTiles(
SearchContext *scx; /* Pointer to search context specifying SearchContext *scx, /* Pointer to search context specifying
* a cell use to search, an area in the * a cell use to search, an area in the
* coordinates of the cell's def, and a * coordinates of the cell's def, and a
* transform back to "root" coordinates. * transform back to "root" coordinates.
*/ */
TileType dinfo; /* Type containing information about the TileType dinfo, /* Type containing information about the
* triangular area to search. * triangular area to search.
*/ */
TileTypeBitMask *mask; /* Only tiles with a type for which TileTypeBitMask *mask, /* Only tiles with a type for which
* a bit in this mask is on are processed. * a bit in this mask is on are processed.
*/ */
int xMask; /* All subcells are visited recursively int xMask, /* All subcells are visited recursively
* until we encounter uses whose flags, * until we encounter uses whose flags,
* when anded with xMask, are not * when anded with xMask, are not
* equal to xMask. * equal to xMask.
*/ */
TerminalPath *tpath; /* Pointer to a structure describing a TerminalPath *tpath, /* Pointer to a structure describing a
* partially filled-in terminal pathname. * partially filled-in terminal pathname.
* Add new components as encountered. * Add new components as encountered.
*/ */
int (*func)(); /* Function to apply at each qualifying tile */ int (*func)(), /* Function to apply at each qualifying tile */
ClientData cdarg; /* Client data for above function */ ClientData cdarg) /* Client data for above function */
{ {
int SimCellTileSrFunc(); int SimCellTileSrFunc();
TreeFilter filter; TreeFilter filter;
@ -746,9 +746,9 @@ SimTreeSrNMTiles(scx, dinfo, mask, xMask, tpath, func, cdarg)
*/ */
int int
SimCellTileSrFunc(scx, fp) SimCellTileSrFunc(
SearchContext *scx; SearchContext *scx,
TreeFilter *fp; TreeFilter *fp)
{ {
TreeContext context; TreeContext context;
TerminalPath *tp; TerminalPath *tp;
@ -860,15 +860,15 @@ cleanup:
*/ */
int int
SimPutLabel(cellDef, rect, align, text, type) SimPutLabel(
CellDef *cellDef; /* Cell in which label is placed */ CellDef *cellDef, /* Cell in which label is placed */
Rect *rect; /* Location of label; see above for description */ Rect *rect, /* Location of label, see above for description */
int align; /* Orientation/alignment of text. If this is < 0, int align, /* Orientation/alignment of text. If this is < 0,
* an orientation will be picked to keep the text * an orientation will be picked to keep the text
* inside the cell boundary. * inside the cell boundary.
*/ */
char *text; /* Pointer to actual text of label */ char *text, /* Pointer to actual text of label */
TileType type; /* Type of tile to be labeled */ TileType type) /* Type of tile to be labeled */
{ {
Label *lab; Label *lab;
int len, x1, x2, y1, y2, tmp, labx, laby; int len, x1, x2, y1, y2, tmp, labx, laby;
@ -963,9 +963,9 @@ SimPutLabel(cellDef, rect, align, text, type)
*/ */
void void
SimRsimHandler(w, cmd) SimRsimHandler(
MagWindow *w; /* Window containing cursor. */ MagWindow *w, /* Window containing cursor. */
TxCommand *cmd; /* Describes what happened. */ TxCommand *cmd) /* Describes what happened. */
{ {
static int buttonCorner = TOOL_ILG; static int buttonCorner = TOOL_ILG;

View File

@ -114,8 +114,8 @@ PlaneMask SimFetPlanes;
*/ */
void void
SimAddDefList(newdef) SimAddDefList(
CellDef *newdef; CellDef *newdef)
{ {
DefListElt *d; DefListElt *d;
@ -163,7 +163,7 @@ SimAddDefList(newdef)
*/ */
void void
SimInitDefList() SimInitDefList(void)
{ {
DefListElt *p, *q; DefListElt *p, *q;
@ -194,8 +194,8 @@ SimInitDefList()
*/ */
void void
SimAddNodeList(newnode) SimAddNodeList(
NodeRegion *newnode; NodeRegion *newnode)
{ {
if( NodeRegList != (NodeRegion *) NULL ) if( NodeRegList != (NodeRegion *) NULL )
newnode->nreg_next = NodeRegList; newnode->nreg_next = NodeRegList;
@ -220,7 +220,7 @@ SimAddNodeList(newnode)
*/ */
void void
SimFreeNodeRegs() SimFreeNodeRegs(void)
{ {
NodeRegion *p, *q; NodeRegion *p, *q;
@ -239,7 +239,8 @@ SimFreeNodeRegs()
* to the region being searched. * to the region being searched.
*---------------------------------------------------------------- *----------------------------------------------------------------
*/ */
int SimInitConnTables() int
SimInitConnTables(void)
{ {
int i, t, sd, p; int i, t, sd, p;
ExtDevice *devptr; ExtDevice *devptr;
@ -337,10 +338,11 @@ typedef struct /* return value from SimFindOneNode */
* *
*---------------------------------------------------------------- *----------------------------------------------------------------
*/ */
char *SimTxtorLabel( nterm, tm, trans ) char *
int nterm; SimTxtorLabel(
Transform *tm; int nterm,
SimTrans *trans; Transform *tm,
SimTrans *trans)
{ {
static char name[30]; static char name[30];
Rect r1, r2; Rect r1, r2;
@ -356,18 +358,20 @@ char *SimTxtorLabel( nterm, tm, trans )
return( name ); return( name );
} }
int SimSDTransFunc( tile, ptile ) int
Tile *tile; SimSDTransFunc(
Tile **ptile; Tile *tile,
Tile **ptile)
{ {
*ptile = tile; *ptile = tile;
return( 1 ); return( 1 );
} }
int SimTransTerms( bp, trans ) int
Boundary *bp; SimTransTerms(
SimTrans *trans; Boundary *bp,
SimTrans *trans)
{ {
TransTerm *term; TransTerm *term;
Tile *tile = bp->b_outside; Tile *tile = bp->b_outside;
@ -427,9 +431,10 @@ int SimTransTerms( bp, trans )
} }
int SimTermNum( trans, reg ) int
SimTrans *trans; SimTermNum(
NodeRegion *reg; SimTrans *trans,
NodeRegion *reg)
{ {
int i, changed; int i, changed;
TransTerm *p1, *p2, tmp; TransTerm *p1, *p2, tmp;
@ -470,10 +475,10 @@ int SimTermNum( trans, reg )
int int
SimTransistorTile(tile, pNum, arg) SimTransistorTile(
Tile *tile; Tile *tile,
int pNum; int pNum,
FindRegion *arg; FindRegion *arg)
{ {
int i; int i;
TileType t; TileType t;
@ -494,10 +499,11 @@ SimTransistorTile(tile, pNum, arg)
} }
int SimFindTxtor( tile, pNum, arg ) int
Tile *tile; SimFindTxtor(
int pNum; Tile *tile,
FindRegion *arg; int pNum,
FindRegion *arg)
{ {
TileType type; TileType type;
@ -549,9 +555,9 @@ int SimFindTxtor( tile, pNum, arg )
*/ */
NodeSpec * NodeSpec *
SimFindOneNode( sx, tile ) SimFindOneNode(
SearchContext *sx; SearchContext *sx,
Tile *tile; Tile *tile)
{ {
CellDef *def = sx->scx_use->cu_def; CellDef *def = sx->scx_use->cu_def;
NodeRegion *reg; NodeRegion *reg;
@ -696,12 +702,12 @@ SimFindOneNode( sx, tile )
*/ */
char * char *
SimGetNodeName(sx, tp, path) SimGetNodeName(
SearchContext *sx; /* current search context */ SearchContext *sx, /* current search context */
Tile *tp; /* tile in this cell which is part Tile *tp, /* tile in this cell which is part
* of the node * of the node
*/ */
char *path; /* path name of hierarchy of search */ char *path) /* path name of hierarchy of search */
{ {
CellDef *def = sx->scx_use->cu_def; CellDef *def = sx->scx_use->cu_def;
NodeRegion *nodeList; NodeRegion *nodeList;
@ -820,7 +826,7 @@ SimGetNodeName(sx, tp, path)
*/ */
void void
SimGetNodeCleanUp() SimGetNodeCleanUp(void)
{ {
SimFreeNodeRegs(); SimFreeNodeRegs();
SimInitDefList(); SimInitDefList();

View File

@ -80,7 +80,7 @@ bool SimRsimRunning = FALSE;
bool SimHasCoords = FALSE; bool SimHasCoords = FALSE;
/* Forward declaration */ /* Forward declaration */
void SimStopRsim(); void SimStopRsim(void);
/* /*
*----------------------------------------------------------------------- *-----------------------------------------------------------------------
@ -99,8 +99,8 @@ void SimStopRsim();
*/ */
char * char *
SimGetNodeCommand(cmd) SimGetNodeCommand(
char *cmd; char *cmd)
{ {
/* This table is used to define which Rsim commands are applied to /* This table is used to define which Rsim commands are applied to
* each node in the selection. Depending on the command, you * each node in the selection. Depending on the command, you
@ -152,8 +152,8 @@ SimGetNodeCommand(cmd)
*/ */
bool bool
SimStartRsim(argv) SimStartRsim(
char *argv[]; /* list of rsim args for the fork */ char *argv[]) /* list of rsim args for the fork */
{ {
int child; int child;
@ -289,8 +289,8 @@ SimStartRsim(argv)
*/ */
void void
SimConnectRsim(escRsim) SimConnectRsim(
bool escRsim; /* TRUE if we should escape back to Magic */ bool escRsim) /* TRUE if we should escape back to Magic */
{ {
static char HELLO_MSG[] = static char HELLO_MSG[] =
"Type \"q\" to quit simulator or \".\" to escape back to Magic.\n"; "Type \"q\" to quit simulator or \".\" to escape back to Magic.\n";
@ -383,8 +383,8 @@ SimConnectRsim(escRsim)
*/ */
bool bool
InitRsim(hello_msg) InitRsim(
char *hello_msg; char *hello_msg)
{ {
char buff[READBUF_SIZE]; char buff[READBUF_SIZE];
char *last; char *last;
@ -463,7 +463,7 @@ InitRsim(hello_msg)
*/ */
void void
SimStopRsim() SimStopRsim(void)
{ {
int pid; int pid;
@ -515,7 +515,7 @@ SimStopRsim()
*/ */
void void
RsimErrorMsg() RsimErrorMsg(void)
{ {
static char msg[] = "The simulator must be running before this command " static char msg[] = "The simulator must be running before this command "
"can be executed. To do\n" "can be executed. To do\n"
@ -548,9 +548,9 @@ RsimErrorMsg()
*/ */
void void
SimRsimIt(cmd, nodeName) SimRsimIt(
char *cmd; char *cmd,
char *nodeName; char *nodeName)
{ {
static char cmdStr[512]; static char cmdStr[512];
@ -619,12 +619,12 @@ SimRsimIt(cmd, nodeName)
*/ */
int int
SimFillBuffer(buffHead, pLastChar, charCount) SimFillBuffer(
char *buffHead; /* ptr to start of buffer */ char *buffHead, /* ptr to start of buffer */
char **pLastChar; /* used to return ptr to last char char **pLastChar, /* used to return ptr to last char
* in the buffer. * in the buffer.
*/ */
int *charCount; /* number of chars in the buffer */ int *charCount) /* number of chars in the buffer */
{ {
int charsRead = 0; int charsRead = 0;
char *temp; char *temp;
@ -723,10 +723,10 @@ try_again:
*/ */
void void
SimShiftChars(buffStart, lineStart, lastChar) SimShiftChars(
char *buffStart; /* beginning of buffer */ char *buffStart, /* beginning of buffer */
char **lineStart; /* ptr to first valid char in buffer */ char **lineStart, /* ptr to first valid char in buffer */
char **lastChar; /* ptr to last valid char in buffer */ char **lastChar) /* ptr to last valid char in buffer */
{ {
char *temp; char *temp;
char *temp1; char *temp1;
@ -761,9 +761,9 @@ SimShiftChars(buffStart, lineStart, lastChar)
*/ */
char * char *
SimFindNewLine(buffStart, buffEnd) SimFindNewLine(
char *buffStart; /* first char in buffer */ char *buffStart, /* first char in buffer */
char *buffEnd; /* last char in buffer */ char *buffEnd) /* last char in buffer */
{ {
char *sp; char *sp;
@ -807,8 +807,8 @@ SimFindNewLine(buffStart, buffEnd)
*/ */
bool bool
SimGetReplyLine(replyLine) SimGetReplyLine(
char **replyLine; char **replyLine)
{ {
static char simReadBuff[READBUF_SIZE]; /* buffer in which to read the static char simReadBuff[READBUF_SIZE]; /* buffer in which to read the
* rsim reply before processing * rsim reply before processing
@ -930,7 +930,7 @@ SimGetReplyLine(replyLine)
*/ */
void void
SimInit() SimInit(void)
{ {
static char *rsimdoc = static char *rsimdoc =
"You are currently using the \"rsim\" tool. The button actions are:\n\ "You are currently using the \"rsim\" tool. The button actions are:\n\

View File

@ -125,17 +125,17 @@ bool SimRsimRunning = FALSE; /* Always false if there's no rsim module */
*/ */
char * char *
SimSelectNode(scx, type, xMask, buffer) SimSelectNode(
SearchContext *scx; /* Area to tree-search for material. The SearchContext *scx, /* Area to tree-search for material. The
* transform must map to EditRoot coordinates. * transform must map to EditRoot coordinates.
*/ */
TileType type; /* The type of material to be considered. */ TileType type, /* The type of material to be considered. */
int xMask; /* Indicates window (or windows) where cells int xMask, /* Indicates window (or windows) where cells
* must be expanded for their contents to be * must be expanded for their contents to be
* considered. 0 means treat everything as * considered. 0 means treat everything as
* expanded. * expanded.
*/ */
char *buffer; /* buffer to hold node name */ char *buffer) /* buffer to hold node name */
{ {
TileTypeBitMask mask; TileTypeBitMask mask;
char *strptr; char *strptr;
@ -180,7 +180,7 @@ SimSelectNode(scx, type, xMask, buffer)
} }
int int
NullFunc() NullFunc(void)
{ {
return(0); return(0);
} }
@ -202,8 +202,8 @@ NullFunc()
*/ */
void void
SimFreeNodeList(List) SimFreeNodeList(
TileListElt **List; TileListElt **List)
{ {
TileListElt *current; TileListElt *current;
TileListElt *temp; TileListElt *temp;
@ -219,8 +219,9 @@ SimFreeNodeList(List)
} }
TileListElt * TileListElt *
simFreeNodeEntry(list, entry) simFreeNodeEntry(
TileListElt *list, *entry; TileListElt *list,
TileListElt *entry)
{ {
TileListElt *prev, *curr; TileListElt *prev, *curr;
@ -257,7 +258,8 @@ simFreeNodeEntry(list, entry)
*/ */
TileListElt * TileListElt *
SimSelectArea(Rect *rect) SimSelectArea(
Rect *rect)
{ {
int plane; int plane;
int SimSelectFunc(); int SimSelectFunc();
@ -317,9 +319,9 @@ SimSelectArea(Rect *rect)
*/ */
int int
SimSelectFunc(tile, pHead) SimSelectFunc(
Tile *tile; /* Tile in SelectDef. */ Tile *tile, /* Tile in SelectDef. */
TileListElt **pHead; /* list of node names found */ TileListElt **pHead) /* list of node names found */
{ {
TileTypeBitMask mask; TileTypeBitMask mask;
SearchContext scx; SearchContext scx;
@ -431,8 +433,8 @@ SimSelectFunc(tile, pHead)
*/ */
bool bool
SimSelection(cmd) SimSelection(
char *cmd; /* rsim command to apply to the selection */ char *cmd) /* rsim command to apply to the selection */
{ {
static char Hstring[] = "RSIM=1"; static char Hstring[] = "RSIM=1";
static char Lstring[] = "RSIM=0"; static char Lstring[] = "RSIM=0";
@ -606,9 +608,9 @@ the selection.\n");
*/ */
void void
SimAddLabels(SelectNodeList, rootuse) SimAddLabels(
TileListElt *SelectNodeList; TileListElt *SelectNodeList,
CellDef *rootuse; /* the root cell def for the window */ CellDef *rootuse) /* the root cell def for the window */
{ {
TileListElt *current; TileListElt *current;
@ -652,8 +654,8 @@ SimAddLabels(SelectNodeList, rootuse)
*/ */
void void
SimRsimMouse(w) SimRsimMouse(
MagWindow *w; MagWindow *w)
{ {
CellUse *cu; CellUse *cu;
@ -720,7 +722,7 @@ SimRsimMouse(w)
*/ */
void void
SimGetnode() SimGetnode(void)
{ {
TileListElt *current; TileListElt *current;
@ -765,7 +767,7 @@ SimGetnode()
*/ */
void void
SimGetsnode() SimGetsnode(void)
{ {
TileListElt *current; TileListElt *current;
@ -813,7 +815,7 @@ SimGetsnode()
*/ */
void void
SimEraseLabels() SimEraseLabels(void)
{ {
SimDefListElt *p; SimDefListElt *p;