From: Jeremy Harris Date: Thu, 1 Sep 2016 18:20:11 +0000 (+0100) Subject: Support "G" multiplier on integer configuration values X-Git-Tag: exim-4_88_RC1~19 X-Git-Url: https://git.exim.org/exim.git/commitdiff_plain/dcb72db9ece0902199a95f6a06fa56ce10587dd4?hp=692b0b1ab0384ebfad82706881b9a547aa334422 Support "G" multiplier on integer configuration values --- diff --git a/doc/doc-docbook/spec.xfpt b/doc/doc-docbook/spec.xfpt index 3ab63e5ec..dc2b6ac05 100644 --- a/doc/doc-docbook/spec.xfpt +++ b/doc/doc-docbook/spec.xfpt @@ -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 -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 diff --git a/doc/doc-txt/NewStuff b/doc/doc-txt/NewStuff index b9ed8a00d..20af1a28f 100644 --- a/doc/doc-txt/NewStuff +++ b/doc/doc-txt/NewStuff @@ -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. +11. Integer values for options can take a "G" multiplier. + Version 4.87 ------------ diff --git a/src/src/readconf.c b/src/src/readconf.c index 646932412..fb9d47a09 100644 --- a/src/src/readconf.c +++ b/src/src/readconf.c @@ -1985,7 +1985,7 @@ switch (type) 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: @@ -2001,7 +2001,6 @@ switch (type) inttype, name); if (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 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, @@ -2034,8 +2039,8 @@ switch (type) *((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: @@ -2049,22 +2054,26 @@ switch (type) 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++; } - 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++; } + else if (tolower(*endptr) == 'k') + endptr++; else - { 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); diff --git a/test/confs/0001 b/test/confs/0001 index 0fd7efe44..8d55b2989 100644 --- a/test/confs/0001 +++ b/test/confs/0001 @@ -530,7 +530,7 @@ appendfile: 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 diff --git a/test/confs/0180 b/test/confs/0180 index b61722c48..c4a0bd5af 100644 --- a/test/confs/0180 +++ b/test/confs/0180 @@ -1,7 +1,7 @@ # 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