Return -1/EINVAL when the buffer is too small.
[gnulib.git] / lib / human.c
index 5582634..b342bf1 100644 (file)
 # include <locale.h>
 #endif
 
-#if HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
-#ifndef HAVE_DECL_GETENV
-"this configure-time declaration test was not run"
-#endif
-#if !HAVE_DECL_GETENV
-char *getenv ();
-#endif
-
-#if HAVE_STRING_H
-# include <string.h>
-#endif
-
-#if HAVE_STRINGS_H
-# include <strings.h>
-#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
@@ -353,11 +339,9 @@ human_readable (uintmax_t n, char *buf, int opts,
          }
       }
 
-    if (inexact_style == human_ceiling
-       ? 0 < tenths + rounding
-       : inexact_style == human_round_to_nearest
-       ? 5 < tenths + (2 < rounding + (amt & 1))
-       : /* inexact_style == human_floor */ 0)
+    if (inexact_style == human_round_to_nearest
+       ? 5 < tenths + (0 < rounding + (amt & 1))
+       : inexact_style == human_ceiling && 0 < tenths + rounding)
       {
        amt++;