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$
*
* Authors: Derk-Jan Hartman <hartman at videolan.org>
......@@ -32,7 +32,6 @@
#endif
#include <vlc_common.h>
#include <vlc_input.h>
#include <vlc_charset.h>
#include <vlc_url.h>
......@@ -40,14 +39,14 @@
# include <dirent.h>
#endif
#include <limits.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <sys/stat.h>
#include <ctype.h>
#include <ctype.h> /* isalnum */
#include "input_internal.h"
/**
......@@ -55,7 +54,6 @@
*/
#define MAX_SUBTITLE_FILES 128
/**
* The possible extensions for subtitle files we support
*/
......@@ -136,11 +134,11 @@ static int whiteonly( const char *s )
enum
{
SUB_PRIORITY_NONE = 0,
SUB_PRIORITY_MATCH_NONE = 1,
SUB_PRIORITY_NONE = 0,
SUB_PRIORITY_MATCH_NONE = 1,
SUB_PRIORITY_MATCH_RIGHT = 2,
SUB_PRIORITY_MATCH_LEFT = 3,
SUB_PRIORITY_MATCH_ALL = 4,
SUB_PRIORITY_MATCH_LEFT = 3,
SUB_PRIORITY_MATCH_ALL = 4,
};
typedef struct
{
......@@ -173,13 +171,12 @@ static int compare_sub_priority( const void *a, const void *b )
int subtitles_Filter( const char *psz_dir_content )
{
const char *tmp = strrchr( psz_dir_content, '.');
int i;
if( !tmp )
return 0;
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 )
return 1;
return 0;
......@@ -262,16 +259,18 @@ 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_fname )
return NULL;
const char *psz_fname = decode_URI( psz_name_org );
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 );
......@@ -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];
char **ppsz_dir_content;
int i_dir_content;
int a;
if( psz_dir == NULL || ( j >= 0 && !strcmp( psz_dir, f_dir ) ) )
continue;
......@@ -341,7 +339,7 @@ char **subtitles_Detect( input_thread_t *p_this, char *psz_path,
continue;
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 tmp_fname_noext[strlen( psz_name ) + 1];
......@@ -415,7 +413,7 @@ char **subtitles_Detect( input_thread_t *p_this, char *psz_path,
}
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 );
}
......
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