Blame SOURCES/procps-ng-3.3.10-top-locale-independent-float-delay.patch

92d9ea
diff -up ./top/top.c.ori ./top/top.c
92d9ea
--- ./top/top.c.ori	2018-01-15 14:04:42.403457405 +0100
92d9ea
+++ ./top/top.c	2018-01-15 14:07:59.663713707 +0100
92d9ea
@@ -1260,15 +1260,25 @@ static char *ioline (const char *prompt)
92d9ea
 
92d9ea
 
92d9ea
         /*
92d9ea
-         * Make locale aware float (but maybe restrict to whole numbers). */
92d9ea
+         * Make locale unaware float (but maybe restrict to whole numbers). */
92d9ea
 static int mkfloat (const char *str, float *num, int whole) {
92d9ea
-   char *ep;
92d9ea
+   char tmp[SMLBUFSIZ], *ep;
92d9ea
 
92d9ea
-   if (whole)
92d9ea
+   if (whole) {
92d9ea
       *num = (float)strtol(str, &ep, 0);
92d9ea
-   else
92d9ea
-      *num = strtof(str, &ep);
92d9ea
-   if (ep != str && *ep == '\0' && *num < INT_MAX)
92d9ea
+      if (ep != str && *ep == '\0' && *num < INT_MAX)
92d9ea
+         return 1;
92d9ea
+      return 0;
92d9ea
+   }
92d9ea
+   snprintf(tmp, sizeof(tmp), "%s", str);
92d9ea
+   *num = strtof(tmp, &ep);
92d9ea
+   if (*ep != '\0') {
92d9ea
+      // fallback - try to swap the floating point separator
92d9ea
+      if (*ep == '.') *ep = ',';
92d9ea
+      else if (*ep == ',') *ep = '.';
92d9ea
+      *num = strtof(tmp, &ep);
92d9ea
+   }
92d9ea
+   if (ep != tmp && *ep == '\0' && *num < INT_MAX)
92d9ea
       return 1;
92d9ea
    return 0;
92d9ea
 } // end: mkfloat