# HG changeset patch # User masneyb # Date 1066488893 0 # Node ID 5f66f09e5194aa361f6d6d5c62e67430c0d2b248 # Parent c8627e70adb5bfd7e0cfc1ff5c78e7aeaa0640cc 2003-10-17 Brian Masney * lib/misc.c (insert_commas) - if _GNU_SOURCE is defined, instead of using my builtin function for formatting numbers, use glibc's %'ld (or %'lld) format to print the numbers out. This is more portable for other locales. diff -r c8627e70adb5 -r 5f66f09e5194 ChangeLog --- a/ChangeLog Sat Oct 18 14:42:17 2003 +0000 +++ b/ChangeLog Sat Oct 18 14:54:53 2003 +0000 @@ -1,4 +1,9 @@ 2003-10-17 Brian Masney + * lib/misc.c (insert_commas) - if _GNU_SOURCE is defined, instead of + using my builtin function for formatting numbers, use glibc's %'ld + (or %'lld) format to print the numbers out. This is more portable for + other locales. + * lib/rfc959.c (rfc959_ipv[46]_data_connection_new) - when there is an error establishing a connection to the remote server, make sure that GFTP_ERETRYABLE is returned. @@ -1563,7 +1568,7 @@ * cvsclean - added this script - * *.[ch] - added $Id: ChangeLog,v 1.150 2003/10/18 14:42:17 masneyb Exp $ tags + * *.[ch] - added $Id: ChangeLog,v 1.151 2003/10/18 14:54:52 masneyb Exp $ tags * debian/* - updated files from Debian maintainer diff -r c8627e70adb5 -r 5f66f09e5194 lib/misc.c --- a/lib/misc.c Sat Oct 18 14:42:17 2003 +0000 +++ b/lib/misc.c Sat Oct 18 14:54:53 2003 +0000 @@ -22,7 +22,33 @@ #include "gftp.h" #include "options.h" -/* FIXME - this isn't right for all locales. Use glib's printf instead */ +#ifdef _GNU_SOURCE + +char * +insert_commas (off_t number, char *dest_str, size_t dest_len) +{ + if (dest_str != NULL) + { +#if defined (_LARGEFILE_SOURCE) + g_snprintf (dest_str, dest_len, "%'lld", number); +#else + g_snprintf (dest_str, dest_len, "%'ld", number); +#endif + } + else + { +#if defined (_LARGEFILE_SOURCE) + dest_str = g_strdup_printf ("%'lld", number); +#else + dest_str = g_strdup_printf ("%'ld", number); +#endif + } + + return (dest_str); +} + +#else + char * insert_commas (off_t number, char *dest_str, size_t dest_len) { @@ -92,6 +118,7 @@ return (dest); } +#endif char * alltrim (char *str) @@ -356,6 +383,10 @@ printf ("%s\n", gftp_version); +#ifdef _GNU_SOURCE + printf ("#define _GNU_SOURCE\n"); +#endif + #ifdef _LARGEFILE_SOURCE printf ("#define _LARGEFILE_SOURCE\n"); #endif