summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Hazel <ph10@hermes.cam.ac.uk>2005-06-17 13:52:14 +0000
committerPhilip Hazel <ph10@hermes.cam.ac.uk>2005-06-17 13:52:14 +0000
commitc6c2dc1dfc3928a5f6c61024b68e011db41884ad (patch)
treee3f0f718db88ef757d3b7fa13740a71fdb67bc72
parent638456761a5573015658c4826824539021d14342 (diff)
Added macros for time_t as for off_t and used them to rework the code of
Tom's prvs patch to avoid the hardwired use of "%lld" and "long long". Replaced the call to snprintf() with a call to string_vformat().
-rw-r--r--doc/doc-txt/ChangeLog13
-rw-r--r--src/src/buildconfig.c30
-rw-r--r--src/src/expand.c5
-rw-r--r--src/src/string.c8
4 files changed, 39 insertions, 17 deletions
diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog
index d5a78abcb..d920ada8b 100644
--- a/doc/doc-txt/ChangeLog
+++ b/doc/doc-txt/ChangeLog
@@ -1,4 +1,4 @@
-$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.162 2005/06/17 10:47:05 ph10 Exp $
+$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.163 2005/06/17 13:52:14 ph10 Exp $
Change log file for Exim from version 4.21
-------------------------------------------
@@ -123,9 +123,9 @@ PH/14 Imported PCRE 6.0; this was more than just a trivial operation because
PH/15 The code I had for printing potentially long long variables in PH/11
above was not the best (it lost precision). The length of off_t variables
is now inspected at build time, and an appropriate printing format (%ld
- or %lld) is chosen and #defined by OFF_T_FMT. We also define ASSUME_
- LONG_LONG_SUPPORT if the length is greater than 4. This is needed for the
- internal formatting function string_vformat().
+ or %lld) is chosen and #defined by OFF_T_FMT. We also define LONGLONG_T
+ to be "long long int" or "long int". This is needed for the internal
+ formatting function string_vformat().
PH/16 Applied Matthew Newton's patch to exicyclog: "If log_file_path is set in
the configuration file to be ":syslog", then the script "guesses" where
@@ -155,6 +155,11 @@ PH/19 Applied Michael Haardt's patch to update Sieve to RFC3028bis. "The
require names are now matched exactly. I enabled the subaddress
extension, but it is not well tested yet (read: it works for me)."
+PH/20 Added macros for time_t as for off_t (see PH/15 above) and used them to
+ rework some of the code of TK/09 above to avoid the hardwired use of
+ "%lld" and "long long". Replaced the call to snprintf() with a call to
+ string_vformat().
+
Exim version 4.51
-----------------
diff --git a/src/src/buildconfig.c b/src/src/buildconfig.c
index ee5e431a9..2cfc32de2 100644
--- a/src/src/buildconfig.c
+++ b/src/src/buildconfig.c
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/buildconfig.c,v 1.8 2005/06/16 14:10:13 ph10 Exp $ */
+/* $Cambridge: exim/src/src/buildconfig.c,v 1.9 2005/06/17 13:52:15 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -15,9 +15,9 @@
/* This auxiliary program builds the file config.h by the following
process:
-First, it determines the size of off_t variables, and generates macro code to
-define OFF_T_FMT as a suitable format, if it is not already defined in the
-system-specific header file.
+First, it determines the size of off_t and time_t variables, and generates
+macro code to define OFF_T_FMT and TIME_T_FMT as suitable formats, if they are
+not already defined in the system-specific header file.
Then it reads Makefile, looking for certain OS-specific definitions which it
uses to define some specific macros. Finally, it reads the defaults file
@@ -102,6 +102,7 @@ int
main(int argc, char **argv)
{
off_t test_off_t = 0;
+time_t test_time_t = 0;
FILE *base;
FILE *new;
int last_initial = 'A';
@@ -147,11 +148,30 @@ fprintf(new, "#ifndef OFF_T_FMT\n");
if (sizeof(test_off_t) > 4)
{
fprintf(new, "#define OFF_T_FMT \"%%lld\"\n");
- fprintf(new, "#define ASSUME_LONG_LONG_SUPPORT\n");
+ fprintf(new, "#define LONGLONG_T long long int\n");
}
else
{
fprintf(new, "#define OFF_T_FMT \"%%ld\"\n");
+ fprintf(new, "#define LONGLONG_T long int\n");
+ }
+fprintf(new, "#endif\n\n");
+
+/* Now do the same thing for time_t variables. If the length is greater than
+4, we want to assume long long support (even if off_t was less than 4). If the
+length is 4 or less, we can leave LONGLONG_T to whatever was defined above for
+off_t. */
+
+fprintf(new, "#ifndef TIME_T_FMT\n");
+if (sizeof(test_time_t) > 4)
+ {
+ fprintf(new, "#define TIME_T_FMT \"%%lld\"\n");
+ fprintf(new, "#undef LONGLONG_T\n");
+ fprintf(new, "#define LONGLONG_T long long int\n");
+ }
+else
+ {
+ fprintf(new, "#define TIME_T_FMT \"%%ld\"\n");
}
fprintf(new, "#endif\n\n");
diff --git a/src/src/expand.c b/src/src/expand.c
index d428c20de..961882397 100644
--- a/src/src/expand.c
+++ b/src/src/expand.c
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/expand.c,v 1.28 2005/06/17 08:23:28 ph10 Exp $ */
+/* $Cambridge: exim/src/src/expand.c,v 1.29 2005/06/17 13:52:15 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -4962,7 +4962,8 @@ uschar *
prvs_daystamp(int day_offset)
{
uschar *days = store_get(10);
-snprintf(CS days, 9, "%lld", (((long long)time(NULL))+(day_offset*86400))/86400);
+(void)string_format(days, 10, TIME_T_FMT,
+ (((LONGLONG_T)time(NULL))+(day_offset*86400))/86400);
return (Ustrlen(days) >= 3) ? &days[Ustrlen(days)-3] : NULL;
}
diff --git a/src/src/string.c b/src/src/string.c
index aa4f93338..1679e8850 100644
--- a/src/src/string.c
+++ b/src/src/string.c
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/string.c,v 1.5 2005/06/16 14:10:13 ph10 Exp $ */
+/* $Cambridge: exim/src/src/string.c,v 1.6 2005/06/17 13:52:15 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -1087,11 +1087,7 @@ while (*fp != 0)
case L_SHORT:
case L_NORMAL: sprintf(CS p, newformat, va_arg(ap, int)); break;
case L_LONG: sprintf(CS p, newformat, va_arg(ap, long int)); break;
- #ifdef ASSUME_LONG_LONG_SUPPORT
- case L_LONGLONG: sprintf(CS p, newformat, va_arg(ap, long long int)); break;
- #else
- case L_LONGLONG: sprintf(CS p, newformat, va_arg(ap, long long int)); break;
- #endif
+ case L_LONGLONG: sprintf(CS p, newformat, va_arg(ap, LONGLONG_T)); break;
}
while (*p) p++;
break;