command: use 'const' with readonly data

This then required a cascade of function APIs to also now receive
const arguments.

This reduces the .data segment use of this module.
This commit is contained in:
Darryl L. Miles 2024-10-04 12:10:59 +01:00 committed by Tim Edwards
parent 5c410e9dcb
commit 0376430702
5 changed files with 9 additions and 9 deletions

View File

@ -201,7 +201,7 @@ cmdEditRedisplayFunc(
MagWindow *w, /* Window containing edit cell. */
Rect *area) /* Area to be redisplayed. */
{
static Rect origin = {{-1, -1}, {1, 1}};
static const Rect origin = {-1, -1, 1, 1};
Rect tmp;
DBWclientRec *crec = (DBWclientRec *) w->w_clientData;

View File

@ -942,7 +942,7 @@ CmdFlush(
{
CellDef *def;
int action;
static char *actionNames[] = { "no", "yes", 0 };
static const char * const actionNames[] = { "no", "yes", 0 };
char *prompt;
bool dereference = FALSE;
char *strNoConfirm;

View File

@ -1566,7 +1566,7 @@ CmdPort(
NULL
};
static int cmdClassToBitmask[] =
static const int cmdClassToBitmask[] =
{
PORT_CLASS_DEFAULT,
PORT_CLASS_INPUT,
@ -1590,7 +1590,7 @@ CmdPort(
NULL
};
static int cmdUseToBitmask[] =
static const int cmdUseToBitmask[] =
{
PORT_USE_DEFAULT,
PORT_USE_ANALOG,
@ -1611,7 +1611,7 @@ CmdPort(
NULL
};
static int cmdShapeToBitmask[] =
static const int cmdShapeToBitmask[] =
{
PORT_SHAPE_DEFAULT,
PORT_SHAPE_ABUT,

View File

@ -720,7 +720,7 @@ cmdCheckNewName(
bool tryRename,
bool noninteractive)
{
static char *yesno[] = { "no", "yes", 0 };
static const char * const yesno[] = { "no", "yes", 0 };
char *filename;
char *prompt;
char *returnname;
@ -1076,7 +1076,7 @@ CmdWarnWrite(void)
{
int count, code;
int cmdWarnWriteFunc(CellDef *cellDef, int *pcount);
static char *yesno[] = { "no", "yes", 0 };
static const char * const yesno[] = { "no", "yes", 0 };
char *prompt;
count = 0;

View File

@ -1932,9 +1932,9 @@ cmdWriteallFunc(
{
char *prompt, *argv;
int i, action, cidx = 0;
static char *actionNames[] =
static const char * const actionNames[] =
{ "write", "flush", "skip", "abort", "autowrite", 0 };
static char *explain[] =
static const char * const explain[] =
{ "", "(bboxes)", "(timestamps)", "(bboxes/timestamps)", 0 };
if (def->cd_flags & CDINTERNAL) return 0;