Commit 3585c395 authored by Gildas Bazin's avatar Gildas Bazin

* src/stream_output/stream_output.c: allows spaces in the options of the sout...

* src/stream_output/stream_output.c: allows spaces in the options of the sout mrl. Heading and trailing spaces in options will be removed.
parent eeb51429
...@@ -710,59 +710,37 @@ static void mrl_Clean( mrl_t *p_mrl ) ...@@ -710,59 +710,37 @@ static void mrl_Clean( mrl_t *p_mrl )
* XXX: psz_chain is modified * XXX: psz_chain is modified
*/ */
#define SKIPSPACE( p ) { while( *p && ( *p == ' ' || *p == '\t' ) ) p++; } #define SKIPSPACE( p ) { while( *p && ( *p == ' ' || *p == '\t' ) ) p++; }
#define SKIPTRAILINGSPACE( p, e ) \
{ while( e > p && ( *(e-1) == ' ' || *(e-1) == '\t' ) ) e--; }
/* go accross " " and { } */ /* go accross " " and { } */
static char *_get_chain_end( char *str ) static char *_get_chain_end( char *str )
{ {
char *p = str; char c, *p = str;
SKIPSPACE( p ); SKIPSPACE( p );
for( ;; ) for( ;; )
{ {
if( *p == '{' || *p == '"' || *p == '\'') if( !*p || *p == ',' || *p == '}' ) return p;
{
char c;
if( *p == '{' ) if( *p != '{' && *p != '"' && *p != '\'' )
{ {
c = '}';
}
else
{
c = *p;
}
p++; p++;
continue;
}
for( ;; ) if( *p == '{' ) c = '}';
{ else c = *p;
if( *p == '\0' ) p++;
{
return p;
}
if( *p == c ) for( ;; )
{
p++;
return p;
}
else if( *p == '{' && c == '}' )
{
p = _get_chain_end( p );
}
else
{
p++;
}
}
}
else if( *p == '\0' || *p == ',' || *p == '}' ||
*p == ' ' || *p == '\t' )
{
return p;
}
else
{ {
p++; if( !*p ) return p;
if( *p == c ) return ++p;
else if( *p == '{' && c == '}' ) p = _get_chain_end( p );
else p++;
} }
} }
} }
...@@ -829,14 +807,35 @@ char *sout_cfg_parser( char **ppsz_name, sout_cfg_t **pp_cfg, char *psz_chain ) ...@@ -829,14 +807,35 @@ char *sout_cfg_parser( char **ppsz_name, sout_cfg_t **pp_cfg, char *psz_chain )
} }
else else
{ {
if( *p == '\'' || *p =='"' || /* Skip heading and trailing spaces.
* This ain't necessary but will avoid simple
* user mistakes. */
SKIPSPACE( p );
}
if( end <= p )
{
cfg.psz_value = NULL;
}
else
{
if( *p == '\'' || *p == '"' ||
( !b_keep_brackets && *p == '{' ) ) ( !b_keep_brackets && *p == '{' ) )
{ {
p++; p++;
end--;
if( *(end-1) != '\'' && *(end-1) == '"' )
SKIPTRAILINGSPACE( p, end );
if( end - 1 <= p ) cfg.psz_value = NULL;
else cfg.psz_value = strndup( p, end -1 - p );
}
else
{
SKIPTRAILINGSPACE( p, end );
if( end <= p ) cfg.psz_value = NULL;
else cfg.psz_value = strndup( p, end - p );
} }
if( end <= p ) cfg.psz_value = NULL;
else cfg.psz_value = strndup( p, end - p );
} }
p = end; p = end;
......
Markdown is supported
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