Support "G" multiplier on integer configuration values
authorJeremy Harris <jgh146exb@wizmail.org>
Thu, 1 Sep 2016 18:20:11 +0000 (19:20 +0100)
committerJeremy Harris <jgh146exb@wizmail.org>
Thu, 1 Sep 2016 20:19:40 +0000 (21:19 +0100)
doc/doc-docbook/spec.xfpt
doc/doc-txt/NewStuff
src/src/readconf.c
test/confs/0001
test/confs/0180

index 3ab63e5ecbb66c924966ba43bf33ae7232ca55a9..dc2b6ac059971dfa761fd1db01005f6c55d63e46 100644 (file)
@@ -5136,7 +5136,11 @@ with the characters &"0x"&, in which case the remainder is interpreted as a
 hexadecimal number.
 
 If an integer value is followed by the letter K, it is multiplied by 1024; if
 hexadecimal number.
 
 If an integer value is followed by the letter K, it is multiplied by 1024; if
-it is followed by the letter M, it is multiplied by 1024x1024. When the values
+it is followed by the letter M, it is multiplied by 1024x1024;
+.new
+if by the letter G, 1024x1024x1024.
+.wen
+When the values
 of integer option settings are output, values which are an exact multiple of
 1024 or 1024x1024 are sometimes, but not always, printed using the letters K
 and M. The printing style is independent of the actual input format that was
 of integer option settings are output, values which are an exact multiple of
 1024 or 1024x1024 are sometimes, but not always, printed using the letters K
 and M. The printing style is independent of the actual input format that was
index b9ed8a00dd330235bd73e3ea0065e6d38e973651..20af1a28fe6899c78e86e626b829d2d1d027d4fe 100644 (file)
@@ -41,6 +41,8 @@ Version 4.88
     and go on with some roughly recognisable name.  Use the "-bP macros"
     command-line option to see what is present.
 
     and go on with some roughly recognisable name.  Use the "-bP macros"
     command-line option to see what is present.
 
+11. Integer values for options can take a "G" multiplier.
+
 
 Version 4.87
 ------------
 
 Version 4.87
 ------------
index 646932412663baf99381ac374051bcb6a0acb12f..fb9d47a099f33f16126105e9a1286698468f2071 100644 (file)
@@ -1985,7 +1985,7 @@ switch (type)
   inttype = US"octal ";
 
   /*  Integer: a simple(ish) case; allow octal and hex formats, and
   inttype = US"octal ";
 
   /*  Integer: a simple(ish) case; allow octal and hex formats, and
-  suffixes K and M. The different types affect output, not input. */
+  suffixes K, M and G. The different types affect output, not input. */
 
   case opt_mkint:
   case opt_int:
 
   case opt_mkint:
   case opt_int:
@@ -2001,7 +2001,6 @@ switch (type)
         inttype, name);
 
     if (errno != ERANGE)
         inttype, name);
 
     if (errno != ERANGE)
-      {
       if (tolower(*endptr) == 'k')
         {
         if (lvalue > INT_MAX/1024 || lvalue < INT_MIN/1024) errno = ERANGE;
       if (tolower(*endptr) == 'k')
         {
         if (lvalue > INT_MAX/1024 || lvalue < INT_MIN/1024) errno = ERANGE;
@@ -2015,7 +2014,13 @@ switch (type)
         else lvalue *= 1024*1024;
         endptr++;
         }
         else lvalue *= 1024*1024;
         endptr++;
         }
-      }
+      else if (tolower(*endptr) == 'g')
+        {
+        if (lvalue > INT_MAX/(1024*1024*1024) || lvalue < INT_MIN/(1024*1024*1024))
+          errno = ERANGE;
+        else lvalue *= 1024*1024*1024;
+        endptr++;
+        }
 
     if (errno == ERANGE || lvalue > INT_MAX || lvalue < INT_MIN)
       log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,
 
     if (errno == ERANGE || lvalue > INT_MAX || lvalue < INT_MIN)
       log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,
@@ -2034,8 +2039,8 @@ switch (type)
     *((int *)((uschar *)data_block + (long int)(ol->value))) = value;
   break;
 
     *((int *)((uschar *)data_block + (long int)(ol->value))) = value;
   break;
 
-  /*  Integer held in K: again, allow octal and hex formats, and suffixes K and
-  M. */
+  /*  Integer held in K: again, allow octal and hex formats, and suffixes K, M
+  and G. */
   /*XXX consider moving to int_eximarith_t (but mind the overflow test 0415) */
 
   case opt_Kint:
   /*XXX consider moving to int_eximarith_t (but mind the overflow test 0415) */
 
   case opt_Kint:
@@ -2049,22 +2054,26 @@ switch (type)
         inttype, name);
 
     if (errno != ERANGE)
         inttype, name);
 
     if (errno != ERANGE)
-      {
-      if (tolower(*endptr) == 'm')
+      if (tolower(*endptr) == 'g')
         {
         {
-        if (value > INT_MAX/1024 || value < INT_MIN/1024) errno = ERANGE;
-          else value *= 1024;
+        if (value > INT_MAX/(1024*1024) || value < INT_MIN/(1024*1024))
+         errno = ERANGE;
+       else
+         value *= 1024*1024;
         endptr++;
         }
         endptr++;
         }
-      else if (tolower(*endptr) == 'k')
+      else if (tolower(*endptr) == 'm')
         {
         {
+        if (value > INT_MAX/1024 || value < INT_MIN/1024)
+         errno = ERANGE;
+       else
+         value *= 1024;
         endptr++;
         }
         endptr++;
         }
+      else if (tolower(*endptr) == 'k')
+        endptr++;
       else
       else
-        {
         value = (value + 512)/1024;
         value = (value + 512)/1024;
-        }
-      }
 
     if (errno == ERANGE) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,
       "absolute value of integer \"%s\" is too large (overflow)", s);
 
     if (errno == ERANGE) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,
       "absolute value of integer \"%s\" is too large (overflow)", s);
index 0fd7efe44c702433e6700514a1897a9f6bb7c428..8d55b2989724e57eff75cb17531b4ba85d38f654 100644 (file)
@@ -530,7 +530,7 @@ appendfile:
   lockfile_timeout = 30m
   mailbox_size = 1000
   mailbox_filecount = 9999
   lockfile_timeout = 30m
   mailbox_size = 1000
   mailbox_filecount = 9999
-  message_size_limit = 1M
+  message_size_limit = 1G
   mode = 0600
   mode_fail_narrower
   no_notify_comsat
   mode = 0600
   mode_fail_narrower
   no_notify_comsat
index b61722c48ac36c85d440bd99f3ccc83ec24860b7..c4a0bd5af631e7ae871291544ac686e0c9e63a01 100644 (file)
@@ -1,7 +1,7 @@
 # Exim test configuration 0180
 
 # Require immense amount of disk space, expecting to fail.  Can unfortunately work on big filesystems.
 # Exim test configuration 0180
 
 # Require immense amount of disk space, expecting to fail.  Can unfortunately work on big filesystems.
-CSS=check_spool_space=400000000K
+CSS=check_spool_space=400G
 
 .include DIR/aux-var/std_conf_prefix
 
 
 .include DIR/aux-var/std_conf_prefix