[MPlayer-cvslog] r24106 - in trunk/gui: interface.c interface.h mplayer/mw.c

iive subversion at mplayerhq.hu
Mon Aug 20 16:17:44 CEST 2007


Author: iive
Date: Mon Aug 20 16:17:43 2007
New Revision: 24106

Log:
remove gconvert_uri_to_filename() and use url_unescape_string() instead.
reasons:
* gconvert strdup()s the original string, but it may exit without returning or freeing it.
* gconvert returns the original pointer when no % escaping is done. It is then free()ed and used in that state.
* gconvert doesn't consider that % may be at the end of the string and could continue parsing past the end.
* gconvert would try to free() pointer that iconv() have modified.
* gconvert would try to convert filenames from utf-8 to iso8859-1. 
  Seems like no other DnD programs convert to utf-8 and/or honors CHARSET.
  Not converting seems to work best. Fix it if problem arises.


Modified:
   trunk/gui/interface.c
   trunk/gui/interface.h
   trunk/gui/mplayer/mw.c

Modified: trunk/gui/interface.c
==============================================================================
--- trunk/gui/interface.c	(original)
+++ trunk/gui/interface.c	Mon Aug 20 16:17:43 2007
@@ -157,49 +157,6 @@ void greplace(char ***list, const char *
  (*list)[i] = gstrdup(replace);
  (*list)[i + 1] = NULL;
 }
-
-#ifdef USE_ICONV
-char * gconvert_uri_to_filename( char * str )
-{
- iconv_t   d;
- char    * out = strdup( str );
- char	 * tmp = NULL;
- char    * ize;
- size_t    inb,outb;
- char    * charset = "ISO8859-1";
- char    * cs;
-
- if ( !strchr( str,'%' ) ) return str;
-	     
- {
-  char * t = calloc( 1,strlen( out ) );
-  int    i,c = 0;
-  for ( i=0;i < (int)strlen( out );i++ )
-   if ( out[i] != '%' ) t[c++]=out[i];
-    else
-     {
-      char tmp[5] = "0xXX"; 
-//	  if ( out[++i] == '%' ) { t[c++]='%'; continue; };
-      tmp[2]=out[++i]; tmp[3]=out[++i]; 
-      t[c++]=(char)strtol( tmp,(char **)NULL,0 );
-     }
-  free( out );
-  out=t;
- }
-
- if ( (cs=getenv( "CHARSET" )) && *cs ) charset=cs;
-
- inb=outb=strlen( out );
- tmp=calloc( 1,outb + 1 );
- ize=tmp;
- d=iconv_open( charset,"UTF-8" );
- if ( (iconv_t)(-1) == d ) return str;
- iconv( d,&out,&inb,&tmp,&outb ); 
- iconv_close( d ); 
- free( out );
- return ize;
-}
-#endif
 							    
 void guiInit( void )
 {

Modified: trunk/gui/interface.h
==============================================================================
--- trunk/gui/interface.h	(original)
+++ trunk/gui/interface.h	Mon Aug 20 16:17:43 2007
@@ -210,7 +210,6 @@ extern float gtkEquChannels[6][10];
 
 extern void * gtkSet( int cmd,float param, void * vparam );
 
-extern char * gconvert_uri_to_filename( char * str );
 extern char * gstrdup( const char * str );
 extern int    gstrcmp( const char * a,const char * b );
 extern void   gfree( void ** p );

Modified: trunk/gui/mplayer/mw.c
==============================================================================
--- trunk/gui/mplayer/mw.c	(original)
+++ trunk/gui/mplayer/mw.c	Mon Aug 20 16:17:43 2007
@@ -20,6 +20,7 @@
 #include "../libvo/fastmemcpy.h"
 
 #include "../stream/stream.h"
+#include "stream/url.h"
 #include "../mixer.h"
 #include "../libvo/sub.h"
 #include "../access_mpcontext.h"
@@ -559,13 +560,7 @@ void mplDandDHandler(int num,char** file
     char* str = strdup( files[f] );
     plItem* item;
 
-#ifdef USE_ICONV
-    if ( strchr( str,'%' ) )
-     {
-      char * tmp=gconvert_uri_to_filename( str );
-      free( str ); str=tmp;
-     }
-#endif
+    url_unescape_string(str, files[f]);
 
     if(stat(str,&buf) == 0 && S_ISDIR(buf.st_mode) == 0) {
       /* this is not a directory so try to play it */



More information about the MPlayer-cvslog mailing list