ph10 2005/06/17 14:52:15 BST
Modified files:
exim-doc/doc-txt ChangeLog
exim-src/src buildconfig.c expand.c string.c
Log:
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().
Revision Changes Path
1.163 +8 -3 exim/exim-doc/doc-txt/ChangeLog
1.9 +24 -4 exim/exim-src/src/buildconfig.c
1.29 +2 -1 exim/exim-src/src/expand.c
1.6 +1 -5 exim/exim-src/src/string.c
Index: ChangeLog
===================================================================
RCS file: /home/cvs/exim/exim-doc/doc-txt/ChangeLog,v
retrieving revision 1.162
retrieving revision 1.163
diff -u -r1.162 -r1.163
--- ChangeLog 17 Jun 2005 10:47:05 -0000 1.162
+++ ChangeLog 17 Jun 2005 13:52:14 -0000 1.163
@@ -1,4 +1,4 @@
-$Cambridge: exim/exim-doc/doc-txt/ChangeLog,v 1.162 2005/06/17 10:47:05 ph10 Exp $
+$Cambridge: exim/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/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
@@ -154,6 +154,11 @@
and a new error check for 8bit text in MIME parts. Comparator and
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
Index: buildconfig.c
===================================================================
RCS file: /home/cvs/exim/exim-src/src/buildconfig.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- buildconfig.c 16 Jun 2005 14:10:13 -0000 1.8
+++ buildconfig.c 17 Jun 2005 13:52:15 -0000 1.9
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/exim-src/src/buildconfig.c,v 1.8 2005/06/16 14:10:13 ph10 Exp $ */
+/* $Cambridge: exim/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 @@
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 @@
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");
Index: expand.c
===================================================================
RCS file: /home/cvs/exim/exim-src/src/expand.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- expand.c 17 Jun 2005 08:23:28 -0000 1.28
+++ expand.c 17 Jun 2005 13:52:15 -0000 1.29
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/exim-src/src/expand.c,v 1.28 2005/06/17 08:23:28 ph10 Exp $ */
+/* $Cambridge: exim/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 @@
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;
}
Index: string.c
===================================================================
RCS file: /home/cvs/exim/exim-src/src/string.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- string.c 16 Jun 2005 14:10:13 -0000 1.5
+++ string.c 17 Jun 2005 13:52:15 -0000 1.6
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/exim-src/src/string.c,v 1.5 2005/06/16 14:10:13 ph10 Exp $ */
+/* $Cambridge: exim/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 @@
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;