Commit 1fb78f47 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Subtitles: small fixes and cosmetics

and for counter scopes
parent a4b3126b
/***************************************************************************** /*****************************************************************************
* subtitles.c * subtitles.c : subtitles detection
***************************************************************************** *****************************************************************************
* Copyright (C) 2003-2006 the VideoLAN team * Copyright (C) 2003-2009 the VideoLAN team
* $Id$ * $Id$
* *
* Authors: Derk-Jan Hartman <hartman at videolan.org> * Authors: Derk-Jan Hartman <hartman at videolan.org>
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#endif #endif
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_input.h>
#include <vlc_charset.h> #include <vlc_charset.h>
#include <vlc_url.h> #include <vlc_url.h>
...@@ -40,14 +39,14 @@ ...@@ -40,14 +39,14 @@
# include <dirent.h> # include <dirent.h>
#endif #endif
#include <limits.h>
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
# include <unistd.h> # include <unistd.h>
#endif #endif
#include <sys/stat.h> #include <sys/stat.h>
#include <ctype.h> #include <ctype.h> /* isalnum */
#include "input_internal.h" #include "input_internal.h"
/** /**
...@@ -55,7 +54,6 @@ ...@@ -55,7 +54,6 @@
*/ */
#define MAX_SUBTITLE_FILES 128 #define MAX_SUBTITLE_FILES 128
/** /**
* The possible extensions for subtitle files we support * The possible extensions for subtitle files we support
*/ */
...@@ -136,11 +134,11 @@ static int whiteonly( const char *s ) ...@@ -136,11 +134,11 @@ static int whiteonly( const char *s )
enum enum
{ {
SUB_PRIORITY_NONE = 0, SUB_PRIORITY_NONE = 0,
SUB_PRIORITY_MATCH_NONE = 1, SUB_PRIORITY_MATCH_NONE = 1,
SUB_PRIORITY_MATCH_RIGHT = 2, SUB_PRIORITY_MATCH_RIGHT = 2,
SUB_PRIORITY_MATCH_LEFT = 3, SUB_PRIORITY_MATCH_LEFT = 3,
SUB_PRIORITY_MATCH_ALL = 4, SUB_PRIORITY_MATCH_ALL = 4,
}; };
typedef struct typedef struct
{ {
...@@ -173,13 +171,12 @@ static int compare_sub_priority( const void *a, const void *b ) ...@@ -173,13 +171,12 @@ static int compare_sub_priority( const void *a, const void *b )
int subtitles_Filter( const char *psz_dir_content ) int subtitles_Filter( const char *psz_dir_content )
{ {
const char *tmp = strrchr( psz_dir_content, '.'); const char *tmp = strrchr( psz_dir_content, '.');
int i;
if( !tmp ) if( !tmp )
return 0; return 0;
tmp++; tmp++;
for( i = 0; sub_exts[i][0]; i++ ) for( int i = 0; sub_exts[i][0]; i++ )
if( strcasecmp( sub_exts[i], tmp ) == 0 ) if( strcasecmp( sub_exts[i], tmp ) == 0 )
return 1; return 1;
return 0; return 0;
...@@ -262,16 +259,18 @@ char **subtitles_Detect( input_thread_t *p_this, char *psz_path, ...@@ -262,16 +259,18 @@ char **subtitles_Detect( input_thread_t *p_this, char *psz_path,
vlc_subfn_t *result = NULL; /* unsorted results */ vlc_subfn_t *result = NULL; /* unsorted results */
char **result2; /* sorted results */ char **result2; /* sorted results */
const char *psz_fname = psz_name_org;
if( !psz_fname ) if( !psz_fname )
return NULL; return NULL;
const char *psz_fname = decode_URI( psz_name_org );
if( !strncmp( psz_fname, "file://", 7 ) ) if( !strncmp( psz_fname, "file://", 7 ) )
{ {
psz_fname += 7; psz_fname += 7;
if( !strncmp( psz_fname, "localhost", 9 ) ) if( !strncmp( psz_fname, "localhost", 9 ) )
psz_fname += 9; psz_fname += 9;
} }
psz_fname = decode_URI( psz_fname );
/* extract filename & dirname from psz_fname */ /* extract filename & dirname from psz_fname */
tmp = strrchr( psz_fname, DIR_SEP_CHAR ); tmp = strrchr( psz_fname, DIR_SEP_CHAR );
...@@ -329,7 +328,6 @@ char **subtitles_Detect( input_thread_t *p_this, char *psz_path, ...@@ -329,7 +328,6 @@ char **subtitles_Detect( input_thread_t *p_this, char *psz_path,
const char *psz_dir = j < 0 ? f_dir : subdirs[j]; const char *psz_dir = j < 0 ? f_dir : subdirs[j];
char **ppsz_dir_content; char **ppsz_dir_content;
int i_dir_content; int i_dir_content;
int a;
if( psz_dir == NULL || ( j >= 0 && !strcmp( psz_dir, f_dir ) ) ) if( psz_dir == NULL || ( j >= 0 && !strcmp( psz_dir, f_dir ) ) )
continue; continue;
...@@ -341,7 +339,7 @@ char **subtitles_Detect( input_thread_t *p_this, char *psz_path, ...@@ -341,7 +339,7 @@ char **subtitles_Detect( input_thread_t *p_this, char *psz_path,
continue; continue;
msg_Dbg( p_this, "looking for a subtitle file in %s", psz_dir ); msg_Dbg( p_this, "looking for a subtitle file in %s", psz_dir );
for( a = 0; a < i_dir_content && i_sub_count < MAX_SUBTITLE_FILES ; a++ ) for( int a = 0; a < i_dir_content && i_sub_count < MAX_SUBTITLE_FILES ; a++ )
{ {
char *psz_name = ppsz_dir_content[a]; char *psz_name = ppsz_dir_content[a];
char tmp_fname_noext[strlen( psz_name ) + 1]; char tmp_fname_noext[strlen( psz_name ) + 1];
...@@ -415,7 +413,7 @@ char **subtitles_Detect( input_thread_t *p_this, char *psz_path, ...@@ -415,7 +413,7 @@ char **subtitles_Detect( input_thread_t *p_this, char *psz_path,
} }
if( ppsz_dir_content ) if( ppsz_dir_content )
{ {
for( a = 0; a < i_dir_content; a++ ) for( int a = 0; a < i_dir_content; a++ )
free( ppsz_dir_content[a] ); free( ppsz_dir_content[a] );
free( ppsz_dir_content ); free( ppsz_dir_content );
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment