changeset 926:7b5aa0420fe2

2007-6-13 Brian Masney <masneyb@gftp.org> * lib/misc.c (insert_commas) lib/gftp.h - explictly cast the number to a long long if it is supported on the system. This fixes a problem where the number is converted to an integer when the sizeof (off_t) != sizeof (long long)
author masneyb
date Thu, 14 Jun 2007 02:06:41 +0000
parents 8dc2c1624fbf
children 9889e8eb3f52
files ChangeLog lib/gftp.h lib/misc.c
diffstat 3 files changed, 21 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Jun 09 11:50:40 2007 +0000
+++ b/ChangeLog	Thu Jun 14 02:06:41 2007 +0000
@@ -1,3 +1,9 @@
+2007-6-13 Brian Masney <masneyb@gftp.org>
+	* lib/misc.c (insert_commas) lib/gftp.h - explictly cast the number to
+	a long long if it is supported on the system. This fixes a problem
+	where the number is converted to an integer when the sizeof (off_t) !=
+	sizeof (long long)
+
 2007-5-18 Brian Masney <masneyb@gftp.org>
 	* lib/protocols.c (gftp_request_destroy) - initialize the 
 	request->server_type if the request structure isn't destroyed.
--- a/lib/gftp.h	Sat Jun 09 11:50:40 2007 +0000
+++ b/lib/gftp.h	Thu Jun 14 02:06:41 2007 +0000
@@ -167,12 +167,14 @@
 #define GFTP_OFF_T_PRINTF_MOD		"%lld"
 #define GFTP_OFF_T_11PRINTF_MOD		"%11lld"
 #define gftp_parse_file_size(str)	strtoll (str, NULL, 10)
+#define GFTP_OFF_T_PRINTF_CONVERSION	long long
 #else
 #define GFTP_OFF_T_HEX_PRINTF_MOD	"%lx"
 #define GFTP_OFF_T_INTL_PRINTF_MOD	"%'ld"
 #define GFTP_OFF_T_PRINTF_MOD		"%ld"
 #define GFTP_OFF_T_11PRINTF_MOD		"%11ld"
 #define gftp_parse_file_size(str)	strtol (str, NULL, 10)
+#define GFTP_OFF_T_PRINTF_CONVERSION	off_t
 #endif
 
 /* Server types (used by FTP protocol from SYST command) */
--- a/lib/misc.c	Sat Jun 09 11:50:40 2007 +0000
+++ b/lib/misc.c	Thu Jun 14 02:06:41 2007 +0000
@@ -27,9 +27,11 @@
 insert_commas (off_t number, char *dest_str, size_t dest_len)
 {
   if (dest_str != NULL)
-    g_snprintf (dest_str, dest_len, GFTP_OFF_T_INTL_PRINTF_MOD, number);
+    g_snprintf (dest_str, dest_len, GFTP_OFF_T_INTL_PRINTF_MOD,
+                (GFTP_OFF_T_PRINTF_CONVERSION) number);
   else
-    dest_str = g_strdup_printf (GFTP_OFF_T_INTL_PRINTF_MOD, number);
+    dest_str = g_strdup_printf (GFTP_OFF_T_INTL_PRINTF_MOD,
+                                (GFTP_OFF_T_PRINTF_CONVERSION) number);
 
   return (dest_str);
 }
@@ -324,6 +326,15 @@
 
   printf ("sizeof (off_t) = %d\n", sizeof (off_t));
 
+#ifdef HAVE_INTL_PRINTF
+  printf ("#define HAVE_INTL_PRINTF\n");
+#endif
+
+  printf ("GFTP_OFF_T_HEX_PRINTF_MOD = %s\n", GFTP_OFF_T_HEX_PRINTF_MOD);
+  printf ("GFTP_OFF_T_INTL_PRINTF_MOD = %s\n", GFTP_OFF_T_INTL_PRINTF_MOD);
+  printf ("GFTP_OFF_T_PRINTF_MOD = %s\n", GFTP_OFF_T_PRINTF_MOD);
+  printf ("GFTP_OFF_T_11PRINTF_MOD = %s\n", GFTP_OFF_T_11PRINTF_MOD);
+
 #ifdef HAVE_GETADDRINFO
   printf ("#define HAVE_GETADDRINFO\n");
 #endif
@@ -352,10 +363,6 @@
   printf ("#define HAVE_GETTEXT\n");
 #endif
 
-#ifdef HAVE_INTL_PRINTF
-  printf ("#define HAVE_INTL_PRINTF\n");
-#endif
-
   printf ("glib version: %d.%d.%d\n", GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION,
           GLIB_MICRO_VERSION);