tweaks: adjust a couple of types, to reduce the number of warnings

This avoids eleven warnings of the kind "comparison between signed
and unsigned integer expressions [-Wsign-compare]".
master
Benno Schulenberg 2018-03-22 19:32:17 +01:00
parent c88a2fd9ca
commit 30fc197b66
6 changed files with 13 additions and 12 deletions

View File

@ -32,9 +32,9 @@ static char **filelist = NULL;
/* The list of files to display in the file browser. */
static size_t filelist_len = 0;
/* The number of files in the list. */
static int width = 0;
static size_t width = 0;
/* The number of files that we can display per screen row. */
static int longest = 0;
static size_t longest = 0;
/* The number of columns in the longest filename in the list. */
static size_t selected = 0;
/* The currently selected filename in the list; zero-based. */
@ -258,9 +258,9 @@ char *do_browser(char *path)
/* In case the specified directory cannot be entered, select it
* (if it is in the current list) so it will be highlighted. */
for (i = 0; i < filelist_len; i++)
if (strcmp(filelist[i], path) == 0)
selected = i;
for (size_t j = 0; j < filelist_len; j++)
if (strcmp(filelist[j], path) == 0)
selected = j;
/* Try opening and reading the specified directory. */
goto read_directory_contents;
@ -525,7 +525,7 @@ void browser_refresh(void)
/* The length of the filename in columns. */
size_t infolen;
/* The length of the file information in columns. */
int infomaxlen = 7;
size_t infomaxlen = 7;
/* The maximum length of the file information in columns:
* normally seven, but will be twelve for "(parent dir)". */
bool dots = (COLS >= 15 && namelen >= longest - infomaxlen);

View File

@ -2600,7 +2600,8 @@ char *input_tab(char *buf, bool allow_files, size_t *place,
if (!*lastwastab)
*lastwastab = TRUE;
else if (num_matches > 1) {
int longest_name = 0, ncols, editline = 0;
size_t longest_name = 0, ncols;
int editline = 0;
/* Sort the list of available choices. */
qsort(matches, num_matches, sizeof(char *), diralphasort);

View File

@ -46,7 +46,7 @@ char *tempfilename = NULL;
* read that file into a new buffer. */
void wrap_the_help_text(bool redisplaying)
{
int sum = 0;
size_t sum = 0;
const char *ptr = start_of_body;
FILE *tempfile = fopen(tempfilename, "w+b");

View File

@ -187,7 +187,7 @@ void do_statusbar_output(int *the_input, size_t input_len,
{
char *output = charalloc(input_len + 1);
char onechar[MAXCHARLEN];
int i, char_len;
size_t char_len, i;
/* Copy the typed stuff so it can be treated. */
for (i = 0; i < input_len; i++)

View File

@ -3577,8 +3577,8 @@ char *copy_completion(char *check_line, int start)
void complete_a_word(void)
{
char *shard, *completion = NULL;
int start_of_shard, shard_length = 0;
int i = 0, j = 0;
size_t start_of_shard, shard_length = 0;
size_t i = 0, j = 0;
completion_word *some_word;
#ifdef ENABLE_WRAPPING
bool was_set_wrapping = !ISSET(NO_WRAP);

View File

@ -456,7 +456,7 @@ size_t strnlenpt(const char *text, size_t maxlen)
return 0;
while (*text != '\0') {
int charlen = parse_mbchar(text, NULL, &width);
size_t charlen = parse_mbchar(text, NULL, &width);
if (maxlen <= charlen)
break;