<html><head></head><body><div class="gmail_quote">On November 18, 2016 4:59:40 AM GMT+02:00, "Filip Roséen" <filip@atch.se> wrote:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">The previous implementation assumed that the data passed was a local<br />path, which limited the usability of the function (effectively<br />preventing subtitles passed as URIs from being added).<br /><br />These changes allow both local paths and URIs to be handled by the<br />function, effectively making sure that file://... are subject to<br />transformation (while leaving other entities untouched).<br /><br />refs #17657<br />---<br /> src/input/input.c | 47 ++++++++++++++++++++++++++++-------------------<br /> 1 file changed, 28 insertions(+), 19 deletions(-)<br /><br />diff --git a/src/input/input.c b/src/input/input.c<br />index cfcb92f..09a4309 100644<br />--- a/src/input/input.c<br />+++ b/src/input/input.c<br />@@ -3041,31 +3041,40 @@ static int input_SlaveSourceAdd( input_thread_t *p_input,<br /> static char *input_SubtitleFile2Uri( input_thread_t *p_input,<br /> const char *psz_subtitle )<br /> {<br />+
vlc_url_t url;<br />+ vlc_UrlParse( &url, psz_subtitle );<br />+<br />+ bool b_proto = url.psz_protocol;<br />+ bool b_local = b_proto == false || !strcasecmp( url.psz_protocol, "file" );<br />+<br />+ vlc_UrlClean( &url );<br />+<br />+ if( !b_local )<br />+ return strdup( psz_subtitle );<br />+<br />+ char* psz_local = b_proto ? vlc_uri2path( psz_subtitle )<br />+ : strdup( psz_subtitle );<br />+ if( psz_local == NULL )<br />+ return NULL;<br />+<br /> /* if we are provided a subtitle.sub file,<br /> * see if we don't have a subtitle.idx and use it instead */<br />- char *psz_idxpath = NULL;<br />- char *psz_extension = strrchr( psz_subtitle, '.');<br />- if( psz_extension && strcmp( psz_extension, ".sub" ) == 0 )<br />- {<br />- psz_idxpath = strdup( psz_subtitle );<br />- if( psz_idxpath )<br />- {<br />- struct stat st;<br /> <br />-
psz_extension = psz_extension - psz_subtitle + psz_idxpath;<br />- strcpy( psz_extension, ".idx" );<br />+ char *psz_ext = strrchr( psz_local, '.');<br />+ if( psz_ext && strcmp( psz_ext, ".sub" ) == 0 )<br />+ {<br />+ struct stat st;<br />+ strcpy( psz_ext, ".idx" );<br /> <br />- if( !vlc_stat( psz_idxpath, &st ) && S_ISREG( st.st_mode ) )<br />- {<br />- msg_Dbg( p_input, "using %s as subtitle file instead of %s",<br />- psz_idxpath, psz_subtitle );<br />- psz_subtitle = psz_idxpath;<br />- }<br />- }<br />+ if( vlc_stat( psz_local, &st ) || !S_ISREG( st.st_mode ) )<br />+ strcpy( psz_ext, ".sub" ); /* reset extension */<br />+ else<br />+ msg_Dbg( p_input, "using %s as subtitle file instead of %s",<br />+ psz_local, psz_subtitle );<br /> }<br /> <br />- char *psz_uri
= vlc_path2uri( psz_subtitle, NULL );<br />- free( psz_idxpath );<br />+ char *psz_uri = vlc_path2uri( psz_local, NULL );<br />+ free( psz_local );<br /> return psz_uri;<br /> }<br /> </pre></blockquote></div><br clear="all">The function name implies path as input so nack. Maybe rename the function, but AFAIR, wz already have support for adding slaves as URI.<br>
-- <br>
Rémi Denis-Courmont</body></html>