Fix --quota on systems with 32bit long type

* src/init.c (cmd_bytes_sum): Use WGINT_MIN and WGINT_MAX in check.
* src/options.h (struct options): Make 'quota' of type wgint.
* src/retr.c: Make 'total_downloaded_bytes' of type wgint.
* src/utils.h: Fix comment.
* src/wget.h: Add WGINT_MIN, remove SUM_SIZE_INT.
This commit is contained in:
Tim Rühsen 2021-01-16 20:00:30 +01:00
parent adc5aa0196
commit ad36a467ac
6 changed files with 7 additions and 8 deletions

View File

@ -1372,13 +1372,13 @@ cmd_bytes_sum (const char *com, const char *val, void *place)
double byte_value;
if (!parse_bytes_helper (val, &byte_value)
|| byte_value < LONG_MIN || byte_value > LONG_MAX)
|| byte_value < WGINT_MIN || byte_value > WGINT_MAX)
{
fprintf (stderr, _("%s: %s: Invalid byte value %s\n"),
exec_name, com, quote (val));
return false;
}
*(SUM_SIZE_INT *) place = (SUM_SIZE_INT) byte_value;
*(wgint *) place = (wgint) byte_value;
return true;
}

View File

@ -171,7 +171,7 @@ struct options
wgint limit_rate; /* Limit the download rate to this
many bps. */
SUM_SIZE_INT quota; /* Maximum file size to download and
wgint quota; /* Maximum file size to download and
store. */
bool server_response; /* Do we print server response? */

View File

@ -62,7 +62,7 @@ as that of the covered work. */
#include "hsts.h"
/* Total size of downloaded files. Used to enforce quota. */
SUM_SIZE_INT total_downloaded_bytes;
wgint total_downloaded_bytes;
/* Total download time in seconds. */
double total_download_time;

View File

@ -37,7 +37,7 @@ extern int numurls;
/* These global vars should be made static to retr.c and exported via
functions! */
extern SUM_SIZE_INT total_downloaded_bytes;
extern wgint total_downloaded_bytes;
extern double total_download_time;
extern FILE *output_stream;
extern bool output_stream_regular;

View File

@ -121,8 +121,7 @@ void free_keys_and_values (struct hash_table *);
const char *with_thousand_seps (wgint);
/* human_readable must be able to accept wgint and SUM_SIZE_INT
arguments. */
/* human_readable must be able to accept wgint arguments. */
char *human_readable (wgint, const int, const int);

View File

@ -141,8 +141,8 @@ as that of the covered work. */
#include <stdint.h>
typedef int64_t wgint;
#define WGINT_MIN INT64_MIN
#define WGINT_MAX INT64_MAX
typedef wgint SUM_SIZE_INT;
#define str_to_wgint strtol