Skip to content

Commit

Permalink
Constify.
Browse files Browse the repository at this point in the history
  • Loading branch information
gwsw committed Nov 8, 2023
1 parent 43bfcdc commit 32842f7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 30 deletions.
6 changes: 3 additions & 3 deletions cmdbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ static int cmd_complete(int action);
static int in_completion = 0;
static char *tk_text;
static char *tk_original;
static char *tk_ipoint;
static char *tk_trial = NULL;
static constant char *tk_ipoint;
static constant char *tk_trial = NULL;
static struct textlist tk_tlist;
#endif

Expand Down Expand Up @@ -1072,7 +1072,7 @@ static void init_compl(void)
/*
* Return the next word in the current completion list.
*/
static char * next_compl(int action, char *prev)
static constant char * next_compl(int action, constant char *prev)
{
switch (action)
{
Expand Down
38 changes: 18 additions & 20 deletions command.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ struct ungot {
};
static struct ungot* ungot = NULL;

static void multi_search(char *pattern, int n, int silent);
static void multi_search(constant char *pattern, int n, int silent);

/*
* Move the cursor to start of prompt line before executing a command.
Expand Down Expand Up @@ -229,7 +229,8 @@ static void mca_opt_toggle(void)
*/
static void exec_mca(void)
{
char *cbuf;
constant char *cbuf;
char *p;

cmd_exec();
cbuf = get_cmdbuf();
Expand Down Expand Up @@ -275,7 +276,9 @@ static void exec_mca(void)
case A_EXAMINE:
if (!secure_allow(SF_EXAMINE))
break;
edit_list(cbuf);
p = save(cbuf);
edit_list(p);
free(p);
#if TAGS
/* If tag structure is loaded then clean it up. */
cleantags();
Expand Down Expand Up @@ -392,8 +395,7 @@ static int mca_opt_first_char(LWCHAR c)
*/
static int mca_opt_nonfirst_char(LWCHAR c)
{
char *p;
constant char *cp;
constant char *p;
constant char *oname;
int err;

Expand All @@ -418,9 +420,7 @@ static int mca_opt_nonfirst_char(LWCHAR c)
return (MCA_MORE);
opt_lower = ASCII_IS_LOWER(p[0]);
err = 0;
cp = p;
curropt = findopt_name(&cp, &oname, &err);
p = (char *) cp; /*{{const-issue}}*/
curropt = findopt_name(&p, &oname, &err);
if (curropt != NULL)
{
/*
Expand All @@ -430,9 +430,9 @@ static int mca_opt_nonfirst_char(LWCHAR c)
*/
cmd_reset();
mca_opt_toggle();
for (cp = oname; *cp != '\0'; cp++)
for (p = oname; *p != '\0'; p++)
{
c = *cp;
c = *p;
if (!opt_lower && ASCII_IS_LOWER(c))
c = ASCII_TO_UPPER(c);
if (cmd_char(c) != CC_OK)
Expand Down Expand Up @@ -705,7 +705,7 @@ static int mca_char(LWCHAR c)
/* Incremental search: do a search after every input char. */
int st = (search_type & (SRCH_FORW|SRCH_BACK|SRCH_NO_MATCH|SRCH_NO_REGEX|SRCH_NO_MOVE|SRCH_WRAP|SRCH_SUBSEARCH_ALL));
int save_updown_match = updown_match;
char *pattern = get_cmdbuf();
constant char *pattern = get_cmdbuf();
if (pattern == NULL)
return (MCA_MORE);
/*
Expand Down Expand Up @@ -1094,7 +1094,7 @@ public LWCHAR peekcc(void)
* If SRCH_FIRST_FILE is set, begin searching at the first file.
* If SRCH_PAST_EOF is set, continue the search thru multiple files.
*/
static void multi_search(char *pattern, int n, int silent)
static void multi_search(constant char *pattern, int n, int silent)
{
int nomore;
IFILE save_ifile;
Expand Down Expand Up @@ -1233,13 +1233,12 @@ public void commands(void)
{
LWCHAR c;
int action;
char *cbuf;
constant char *cbuf;
constant char *msg;
int newaction;
int save_jump_sline;
int save_search_type;
constant char *extra;
char tbuf[2];
PARG parg;
IFILE old_ifile;
IFILE new_ifile;
Expand Down Expand Up @@ -1323,6 +1322,7 @@ public void commands(void)
/*
* Decode the command character and decide what to do.
*/
extra = NULL;
if (mca)
{
/*
Expand All @@ -1337,6 +1337,7 @@ public void commands(void)
cbuf = get_cmdbuf();
if (cbuf == NULL)
continue;
action = fcmd_decode(cbuf, &extra);
} else
{
/*
Expand All @@ -1347,12 +1348,9 @@ public void commands(void)
* want erase_char/kill_char to be treated
* as line editing characters.
*/
tbuf[0] = c;
tbuf[1] = '\0';
cbuf = tbuf;
char tbuf[2] = { c, '\0' };
action = fcmd_decode(tbuf, &extra);
}
extra = NULL;
action = fcmd_decode(cbuf, &extra);
/*
* If an "extra" string was returned,
* process it as a string of command characters.
Expand Down Expand Up @@ -1653,7 +1651,7 @@ public void commands(void)
if (number <= 0) number = 1; \
mca_search(); \
cmd_exec(); \
multi_search((char *)NULL, (int) number, 0);
multi_search(NULL, (int) number, 0);

case A_F_SEARCH:
/*
Expand Down
14 changes: 7 additions & 7 deletions edit.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public ino_t curr_ino;
* words, returning each one as a standard null-terminated string.
* back_textlist does the same, but runs thru the list backwards.
*/
public void init_textlist(struct textlist *tlist, char *str)
public void init_textlist(struct textlist *tlist, mutable char *str)
{
char *s;
#if SPACES_IN_FILENAMES
Expand Down Expand Up @@ -100,9 +100,9 @@ public void init_textlist(struct textlist *tlist, char *str)
}
}

public char * forw_textlist(struct textlist *tlist, char *prev)
public constant char * forw_textlist(struct textlist *tlist, constant char *prev)
{
char *s;
constant char *s;

/*
* prev == NULL means return the first word in the list.
Expand All @@ -121,9 +121,9 @@ public char * forw_textlist(struct textlist *tlist, char *prev)
return (s);
}

public char * back_textlist(struct textlist *tlist, char *prev)
public constant char * back_textlist(struct textlist *tlist, constant char *prev)
{
char *s;
constant char *s;

/*
* prev == NULL means return the last word in the list.
Expand Down Expand Up @@ -678,9 +678,9 @@ public int edit_list(char *filelist)
{
IFILE save_ifile;
constant char *good_filename;
char *filename;
constant char *filename;
char *gfilelist;
char *gfilename;
constant char *gfilename;
char *qfilename;
struct textlist tl_files;
struct textlist tl_gfiles;
Expand Down

0 comments on commit 32842f7

Please sign in to comment.