aboutsummaryrefslogtreecommitdiffstats
path: root/ffprobe.c
diff options
context:
space:
mode:
authorAlexander Strasser <eclipse7@gmx.net>2012-09-17 01:26:11 +0200
committerAlexander Strasser <eclipse7@gmx.net>2012-09-25 01:32:13 +0200
commitf70122dd574e95bb77993abbecaae9ba1020336f (patch)
tree54f08223768f04f2902621773c3533f224eb4021 /ffprobe.c
parent7e3208a0876bcbce41549f475882c653f2cbc007 (diff)
downloadffmpeg-f70122dd574e95bb77993abbecaae9ba1020336f.tar.gz
ffprobe: Simplify CSV field quoting code
Sync with bac1b31 . Signed-off-by: Alexander Strasser <eclipse7@gmx.net>
Diffstat (limited to 'ffprobe.c')
-rw-r--r--ffprobe.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/ffprobe.c b/ffprobe.c
index 48d395bda4..8a369ba1b8 100644
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -26,6 +26,8 @@
#include "config.h"
#include "version.h"
+#include <string.h>
+
#include "libavformat/avformat.h"
#include "libavcodec/avcodec.h"
#include "libavutil/avstring.h"
@@ -565,21 +567,15 @@ static const char *c_escape_str(AVBPrint *dst, const char *src, const char sep,
*/
static const char *csv_escape_str(AVBPrint *dst, const char *src, const char sep, void *log_ctx)
{
- const char *p;
- int quote = 0;
-
- /* check if input needs quoting */
- for (p = src; *p; p++)
- if (*p == '"' || *p == sep || *p == '\n' || *p == '\r')
- quote = 1;
+ int quote = !!src[strcspn(src, "\",\n\r")];
if (quote)
av_bprint_chars(dst, '\"', 1);
- for (p = src; *p; p++) {
- if (*p == '"')
+ for (; *src; src++) {
+ if (*src == '"')
av_bprint_chars(dst, '\"', 1);
- av_bprint_chars(dst, *p, 1);
+ av_bprint_chars(dst, *src, 1);
}
if (quote)
av_bprint_chars(dst, '\"', 1);