mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-09 08:55:33 +00:00
quote spaces in tokens passed to gst_parse_launchv. this restores the old (shell-friendly) quoting behavior.
Original commit message from CVS: quote spaces in tokens passed to gst_parse_launchv. this restores the old (shell-friendly) quoting behavior.
This commit is contained in:
parent
2223a9a8c4
commit
157e961c26
3 changed files with 63 additions and 5 deletions
|
@ -235,6 +235,7 @@ make_connections (graph_t *g, GError **error)
|
|||
|
||||
a = c->src_pads;
|
||||
b = c->sink_pads;
|
||||
// g_print ("a: %p, b: %p\n", a, b);
|
||||
if (a && b) {
|
||||
/* balanced multipad connection */
|
||||
while (a && b) {
|
||||
|
@ -266,11 +267,14 @@ make_connections (graph_t *g, GError **error)
|
|||
}
|
||||
} else if (a) {
|
||||
if ((pt1 = gst_element_get_pad_template (src, (gchar*)a->data))) {
|
||||
// g_print ("have padtemplate %s, SOMETIMES=%s\n", pt1->name_template, pt1->presence == GST_PAD_SOMETIMES ? "TRUE" : "FALSE");
|
||||
if ((p1 = gst_element_get_pad (src, (gchar*)a->data)) || pt1->presence == GST_PAD_SOMETIMES) {
|
||||
if (!p1) {
|
||||
/* sigh, a hack until i fix the gstelement api... */
|
||||
if ((pt2 = gst_element_get_compatible_pad_template (sink, pt1))) {
|
||||
// g_print ("have compatible pad template %s\n", pt2->name_template);
|
||||
if ((p2 = gst_element_get_pad (sink, pt2->name_template))) {
|
||||
// g_print ("got the pad\n");
|
||||
dc = g_new0 (dynamic_connection_t, 1);
|
||||
dc->srcpadname = (gchar*)a->data;
|
||||
dc->target = p2;
|
||||
|
@ -411,16 +415,66 @@ GstBin *
|
|||
gst_parse_launchv (const gchar **argv, GError **error)
|
||||
{
|
||||
GstBin *pipeline;
|
||||
gchar *pipeline_description;
|
||||
GString *str;
|
||||
const gchar **argvp, *arg;
|
||||
gchar *tmp;
|
||||
|
||||
/* i think this cast works out ok... */
|
||||
pipeline_description = g_strjoinv (" ", (gchar**)argv);
|
||||
/* let's give it a nice size. */
|
||||
str = g_string_sized_new (1024);
|
||||
|
||||
pipeline = gst_parse_launch (pipeline_description, error);
|
||||
argvp = argv;
|
||||
while (*argvp) {
|
||||
arg = *argvp;
|
||||
tmp = _gst_parse_escape (arg);
|
||||
g_string_append (str, tmp);
|
||||
g_free (tmp);
|
||||
g_string_append (str, " ");
|
||||
argvp++;
|
||||
}
|
||||
|
||||
pipeline = gst_parse_launch (str->str, error);
|
||||
|
||||
g_string_free (str, TRUE);
|
||||
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
gchar *_gst_parse_escape (const gchar *str)
|
||||
{
|
||||
GString *gstr = NULL;
|
||||
|
||||
g_return_val_if_fail (str != NULL, NULL);
|
||||
|
||||
gstr = g_string_sized_new (strlen (str));
|
||||
|
||||
while (*str) {
|
||||
if (*str == ' ')
|
||||
g_string_append_c (gstr, '\\');
|
||||
g_string_append_c (gstr, *str);
|
||||
str++;
|
||||
}
|
||||
|
||||
return gstr->str;
|
||||
}
|
||||
|
||||
void _gst_parse_unescape (gchar *str)
|
||||
{
|
||||
gchar *walk;
|
||||
|
||||
g_return_if_fail (str != NULL);
|
||||
|
||||
walk = str;
|
||||
|
||||
while (*walk) {
|
||||
if (*walk == '\\')
|
||||
walk++;
|
||||
*str = *walk;
|
||||
str++;
|
||||
walk++;
|
||||
}
|
||||
*str = '\0';
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_parse_launch:
|
||||
* @pipeline_description: the command line describing the pipeline
|
||||
|
|
|
@ -25,7 +25,8 @@ _identifier [[:alpha:]][[:alnum:]\-_%]*
|
|||
_lconnection ({_identifier}\.)?{_identifier}!
|
||||
_rconnection !({_identifier}\.)?{_identifier}
|
||||
_bconnection ({_identifier}\.)?{_identifier}!({_identifier}\.)?{_identifier}
|
||||
_string ([^[:space:]\"]|"\\\"")+|("\""([^\"]|"\\\"")*"\"")
|
||||
_char ([^[:space:]])|("\\".)
|
||||
_string {_char}+|("\""([^\"]|"\\\"")*"\"")
|
||||
|
||||
%x value
|
||||
%option noyywrap
|
||||
|
@ -65,6 +66,7 @@ _string ([^[:space:]\"]|"\\\"")+|("\""([^\"]|"\\\"")*"\"")
|
|||
yytext++;
|
||||
*(yytext + strlen (yytext) - 1) = '\0';
|
||||
}
|
||||
_gst_parse_unescape (yytext);
|
||||
PRINT ("A string: \"%s\"\n", yytext);
|
||||
lvalp->v = g_new0 (GValue, 1);
|
||||
g_value_init (lvalp->v, G_TYPE_STRING);
|
||||
|
|
|
@ -41,3 +41,5 @@ struct _graph_t {
|
|||
|
||||
graph_t * _gst_parse_launch (const gchar *str, GError **error);
|
||||
|
||||
gchar *_gst_parse_escape (const gchar *str);
|
||||
void _gst_parse_unescape (gchar *str);
|
||||
|
|
Loading…
Reference in a new issue