Skip to content

Commit

Permalink
Final (?) type cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
gwsw committed Nov 14, 2023
1 parent a82a2a9 commit d46500e
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions forwback.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public void forw(int n, POSITION pos, int force, int only_last, int nblank)

#if HILITE_SEARCH
if (pos != NULL_POSITION && (hilite_search == OPT_ONPLUS || is_filtering() || status_col)) {
prep_hilite(pos, pos + 4*size_linebuf, ignore_eoi ? 1 : -1);
prep_hilite(pos, pos + (POSITION) (4*size_linebuf), ignore_eoi ? 1 : -1);
pos = next_unfiltered(pos);
}
#endif
Expand Down Expand Up @@ -401,7 +401,7 @@ public void back(int n, POSITION pos, int force, int only_last)
do_repaint = (n > get_back_scroll() || (only_last && n > sc_height-1) || header_lines > 0);
#if HILITE_SEARCH
if (pos != NULL_POSITION && (hilite_search == OPT_ONPLUS || is_filtering() || status_col)) {
prep_hilite((pos < 3*size_linebuf) ? 0 : pos - 3*size_linebuf, pos, -1);
prep_hilite((pos < 3*size_linebuf) ? 0 : pos - (POSITION) (3*size_linebuf), pos, -1);
}
#endif
while (--n >= 0)
Expand Down
6 changes: 2 additions & 4 deletions input.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ public POSITION forw_line_seg(POSITION curr_pos, lbool skipeol, lbool rscroll, l
* If we're not ignoring EOI, we *could* do the same, but
* for efficiency we prepare several lines ahead at once.
*/
prep_hilite(curr_pos, curr_pos + 3*size_linebuf,
ignore_eoi ? 1 : -1);
prep_hilite(curr_pos, curr_pos + (POSITION) (3*size_linebuf), ignore_eoi ? 1 : -1);
curr_pos = next_unfiltered(curr_pos);
}
#endif
Expand Down Expand Up @@ -357,8 +356,7 @@ public POSITION back_line(POSITION curr_pos)
}
#if HILITE_SEARCH
if (hilite_search == OPT_ONPLUS || is_filtering() || status_col)
prep_hilite((curr_pos < 3*size_linebuf) ?
0 : curr_pos - 3*size_linebuf, curr_pos, -1);
prep_hilite((curr_pos < 3*size_linebuf) ? 0 : curr_pos - (POSITION) (3*size_linebuf), curr_pos, -1);
#endif
if (ch_seek(curr_pos-1))
{
Expand Down
2 changes: 2 additions & 0 deletions lang.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

#define ptr_diff(p1,p2) ((size_t) ((p1)-(p2)))

#define size_t_null ((size_t)-1)

#ifndef NULL
#define NULL 0
#endif
Expand Down
4 changes: 2 additions & 2 deletions lessecho.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,13 @@ static long lstrtol(char *s, char **pend, int radix)
return (n);
}

static void add_metachar(int ch)
static void add_metachar(char ch)
{
if (num_metachars+1 >= size_metachars)
{
char *p;
size_metachars = (size_metachars > 0) ? size_metachars*2 : 16;
p = (char *) malloc(size_metachars);
p = (char *) malloc((size_t) size_metachars);
if (p == NULL)
pr_error("Cannot allocate memory");

Expand Down
8 changes: 4 additions & 4 deletions lesskey_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ static void parse_error(constant char *fmt, constant char *arg1)
char buf[1024];
int n = SNPRINTF2(buf, sizeof(buf), "%s: line %d: ", lesskey_file, linenum);
if (n >= 0 && n < sizeof(buf))
SNPRINTF1(buf+n, sizeof(buf)-n, fmt, arg1);
SNPRINTF1(buf+n, sizeof(buf)-(size_t)n, fmt, arg1);
++errors;
lesskey_parse_error(buf);
}
Expand All @@ -159,7 +159,7 @@ static void init_tables(struct lesskey_tables *tables)

#define CHAR_STRING_LEN 8

static constant char * char_string(char *buf, int ch, int lit)
static constant char * char_string(char *buf, char ch, int lit)
{
if (lit || (ch >= 0x20 && ch < 0x7f))
{
Expand Down Expand Up @@ -209,7 +209,7 @@ static constant char * tstr(char **pp, int xlate)
ch = 0;
i = 0;
do
ch = 8*ch + (*p - '0');
ch = (char) (8*ch + (*p - '0'));
while (*++p >= '0' && *p <= '7' && ++i < 3);
*pp = p;
if (xlate && ch == CONTROL('K'))
Expand Down Expand Up @@ -356,7 +356,7 @@ static void erase_cmd_char(struct lesskey_tables *tables)
static void add_cmd_str(constant char *s, struct lesskey_tables *tables)
{
for ( ; *s != '\0'; s++)
add_cmd_char(*s, tables);
add_cmd_char((unsigned char) *s, tables);
}

/*
Expand Down
6 changes: 3 additions & 3 deletions line.c
Original file line number Diff line number Diff line change
Expand Up @@ -1329,7 +1329,7 @@ public void null_line(void)
* lines which are not split for screen width.
* {{ This is supposed to be more efficient than forw_line(). }}
*/
public POSITION forw_raw_line_len(POSITION curr_pos, ssize_t read_len, constant char **linep, size_t *line_lenp)
public POSITION forw_raw_line_len(POSITION curr_pos, size_t read_len, constant char **linep, size_t *line_lenp)
{
size_t n;
int c;
Expand Down Expand Up @@ -1360,7 +1360,7 @@ public POSITION forw_raw_line_len(POSITION curr_pos, ssize_t read_len, constant
}
}
linebuf.buf[n++] = (char) c;
if (read_len >= 0 && n >= read_len)
if (read_len != size_t_null && read_len > 0 && n >= read_len)
{
new_pos = ch_tell();
break;
Expand All @@ -1377,7 +1377,7 @@ public POSITION forw_raw_line_len(POSITION curr_pos, ssize_t read_len, constant

public POSITION forw_raw_line(POSITION curr_pos, constant char **linep, size_t *line_lenp)
{
return forw_raw_line_len(curr_pos, -1, linep, line_lenp);
return forw_raw_line_len(curr_pos, size_t_null, linep, line_lenp);
}

/*
Expand Down
4 changes: 2 additions & 2 deletions prompt.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ static lbool cond(char c, int where)
* Here we decode that letter and take the appropriate action,
* usually by appending something to the message being built.
*/
static void protochar(int c, int where, int iseditproto)
static void protochar(char c, int where, int iseditproto)
{
POSITION pos;
POSITION len;
Expand Down Expand Up @@ -459,7 +459,7 @@ static constant char * wherechar(char constant *p, int *wp)
public constant char * pr_expand(constant char *proto)
{
constant char *p;
int c;
char c;
int where;

mp = message;
Expand Down
8 changes: 4 additions & 4 deletions search.c
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ public POSITION prev_unfiltered(POSITION pos)

static void shift_visible(size_t start_off, size_t end_off, size_t line_len)
{
size_t swidth = (size_t) sc_width - line_pfx_width();
size_t swidth = (size_t) (sc_width - line_pfx_width());
int new_hshift;
if (end_off < swidth) /* whole string is in first screen */
new_hshift = 0;
Expand Down Expand Up @@ -1209,8 +1209,8 @@ static int search_range(POSITION pos, POSITION endpos, int search_type, int matc
int *chpos;
POSITION linepos, oldpos;
int skip_bytes = 0;
size_t swidth = (size_t) sc_width - line_pfx_width(); /*{{type-issue}}*/
size_t sheight = (size_t) sc_height - sindex_from_sline(jump_sline);
size_t swidth = (size_t) (sc_width - line_pfx_width()); /*{{type-issue}}*/
size_t sheight = (size_t) (sc_height - sindex_from_sline(jump_sline));

linenum = find_linenum(pos);
if (nosearch_headers && linenum <= header_lines)
Expand Down Expand Up @@ -1423,7 +1423,7 @@ static int search_range(POSITION pos, POSITION endpos, int search_type, int matc
{
size_t end_off = ptr_diff(ep[0], cline);
if (end_off >= swidth * sheight / 4) /* heuristic */
*plastlinepos = get_lastlinepos(linepos, linepos + chpos[end_off], sheight);
*plastlinepos = get_lastlinepos(linepos, linepos + chpos[end_off], (int) sheight);
}
}
free(cline);
Expand Down
2 changes: 1 addition & 1 deletion xbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ static lbool help_fixup(void *r, uintmax val, int rsize, int rsigned)
*pr = (unsigned long) val;
#ifdef ULLONG_MAX
} else if (rsize == sizeof (unsigned long long)) {
long long *pr = r;
unsigned long long *pr = r;
if (ULLONG_MAX < val)
return TRUE;
*pr = (unsigned long long) val;
Expand Down

0 comments on commit d46500e

Please sign in to comment.