[MPlayer-dev-eng] [PATCH] suboption escaping
Joey Parrish
joey at nicewarrior.org
Sat Aug 20 03:38:23 CEST 2005
On Fri, Aug 19, 2005 at 09:14:30PM +0200, Reimar Döffinger wrote:
> On Fri, Aug 19, 2005 at 10:09:21AM -0500, Joey Parrish wrote:
> > On Thu, Aug 18, 2005 at 11:51:10PM +0200, Reimar Döffinger wrote:
> > > IMHO the current way to parse it is broken (first strtok and then
> > > sscanf). I think it would be better to first assign the subopt variable
> > > (by finding the end of the option string by searching for '=' or ':'),
> >
> > No, this doesn't work. If you end subopt by finding :, then we can't
> > have : in a value. That's the whole reason for my patch.
>
> No, I meant search for ':' _or_ '=', whichever comes first. Of course,
> the suboption name can't contain a ':' or '=' in that case, but I'd say
> that's no problem.
>
> > > and then parse the value (if any). e.g. if it starts with " search for
> > > the closing " and copy all of it. if not you can do backslash escaping
> > > processing. Etc.
> >
> > I would accept "" parsing if you have a patch to offer. All I care
> > about is mencoder -info "title=Star Trek: The Next Generation". If you
> > can make this work (other than the %len% method, which is a pain for
> > scripting) then I'll be happy.
>
> Hmmm... I'd prefer somebody else to do it, but I can try to whip
> something up if nobody else does...
Well, since I've already done it this way, why not tweak this patch? I
still think it's the best thing proposed in this thread. (Yes, bias.)
IIRC, your main objection is with the sscanf line. Ideally, we would
take everything after the first =, because the strtokex call has decided
where the value should end. According to sscanf documentation, %s will
not match whitespace. %[] will match based on a character set, but how
do we define this set? I tried %[.] thinking that . is a regex
character meaning "any", but it was taken literally. What I ended up
doing for this patch is excluding =, thinking that it was not a valid
character in this context anyway. Is this untrue?
Anyhow, I've just discovered that I can exclude a non-printable
character to get the desired behavior out of sscanf. %[^\033] seems a
bit of a hack, but it works and is clean.
Thoughts?
--Joey
--
"I eat donuts for dying children." --Andrew
More information about the MPlayer-dev-eng
mailing list