Added the possibility to escape chars in gstparse. You can now give it a cmdline like disksrc location=some\ sort\ of...

Original commit message from CVS:
Added the possibility to escape chars in gstparse. You can now give it a
cmdline like disksrc location=some\ sort\ of.mp3 ! .... and it does the
right thing.
This commit is contained in:
Wim Taymans 2001-05-20 20:05:29 +00:00
parent 90c0acec1c
commit 704918c3fa

View file

@ -354,6 +354,7 @@ gst_parse_launch(const gchar *cmdline,GstBin *parent)
gint newargc; gint newargc;
gint i; gint i;
const gchar *cp, *start, *end; const gchar *cp, *start, *end;
gchar *temp;
GSList *string_list = NULL, *slist; GSList *string_list = NULL, *slist;
priv.bincount = 0; priv.bincount = 0;
@ -366,20 +367,32 @@ gst_parse_launch(const gchar *cmdline,GstBin *parent)
end = cmdline + strlen(cmdline); end = cmdline + strlen(cmdline);
newargc = 0; newargc = 0;
temp = "";
// Extract the arguments to a gslist in reverse order // Extract the arguments to a gslist in reverse order
for (cp = cmdline; cp < end; ) { for (cp = cmdline; cp < end; ) {
i = strcspn(cp, "([{}]) \""); i = strcspn(cp, "([{}]) \"\\");
if (i > 0) { if (i > 0) {
temp = g_strconcat (temp, g_strndup (cp, i), NULL);
// see if we have an escape char
if (cp[i] != '\\') {
// normal argument - copy and add to the list // normal argument - copy and add to the list
string_list = g_slist_prepend(string_list, g_strndup(cp, i)); string_list = g_slist_prepend(string_list, temp);
newargc++; newargc++;
temp = "";
}
else {
temp = g_strconcat (temp, g_strndup (&cp[++i], 1), NULL);
}
cp += i; cp += i;
} }
// skip spaces // skip spaces
while (cp < end && *cp == ' ') while (cp < end && *cp == ' ') {
cp++; cp++;
}
// handle quoted arguments // handle quoted arguments
if (*cp == '"') { if (*cp == '"') {