aboutsummaryrefslogtreecommitdiff
path: root/lib/csv/format.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/csv/format.c')
-rw-r--r--lib/csv/format.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/csv/format.c b/lib/csv/format.c
index 31e4bbe..1394dc7 100644
--- a/lib/csv/format.c
+++ b/lib/csv/format.c
@@ -36,13 +36,17 @@ int asprintf(char *strp[], const char *fmt, ...) {
return r;}
#endif // asprintf
-CAMLprim value show_float( value float_param )
+CAMLprim value show_float(value locale_param, value float_param )
{
- CAMLparam1( float_param );
+ CAMLparam2(locale_param, float_param );
CAMLlocal1( ml_data );
double f = Double_val(float_param);
char* raw_data;
+ const char *s;
+ s = String_val(locale_param);
+ const char *saved_locale = setlocale(LC_NUMERIC, s);
int data_len = asprintf(&raw_data, "%f", f);
+ setlocale(LC_NUMERIC, saved_locale);
ml_data = caml_copy_string( raw_data );
free(raw_data);
CAMLreturn( ml_data );