[vlc-devel] [PATCH] subtitles: don't force double directory separators

Rémi Denis-Courmont remi at remlab.net
Tue Aug 25 10:32:46 CEST 2015


Le 2015-08-25 11:20, Steve Lhomme a écrit :
> WindowsPhone doesn't like double backslashes in the path

So what? You can't possibly be suggesting that we go through all the 
hoops below everytime we concatenate file paths or file URIs in VLC or 
contribs...

> ---
>  src/input/subtitles.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/src/input/subtitles.c b/src/input/subtitles.c
> index 60e59c2..d84339c 100644
> --- a/src/input/subtitles.c
> +++ b/src/input/subtitles.c
> @@ -360,8 +360,16 @@ char **subtitles_Detect( input_thread_t *p_this,
> char *psz_path,
>                  struct stat st;
>                  char *path;
>
> -                if( asprintf( &path, "%s"DIR_SEP"%s", psz_dir,
> psz_name ) < 0 )
> -                    continue;
> +                if( psz_dir[0] == '\0' ) {
> +                    if( asprintf( &path, "%s", psz_name ) < 0 )
> +                        continue;
> +                } else if( psz_dir[strlen( psz_dir ) - 1] ==
> DIR_SEP_CHAR ) {
> +                    if( asprintf( &path, "%s%s", psz_dir, psz_name ) 
> < 0 )
> +                        continue;
> +                } else {
> +                    if( asprintf( &path, "%s"DIR_SEP"%s", psz_dir,
> psz_name ) < 0 )
> +                        continue;
> +                }
>
>                  if( strcmp( path, psz_fname )
>                   && vlc_stat( path, &st ) == 0

-- 
Rémi Denis-Courmont
http://www.remlab.net/


More information about the vlc-devel mailing list