Closed jwm-art-net closed 6 years ago
When locale independant save files are implemented, old saves with locale dependant numbers should be loadable as well.
Agreed, though I was wondering if a stylesheet could do the job rather than me having two lots of code, one for old files and another lot for new? (and if you'd be willing to help ;-) (when the time comes that is...)
Yes, I am willing to help, but using an XSL stylesheet either requires
IMHO, saving should only write the new format, so no different code paths are necessary, and only loading remains.
This can then be boiled down to one function: dish_file_read_float https://github.com/jwm-art-net/Petri-Foo/blob/master/libpetrifui/dish_file.c#L1338
Only in that function different paths are needed - at least that is what I found out while quickly looking over the source, but I might be wrong here.
Starting to wonder if I've not misunderstood David's comment. Not really sure what needs to be changed here? ... edit... oh it's the snprintf isn't it, that's where the localization creeps in. https://github.com/jwm-art-net/Petri-Foo/blob/master/libpetrifui/dish_file.c#L368 i'm working on other stuff at the mo... will have to wait.
As far as I understand it:
Currently floats are stored locale dependant in the XML because of the call to snprintf()
in dish_file_write_float()
and other functions.
These should be converted to not write the float values as strings, but using $function_for_writing_decimal_values from libxml2.
The same applies to loading the values, this should be done using $function_for_reading_decimal_values from libxml2.
My last comment refers to reading of the values:
If you want users to be able to load their banks with commata as decimal separators (0,100000
instead of 0.100000
), then a workaround for this can be included in the function, that already deals with reading float values.
Saving to the "old" format would not have to be implemented, but maybe current versions of petri-foo may not be able to load saved banks from future versions.
Apparently there are no special functions in libxml2 for reading and writing float values, so a simple fix is to call setlocale(LC_NUMERIC, "C");
before and setlocale(LC_NUMERIC, "");
after reading and writing the save files.
See pull request #20
This can be closed, as #20 is merged.
This can be closed, as #20 is merged.
"..should really be using the standard XSD types for numeric literals, e.g. xsd:decimal[1], which are not locale dependent.." see: http://lists.linuxaudio.org/pipermail/linux-audio-dev/2014-February/034665.html
I wouldn't be suprised if there were other cases where the XML could be vastly improved.