Commit 49faf2e1 authored by Laurent Aimar's avatar Laurent Aimar
Browse files

* sub.c : fixed a warning.

parent 4a8900b3
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* sub.c * sub.c
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2003 VideoLAN * Copyright (C) 1999-2003 VideoLAN
* $Id: sub.c,v 1.22 2003/08/23 22:02:45 hartman Exp $ * $Id: sub.c,v 1.23 2003/08/24 00:36:38 fenrir Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -243,7 +243,8 @@ char* sub_detect( subtitle_demux_t *p_sub, char *psz_filename) ...@@ -243,7 +243,8 @@ char* sub_detect( subtitle_demux_t *p_sub, char *psz_filename)
DIR *p_dir_handle; DIR *p_dir_handle;
struct dirent *p_dir_afile; struct dirent *p_dir_afile;
char * ppsz_sub_exts[] = { "sub", "srt", "smi", "ssa", NULL}; char * ppsz_sub_exts[] = { "sub", "srt", "smi", "ssa", NULL};
char *psz_result, *psz_basename, *psz_dir, *psz_file_noext, *psz_extension; char *psz_result, *psz_basename, *psz_dir = NULL;
char *psz_file_noext, *psz_extension;
int i; int i;
size_t i_dirlen = 0; size_t i_dirlen = 0;
...@@ -264,20 +265,20 @@ char* sub_detect( subtitle_demux_t *p_sub, char *psz_filename) ...@@ -264,20 +265,20 @@ char* sub_detect( subtitle_demux_t *p_sub, char *psz_filename)
return ""; return "";
} }
strncpy( psz_dir, psz_filename, i_dirlen ); strncpy( psz_dir, psz_filename, i_dirlen );
psz_dir[i_dirlen] = '\0'; psz_dir[i_dirlen] = '\0';
++psz_basename; ++psz_basename;
} }
else else
{ {
psz_basename = psz_filename; psz_basename = psz_filename;
} }
psz_extension = strrchr( psz_basename , '.' ); psz_extension = strrchr( psz_basename , '.' );
if( psz_extension ) if( psz_extension )
{ {
size_t i_baselen = ( 1 + psz_extension ) - psz_basename; size_t i_baselen = ( 1 + psz_extension ) - psz_basename;
psz_file_noext = (char*)malloc( i_baselen + 1 ); psz_file_noext = (char*)malloc( i_baselen + 1 );
if( !psz_file_noext ) if( !psz_file_noext )
{ {
...@@ -288,14 +289,14 @@ char* sub_detect( subtitle_demux_t *p_sub, char *psz_filename) ...@@ -288,14 +289,14 @@ char* sub_detect( subtitle_demux_t *p_sub, char *psz_filename)
++psz_extension; ++psz_extension;
} }
else return ""; else return "";
p_dir_handle = opendir( psz_dir ); p_dir_handle = opendir( psz_dir ? psz_dir : "" );
if( p_dir_handle ) { if( p_dir_handle ) {
int i_found = 0; int i_found = 0;
while(( p_dir_afile = readdir( p_dir_handle ))) { while(( p_dir_afile = readdir( p_dir_handle ))) {
char* psz_afile_ext = strrchr( p_dir_afile->d_name, '.' ); char* psz_afile_ext = strrchr( p_dir_afile->d_name, '.' );
if( psz_afile_ext ) if( psz_afile_ext )
{ {
++psz_afile_ext; ++psz_afile_ext;
...@@ -323,7 +324,6 @@ char* sub_detect( subtitle_demux_t *p_sub, char *psz_filename) ...@@ -323,7 +324,6 @@ char* sub_detect( subtitle_demux_t *p_sub, char *psz_filename)
} }
closedir( p_dir_handle ); closedir( p_dir_handle );
} }
} }
return ""; return "";
} }
......
Supports Markdown
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