Added macros for time_t as for off_t and used them to rework the code of
authorPhilip Hazel <ph10@hermes.cam.ac.uk>
Fri, 17 Jun 2005 13:52:14 +0000 (13:52 +0000)
committerPhilip Hazel <ph10@hermes.cam.ac.uk>
Fri, 17 Jun 2005 13:52:14 +0000 (13:52 +0000)
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().

doc/doc-txt/ChangeLog
src/src/buildconfig.c
src/src/expand.c
src/src/string.c

index d5a78abcb5a441a15fca247d789404d7a3497125..d920ada8bb6afd86575ba2a697ec4bbd93fc29a0 100644 (file)
@@ -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
 -----------------
index ee5e431a9172d965d562be662cffd65a54329095..2cfc32de26bfcb5112f1a5ed4121cfa418912a64 100644 (file)
@@ -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");
 
index d428c20deafa63e1318eb6ad7436439a19cc77d6..9618823973e9f63a49e1f6b60d5eefe8fa2dcb01 100644 (file)
@@ -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;
 }
 
index aa4f9333801683262a21d29a19e535d05e94f529..1679e8850e568d728cdf89687f27983c68351382 100644 (file)
@@ -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;