[vlc-commits] commit: Simplification (make_path always returns an absolute path) ( Rémi Denis-Courmont )
git at videolan.org
git at videolan.org
Mon May 31 15:26:28 CEST 2010
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon May 31 16:25:27 2010 +0300| [6c38339282c055a63d4739594790d87bb02bf875] | committer: Rémi Denis-Courmont
Simplification (make_path always returns an absolute path)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6c38339282c055a63d4739594790d87bb02bf875
---
src/input/subtitles.c | 38 +++++++++-----------------------------
1 files changed, 9 insertions(+), 29 deletions(-)
diff --git a/src/input/subtitles.c b/src/input/subtitles.c
index 2ca105f..7c0b6ad 100644
--- a/src/input/subtitles.c
+++ b/src/input/subtitles.c
@@ -251,8 +251,7 @@ char **subtitles_Detect( input_thread_t *p_this, char *psz_path,
{
int i_fuzzy;
int j, i_result2, i_sub_count, i_fname_len;
- char *f_dir = NULL, *f_fname = NULL, *f_fname_noext = NULL, *f_fname_trim = NULL;
- char *tmp = NULL;
+ char *f_fname_noext = NULL, *f_fname_trim = NULL;
char **subdirs; /* list of subdirectories to look in */
@@ -267,39 +266,21 @@ char **subtitles_Detect( input_thread_t *p_this, char *psz_path,
return NULL;
/* extract filename & dirname from psz_fname */
- tmp = strrchr( psz_fname, DIR_SEP_CHAR );
- if( tmp )
+ char *f_dir = strdup( psz_fname );
+ if( f_dir == NULL )
{
- const int i_dirlen = strlen(psz_fname)-strlen(tmp)+1; /* include the separator */
- f_fname = strdup( &tmp[1] ); /* skip the separator */
- f_dir = strndup( psz_fname, i_dirlen );
+ free( psz_fname );
+ return NULL;
}
- else
- {
-#if defined (HAVE_UNISTD_H) && !defined (UNDER_CE)
- /* Get the current working directory */
- char *psz_cwd = getcwd( NULL, 0 );
-#else
- 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 )
- f_dir = NULL; /* Assure that function will return in next test */
- free( psz_cwd );
- }
- if( !f_fname || !f_dir )
+ char *f_fname = strrchr( f_dir, DIR_SEP_CHAR );
+ if( !f_fname )
{
- free( f_fname );
free( f_dir );
free( psz_fname );
return NULL;
}
+ *(f_fname++) = 0; /* skip dir separator */
i_fname_len = strlen( f_fname );
@@ -307,7 +288,6 @@ char **subtitles_Detect( input_thread_t *p_this, char *psz_path,
f_fname_trim = malloc(i_fname_len + 1 );
if( !f_fname_noext || !f_fname_trim )
{
- free( f_fname );
free( f_dir );
free( f_fname_noext );
free( f_fname_trim );
@@ -344,6 +324,7 @@ char **subtitles_Detect( input_thread_t *p_this, char *psz_path,
char tmp_fname_noext[strlen( psz_name ) + 1];
char tmp_fname_trim[strlen( psz_name ) + 1];
char tmp_fname_ext[strlen( psz_name ) + 1];
+ char *tmp;
int i_prio;
@@ -423,7 +404,6 @@ char **subtitles_Detect( input_thread_t *p_this, char *psz_path,
free( subdirs[j] );
free( subdirs );
}
- free( f_fname );
free( f_dir );
free( f_fname_trim );
free( f_fname_noext );
More information about the vlc-commits
mailing list