LookupStruct() constify call-site

irouter/irTestCmd.c: LookupStruct() constify call-site
irouter/irCommand.c: LookupStruct() constify call-site
mzrouter/mzTestCmd.c: LookupStruct() constify call-site
mzrouter/mzTech.c: LookupStruct() constify call-site
router/rtrCmd.c: LookupStruct() constify call-site
plow/PlowTest.c: LookupStruct() constify call-site
plow/PlowTech.c: LookupStruct() constify call-site
plot/plotVers.c: LookupStruct() constify call-site
grouter/grouteTest.c: LookupStruct() constify call-site
garouter/gaTest.c: LookupStruct() constify call-site
extract/ExtTest.c: LookupStruct() constify call-site
extract/ExtTech.c: LookupStruct() constify call-site
extflat/EFread.c: LookupStruct() constify call-site
DRCtech.c: LookupStruct() constify call-site
debugFlags.c: LookupStruct() constify call-site
CmdSubrs.c: LookupStruct() constify call-site
geometry.c: LookupStruct() constify call-site
set.c: LookupStruct() constify call-site
This commit is contained in:
Darryl L. Miles 2024-10-10 20:13:24 +01:00 committed by Tim Edwards
parent fb8f7b94aa
commit 14b6453707
18 changed files with 95 additions and 95 deletions

View File

@ -396,10 +396,10 @@ CmdParseLayers(
#define LN_CONNECT 5
static struct
{
char *layer_name;
const char *layer_name;
int layer_value;
}
special[] =
const special[] =
{
{"$", LN_DOLLAR},
{"*", LN_ALL},
@ -439,7 +439,7 @@ CmdParseLayers(
type = DBTechNameTypes(name, &newmask);
if (type == -2)
{
which = LookupStruct(name, (LookupTable *) special, sizeof special[0]);
which = LookupStruct(name, (const LookupTable *) special, sizeof special[0]);
if (which >= 0)
{
switch (special[which].layer_value)

View File

@ -214,7 +214,7 @@ DebugSet(clientID, argc, argv, value)
dc = &debugClients[id];
for (; argc-- > 0; argv++)
{
n = LookupStruct(*argv, (LookupTable *) dc->dc_flags,
n = LookupStruct(*argv, (const LookupTable *) dc->dc_flags,
sizeof dc->dc_flags[0]);
if (n < 0)
{

View File

@ -1021,13 +1021,13 @@ DRCTechAddRule(sectionName, argc, argv)
{
int which, distance, mdist;
char *fmt;
static struct
static const struct
{
char *rk_keyword; /* Initial keyword */
const char *rk_keyword; /* Initial keyword */
int rk_minargs; /* Min # arguments */
int rk_maxargs; /* Max # arguments */
int (*rk_proc)(); /* Procedure implementing this keyword */
char *rk_err; /* Error message */
const char *rk_err; /* Error message */
} ruleKeys[] = {
{"angles", 4, 4, drcAngles,
"layers 45|90 why"},
@ -1080,7 +1080,7 @@ DRCTechAddRule(sectionName, argc, argv)
drcRulesSpecified += 1;
which = LookupStruct(argv[0], (LookupTable *) ruleKeys, sizeof ruleKeys[0]);
which = LookupStruct(argv[0], (const LookupTable *) ruleKeys, sizeof ruleKeys[0]);
if (which < 0)
{
TechError("Bad DRC rule type \"%s\"\n", argv[0]);

View File

@ -63,9 +63,9 @@ typedef enum
SUBCAP, SUBSTRATE, TECH, TIMESTAMP, USE, VERSION, EXT_STYLE
} Key;
static struct
static const struct
{
char *k_name; /* Name of first token on line */
const char *k_name; /* Name of first token on line */
Key k_key; /* Internal name for token of this type */
int k_mintokens; /* Min total # of tokens on line of this type */
}
@ -255,7 +255,7 @@ readfile:
efReadLineNum = 0;
while ((argc = efReadLine(&line, &size, inf, argv)) >= 0)
{
n = LookupStruct(argv[0], (LookupTable *) keyTable, sizeof keyTable[0]);
n = LookupStruct(argv[0], (const LookupTable *) keyTable, sizeof keyTable[0]);
if (n < 0)
{
efReadError("Unrecognized token \"%s\" (ignored)\n", argv[0]);

View File

@ -89,14 +89,14 @@ typedef enum
typedef struct
{
char *k_name;
const char *k_name;
int k_key;
int k_minargs;
int k_maxargs;
char *k_usage;
const char *k_usage;
} keydesc;
static keydesc keyTable[] = {
static const keydesc keyTable[] = {
{"areacap", AREAC, 3, 3,
"types capacitance"},
@ -202,7 +202,7 @@ static keydesc keyTable[] = {
/* types are enumerated in extract.h */
static keydesc devTable[] = {
static const keydesc devTable[] = {
{"mosfet", DEV_MOSFET, 5, 10,
"name gate-types src-types [drn-types] sub-types|None sub-node [gscap gccap]"},
@ -1954,7 +1954,7 @@ ExtTechLine(sectionName, argc, argv)
TileTypeBitMask near, far, ov, shield, subsTypes, idTypes;
char *subsName, *transName, *cp, *endptr, *paramName;
TileType s, t, r, o;
keydesc *kp, *dv;
const keydesc *kp, *dv;
bool isLinear;
HashEntry *he;
EdgeCap *cnew;
@ -1973,7 +1973,7 @@ ExtTechLine(sectionName, argc, argv)
return (TRUE);
}
n = LookupStruct(argv[0], (LookupTable *) keyTable, sizeof keyTable[0]);
n = LookupStruct(argv[0], (const LookupTable *) keyTable, sizeof keyTable[0]);
if (n < 0)
{
TechError("Illegal keyword. Legal keywords are:\n\t");
@ -2343,7 +2343,7 @@ ExtTechLine(sectionName, argc, argv)
/* Parse second argument for device type */
n = LookupStruct(argv[1], (LookupTable *)devTable, sizeof devTable[0]);
n = LookupStruct(argv[1], (const LookupTable *)devTable, sizeof devTable[0]);
if (n < 0)
{
TechError("Illegal device. Legal devices are:\n\t");

View File

@ -123,9 +123,9 @@ ExtractTest(w, cmd)
typedef enum { CLRDEBUG, CLRLENGTH, DRIVER, DUMP, INTERACTIONS,
INTERCOUNT, EXTPARENTS, RECEIVER, SETDEBUG, SHOWDEBUG,
SHOWPARENTS, SHOWTECH, STATS, STEP, TIME } cmdType;
static struct
static const struct
{
char *cmd_name;
const char *cmd_name;
cmdType cmd_val;
} cmds[] = {
{"clrdebug", CLRDEBUG},
@ -163,7 +163,7 @@ ExtractTest(w, cmd)
return;
}
n = LookupStruct(cmd->tx_argv[1], (LookupTable *) cmds, sizeof cmds[0]);
n = LookupStruct(cmd->tx_argv[1], (const LookupTable *) cmds, sizeof cmds[0]);
if (n < 0)
{
TxError("Unrecognized subcommand: %s\n", cmd->tx_argv[1]);

View File

@ -93,7 +93,7 @@ GATest(w, cmd)
{
int n;
typedef enum { CLRDEBUG, SETDEBUG, SHOWDEBUG} cmdType;
static struct
static const struct
{
char *cmd_name;
cmdType cmd_val;
@ -111,7 +111,7 @@ GATest(w, cmd)
goto badCmd;
}
n = LookupStruct(cmd->tx_argv[1], (LookupTable *) cmds, sizeof cmds[0]);
n = LookupStruct(cmd->tx_argv[1], (const LookupTable *) cmds, sizeof cmds[0]);
if (n < 0)
{
TxError("Unrecognized subcommand: %s\n", cmd->tx_argv[1]);

View File

@ -119,9 +119,9 @@ GlTest(w, cmd)
typedef enum { CLRDEBUG, ONLYNET, SETDEBUG, SHOWDEBUG, SIDES } cmdType;
Rect editArea;
int n;
static struct
static const struct
{
char *cmd_name;
const char *cmd_name;
cmdType cmd_val;
} cmds[] = {
{"clrdebug", CLRDEBUG},
@ -141,7 +141,7 @@ GlTest(w, cmd)
goto badCmd;
}
n = LookupStruct(cmd->tx_argv[1], (LookupTable *) cmds, sizeof cmds[0]);
n = LookupStruct(cmd->tx_argv[1], (const LookupTable *) cmds, sizeof cmds[0]);
if (n < 0)
{
TxError("Unrecognized subcommand: %s\n", cmd->tx_argv[1]);

View File

@ -59,13 +59,13 @@ static MagWindow *irWindow;
/* Subcommand table - declared here since its referenced before defined */
typedef struct
{
char *sC_name; /* name of iroute subcommand */
const char *sC_name; /* name of iroute subcommand */
void (*sC_proc)(); /* Procedure implementing this subcommand */
char *sC_commentString; /* describes subcommand */
char *sC_usage; /* command syntax */
const char *sC_commentString; /* describes subcommand */
const char *sC_usage; /* command syntax */
} SubCmdTableE;
extern SubCmdTableE irSubcommands[];
extern const SubCmdTableE irSubcommands[];
/*
@ -105,9 +105,9 @@ irSetNoisyAutoInt(parm, valueS, file)
/* special value Table */
#define V_AUTOMATIC -1
static struct
static const struct
{
char *sv_name; /* name */
const char *sv_name; /* name */
int sv_type;
} specialValues[] = {
{"automatic", V_AUTOMATIC},
@ -122,7 +122,7 @@ irSetNoisyAutoInt(parm, valueS, file)
/* check if special value */
which = LookupStruct(
valueS,
(char **) specialValues,
(const LookupTable *) specialValues,
sizeof specialValues[0]);
if(which == -1)
@ -674,9 +674,9 @@ FILE *file;
/* special arg Table */
#define SP_COMMAND -1
#define SP_DOT -2
static struct
static const struct
{
char *sp_name; /* name */
const char *sp_name; /* name */
int sp_type;
} specialArgs[] = {
{"command", SP_COMMAND},
@ -690,7 +690,7 @@ FILE *file;
/* check if special arg */
which = LookupStruct(
s,
(char **) specialArgs,
(const LookupTable *) specialArgs,
sizeof specialArgs[0]);
if(which == -1)
@ -776,9 +776,9 @@ FILE *file;
*/
/* Contact Parameter Table */
static struct
static const struct
{
char *cP_name; /* name of parameter */
const char *cP_name; /* name of parameter */
#ifdef MAGIC_WRAPPER
Tcl_Obj *(*cP_proc)(); /* Procedure processing this parameter */
#else
@ -938,7 +938,7 @@ irContactsCmd(w, cmd)
/* Lookup parameter name in contact parm table */
which = LookupStruct(
cmd->tx_argv[3],
(char **) cParms,
(const LookupTable *) cParms,
sizeof cParms[0]);
/* Process table lookup */
@ -1001,7 +1001,7 @@ irContactsCmd(w, cmd)
/* Lookup contact parameter name in table */
which = LookupStruct(
cmd->tx_argv[3],
(char **) cParms,
(const LookupTable *) cParms,
sizeof cParms[0]);
/* Process result of lookup */
@ -1094,7 +1094,7 @@ irHelpCmd(w, cmd)
/* Lookup subcommand in table, and printed associated help info */
which = LookupStruct(
cmd->tx_argv[2],
(char **) irSubcommands,
(const LookupTable *) irSubcommands,
sizeof irSubcommands[0]);
/* Process result of lookup */
@ -1145,9 +1145,9 @@ irHelpCmd(w, cmd)
*/
/* Layer Parameter Table */
static struct
static const struct
{
char *lP_name; /* name of parameter */
const char *lP_name; /* name of parameter */
#ifdef MAGIC_WRAPPER
Tcl_Obj *(*lP_proc)(); /* procedure processing this parameter */
#else
@ -1312,7 +1312,7 @@ irLayersCmd(w, cmd)
/* Lookup parameter name in layer parm table */
which = LookupStruct(
cmd->tx_argv[3],
(char **) lParms,
(const LookupTable *) lParms,
sizeof lParms[0]);
/* Process table lookup */
@ -1377,7 +1377,7 @@ irLayersCmd(w, cmd)
/* Lookup route layer parameter name in table */
which = LookupStruct(
cmd->tx_argv[3],
(char **) lParms,
(const LookupTable *) lParms,
sizeof lParms[0]);
/* Process result of lookup */
@ -1742,9 +1742,9 @@ leaveClean:
*/
/* Search Parameter Table */
static struct
static const struct
{
char *srP_name; /* name of parameter */
const char *srP_name; /* name of parameter */
void (*srP_proc)(); /* Procedure processing this parameter */
} srParms[] = {
{"rate", irSrSetRate},
@ -1779,7 +1779,7 @@ irSearchCmd(w, cmd)
/* Lookup parameter name in contact parm table */
which = LookupStruct(
cmd->tx_argv[2],
(char **) srParms,
(const LookupTable *) srParms,
sizeof srParms[0]);
/* Process table lookup */
@ -1863,9 +1863,9 @@ irSpacingsCmd(w, cmd)
int which, value, argI, i, n;
/* Special Value Table */
static struct
static const struct
{
char *sV_name; /* name of value */
const char *sV_name; /* name of value */
int sV_value; /* corresponding interger value */
} sValue[] = {
{"n", -1},
@ -1876,9 +1876,9 @@ irSpacingsCmd(w, cmd)
};
/* Subcell Table */
static struct
static const struct
{
char *sT_name; /* name of value */
const char *sT_name; /* name of value */
int sT_value; /* corresponding interger value */
} subcellTable[] = {
{"subcell", TT_SUBCELL},
@ -1976,7 +1976,7 @@ irSpacingsCmd(w, cmd)
/* if not a real type, check to see if "SUBCELL" */
which = LookupStruct(
cmd->tx_argv[3],
(char **) subcellTable,
(const LookupTable *) subcellTable,
sizeof subcellTable[0]);
if ( which>= 0)
tileType = TT_SUBCELL;
@ -2033,7 +2033,7 @@ irSpacingsCmd(w, cmd)
/* if not a real type, check to see if "SUBCELL" */
which = LookupStruct(
cmd->tx_argv[argI],
(char **) subcellTable,
(const LookupTable *) subcellTable,
sizeof subcellTable[0]);
if ( which>= 0)
tileType = TT_SUBCELL;
@ -2066,7 +2066,7 @@ irSpacingsCmd(w, cmd)
/* Lookup in special value table */
which = LookupStruct(
s,
(char **) sValue,
(const LookupTable *) sValue,
sizeof sValue[0]);
/* Process result of lookup */
@ -2233,9 +2233,9 @@ irVersionCmd(w, cmd)
*/
/* Wizard Parameter Table */
static struct
static const struct
{
char *wzdP_name; /* name of parameter */
const char *wzdP_name; /* name of parameter */
void (*wzdP_proc)(); /* Procedure processing this parameter */
} wzdParms[] = {
{"bloom", irWzdSetBloomCost},
@ -2276,7 +2276,7 @@ irWizardCmd(w, cmd)
/* Lookup parameter name in contact parm table */
which = LookupStruct(
cmd->tx_argv[2],
(char **) wzdParms,
(const LookupTable *) wzdParms,
sizeof wzdParms[0]);
/* Process table lookup */
@ -2509,7 +2509,7 @@ irSaveParametersCmd(w, cmd)
/*--- Subcommand Table ---*/
SubCmdTableE irSubcommands[] = {
const SubCmdTableE irSubcommands[] = {
{"contacts", irContactsCmd,
"set route-contact parameters",
"contacts [type] [parameter] [value1] ... [valuen]\n\
@ -2637,7 +2637,7 @@ IRCommand(w, cmd)
/* Lookup subcommand in table */
which = LookupStruct(
cmd->tx_argv[1],
(char **) irSubcommands,
(const LookupTable *) irSubcommands,
sizeof irSubcommands[0]);
/* Process result of lookup */

View File

@ -52,12 +52,12 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
/* Subcommand table - declared here since its referenced before defined */
typedef struct
{
char *sC_name; /* name of iroute subcommand */
const char *sC_name; /* name of iroute subcommand */
void (*sC_proc)(); /* Procedure implementing this subcommand */
char *sC_commentString;
char *sC_usage;
const char *sC_commentString;
const char *sC_usage;
} TestCmdTableE;
extern TestCmdTableE irTestCommands[];
extern const TestCmdTableE irTestCommands[];
/*
@ -154,7 +154,7 @@ irHelpTstCmd(w, cmd)
/* Lookup subcommand in table, and printed associated help info */
which = LookupStruct(
cmd->tx_argv[2],
(char **) irTestCommands,
(const LookupTable *) irTestCommands,
sizeof irTestCommands[0]);
/* Process result of lookup */
@ -219,7 +219,7 @@ irParmsTstCmd(w, cmd)
}
/*--------------------------- Command Table ------------------------------ */
TestCmdTableE irTestCommands[] = {
const TestCmdTableE irTestCommands[] = {
{"debug", irDebugTstCmd,
"set or clear debug flags",
"debug [flag] [value]"},
@ -284,7 +284,7 @@ IRTest(w, cmd)
/* Lookup subcommand in table */
which = LookupStruct(
cmd->tx_argv[1],
(char **) irTestCommands,
(const LookupTable *) irTestCommands,
sizeof irTestCommands[0]);
/* Process result of lookup */

View File

@ -812,7 +812,7 @@ mzTechSpacing(argc, argv)
char *s;
/* Subcell Table */
static struct
static const struct
{
char *sT_name; /* name of value */
int sT_value; /* corresponding interger value */
@ -849,7 +849,7 @@ mzTechSpacing(argc, argv)
/* if not a real type, check to see if "SUBCELL" */
which = LookupStruct(
argv[argI],
(LookupTable *) subcellTable,
(const LookupTable *) subcellTable,
sizeof subcellTable[0]);
if ( which>= 0)
tileType = TT_SUBCELL;

View File

@ -53,13 +53,13 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
/* Subcommand table - declared here since its referenced before defined */
typedef struct
{
char *sC_name; /* name of iroute subcommand */
const char *sC_name; /* name of iroute subcommand */
void (*sC_proc)(); /* Procedure implementing this
subcommand */
char *sC_commentString;
char *sC_usage;
const char *sC_commentString;
const char *sC_usage;
} TestCmdTableE;
extern TestCmdTableE mzTestCommands[];
extern const TestCmdTableE mzTestCommands[];
/*
@ -251,7 +251,7 @@ mzHelpTstCmd(w, cmd)
/* Lookup subcommand in table, and printed associated help info */
which = LookupStruct(
cmd->tx_argv[2],
(LookupTable *) mzTestCommands,
(const LookupTable *) mzTestCommands,
sizeof mzTestCommands[0]);
/* Process result of lookup */
@ -536,7 +536,7 @@ mzVersionCmd(w, cmd)
/*--------------------------- Command Table ------------------------------ */
TestCmdTableE mzTestCommands[] = {
const TestCmdTableE mzTestCommands[] = {
{"debug", mzDebugTstCmd,
"set or clear debug flags",
"debug [flag] [value]"},
@ -592,7 +592,7 @@ MZTest(w, cmd)
/* Lookup subcommand in table */
which = LookupStruct(
cmd->tx_argv[1],
(LookupTable *) mzTestCommands,
(const LookupTable *) mzTestCommands,
sizeof mzTestCommands[0]);
/* Process result of lookup */

View File

@ -407,7 +407,7 @@ PlotColorVersTechLine(sectionName, argc, argv)
char *argv[]; /* Pointers to fields of line. */
{
VersatecStyle *new;
static struct { char *l_str; int l_color; } colors[] = {
static const struct { const char *l_str; int l_color; } colors[] = {
{"black", BLACK},
{"cyan", CYAN},
{"magenta", MAGENTA},
@ -449,7 +449,7 @@ PlotColorVersTechLine(sectionName, argc, argv)
freeMagic((char *)new);
return TRUE;
}
i = LookupStruct(argv[1], (LookupTable *) colors, sizeof colors[0]);
i = LookupStruct(argv[1], (const LookupTable *) colors, sizeof colors[0]);
if (i < 0)
{
TechError("First field must be BLACK, CYAN, MAGENTA or YELLOW.\n");

View File

@ -175,9 +175,9 @@ PlowDRCLine(sectionName, argc, argv)
char *argv[];
{
int which;
static struct
static const struct
{
char *rk_keyword; /* Initial keyword */
const char *rk_keyword; /* Initial keyword */
int rk_minargs; /* Min # arguments */
int rk_maxargs; /* Max # arguments */
int (*rk_proc)(); /* Procedure implementing this keyword */
@ -193,7 +193,7 @@ PlowDRCLine(sectionName, argc, argv)
* Leave the job of printing error messages to the DRC tech file reader.
* We only process a few of the various design-rule types here anyway.
*/
which = LookupStruct(argv[0], (LookupTable *) ruleKeys, sizeof ruleKeys[0]);
which = LookupStruct(argv[0], (const LookupTable *) ruleKeys, sizeof ruleKeys[0]);
if (which >= 0)
{
rp = &ruleKeys[which];

View File

@ -99,11 +99,11 @@ typedef enum
PC_WHENTOP, PC_WHENBOT,
PC_SETD, PC_CLRD, PC_SHOWD
} pCmd;
struct
const struct
{
char *p_name;
const char *p_name;
pCmd p_cmd;
char *p_help;
const char *p_help;
} plowCmds[] = {
{"clrdebug", PC_CLRD, "flags"},
{"help", PC_HELP, ""},
@ -423,7 +423,7 @@ plowGetCommand(cmd)
}
plowIndex = LookupStruct(cmd->tx_argv[1],
(LookupTable *) plowCmds, sizeof plowCmds[0]);
(const LookupTable *) plowCmds, sizeof plowCmds[0]);
if (plowIndex < 0)
{
TxError("Bad plowing command '%s'.\n", cmd->tx_argv[1]);

View File

@ -267,9 +267,9 @@ CmdGaRoute(w, cmd)
int n, chanType;
Rect editArea;
FILE *f;
static struct
static const struct
{
char *cmd_name;
const char *cmd_name;
cmdType cmd_val;
} cmds[] = {
{"channel xl yl xh yh [type]\n\
@ -290,7 +290,7 @@ channel [type] define a channel", CHANNEL},
if (cmd->tx_argc == 1)
goto doRoute;
n = LookupStruct(cmd->tx_argv[1], (LookupTable *) cmds, sizeof cmds[0]);
n = LookupStruct(cmd->tx_argv[1], (const LookupTable *) cmds, sizeof cmds[0]);
if (n < 0)
{
if (n == -1)

View File

@ -360,9 +360,9 @@ GeoNameToPos(name, manhattan, verbose)
* valid directions.
*/
{
static struct pos
static const struct pos
{
char *pos_name;
const char *pos_name;
int pos_value;
bool pos_manhattan;
}
@ -403,11 +403,11 @@ GeoNameToPos(name, manhattan, verbose)
{"west", GEO_WEST, TRUE},
{0}
};
struct pos *pp;
char *fmt;
const struct pos *pp;
int pos;
pos = LookupStruct(name, (LookupTable *) positions, sizeof positions[0]);
pos = LookupStruct(name, (const LookupTable *) positions, sizeof positions[0]);
if ((pos >= 0) && (!manhattan || positions[pos].pos_manhattan))
return positions[pos].pos_value;

View File

@ -104,9 +104,9 @@ SetNoisyBool(parm,valueS,file)
int n, which, result = -2;
/* Bool string Table */
static struct
static const struct
{
char *bS_name; /* name */
const char *bS_name; /* name */
bool bS_value; /* procedure processing this parameter */
} boolStrings[] = {
{"yes", TRUE},
@ -126,7 +126,7 @@ SetNoisyBool(parm,valueS,file)
/* Lookup value string in boolString table */
which = LookupStruct(
valueS,
(LookupTable *) boolStrings,
(const LookupTable *) boolStrings,
sizeof boolStrings[0]);
/* Process result of lookup */