1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-17 18:45:10 +00:00

Add fscanf_no_i18n() to fix sf.net #3154556

This commit is contained in:
Nikolas Garofil 2011-02-10 01:08:34 +01:00
parent 6287b22a3d
commit 2aafb591ee

View File

@ -871,6 +871,26 @@ int update_cpu_usage(void)
return 0;
}
//fscanf() that reads floats with points even if you are using a locale where
//floats are with commas
int fscanf_no_i18n(FILE *stream, const char *format, ...) {
int returncode;
va_list ap;
#ifdef BUILD_I18N
const char *oldlocale = setlocale(LC_NUMERIC, NULL);
setlocale(LC_NUMERIC, "C");
#endif
va_start(ap, format);
returncode = vfscanf(stream, format, ap);
va_end(ap);
#ifdef BUILD_I18N
setlocale(LC_NUMERIC, oldlocale);
#endif
return returncode;
}
int update_load_average(void)
{
#ifdef HAVE_GETLOADAVG
@ -891,7 +911,7 @@ int update_load_average(void)
info.loadavg[0] = info.loadavg[1] = info.loadavg[2] = 0.0;
return 0;
}
if (fscanf(fp, "%f %f %f", &info.loadavg[0], &info.loadavg[1],
if (fscanf_no_i18n(fp, "%f %f %f", &info.loadavg[0], &info.loadavg[1],
&info.loadavg[2]) < 0)
info.loadavg[0] = info.loadavg[1] = info.loadavg[2] = 0.0;
fclose(fp);