From: Andy W. <wi...@us...> - 2002-04-13 17:11:55
|
CVS Root: /cvsroot/gstreamer Module: gstreamer Changes by: wingo Date: Sat Apr 13 2002 10:11:55 PDT Log message: quote spaces in tokens passed to gst_parse_launchv. this restores the old (shell-friendly) quoting behavior. Modified files: gst : gstparse.c gst/parse : parse.l types.h Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/gstparse.c.diff?r1=1.47&r2=1.48 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/parse/parse.l.diff?r1=1.4&r2=1.5 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/parse/types.h.diff?r1=1.2&r2=1.3 ====Begin Diffs==== Index: gstparse.c =================================================================== RCS file: /cvsroot/gstreamer/gstreamer/gst/gstparse.c,v retrieving revision 1.47 retrieving revision 1.48 diff -u -d -r1.47 -r1.48 --- gstparse.c 12 Apr 2002 20:06:14 -0000 1.47 +++ gstparse.c 13 Apr 2002 17:11:41 -0000 1.48 @@ -235,6 +235,7 @@ 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 @@ } } 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,14 +415,64 @@ 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); + + 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 (pipeline_description, error); + 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'; } /** Index: parse.l =================================================================== RCS file: /cvsroot/gstreamer/gstreamer/gst/parse/parse.l,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- parse.l 7 Apr 2002 23:32:14 -0000 1.4 +++ parse.l 13 Apr 2002 17:11:42 -0000 1.5 @@ -25,7 +25,8 @@ _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 @@ 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); Index: types.h =================================================================== RCS file: /cvsroot/gstreamer/gstreamer/gst/parse/types.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- types.h 7 Apr 2002 23:32:14 -0000 1.2 +++ types.h 13 Apr 2002 17:11:42 -0000 1.3 @@ -41,3 +41,5 @@ graph_t * _gst_parse_launch (const gchar *str, GError **error); +gchar *_gst_parse_escape (const gchar *str); +void _gst_parse_unescape (gchar *str); |