ffprobe: prefer av_strtok() over av_get_token() for parsing print_format string
Simplify, and avoid the need for multiple escaping levels.
This commit is contained in:
parent
b35e9e19e9
commit
b874e2d0a0
25
ffprobe.c
25
ffprobe.c
@ -809,26 +809,20 @@ static int probe_file(const char *filename)
|
|||||||
AVFormatContext *fmt_ctx;
|
AVFormatContext *fmt_ctx;
|
||||||
int ret;
|
int ret;
|
||||||
Writer *w;
|
Writer *w;
|
||||||
const char *buf = print_format;
|
char *buf;
|
||||||
char *w_str = NULL, *w_args = NULL;
|
char *w_name = NULL, *w_args = NULL;
|
||||||
WriterContext *wctx;
|
WriterContext *wctx;
|
||||||
|
|
||||||
writer_register_all();
|
writer_register_all();
|
||||||
|
|
||||||
if (buf) {
|
if (!print_format)
|
||||||
w_str = av_get_token(&buf, "=");
|
print_format = av_strdup("default");
|
||||||
if (*buf == '=') {
|
w_name = av_strtok(print_format, "=", &buf);
|
||||||
buf++;
|
w_args = buf;
|
||||||
w_args = av_get_token(&buf, "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!w_str)
|
w = writer_get_by_name(w_name);
|
||||||
w_str = av_strdup("default");
|
|
||||||
|
|
||||||
w = writer_get_by_name(w_str);
|
|
||||||
if (!w) {
|
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);
|
ret = AVERROR(EINVAL);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
@ -848,8 +842,7 @@ static int probe_file(const char *filename)
|
|||||||
writer_close(&wctx);
|
writer_close(&wctx);
|
||||||
|
|
||||||
end:
|
end:
|
||||||
av_free(w_str);
|
av_free(print_format);
|
||||||
av_free(w_args);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user