#include "gstrtsprange.h"
+static gdouble
+gst_strtod (const gchar * dstr)
+{
+ gchar s[G_ASCII_DTOSTR_BUF_SIZE] = { 0, };
+
+ /* canonicalise floating point string so we can handle float strings
+ * in the form "24.930" or "24,930" irrespective of the current locale.
+ * We should always be getting floats in 24.930 format with a floating point,
+ * but let's accept malformed ones as well, easy mistake to make after all */
+ g_strlcpy (s, dstr, sizeof (s));
+ g_strdelimit (s, ",", '.');
+ return g_ascii_strtod (s, NULL);
+}
+
/* npt-time = "now" | npt-sec | npt-hhmmss
* npt-sec = 1*DIGIT [ "." *DIGIT ]
* npt-hhmmss = npt-hh ":" npt-mm ":" npt-ss [ "." *DIGIT ]
} else if (str[0] == '\0') {
time->type = GST_RTSP_TIME_END;
} else if (strstr (str, ":")) {
- gfloat seconds;
gint hours, mins;
- sscanf (str, "%2d:%2d:%f", &hours, &mins, &seconds);
-
+ sscanf (str, "%2d:%2d:", &hours, &mins);
+ str = strchr (str, ':') + 1;
+ str = strchr (str, ':') + 1;
time->type = GST_RTSP_TIME_SECONDS;
- time->seconds = ((hours * 60) + mins) * 60 + seconds;
+ time->seconds = ((hours * 60) + mins) * 60 + gst_strtod (str);
} else {
- gfloat seconds;
-
- sscanf (str, "%f", &seconds);
-
time->type = GST_RTSP_TIME_SECONDS;
- time->seconds = seconds;
+ time->seconds = gst_strtod (str);
}
return GST_RTSP_OK;
}
static gboolean
npt_time_string (const GstRTSPTime * time, GString * string)
{
+ gchar dstrbuf[G_ASCII_DTOSTR_BUF_SIZE] = { 0, };
gboolean res = TRUE;;
switch (time->type) {
case GST_RTSP_TIME_SECONDS:
- g_string_append_printf (string, "%f", time->seconds);
+ /* need to format floating point value strings as in C locale */
+ g_ascii_dtostr (dstrbuf, G_ASCII_DTOSTR_BUF_SIZE, time->seconds);
+ g_string_append (string, dstrbuf);
break;
case GST_RTSP_TIME_NOW:
g_string_append (string, "now");