FLTK logo

[fltk.coredev] Fl_Preferences issues

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.coredev  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Fl_Preferences issues Ian MacArthur Sep 23, 2020  
 
All,

In an off-list discussion elsewhere, a potential issue was flagged with Fl_Preferences interacting oddly with locale settings, specifically with the handling of the decimal separator.
In this case a FI locale was used but ISTR that uses the same decimal separator as, say, DE uses, so I imagine that several of the fltk regulars would have seen this (like, maybe, Matt who wrote Fl_preferences, for example...)

Anyway, I’ll post parts of the original below for the details, though I recall that we had some discussion about locale settings recently but can’t recall the outcome.

I wondered if we have seen this before and what the thinking is on non-C-locale settings etc...?

Cheers,

> 
> I'm pretty sure one of my fldigi users (http://www.w1hkj.com/files/fldigi/) has found a bug in Fl_Preferences.
> 
> Fl_Preferences::get, fails if the system locale does not use a period as the decimal separator character.  The problem was discovered by a user in the FI_fi locale.
> 
> Symptom:
> 
>     method set correctly writes the double value with the locale decimal separator
>     method get fails.
> 
> My code does not execute a setenv(LC_NUMERIC,..., but relies on that environment variable set in the user's system (Fedora F32).  I'm not sure why the set works and the get does not.
> 
> 

> /**
>  Reads an entry from the group. A default value must be
>  supplied. The return value indicates if the value was available
>  (non-zero) or the default was used (0).
> 
>  \param[in] key name of entry
>  \param[out] value returned from preferences or default value if none was set
>  \param[in] defaultValue default value to be used if no preference was set
>  \return 0 if the default value was used
>  */
> char Fl_Preferences::get( const char *key, double &value, double defaultValue ) {
>   const char *v = node->get( key );
>   value = v ? atof( v ) : defaultValue;
>   return ( v != 0 );
> }
> 
> /**
>  Sets an entry (name/value pair). The return value indicates if there
>  was a problem storing the data in memory. However it does not
>  reflect if the value was actually stored in the preferences
>  file.
> 
>  \param[in] key name of entry
>  \param[in] value set this entry to \p value
>  \return 0 if setting the value failed
>  */
> char Fl_Preferences::set( const char *key, double value ) {
>   sprintf( nameBuffer, "%g", value );
>   node->set( key, nameBuffer );
>   return 1;
> }
> 
> 

-- 
You received this message because you are subscribed to the Google Groups "fltk.coredev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkcoredev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkcoredev/1108CAC0-0BD8-40FC-A296-524ACEEB45D5%40gmail.com.
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.