Mercurial > gftp.yaz
comparison lib/misc.c @ 289:5f66f09e5194
2003-10-17 Brian Masney <masneyb@gftp.org>
* 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.
author | masneyb |
---|---|
date | Sat, 18 Oct 2003 14:54:53 +0000 |
parents | 71d0098c3735 |
children | 6e255984c0b0 |
comparison
equal
deleted
inserted
replaced
288:c8627e70adb5 | 289:5f66f09e5194 |
---|---|
20 static const char cvsid[] = "$Id$"; | 20 static const char cvsid[] = "$Id$"; |
21 | 21 |
22 #include "gftp.h" | 22 #include "gftp.h" |
23 #include "options.h" | 23 #include "options.h" |
24 | 24 |
25 /* FIXME - this isn't right for all locales. Use glib's printf instead */ | 25 #ifdef _GNU_SOURCE |
26 | |
27 char * | |
28 insert_commas (off_t number, char *dest_str, size_t dest_len) | |
29 { | |
30 if (dest_str != NULL) | |
31 { | |
32 #if defined (_LARGEFILE_SOURCE) | |
33 g_snprintf (dest_str, dest_len, "%'lld", number); | |
34 #else | |
35 g_snprintf (dest_str, dest_len, "%'ld", number); | |
36 #endif | |
37 } | |
38 else | |
39 { | |
40 #if defined (_LARGEFILE_SOURCE) | |
41 dest_str = g_strdup_printf ("%'lld", number); | |
42 #else | |
43 dest_str = g_strdup_printf ("%'ld", number); | |
44 #endif | |
45 } | |
46 | |
47 return (dest_str); | |
48 } | |
49 | |
50 #else | |
51 | |
26 char * | 52 char * |
27 insert_commas (off_t number, char *dest_str, size_t dest_len) | 53 insert_commas (off_t number, char *dest_str, size_t dest_len) |
28 { | 54 { |
29 char *frompos, *topos, src[50], *dest; | 55 char *frompos, *topos, src[50], *dest; |
30 int len, num, rem, i; | 56 int len, num, rem, i; |
90 } | 116 } |
91 *topos = '\0'; | 117 *topos = '\0'; |
92 return (dest); | 118 return (dest); |
93 } | 119 } |
94 | 120 |
121 #endif | |
95 | 122 |
96 char * | 123 char * |
97 alltrim (char *str) | 124 alltrim (char *str) |
98 { | 125 { |
99 char *pos, *newpos; | 126 char *pos, *newpos; |
354 { | 381 { |
355 int i; | 382 int i; |
356 | 383 |
357 printf ("%s\n", gftp_version); | 384 printf ("%s\n", gftp_version); |
358 | 385 |
386 #ifdef _GNU_SOURCE | |
387 printf ("#define _GNU_SOURCE\n"); | |
388 #endif | |
389 | |
359 #ifdef _LARGEFILE_SOURCE | 390 #ifdef _LARGEFILE_SOURCE |
360 printf ("#define _LARGEFILE_SOURCE\n"); | 391 printf ("#define _LARGEFILE_SOURCE\n"); |
361 #endif | 392 #endif |
362 | 393 |
363 #ifdef _FILE_OFFSET_BITS | 394 #ifdef _FILE_OFFSET_BITS |