summaryrefslogtreecommitdiff
path: root/src
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 /src
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().
Diffstat (limited to 'src')
-rw-r--r--src/src/buildconfig.c30
-rw-r--r--src/src/expand.c5
-rw-r--r--src/src/string.c8
3 files changed, 30 insertions, 13 deletions
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;