Hi!

I found a weird behavior of 'float>string' word on Gtk UI backend:
( scratchpad ) 123456.789 float>string .
"123456,789.0"

'float>string' word calls 'snprintf' (vm/os-unix.hpp) with "%.16g"
format, then 'fix-float' word appends ".0" to results like "1234"
(i.e. w/o ".").
Gtk calls setlocal(LC_ALL, "") during an initialization, so 'snprintf'
uses "," as a decimal separator (on my system).
Actually X11 backend also calls 'setlocale':
...
LC_ALL "" setlocale [ "setlocale() failed" print flush ] unless
...
But these statements don't work as expected.

'locale.h' uses these constants for locale's categories:
  __LC_CTYPE = 0,
  __LC_NUMERIC = 1,
  __LC_TIME = 2,
  __LC_COLLATE = 3,
  __LC_MONETARY = 4,
  __LC_MESSAGES = 5,
  __LC_ALL = 6,
  ...

x11/xlib.factor contains different constants:
! !!! category of setlocale
CONSTANT: LC_ALL      0
CONSTANT: LC_COLLATE  1
CONSTANT: LC_CTYPE    2
CONSTANT: LC_MONETARY 3
CONSTANT: LC_NUMERIC  4
CONSTANT: LC_TIME     5

X11/Xlocal.h:
#ifndef X_LOCALE
#include <locale.h>
#else

#define LC_ALL      0
#define LC_COLLATE  1
#define LC_CTYPE    2
#define LC_MONETARY 3
#define LC_NUMERIC  4
#define LC_TIME     5

i.e. X11 uses definitions from 'locale.h' if 'X_LOCALE' isn't defined.

on X11 backend:
( scratchpad ) 6 "" setlocale drop 123456.789 float>string .
"123456,789.0"

on Gtk backend:
( scratchpad ) 6 "C" setlocale drop 123456.789 float>string .
"123456.789"
(of course '1 "C" setlocale' (LC_NUMERIC) returns the same result)

My conclusions:
1. At least LC_NUMERIC category should be set to "C" on all backends.
2. X11 backend should use correct values of constants.

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to