[MPlayer-users] gui.conf/locale bug fix

Dietrich Clauß dc2 at clauss.dyndns.org
Thu Sep 5 16:51:01 CEST 2002


Hi,

in current version the config file seems to be read using i18n and written
without.. I fixed it with the attached patch. 

from my version.h: CVS-020905-13:18-2.95.4
tested on debian/x86, LANG=de_DE


- Dietrich
-------------- next part --------------
diff -u -r orig/Gui/CVS/Entries main/Gui/CVS/Entries
--- orig/Gui/CVS/Entries	Thu Sep  5 15:09:25 2002
+++ main/Gui/CVS/Entries	Thu Sep  5 13:18:11 2002
@@ -11,4 +11,4 @@
 /interface.c/1.48/Tue Sep  3 11:18:02 2002//
 /interface.h/1.25/Tue Sep  3 11:18:02 2002//
 /Makefile/1.14/Thu Sep  5 11:18:11 2002//
-/cfg.c/1.13/Thu Sep  5 13:09:24 2002//
+/cfg.c/1.13/Thu Sep  5 11:18:11 2002//
diff -u -r orig/Gui/cfg.c main/Gui/cfg.c
--- orig/Gui/cfg.c	Thu Sep  5 15:09:24 2002
+++ main/Gui/cfg.c	Thu Sep  5 15:03:54 2002
@@ -132,6 +132,10 @@
  char * cfg = get_path( "gui.conf" );
  FILE * f;
 
+#ifdef USE_SETLOCALE
+ setlocale( LC_ALL,"C" );
+#endif
+
 // -- read configuration
  mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[cfg] read config file: %s\n",cfg );
  gui_conf=m_config_new( play_tree_new() ); 
@@ -177,6 +181,10 @@
   }
  free( cfg );
 
+#ifdef USE_SETLOCALE
+ setlocale( LC_ALL,"" );
+#endif
+
  return 0;
 }
 
@@ -187,7 +195,7 @@
  int    i;
 
 #ifdef USE_SETLOCALE
- setlocale( LC_ALL,"" );
+ setlocale( LC_ALL,"C" );
 #endif
 
 // -- save configuration 
@@ -200,23 +208,7 @@
        case CONF_TYPE_INT:
        case CONF_TYPE_FLAG:   fprintf( f,"%s = %d\n",gui_opts[i].name,*( (int *)gui_opts[i].p ) );   				      break;
        case CONF_TYPE_FLOAT:  
-    	    #if 0
     	    fprintf( f,"%s = %f\n",gui_opts[i].name,*( (float *)gui_opts[i].p ) );
-	    #else
-	    #warning ugly hakk for fucking locale
-	    {
-	     char tmp[64];
-	     snprintf( tmp,64,"%f",*( (float *)gui_opts[i].p ) );
-	     // locale emulator
-	     // { char * c = strchr( tmp,'.' ); if ( c ) *c=','; }
-	     // ---
-	     { int i;
-	       for ( i=0;i < strlen( tmp );i++ )
-	        if ( ( tmp[i] != '.' )&&( ( tmp[i] < '0' )||( tmp[i] > '9' ) ) ) tmp[i]='.';
-	     }
-	     fprintf( f,"%s = %s\n",gui_opts[i].name,tmp );
-	    }
-	    #endif
 	    break;
        case CONF_TYPE_STRING: 
             {
@@ -260,6 +252,10 @@
    fclose( f );
   }
  free( cfg );
+
+#ifdef USE_SETLOCALE
+ setlocale( LC_ALL,"" );
+#endif
 
  return 0;
 }


More information about the MPlayer-users mailing list