GNOME Bugzilla – Bug 778308
Script-Fu Prints floating numbers with a comma instead of a point and adds '.0'
Last modified: 2018-05-24 17:23:31 UTC
The output of script-fu (whether through the console or with gimp -c --batch-interpreter=plug-in-script-fu-eval -b - ) of floating values is strange and is not accepted as such again by script-fu itself: The decimal point gets replaced with a comma, and then a period and 0 get appended. Example output ts> (- 0.5 0.1) 0,4.0 (expected: 0.4) ts> 34.5 34,5.0 (expected: 34.5) ts> '(0.4 0.4) (0,4.0 0,4.0) (expected: (0.4 0.4) I tried this with an 'unwrapped' tinyscheme (1.41), and got normal output.
That happens with a german locale. Something is horribly broken in there.
Also happens on master btw. Niels, does it also happen with 'unwrapped' tinyscheme when you use ther german locale?
Niels, can you answer the question, please?
Niels?
The problem is in the atom2str() routine. Inexact (non-integer) numbers are converted to a string using snprintf() with the %g format. The %g format suppresses trailing zeros. The R5RS states that inexact numbers should show at least one decimal place. This means an inexact 4 is to be printed as 4.0. An if statement looks for a . or an e in the string version of the number. If neither is found ".0" is appended. This doesn't work in a locale that does not use the a period as a decimal point separator. The code needs to be updated to use the record separator pointed to by the lconv struct.
No, the code needs to be updated to never print commas and always use '.' as a decimal separator. This is a programming language and no word processor :)
True, Michael, but you would expect the program to follow the conventions of the locale in which it is operating. I don't think you would want Script-Fu to ignore locale and have strings always shown in English so that numbers can always use the dot separator. The line in scheme.c that looks for either '.' or 'e' in the number could include ',' but the locale needs to be consulted as to which character should be appended before the '0' for inexact numbers that have integer equivalents.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gimp/issues/1049.