change some listing.c variables to unsigned.

The values are unsigned, and changing the types allows some casts to
be removed.
This commit is contained in:
Alan Modra
2025-06-09 12:54:42 +09:30
parent 02aa7e267b
commit a259da93f3
3 changed files with 16 additions and 16 deletions

View File

@@ -930,7 +930,7 @@ This program has absolutely no warranty.\n"));
break; break;
case OPTION_LISTING_LHS_WIDTH2: case OPTION_LISTING_LHS_WIDTH2:
{ {
int tmp = atoi (optarg); unsigned int tmp = atoi (optarg);
if (tmp > listing_lhs_width) if (tmp > listing_lhs_width)
listing_lhs_width_second = tmp; listing_lhs_width_second = tmp;

View File

@@ -190,10 +190,10 @@ struct list_info_struct
typedef struct list_info_struct list_info_type; typedef struct list_info_struct list_info_type;
int listing_lhs_width = LISTING_LHS_WIDTH; unsigned int listing_lhs_width = LISTING_LHS_WIDTH;
int listing_lhs_width_second = LISTING_LHS_WIDTH_SECOND; unsigned int listing_lhs_width_second = LISTING_LHS_WIDTH_SECOND;
int listing_lhs_cont_lines = LISTING_LHS_CONT_LINES; unsigned int listing_lhs_cont_lines = LISTING_LHS_CONT_LINES;
int listing_rhs_width = LISTING_RHS_WIDTH; unsigned int listing_rhs_width = LISTING_RHS_WIDTH;
struct list_info_struct * listing_tail; struct list_info_struct * listing_tail;
@@ -201,8 +201,8 @@ static file_info_type * file_info_head;
static file_info_type * last_open_file_info; static file_info_type * last_open_file_info;
static FILE * last_open_file; static FILE * last_open_file;
static struct list_info_struct * head; static struct list_info_struct * head;
static int paper_width = 200; static unsigned int paper_width = 200;
static int paper_height = 60; static unsigned int paper_height = 60;
extern int listing; extern int listing;
@@ -735,7 +735,7 @@ listing_page (list_info_type *list)
{ {
/* Grope around, see if we can see a title or subtitle edict coming up /* Grope around, see if we can see a title or subtitle edict coming up
soon. (we look down 10 lines of the page and see if it's there) */ soon. (we look down 10 lines of the page and see if it's there) */
if ((eject || (on_page >= (unsigned int) paper_height)) if ((eject || (on_page >= paper_height))
&& paper_height != 0) && paper_height != 0)
{ {
unsigned int c = 10; unsigned int c = 10;
@@ -793,7 +793,7 @@ emit_line (list_info_type * list, const char * format, ...)
static unsigned int static unsigned int
calc_hex (list_info_type *list) calc_hex (list_info_type *list)
{ {
int data_buffer_size; size_t data_buffer_size;
list_info_type *first = list; list_info_type *first = list;
unsigned int address = ~(unsigned int) 0; unsigned int address = ~(unsigned int) 0;
fragS *frag; fragS *frag;
@@ -920,7 +920,7 @@ print_lines (list_info_type *list, unsigned int lineno,
emit_line (list, "**** %s\n", msg->message); emit_line (list, "**** %s\n", msg->message);
for (lines = 0; for (lines = 0;
lines < (unsigned int) listing_lhs_cont_lines lines < listing_lhs_cont_lines
&& src[cur]; && src[cur];
lines++) lines++)
{ {
@@ -1356,7 +1356,7 @@ print_timestamp (void)
static void static void
print_single_option (char * opt, int *pos) print_single_option (char * opt, int *pos)
{ {
int opt_len = strlen (opt); size_t opt_len = strlen (opt);
if ((*pos + opt_len) < paper_width) if ((*pos + opt_len) < paper_width)
{ {
@@ -1525,7 +1525,7 @@ listing_psize (int width_only)
{ {
paper_height = get_absolute_expression (); paper_height = get_absolute_expression ();
if (paper_height < 0 || paper_height > 1000) if (paper_height > 1000)
{ {
paper_height = 0; paper_height = 0;
as_warn (_("strange paper height, set to no form")); as_warn (_("strange paper height, set to no form"));

View File

@@ -70,10 +70,10 @@ void listing_width (unsigned int x);
#define listing_source_line(line) ((void)(line)) #define listing_source_line(line) ((void)(line))
#endif #endif
extern int listing_lhs_width; extern unsigned int listing_lhs_width;
extern int listing_lhs_width_second; extern unsigned int listing_lhs_width_second;
extern int listing_lhs_cont_lines; extern unsigned int listing_lhs_cont_lines;
extern int listing_rhs_width; extern unsigned int listing_rhs_width;
extern struct list_info_struct *listing_tail; extern struct list_info_struct *listing_tail;