# HG changeset patch
# User MakeMyDay <makemyday@gmx-topmail.de>
# Date 1462123729 -7200
#      Sun May 01 19:28:49 2016 +0200
# Branch THUNDERBIRD3880_2016050308_RELBRANCH
# Node ID 5d4558af351a1fd5cb96629c9e76494406a62231
# Parent  75585db7937f5843b7096da826960ac3050d88f7
Bug 1261692 - MODIFICATION_FAILED error when decimal separator is comma;r+a=philipp

make sure snprintf uses the "C" locale when printing floating point numbers

thanks for the patch Christophe!

Backport of upstream commit https://github.com/libical/libical/commit/d3623d1f5a9ef3be16bd32e117c0d96f1f9626d2

diff --git a/calendar/libical/src/libical/icalvalue.c b/calendar/libical/src/libical/icalvalue.c
--- a/calendar/libical/src/libical/icalvalue.c
+++ b/calendar/libical/src/libical/icalvalue.c
@@ -1035,39 +1035,61 @@
     return str;
 
 }
 
 static char* icalvalue_float_as_ical_string_r(const icalvalue* value) {
 
     float data;
     char* str;
+    char* old_locale;
     icalerror_check_arg_rz( (value!=0),"value");
     data = icalvalue_get_float(value);
 
+    /* bypass current locale in order to make
+       sure snprintf uses a '.' as a separator
+       set locate to 'C' and keep old locale */
+    old_locale = strdup (setlocale (LC_NUMERIC,NULL));
+    setlocale (LC_NUMERIC,"C");
+
     str = (char*)icalmemory_new_buffer(40);
 
     snprintf(str,40,"%f",data);
 
+    /* restore saved locale */
+    setlocale (LC_NUMERIC,old_locale);
+    free (old_locale);
+
     return str;
 }
 
 
 static char* icalvalue_geo_as_ical_string_r(const icalvalue* value) {
 
     struct icalgeotype data;
     char* str;
+    char* old_locale;
     icalerror_check_arg_rz( (value!=0),"value");
 
     data = icalvalue_get_geo(value);
 
+    /* bypass current locale in order to make
+     * sure snprintf uses a '.' as a separator
+     * set locate to 'C' and keep old locale */
+    old_locale = strdup (setlocale (LC_NUMERIC,NULL));
+    setlocale (LC_NUMERIC,"C");
+
     str = (char*)icalmemory_new_buffer(80);
 
     snprintf(str,80,"%f;%f",data.lat,data.lon);
 
+    /* restore saved locale */
+    setlocale (LC_NUMERIC,old_locale);
+    free (old_locale);
+
     return str;
 }
 
 
 static char* icalvalue_datetimeperiod_as_ical_string_r(const icalvalue* value) {
     struct icaldatetimeperiodtype dtp = icalvalue_get_datetimeperiod(value);
 
     icalerror_check_arg_rz( (value!=0),"value");
