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

Steve Lhomme robux4 at videolabs.io
Tue Aug 25 10:37:50 CEST 2015


On Tue, Aug 25, 2015 at 10:32 AM, Rémi Denis-Courmont <remi at remlab.net> wrote:
> 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...

One at a time, why not ?
It would also help cleaning code that transforms ""+filename into
""+\+filename which is also fixed in this patch.

>> ---
>>  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/
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list