summaryrefslogtreecommitdiff
path: root/ffprobe.c
diff options
context:
space:
mode:
authorStefano Sabatini <stefasab@gmail.com>2011-10-15 00:38:29 +0200
committerStefano Sabatini <stefasab@gmail.com>2011-10-18 18:21:03 +0200
commitb874e2d0a04603f28bbfe5b87de9e01e7e87bf43 (patch)
tree0f30cd3ffd94f7f03b9f32d3a9c80c4795c46dc6 /ffprobe.c
parentb35e9e19e93b0c69303444e9974ee640a924f798 (diff)
downloadffmpeg-b874e2d0a04603f28bbfe5b87de9e01e7e87bf43.tar.gz
ffprobe: prefer av_strtok() over av_get_token() for parsing print_format string
Simplify, and avoid the need for multiple escaping levels.
Diffstat (limited to 'ffprobe.c')
-rw-r--r--ffprobe.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/ffprobe.c b/ffprobe.c
index e648922584..d6c7093143 100644
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -809,26 +809,20 @@ static int probe_file(const char *filename)
AVFormatContext *fmt_ctx;
int ret;
Writer *w;
- const char *buf = print_format;
- char *w_str = NULL, *w_args = NULL;
+ char *buf;
+ char *w_name = NULL, *w_args = NULL;
WriterContext *wctx;
writer_register_all();
- if (buf) {
- w_str = av_get_token(&buf, "=");
- if (*buf == '=') {
- buf++;
- w_args = av_get_token(&buf, "");
- }
- }
-
- if (!w_str)
- w_str = av_strdup("default");
+ if (!print_format)
+ print_format = av_strdup("default");
+ w_name = av_strtok(print_format, "=", &buf);
+ w_args = buf;
- w = writer_get_by_name(w_str);
+ w = writer_get_by_name(w_name);
if (!w) {
- av_log(NULL, AV_LOG_ERROR, "Invalid output format '%s'\n", w_str);
+ av_log(NULL, AV_LOG_ERROR, "Unknown output format with name '%s'\n", w_name);
ret = AVERROR(EINVAL);
goto end;
}
@@ -848,8 +842,7 @@ static int probe_file(const char *filename)
writer_close(&wctx);
end:
- av_free(w_str);
- av_free(w_args);
+ av_free(print_format);
return ret;
}