mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-27 10:40:34 +00:00
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:
parent
90c0acec1c
commit
704918c3fa
1 changed files with 18 additions and 5 deletions
|
@ -354,6 +354,7 @@ gst_parse_launch(const gchar *cmdline,GstBin *parent)
|
|||
gint newargc;
|
||||
gint i;
|
||||
const gchar *cp, *start, *end;
|
||||
gchar *temp;
|
||||
GSList *string_list = NULL, *slist;
|
||||
|
||||
priv.bincount = 0;
|
||||
|
@ -366,20 +367,32 @@ gst_parse_launch(const gchar *cmdline,GstBin *parent)
|
|||
end = cmdline + strlen(cmdline);
|
||||
newargc = 0;
|
||||
|
||||
temp = "";
|
||||
|
||||
// Extract the arguments to a gslist in reverse order
|
||||
for (cp = cmdline; cp < end; ) {
|
||||
i = strcspn(cp, "([{}]) \"");
|
||||
i = strcspn(cp, "([{}]) \"\\");
|
||||
|
||||
if (i > 0) {
|
||||
// normal argument - copy and add to the list
|
||||
string_list = g_slist_prepend(string_list, g_strndup(cp, i));
|
||||
newargc++;
|
||||
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
|
||||
string_list = g_slist_prepend(string_list, temp);
|
||||
newargc++;
|
||||
temp = "";
|
||||
}
|
||||
else {
|
||||
temp = g_strconcat (temp, g_strndup (&cp[++i], 1), NULL);
|
||||
}
|
||||
cp += i;
|
||||
}
|
||||
|
||||
// skip spaces
|
||||
while (cp < end && *cp == ' ')
|
||||
while (cp < end && *cp == ' ') {
|
||||
cp++;
|
||||
}
|
||||
|
||||
// handle quoted arguments
|
||||
if (*cp == '"') {
|
||||
|
|
Loading…
Reference in a new issue