1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

warc: remove a magic number

This commit is contained in:
Giuseppe Scrivano 2012-11-26 22:50:06 +01:00
parent b60ff61b75
commit 3ebbd84518
3 changed files with 13 additions and 2 deletions

View File

@ -1,3 +1,10 @@
2012-11-26 Giuseppe Scrivano <gscrivano@gnu.org>
* wget.h (MAX_INT_TO_STRING_LEN): Define macro.
* warc.c (warc_write_block_from_file): Use `MAX_INT_TO_STRING_LEN'
to find the buffer size.
(warc_write_cdx_record): Likewise.
2012-09-03 Tim Ruehsen <tim.ruehsen@gmx.de>
* http.c (digest_authentication_encode): Add support for RFC 2617

View File

@ -245,7 +245,7 @@ static bool
warc_write_block_from_file (FILE *data_in)
{
/* Add the Content-Length header. */
char content_length[22];
char content_length[MAX_INT_TO_STRING_LEN(off_t)];
fseeko (data_in, 0L, SEEK_END);
number_to_string (content_length, ftello (data_in));
warc_write_header ("Content-Length", content_length);
@ -1225,7 +1225,7 @@ warc_write_cdx_record (const char *url, const char *timestamp_str,
if (redirect_location == NULL || strlen(redirect_location) == 0)
redirect_location = "-";
char offset_string[22];
char offset_string[MAX_INT_TO_STRING_LEN(off_t)];
number_to_string (offset_string, offset);
/* Print the CDX line. */

View File

@ -314,6 +314,10 @@ typedef double SUM_SIZE_INT;
0-pad the address.) */
#define PTR_FORMAT(p) (int) (2 * sizeof (void *)), (unsigned long) (p)
/* Find the maximum buffer length needed to print an integer of type `x'
in base 10. 24082 / 10000 = 8*log_{10}(2). */
#define MAX_INT_TO_STRING_LEN(x) ((sizeof(x) * 24082 / 10000) + 2)
extern const char *exec_name;
/* Document type ("dt") flags */