diff lib/misc.c @ 220:6de9a8280aa4

2003-7-10 Brian Masney <masneyb@gftp.org> * lib/misc.c (insert_commas) - improved calculating # of digits in number. (Not sure if this worked properly for long long's, aka off_t when _LARGEFILE_SOURCE is defined) * src/gtk/transfer.c (update_file_status) - changed type of remaining field to be off_t. (hopefully fixes >2.1GB problem) * lib/protocols.c (gftp_calc_kbs) - improved throttling module.
author masneyb
date Fri, 11 Jul 2003 01:48:08 +0000
parents cf4098008615
children a85a097bbb02
line wrap: on
line diff
--- a/lib/misc.c	Wed Jul 09 23:25:57 2003 +0000
+++ b/lib/misc.c	Fri Jul 11 01:48:08 2003 +0000
@@ -29,11 +29,17 @@
   char *frompos, *topos, src[50], *dest;
   int len, num, rem, i;
 
+#if defined (_LARGEFILE_SOURCE)
+  g_snprintf (src, sizeof (src), "%lld", number);
+#else
+  g_snprintf (src, sizeof (src), "%ld", number);
+#endif
+
   if (dest_str != NULL)
     *dest_str = '\0';
-  len = (number > 0 ? log10 (number) : 0) + 2;
 
-  if (len <= 0) 
+  len = strlen (src);
+  if (len == 0)
     {
       if (dest_str != NULL)
         strncpy (dest_str, "0", dest_len);
@@ -43,6 +49,7 @@
     }
 
   len += len / 3;
+
   if (dest_str != NULL && len > dest_len)
     {
       
@@ -57,12 +64,6 @@
   else
     dest = dest_str;
 
-#if defined (_LARGEFILE_SOURCE)
-  g_snprintf (src, sizeof (src), "%lld", number);
-#else
-  g_snprintf (src, sizeof (src), "%ld", number);
-#endif
-
   num = strlen (src) / 3 - 1;
   rem = strlen (src) % 3;
   frompos = src;