]> git.sesse.net Git - vlc/blobdiff - src/input/subtitles.c
Moved "sub-margin" to vout.
[vlc] / src / input / subtitles.c
index 8ce05ea66c820b29c88337127200a5e334ae73b4..2ca105ff08618b16702eea71c662e485639ebcd2 100644 (file)
@@ -32,7 +32,7 @@
 #endif
 
 #include <vlc_common.h>
-#include <vlc_charset.h>
+#include <vlc_fs.h>
 #include <vlc_url.h>
 
 #ifdef HAVE_DIRENT_H
@@ -259,19 +259,13 @@ char **subtitles_Detect( input_thread_t *p_this, char *psz_path,
     vlc_subfn_t *result = NULL; /* unsorted results */
     char **result2; /* sorted results */
 
-    const char *psz_fname = psz_name_org;
+    if( !psz_name_org )
+        return NULL;
 
+    char *psz_fname = make_path( psz_name_org );
     if( !psz_fname )
         return NULL;
 
-    if( !strncmp( psz_fname, "file://", 7 ) )
-    {
-        psz_fname += 7;
-        if( !strncmp( psz_fname, "localhost", 9 ) )
-            psz_fname += 9;
-    }
-    psz_fname = decode_URI( psz_fname );
-
     /* extract filename & dirname from psz_fname */
     tmp = strrchr( psz_fname, DIR_SEP_CHAR );
     if( tmp )
@@ -289,7 +283,10 @@ char **subtitles_Detect( input_thread_t *p_this, char *psz_path,
         char *psz_cwd = NULL;
 #endif
         if( !psz_cwd )
+        {
+            free( psz_fname );
             return NULL;
+        }
 
         f_fname = strdup( psz_fname );
         if( asprintf( &f_dir, "%s%c", psz_cwd, DIR_SEP_CHAR ) == -1 )
@@ -300,6 +297,7 @@ char **subtitles_Detect( input_thread_t *p_this, char *psz_path,
     {
         free( f_fname );
         free( f_dir );
+        free( psz_fname );
         return NULL;
     }
 
@@ -313,6 +311,7 @@ char **subtitles_Detect( input_thread_t *p_this, char *psz_path,
         free( f_dir );
         free( f_fname_noext );
         free( f_fname_trim );
+        free( psz_fname );
         return NULL;
     }
 
@@ -333,7 +332,7 @@ char **subtitles_Detect( input_thread_t *p_this, char *psz_path,
             continue;
 
         /* parse psz_src dir */
-        i_dir_content = utf8_scandir( psz_dir, &ppsz_dir_content,
+        i_dir_content = vlc_scandir( psz_dir, &ppsz_dir_content,
                                       subtitles_Filter, NULL );
         if( i_dir_content < 0 )
             continue;
@@ -394,7 +393,7 @@ char **subtitles_Detect( input_thread_t *p_this, char *psz_path,
                 if( !strcmp( psz_path, psz_fname ) )
                     continue;
 
-                if( !utf8_stat( psz_path, &st ) && S_ISREG( st.st_mode ) && result )
+                if( !vlc_stat( psz_path, &st ) && S_ISREG( st.st_mode ) && result )
                 {
                     msg_Dbg( p_this,
                             "autodetected subtitle: %s with priority %d",
@@ -428,6 +427,7 @@ char **subtitles_Detect( input_thread_t *p_this, char *psz_path,
     free( f_dir );
     free( f_fname_trim );
     free( f_fname_noext );
+    free( psz_fname );
 
     if( !result )
         return NULL;