[FFmpeg-devel] [PATCH] lavf/segment: Simplify CSV field quoting code

Alexander Strasser eclipse7 at gmx.net
Sat Sep 15 02:39:52 CEST 2012


Stefano Sabatini wrote:
> On date Sunday 2012-09-09 21:54:04 +0200, Alexander Strasser encoded:
[...]
> >  libavformat/segment.c | 9 ++-------
> >  1 file changed, 2 insertions(+), 7 deletions(-)
> > 
> > diff --git a/libavformat/segment.c b/libavformat/segment.c
> > index 5ae15bd..a5bed1b 100644
> > --- a/libavformat/segment.c
> > +++ b/libavformat/segment.c
> > @@ -73,14 +73,9 @@ typedef struct {
> >  static void print_csv_escaped_str(AVIOContext *ctx, const char *str)
> >  {
> >      const char *p;
> > -    int quote = 0;
> > +    int quote;
> >  
> > -    /* check if input needs quoting */
> > -    for (p = str; *p; p++)
> > -        if (strchr("\",\n\r", *p)) {
> > -            quote = 1;
> > -            break;
> > -        }
> 
> > +    quote = !!str[strcspn(str, "\",\n\r")];
> 
> Can be merged with declaration.
> 
> Patch looks OK, maybe add a comment like:
> 
> // check if string contains special characters
> int quote = ...;

  For the record: I sent a new patch set superseding this one.

  Alexander


More information about the ffmpeg-devel mailing list