]> git.sesse.net Git - vlc/commitdiff
- Use iconv transliteration instead of custom code
authorRémi Denis-Courmont <rem@videolan.org>
Sun, 26 Mar 2006 20:25:07 +0000 (20:25 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Sun, 26 Mar 2006 20:25:07 +0000 (20:25 +0000)
- Supposedly fix a memleak
- Fix a few warnings

modules/control/http/http.c
modules/control/http/util.c

index 207a36058d3387951d39a55f9f92c7758158238a..8483b4e8f390efc49193317a74a8ff3c658be068 100644 (file)
@@ -167,10 +167,13 @@ static int Open( vlc_object_t *p_this )
 
     if( strcmp( psz_src, "UTF-8" ) )
     {
-        p_sys->iconv_from_utf8 = vlc_iconv_open( psz_src, "UTF-8" );
+        char psz_encoding[strlen( psz_src ) + sizeof( "//translit")];
+        sprintf( psz_encoding, "%s//translit", psz_src);
+
+        p_sys->iconv_from_utf8 = vlc_iconv_open( psz_encoding, "UTF-8" );
         if( p_sys->iconv_from_utf8 == (vlc_iconv_t)-1 )
             msg_Warn( p_intf, "unable to perform charset conversion to %s",
-                      psz_src );
+                      psz_encoding );
         else
         {
             p_sys->iconv_to_utf8 = vlc_iconv_open( "UTF-8", psz_src );
@@ -185,7 +188,7 @@ static int Open( vlc_object_t *p_this )
         p_sys->iconv_from_utf8 = p_sys->iconv_to_utf8 = (vlc_iconv_t)-1;
     }
 
-    p_sys->psz_charset = strdup( psz_src );
+    p_sys->psz_charset = psz_src;
     psz_src = NULL;
 
     /* determine file handler associations */
index 15569ed4090c27f478635bfb1d91cb3908935f78..1a9e6b6576d2fb8aa14398ece1c49c9af1a259c5 100644 (file)
@@ -357,26 +357,9 @@ char *E_(FromUTF8)( intf_thread_t *p_intf, char *psz_utf8 )
         char *psz_out = psz_local;
         size_t i_ret;
         char psz_tmp[i_in + 1];
-        char *psz_in = psz_tmp;
-        uint8_t *p = (uint8_t *)psz_tmp;
+        const char *psz_in = psz_tmp;
         strcpy( psz_tmp, psz_utf8 );
 
-        /* Fix Unicode quotes. If we are here we are probably converting
-         * to an inferior charset not understanding Unicode quotes. */
-        while( *p )
-        {
-            if( p[0] == 0xe2 && p[1] == 0x80 && p[2] == 0x99 )
-            {
-                *p = '\'';
-                memmove( &p[1], &p[3], strlen((char *)&p[3]) + 1 );
-            }
-            if( p[0] == 0xe2 && p[1] == 0x80 && p[2] == 0x9a )
-            {
-                *p = '"';
-                memmove( &p[1], &p[3], strlen((char *)&p[3]) + 1 );
-            }
-            p++;
-        }
         i_in = strlen( psz_tmp );
 
         i_ret = vlc_iconv( p_sys->iconv_from_utf8, &psz_in, &i_in,
@@ -403,7 +386,7 @@ char *E_(ToUTF8)( intf_thread_t *p_intf, char *psz_local )
 
     if ( p_sys->iconv_to_utf8 != (vlc_iconv_t)-1 )
     {
-        char *psz_in = psz_local;
+        const char *psz_in = psz_local;
         size_t i_in = strlen(psz_in);
         size_t i_out = i_in * 6;
         char *psz_utf8 = malloc(i_out + 1);
@@ -471,7 +454,7 @@ void E_(PlaylistListNode)( intf_thread_t *p_intf, playlist_t *p_pl,
                 E_(mvar_AppendNewVar)( itm, "ro", "rw" );
             }
 
-            sprintf( value, "%d", p_node->input.i_duration );
+            sprintf( value, "%ld", (long)p_node->input.i_duration );
             E_(mvar_AppendNewVar)( itm, "duration", value );
 
             E_(mvar_AppendVar)( s, itm );