[FFmpeg-devel] [PATCH] Implement av_get_token()

Stefano Sabatini stefano.sabatini-lala
Sat Apr 25 13:21:49 CEST 2009


On date Friday 2009-04-24 15:18:45 +0200, Michael Niedermayer encoded:
> On Fri, Apr 24, 2009 at 01:32:08AM +0200, Stefano Sabatini wrote:
> > Hi, as in subject.
> > Maybe it should be implemented in libavutil/avstring.h, but then maybe
> > is also better to wait for it to stabilize.
> > 
> > This is the output of the test program:
> > 
> > || -> || + ||
> > |:| -> || + |:|
> > |    | -> || + ||
> > |foo     | -> |foo| + ||
> > |     foo| -> |foo| + ||
> > |      foo       | -> |foo| + ||
> > | foo   bar    :   blahblah| -> |foo   bar| + |:   blahblah|
> > |\f\o\o| -> |foo| + ||
> > |'foo : \ \  '   : blahblah| -> |foo : \ \| + |: blahblah|
> > |'\fo\o:': blahblah| -> |\fo\o:| + |: blahblah|
> > |\'fo\o\:':  foo'  :blahblah| -> |'foo::  foo| + |:blahblah|
> 
> add \ at the end escaing the traiing null
> and unterminated '
> and escaped leading and trailing whitespace

OK.

[..]
> > +    /* strip trailing whitespaces */
> > +    out--;
> > +    while(--out >= ret && strspn(out, WHITESPACES))
> > +        *out = 0;
> 
> this will remove escaped trailing whitespaces

Reimplemeneted as a finite state machine, as the previous apporach was
resulting messy and unreadable.

The result of the test is now:

|''| -> || + ||
|| -> || + ||
|:| -> || + |:|
|\| -> || + ||
|'| -> || + ||
|    ''    :| -> || + |:|
|foo   '' :| -> |foo   | + |:|
|'foo'| -> |foo| + ||
|foo     | -> |foo| + ||
|foo\| -> |foo| + ||
|foo':  blah:blah| -> |foo:  blah:blah| + ||
|foo\:  blah:blah| -> |foo:  blah| + |:blah|
|foo'| -> |foo| + ||
|'foo :  '  :blahblah| -> |foo :  | + |:blahblah|
|\ :blah| -> | | + |:blah|
|     foo| -> |foo| + ||
|      foo       | -> |foo| + ||
|      foo     \ | -> |foo      | + ||
|foo ':blah| -> |foo :blah| + ||
| foo   bar    :   blahblah| -> |foo   bar| + |:   blahblah|
|\f\o\o| -> |foo| + ||
|'foo : \ \  '   : blahblah| -> |foo : \ \  | + |: blahblah|
|'\fo\o:': blahblah| -> |\fo\o:| + |: blahblah|
|\'fo\o\:':  foo  '  :blahblah| -> |'foo::  foo  | + |:blahblah|

Regards.
-- 
FFmpeg = Faboulous Frenzy Majestic Peaceless Elastic Governor
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lavfi-implement-get-token.patch
Type: text/x-diff
Size: 5375 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090425/bf396dba/attachment.patch>



More information about the ffmpeg-devel mailing list