]> sjero.net Git - wget/commitdiff
[svn] Rename LARGE_INT to SUM_SIZE_INT, and simplify its handling.
authorhniksic <devnull@localhost>
Sat, 25 Jun 2005 14:39:51 +0000 (07:39 -0700)
committerhniksic <devnull@localhost>
Sat, 25 Jun 2005 14:39:51 +0000 (07:39 -0700)
12 files changed:
src/ChangeLog
src/ftp.c
src/http.c
src/init.c
src/main.c
src/options.h
src/recur.c
src/retr.c
src/sysdep.h
src/utils.c
src/utils.h
src/wget.h

index a6fbc346b0fbdc648b3969cc139c8d3980bc55ae..c57476f74e86fd14053310899536489ebefd77d0 100644 (file)
@@ -1,3 +1,16 @@
+2005-06-25  Hrvoje Niksic  <hniksic@xemacs.org>
+
+       * utils.c (with_thousand_seps_sum): Now defined only if
+       SUM_SIZE_INT is double.
+
+       * wget.h (SUM_SIZE_INT): Instead of bothering with long, long
+       long, __int64, and friends, simply either use wgint or double, end
+       of story.  Since we know how to print either, we no longer need
+       LARGE_INT_FMT.
+
+       * sysdeps.h (LARGE_INT): Renamed to SUM_SIZE_INT to better reflect
+       its intent, and moved to wget.h.
+
 2005-06-25  Hrvoje Niksic  <hniksic@xemacs.org>
 
        * Makefile.in: No need to clean .libs.
index e8e9a5a4a34f196e41b06d2c9f91a9f447320c7f..b32d329e90dc2f7f74fa6598ef8e75c3d723c67b 100644 (file)
--- a/src/ftp.c
+++ b/src/ftp.c
@@ -50,7 +50,7 @@ so, delete this exception statement from your version.  */
 #include "convert.h"           /* for downloaded_file */
 #include "recur.h"             /* for INFINITE_RECURSION */
 
-extern LARGE_INT total_downloaded_bytes;
+extern SUM_SIZE_INT total_downloaded_bytes;
 
 /* File where the "ls -al" listing will be saved.  */
 #define LIST_FILENAME ".listing"
index 30a1ca24ebe29e1407d3e7f523ec99c292f5a140..36a8e9fbf5a195f30c3faf95813d0948142ada26 100644 (file)
@@ -59,7 +59,7 @@ so, delete this exception statement from your version.  */
 #include "convert.h"
 
 extern char *version_string;
-extern LARGE_INT total_downloaded_bytes;
+extern SUM_SIZE_INT total_downloaded_bytes;
 
 extern FILE *output_stream;
 extern bool output_stream_regular;
index 686cac9692f7b7ad97a31bc793a4acdb6275f15a..a86006b4071ed6e8e72eb766b441b9afe5ec4334 100644 (file)
@@ -63,7 +63,7 @@ static bool enable_tilde_expansion;
 
 CMD_DECLARE (cmd_boolean);
 CMD_DECLARE (cmd_bytes);
-CMD_DECLARE (cmd_bytes_large);
+CMD_DECLARE (cmd_bytes_sum);
 #ifdef HAVE_SSL
 CMD_DECLARE (cmd_cert_type);
 #endif
@@ -200,7 +200,7 @@ static struct {
   { "proxypassword",   &opt.proxy_passwd,      cmd_string },
   { "proxyuser",       &opt.proxy_user,        cmd_string },
   { "quiet",           &opt.quiet,             cmd_boolean },
-  { "quota",           &opt.quota,             cmd_bytes_large },
+  { "quota",           &opt.quota,             cmd_bytes_sum },
 #ifdef HAVE_SSL
   { "randomfile",      &opt.random_file,       cmd_file },
 #endif
@@ -862,7 +862,7 @@ cmd_directory_vector (const char *com, const char *val, void *place)
   return true;
 }
 
-/* Engine for cmd_bytes and cmd_bytes_large: converts a string such as
+/* Engine for cmd_bytes and cmd_bytes_sum: converts a string such as
    "100k" or "2.5G" to a floating point number.  */
 
 static bool
@@ -948,12 +948,12 @@ cmd_bytes (const char *com, const char *val, void *place)
 }
 
 /* Like cmd_bytes, but PLACE is interpreted as a pointer to
-   LARGE_INT.  It works by converting the string to double, therefore
+   SIZE_SUM.  It works by converting the string to double, therefore
    working with values up to 2^53-1 without loss of precision.  This
    value (8192 TB) is large enough to serve for a while.  */
 
 static bool
-cmd_bytes_large (const char *com, const char *val, void *place)
+cmd_bytes_sum (const char *com, const char *val, void *place)
 {
   double byte_value;
   if (!parse_bytes_helper (val, &byte_value))
@@ -962,7 +962,7 @@ cmd_bytes_large (const char *com, const char *val, void *place)
               exec_name, com, val);
       return false;
     }
-  *(LARGE_INT *)place = (LARGE_INT)byte_value;
+  *(SUM_SIZE_INT *) place = (SUM_SIZE_INT) byte_value;
   return true;
 }
 
index c39432a2589a7c0b5578a576ffabd6e5e5c03dbd..a70812333e2be7881bec7a505c36bc0e5c8df29a 100644 (file)
@@ -61,7 +61,7 @@ so, delete this exception statement from your version.  */
 
 struct options opt;
 
-extern LARGE_INT total_downloaded_bytes;
+extern SUM_SIZE_INT total_downloaded_bytes;
 extern char *version_string;
 
 extern struct cookie_jar *wget_cookie_jar;
@@ -961,13 +961,14 @@ Can't timestamp and not clobber old files at the same time.\n"));
     {
       logprintf (LOG_NOTQUIET,
                 _("\nFINISHED --%s--\nDownloaded: %s bytes in %d files\n"),
-                time_str (NULL), with_thousand_seps_large (total_downloaded_bytes),
+                time_str (NULL),
+                with_thousand_seps_sum (total_downloaded_bytes),
                 opt.numurls);
       /* Print quota warning, if exceeded.  */
       if (opt.quota && total_downloaded_bytes > opt.quota)
        logprintf (LOG_NOTQUIET,
                   _("Download quota (%s bytes) EXCEEDED!\n"),
-                  with_thousand_seps_large (opt.quota));
+                  with_thousand_seps_sum (opt.quota));
     }
 
   if (opt.cookies_output)
index 097a0ffb4e96611dfb318a34c2aca576ea44d980..e6b5051555c95b3628c7f954d1cf1090eaad66ed 100644 (file)
@@ -116,7 +116,7 @@ struct options
 
   wgint limit_rate;            /* Limit the download rate to this
                                   many bps. */
-  LARGE_INT quota;             /* Maximum file size to download and
+  SUM_SIZE_INT quota;          /* Maximum file size to download and
                                   store. */
 
   int numurls;                 /* Number of successfully downloaded
index 4975d610b5adf39d05634fee363dcb3a18f1c1af..75ed6f9d13599ba30fb5aea942d343a60552076d 100644 (file)
@@ -50,7 +50,7 @@ so, delete this exception statement from your version.  */
 #include "convert.h"
 
 extern char *version_string;
-extern LARGE_INT total_downloaded_bytes;
+extern SUM_SIZE_INT total_downloaded_bytes;
 
 extern struct hash_table *dl_url_file_map;
 extern struct hash_table *downloaded_html_set;
index 30b81a881a7e489f3428ef37b3f45d9e62d62418..0285a57a90c2b12f503d6e08bb285ccf8e232fe6 100644 (file)
@@ -52,7 +52,7 @@ so, delete this exception statement from your version.  */
 #include "ptimer.h"
 
 /* Total size of downloaded files.  Used to enforce quota.  */
-LARGE_INT total_downloaded_bytes;
+SUM_SIZE_INT total_downloaded_bytes;
 
 /* If non-NULL, the stream to which output should be written.  This
    stream is initialized when `-O' is used.  */
index 344fe822323514e1ecbea01d8342be53c6abb8f8..408083f885cc613fe35acc5324ae1d9da21831ee 100644 (file)
@@ -96,35 +96,6 @@ typedef unsigned char _Bool;
 # define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
 #endif
 
-/* Define a large integral type useful for storing large sizes that
-   exceed sizes of one download, such as when printing the sum of all
-   downloads.  Note that this has nothing to do with large file
-   support, which determines the wgint type.  This should be as large
-   as possible even on systems where when wgint is 32-bit; also,
-   unlike wgint, this can be a floating point type.
-
-   We use a 64-bit integral type where available, `double' otherwise.
-   It's hard to print LARGE_INT's portably, but fortunately it's
-   rarely needed.  */
-
-#if SIZEOF_LONG >= 8
-/* Long is large enough: use it.  */
-typedef long LARGE_INT;
-# define LARGE_INT_FMT "%ld"
-#elif SIZEOF_LONG_LONG >= 8
-/* Long long is large enough: use it.  */
-typedef long long LARGE_INT;
-# define LARGE_INT_FMT "%lld"
-#elif WINDOWS
-/* Use __int64 under Windows. */
-typedef __int64 LARGE_INT;
-# define LARGE_INT_FMT "%I64"
-#else
-/* Large integer type unavailable; fake it with `double'.  */
-typedef double LARGE_INT;
-# define LARGE_INT_FMT "%.0f"
-#endif
-
 /* These are needed so we can #define struct_stat to struct _stati64
    under Windows. */
 #ifndef struct_stat
index 4dffdfe8a551937418e4d5e9e65109eb23e8a1eb..5eb0d88cd10846f8a5ee7d90afbf6267b125c7da 100644 (file)
@@ -1162,7 +1162,7 @@ free_keys_and_values (struct hash_table *ht)
 
 \f
 /* Add thousand separators to a number already in string form.  Used
-   by with_thousand_seps and with_thousand_seps_large.  */
+   by with_thousand_seps and with_thousand_seps_sum.  */
 
 static char *
 add_thousand_seps (const char *repr)
@@ -1213,30 +1213,19 @@ with_thousand_seps (wgint l)
   return add_thousand_seps (inbuf);
 }
 
-/* Write a string representation of LARGE_INT NUMBER into the provided
-   buffer.
-
-   It would be dangerous to use sprintf, because the code wouldn't
-   work on a machine with gcc-provided long long support, but without
-   libc support for "%lld".  However, such old systems platforms
-   typically lack snprintf and will end up using our version, which
-   does support "%lld" whereever long longs are available.  */
-
-static void
-large_int_to_string (char *buffer, int bufsize, LARGE_INT number)
-{
-  snprintf (buffer, bufsize, LARGE_INT_FMT, number);
-}
-
-/* The same as with_thousand_seps, but works on LARGE_INT.  */
+/* When SUM_SIZE_INT is wgint, with_thousand_seps_large is #defined to
+   with_thousand_seps.  The function below is used on non-LFS systems
+   where SUM_SIZE_INT typedeffed to double.  */
 
+#ifndef with_thousand_seps_sum
 char *
-with_thousand_seps_large (LARGE_INT l)
+with_thousand_seps_sum (SUM_SIZE_INT l)
 {
-  char inbuf[48];
-  large_int_to_string (inbuf, sizeof (inbuf), l);
+  char inbuf[64];
+  snprintf (inbuf, sizeof (inbuf), "%.0f", l);
   return add_thousand_seps (inbuf);
 }
+#endif /* not with_thousand_seps_sum */
 
 /* N, a byte quantity, is converted to a human-readable abberviated
    form a la sizes printed by `ls -lh'.  The result is written to a
index 26364cbcc2b64719f658ed988e00e5bdf934d977..043924d4464251fab4a7f24452fcc3f4ad45e853 100644 (file)
@@ -95,7 +95,9 @@ void string_set_free (struct hash_table *);
 void free_keys_and_values (struct hash_table *);
 
 char *with_thousand_seps (wgint);
-char *with_thousand_seps_large (LARGE_INT);
+#ifndef with_thousand_seps_sum
+char *with_thousand_seps_sum (SUM_SIZE_INT);
+#endif
 char *human_readable (wgint);
 int numdigit (wgint);
 char *number_to_string (char *, wgint);
index 7b76f8d83834cbf550680d0101bddb45a8019607..21fa88104c7c5be5ea4b1215d8c37aa9da00ee3b 100644 (file)
@@ -129,6 +129,25 @@ typedef off_t wgint;
 # endif
 #endif
 
+/* Now define a large integral type useful for storing sizes of *sums*
+   of downloads, such as the value of the --quota option.  This should
+   be a type able to hold 2G+ values even on systems without large
+   file support.  (It is useful to limit Wget's download quota to say
+   10G even if a single file cannot be that large.)
+
+   To make sure we get the largest size possible, we use `double' on
+   systems without a 64-bit integral type.  (Since it is used in very
+   few places in Wget, this is acceptable.)  */
+
+#if SIZEOF_WGINT >= 8
+/* just use wgint, which we already know how to print */
+typedef wgint SUM_SIZE_INT;
+# define with_thousand_seps_sum with_thousand_seps
+#else
+/* On systems without LFS, use double, which buys us integers up to 2^53. */
+typedef double SUM_SIZE_INT;
+#endif
+
 #include "options.h"
 
 /* Everything uses this, so include them here directly.  */