Bug 1395524 - Use AppendFloat when converting the float interval to the env var string. r?njn
MozReview-Commit-ID: GsW9W3aJZTg
--- a/tools/profiler/core/platform.cpp
+++ b/tools/profiler/core/platform.cpp
@@ -2512,18 +2512,25 @@ AutoSetProfilerEnvVarsForChildProcess::A
return;
}
PR_SetEnv("MOZ_PROFILER_STARTUP=1");
SprintfLiteral(mSetEntries, "MOZ_PROFILER_STARTUP_ENTRIES=%d",
ActivePS::Entries(lock));
PR_SetEnv(mSetEntries);
- SprintfLiteral(mSetInterval, "MOZ_PROFILER_STARTUP_INTERVAL=%f",
- ActivePS::Interval(lock));
+ // Use AppendFloat instead of SprintfLiteral with %f because the decimal
+ // separator used by %f is locale-dependent. But the string we produce needs
+ // to be parseable by strtod, which only accepts the period character as a
+ // decimal separator. AppendFloat always uses the period character.
+ nsCString setInterval;
+ setInterval.AppendLiteral("MOZ_PROFILER_STARTUP_INTERVAL=");
+ setInterval.AppendFloat(ActivePS::Interval(lock));
+ strncpy(mSetInterval, setInterval.get(), MOZ_ARRAY_LENGTH(mSetInterval));
+ mSetInterval[MOZ_ARRAY_LENGTH(mSetInterval) - 1] = '\0';
PR_SetEnv(mSetInterval);
SprintfLiteral(mSetFeaturesBitfield,
"MOZ_PROFILER_STARTUP_FEATURES_BITFIELD=%d",
ActivePS::Features(lock));
PR_SetEnv(mSetFeaturesBitfield);
std::string filtersString;