Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VLC
Manage
Activity
Members
Labels
Plan
Issues
4k
Issue boards
Milestones
Code
Merge requests
450
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VideoLAN
VLC
Commits
85e000fa
Commit
85e000fa
authored
18 years ago
by
Marian Ďurkovič
Browse files
Options
Downloads
Patches
Plain Diff
VLM quoting magic for partially quoted strings
parent
a658df6d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/input/vlm.c
+77
-38
77 additions, 38 deletions
src/input/vlm.c
with
77 additions
and
38 deletions
src/input/vlm.c
+
77
−
38
View file @
85e000fa
...
...
@@ -261,26 +261,37 @@ static const char quotes[] = "\"'";
*/
static
const
char
*
FindCommandEnd
(
const
char
*
psz_sent
)
{
const
char
quote
=
strchr
(
quotes
,
psz_sent
[
0
])
?
psz_sent
[
0
]
:
0
;
char
c
;
if
(
quote
)
psz_sent
++
;
// skip opening quote
char
c
,
quote
=
0
;
while
((
c
=
*
psz_sent
)
!=
'\0'
)
{
if
(
(
quote
==
'"'
)
&&
(
c
==
'\\'
)
)
if
(
!
quote
)
{
psz_sent
++
;
// move past backslash
if
(
*
psz_sent
==
'\0'
)
return
NULL
;
// cannot escape "nothing"
if
(
strchr
(
quotes
,
c
))
// opening quote
quote
=
c
;
else
if
(
isspace
(
c
))
// non-escaped space
return
psz_sent
;
else
if
(
c
==
'\\'
)
{
psz_sent
++
;
// skip escaped character
if
(
*
psz_sent
==
'\0'
)
return
psz_sent
;
}
}
else
if
(
c
==
quote
)
// non-escaped matching quote
return
psz_sent
+
1
;
else
if
((
!
quote
)
&&
isspace
(
c
))
// non-escaped blank
return
psz_sent
;
{
if
(
c
==
quote
)
// non-escaped matching quote
quote
=
0
;
else
if
((
quote
==
'"'
)
&&
(
c
==
'\\'
))
{
psz_sent
++
;
// skip escaped character
if
(
*
psz_sent
==
'\0'
)
return
NULL
;
// error, closing quote missing
}
}
psz_sent
++
;
}
...
...
@@ -301,36 +312,64 @@ static const char *FindCommandEnd (const char *psz_sent)
*/
static
int
Unescape
(
char
*
out
,
const
char
*
in
)
{
c
onst
char
quote
=
strchr
(
quotes
,
in
[
0
])
?
in
[
0
]
:
0
;
c
har
c
,
quote
=
0
;
if
(
quote
)
in
++
;
// skips opening quote
for
(;;)
while
((
c
=
*
in
++
)
!=
'\0'
)
{
char
c
=
*
in
++
;
if
((
c
==
'\0'
)
||
(
c
==
quote
))
break
;
if
((
quote
==
'"'
)
&&
(
c
==
'\\'
))
if
(
!
quote
)
{
switch
(
c
=
*
in
++
)
if
(
strchr
(
quotes
,
c
))
// opening quote
{
case
'"'
:
*
out
++
=
'"'
;
continue
;
case
'\\'
:
*
out
++
=
'\\'
;
quote
=
c
;
continue
;
}
else
if
(
c
==
'\\'
)
{
switch
(
c
=
*
in
++
)
{
case
'"'
:
case
'\''
:
case
'\\'
:
*
out
++
=
c
;
continue
;
case
'\0'
:
*
out
=
'\0'
;
return
0
;
}
if
(
isspace
(
c
))
{
*
out
++
=
c
;
continue
;
case
'\0'
:
// should never happen
*
out
=
'\0'
;
return
-
1
;
}
/* None of the special cases - copy the backslash */
*
out
++
=
'\\'
;
}
}
else
{
if
(
c
==
quote
)
// non-escaped matching quote
{
quote
=
0
;
continue
;
}
if
((
quote
==
'"'
)
&&
(
c
==
'\\'
))
{
switch
(
c
=
*
in
++
)
{
case
'"'
:
case
'\\'
:
*
out
++
=
c
;
continue
;
case
'\0'
:
// should never happen
*
out
=
'\0'
;
return
-
1
;
}
/* None of the special cases - copy the backslash */
*
out
++
=
'\\'
;
}
/* None of the special cases - copy the backslash */
*
out
++
=
'\\'
;
}
*
out
++
=
c
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment