Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Strasser <eclipse7@gmx.net>2012-09-09 23:27:13 +0400
committerAlexander Strasser <eclipse7@gmx.net>2012-09-16 00:55:21 +0400
commitbac1b31bf63554bd9e0e38ef06125234aff41dc9 (patch)
tree827b10b8ca8a75c74af166463c50b52eee4e946d
parentaefed6ca87971a9d277157c92fef4cdd42c5c1e2 (diff)
lavf/segment: Simplify CSV field quoting code
Should also be faster (though I doubt that hardly ever matters for the usage here). Also remove the pointer copy. Since we do not need to reset the pointer to the start of the string, it is not needed anymore. Signed-off-by: Alexander Strasser <eclipse7@gmx.net>
-rw-r--r--libavformat/segment.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/libavformat/segment.c b/libavformat/segment.c
index dc123495da..07b8da3e2a 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -76,23 +76,15 @@ typedef struct {
static void print_csv_escaped_str(AVIOContext *ctx, const char *str)
{
- const char *p;
- int quote = 0;
-
- /* check if input needs quoting */
- for (p = str; *p; p++)
- if (strchr("\",\n\r", *p)) {
- quote = 1;
- break;
- }
+ int quote = !!str[strcspn(str, "\",\n\r")];
if (quote)
avio_w8(ctx, '"');
- for (p = str; *p; p++) {
- if (*p == '"')
+ for (; *str; str++) {
+ if (*str == '"')
avio_w8(ctx, '"');
- avio_w8(ctx, *p);
+ avio_w8(ctx, *str);
}
if (quote)
avio_w8(ctx, '"');