* top: provides more accurate cpu usage at startup
* top: display NUMA node under which a thread ran
* top: fix argument parsing quirk resulting in SEGV Redhat #1450429
+ * top: delay interval accepts non-locale radix point Redhat #1182248
* watch: define HOST_NAME_MAX where not defined Debian #830734
procps-ng-3.3.12
/*
- * Make locale aware float (but maybe restrict to whole numbers). */
+ * Make locale unaware float (but maybe restrict to whole numbers). */
static int mkfloat (const char *str, float *num, int whole) {
- char *ep;
+ char tmp[SMLBUFSIZ], *ep;
- if (whole)
+ if (whole) {
*num = (float)strtol(str, &ep, 0);
- else
- *num = strtof(str, &ep);
- if (ep != str && *ep == '\0' && *num < INT_MAX)
+ if (ep != str && *ep == '\0' && *num < INT_MAX)
+ return 1;
+ return 0;
+ }
+ snprintf(tmp, sizeof(tmp), "%s", str);
+ *num = strtof(tmp, &ep);
+ if (*ep != '\0') {
+ // fallback - try to swap the floating point separator
+ if (*ep == '.') *ep = ',';
+ else if (*ep == ',') *ep = '.';
+ *num = strtof(tmp, &ep);
+ }
+ if (ep != tmp && *ep == '\0' && *num < INT_MAX)
return 1;
return 0;
} // end: mkfloat