aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorvektor <devnull@localhost>2004-10-21 03:28:30 +0000
committervektor <devnull@localhost>2004-10-21 03:28:30 +0000
commit00fc113bfb538df2c75c4d4bfd144c1062d3ef1b (patch)
tree0afd626f703424bd381375499e157163f4dd0224 /src
parent094af8aa7f136fe6b25712abe7913a99d6663162 (diff)
20 Oct 2004 Billy Biggs <vektor@dumbterm.net>
* tvtime/src/tvtime.c: Protect the overscan parameter from being written in a locale that likes to use commas instead of periods in floating point numbers. * tvtime/src/tvtimeconf.c: Protect the overscan parameter from being read in a locale that likes to use commas instead of periods in floating point numbers. * tvtime/src/utils.c: Since the overscan parameter is now protected, we don't need to mess up the UI's display of floating point numbers.
Diffstat (limited to 'src')
-rw-r--r--src/tvtime.c7
-rw-r--r--src/tvtimeconf.c8
-rw-r--r--src/utils.c1
3 files changed, 15 insertions, 1 deletions
diff --git a/src/tvtime.c b/src/tvtime.c
index 6942c51..4835f3e 100644
--- a/src/tvtime.c
+++ b/src/tvtime.c
@@ -1185,6 +1185,7 @@ int tvtime_main( rtctimer_t *rtctimer, int read_stdin, int realtime,
int return_value = 0;
int last_current_id = -1;
int quiet_screenshots = 0;
+ char prevloc[ 256 ];
int i;
ct = config_new();
@@ -2493,9 +2494,15 @@ int tvtime_main( rtctimer_t *rtctimer, int read_stdin, int realtime,
snprintf( number, 4, "%d", framerate_mode );
config_save( ct, "FramerateMode", number );
+ /* Make sure floating point numbers are always written to the config
+ * file in "C" locale format.
+ */
+ strncpy( prevloc, setlocale( LC_NUMERIC, NULL ), sizeof( prevloc ) );
+ setlocale( LC_NUMERIC, "C" );
snprintf( number, 4, "%2.1f",
commands_get_overscan( commands ) * 2.0 * 100.0 );
config_save( ct, "OverScan", number );
+ setlocale( LC_NUMERIC, prevloc );
snprintf( number, 4, "%d", commands_check_freq_present( commands ) );
config_save( ct, "CheckForSignal", number );
diff --git a/src/tvtimeconf.c b/src/tvtimeconf.c
index 4f35865..0600474 100644
--- a/src/tvtimeconf.c
+++ b/src/tvtimeconf.c
@@ -373,10 +373,18 @@ static void parse_option( config_t *ct, xmlNodePtr node )
}
if( !xmlStrcasecmp( name, BAD_CAST "Overscan" ) ) {
+ char prevloc[ 256 ];
+
+ /* Make sure floating point numbers are always written to
+ * the config file in "C" locale format.
+ */
+ strncpy( prevloc, setlocale( LC_NUMERIC, NULL ), sizeof prevloc );
+ setlocale( LC_NUMERIC, "C" );
ct->overscan = ( atof( curval ) / 2.0 ) / 100.0;
if( !isnormal( ct->overscan ) ) {
ct->overscan = 0.0;
}
+ setlocale( LC_NUMERIC, prevloc );
}
if( !xmlStrcasecmp( name, BAD_CAST "MixerDevice" ) ) {
diff --git a/src/utils.c b/src/utils.c
index f168500..5f3d5c0 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -626,7 +626,6 @@ void setup_i18n( void )
{
#ifdef ENABLE_NLS
setlocale( LC_ALL, "" );
- setlocale( LC_NUMERIC, "C" );
bindtextdomain( "tvtime", LOCALEDIR );
textdomain( "tvtime" );
#endif

Privacy Policy