Skip to content

Commit

Permalink
More constifying.
Browse files Browse the repository at this point in the history
  • Loading branch information
gwsw committed Nov 7, 2023
1 parent 5354c92 commit 8b6e333
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 70 deletions.
27 changes: 14 additions & 13 deletions charset.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ struct cs_alias {
#define IS_CONTROL_CHAR 02

static char chardef[256];
static char *binfmt = NULL;
static char *utfbinfmt = NULL;
static constant char *binfmt = NULL;
static constant char *utfbinfmt = NULL;
public int binattr = AT_STANDOUT|AT_COLOR_BIN;

static struct xbuffer user_wide_array;
Expand Down Expand Up @@ -241,7 +241,7 @@ static void ichardef_utf(char *s)
* b binary character
* c control character
*/
static void ichardef(char *s)
static void ichardef(constant char *s)
{
char *cp;
int n;
Expand Down Expand Up @@ -298,7 +298,7 @@ static void ichardef(char *s)
* Define a charset, given a charset name.
* The valid charset names are listed in the "charsets" array.
*/
static int icharset(char *name, int no_error)
static int icharset(constant char *name, int no_error)
{
struct charset *p;
struct cs_alias *a;
Expand Down Expand Up @@ -363,7 +363,7 @@ static void ilocale(void)
/*
* Define the printing format for control (or binary utf) chars.
*/
public void setfmt(char *s, char **fmtvarptr, int *attrptr, char *default_fmt, int for_printf)
public void setfmt(constant char *s, constant char **fmtvarptr, int *attrptr, constant char *default_fmt, int for_printf)
{
if (s && utf_mode)
{
Expand Down Expand Up @@ -412,7 +412,7 @@ public void setfmt(char *s, char **fmtvarptr, int *attrptr, char *default_fmt, i
*/
static void set_charset(void)
{
char *s;
constant char *s;

ichardef_utf(lgetenv("LESSUTFCHARDEF"));

Expand Down Expand Up @@ -492,7 +492,7 @@ static void set_charset(void)
*/
public void init_charset(void)
{
char *s;
constant char *s;

#if HAVE_LOCALE
setlocale(LC_ALL, "");
Expand Down Expand Up @@ -531,7 +531,7 @@ public int control_char(LWCHAR c)
* Return the printable form of a character.
* For example, in the "ascii" charset '\3' is printed as "^C".
*/
public char * prchar(LWCHAR c)
public constant char * prchar(LWCHAR c)
{
/* {{ This buffer can be overrun if LESSBINFMT is a long string. }} */
static char buf[MAX_PRCHAR_LEN+1];
Expand Down Expand Up @@ -565,7 +565,7 @@ public char * prchar(LWCHAR c)
/*
* Return the printable form of a UTF-8 character.
*/
public char * prutfchar(LWCHAR ch)
public constant char * prutfchar(LWCHAR ch)
{
static char buf[MAX_PRCHAR_LEN+1];

Expand Down Expand Up @@ -594,7 +594,7 @@ public char * prutfchar(LWCHAR ch)
/*
* Get the length of a UTF-8 character in bytes.
*/
public int utf_len(int ch)
public int utf_len(unsigned char ch)
{
if ((ch & 0x80) == 0)
return 1;
Expand All @@ -617,11 +617,11 @@ public int utf_len(int ch)
/*
* Does the parameter point to the lead byte of a well-formed UTF-8 character?
*/
public int is_utf8_well_formed(char *ss, int slen)
public int is_utf8_well_formed(constant char *ss, int slen)
{
int i;
int len;
unsigned char *s = (unsigned char *) ss;
constant unsigned char *s = (constant unsigned char *) ss;

if (IS_UTF8_INVALID(s[0]))
return (0);
Expand Down Expand Up @@ -663,8 +663,9 @@ public void utf_skip_to_lead(char **pp, char *limit)
/*
* Get the value of a UTF-8 character.
*/
public LWCHAR get_wchar(constant char *p)
public LWCHAR get_wchar(constant char *sp)
{
constant unsigned char *p = (constant unsigned char *) sp;
switch (utf_len(p[0]))
{
case 1:
Expand Down
24 changes: 12 additions & 12 deletions cmdbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ public int len_cmdbuf(void)
* {{ Returning pwidth and bswidth separately is a historical artifact
* since they're always the same. Maybe clean this up someday. }}
*/
static char * cmd_step_common(char *p, LWCHAR ch, int len, int *pwidth, int *bswidth)
static constant char * cmd_step_common(char *p, LWCHAR ch, int len, int *pwidth, int *bswidth)
{
char *pr;
constant char *pr;
int width;

if (len == 1)
Expand Down Expand Up @@ -221,7 +221,7 @@ static char * cmd_step_common(char *p, LWCHAR ch, int len, int *pwidth, int *bsw
/*
* Step a pointer one character right in the command buffer.
*/
static char * cmd_step_right(char **pp, int *pwidth, int *bswidth)
static constant char * cmd_step_right(char **pp, int *pwidth, int *bswidth)
{
char *p = *pp;
LWCHAR ch = step_char(pp, +1, p + strlen(p));
Expand All @@ -232,7 +232,7 @@ static char * cmd_step_right(char **pp, int *pwidth, int *bswidth)
/*
* Step a pointer one character left in the command buffer.
*/
static char * cmd_step_left(char **pp, int *pwidth, int *bswidth)
static constant char * cmd_step_left(char **pp, int *pwidth, int *bswidth)
{
char *p = *pp;
LWCHAR ch = step_char(pp, -1, cmdbuf);
Expand Down Expand Up @@ -278,7 +278,7 @@ public void cmd_repaint(constant char *old_cp)
{
char *np = cp;
int width;
char *pr = cmd_step_right(&np, &width, NULL);
constant char *pr = cmd_step_right(&np, &width, NULL);
if (cmd_col + width >= sc_width)
break;
cp = np;
Expand All @@ -289,7 +289,7 @@ public void cmd_repaint(constant char *old_cp)
{
char *np = cp;
int width;
char *pr = cmd_step_right(&np, &width, NULL);
constant char *pr = cmd_step_right(&np, &width, NULL);
if (width > 0)
break;
cp = np;
Expand Down Expand Up @@ -374,7 +374,7 @@ static void cmd_rshift(void)
*/
static int cmd_right(void)
{
char *pr;
constant char *pr;
char *ncp;
int width;

Expand Down Expand Up @@ -436,7 +436,7 @@ static int cmd_left(void)
/*
* Insert a char into the command buffer, at the current position.
*/
static int cmd_ichar(char *cs, int clen)
static int cmd_ichar(constant char *cs, int clen)
{
char *s;

Expand Down Expand Up @@ -901,13 +901,13 @@ static int cmd_edit(int c)
/*
* Insert a string into the command buffer, at the current position.
*/
static int cmd_istr(char *str)
static int cmd_istr(constant char *str)
{
char *s;
int action;
char *endline = str + strlen(str);
constant char *endline = str + strlen(str);

for (s = str; *s != '\0'; )
for (s = (char *) str; *s != '\0'; ) /*{{const-issue}}*/
{
char *os = s;
step_char(&s, +1, endline);
Expand Down Expand Up @@ -1320,7 +1320,7 @@ public char * get_cmdbuf(void)
/*
* Return the last (most recent) string in the current command history.
*/
public char * cmd_lastpattern(void)
public constant char * cmd_lastpattern(void)
{
if (curr_mlist == NULL)
return (NULL);
Expand Down
16 changes: 6 additions & 10 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(char *pattern, int n, int silent);

/*
* Move the cursor to start of prompt line before executing a command.
Expand Down Expand Up @@ -201,14 +201,10 @@ static void mca_search(void)
*/
static void mca_opt_toggle(void)
{
int no_prompt;
int flag;
char *dash;
int no_prompt = (optflag & OPT_NO_PROMPT);
int flag = (optflag & ~OPT_NO_PROMPT);
constant char *dash = (flag == OPT_NO_TOGGLE) ? "_" : "-";

no_prompt = (optflag & OPT_NO_PROMPT);
flag = (optflag & ~OPT_NO_PROMPT);
dash = (flag == OPT_NO_TOGGLE) ? "_" : "-";

set_mca(A_OPT_TOGGLE);
cmd_putstr(dash);
if (optgetname)
Expand Down Expand Up @@ -1074,7 +1070,7 @@ public void ungetcc_back(LWCHAR c)
* Unget a whole string of command characters.
* The next sequence of getcc()'s will return this string.
*/
public void ungetsc(char *s)
public void ungetsc(constant char *s)
{
while (*s != '\0')
ungetcc_back(*s++);
Expand Down Expand Up @@ -1238,7 +1234,7 @@ public void commands(void)
int newaction;
int save_jump_sline;
int save_search_type;
char *extra;
constant char *extra;
char tbuf[2];
PARG parg;
IFILE old_ifile;
Expand Down
Loading

0 comments on commit 8b6e333

Please sign in to comment.