Message ID | 20191011163638.1990-1-jamrial@gmail.com |
---|---|
State | Accepted |
Commit | 2e4f86e04ca6abdf8a1829dce210ceeef46eb224 |
Headers | show |
On 10/11/2019 1:36 PM, James Almer wrote: > The "type" entry was hardcoded with an trailing comma, even if it was > the only entry in the section. > > Fixes ticket #8228. > > Signed-off-by: James Almer <jamrial@gmail.com> > --- > fftools/ffprobe.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c > index 2380417229..a95d74346d 100644 > --- a/fftools/ffprobe.c > +++ b/fftools/ffprobe.c > @@ -1535,7 +1535,7 @@ static void json_print_section_header(WriterContext *wctx) > if (parent_section && parent_section->id == SECTION_ID_PACKETS_AND_FRAMES) { > if (!json->compact) > JSON_INDENT(); > - printf("\"type\": \"%s\"%s", section->name, json->item_sep); > + printf("\"type\": \"%s\"", section->name); > } > } > av_bprint_finalize(&buf, NULL); > @@ -1579,8 +1579,10 @@ static inline void json_print_item_str(WriterContext *wctx, > static void json_print_str(WriterContext *wctx, const char *key, const char *value) > { > JSONContext *json = wctx->priv; > + const struct section *parent_section = wctx->level ? > + wctx->section[wctx->level-1] : NULL; > > - if (wctx->nb_item[wctx->level]) > + if (wctx->nb_item[wctx->level] || (parent_section && parent_section->id == SECTION_ID_PACKETS_AND_FRAMES)) > printf("%s", json->item_sep); > if (!json->compact) > JSON_INDENT(); > @@ -1590,9 +1592,11 @@ static void json_print_str(WriterContext *wctx, const char *key, const char *val > static void json_print_int(WriterContext *wctx, const char *key, long long int value) > { > JSONContext *json = wctx->priv; > + const struct section *parent_section = wctx->level ? > + wctx->section[wctx->level-1] : NULL; > AVBPrint buf; > > - if (wctx->nb_item[wctx->level]) > + if (wctx->nb_item[wctx->level] || (parent_section && parent_section->id == SECTION_ID_PACKETS_AND_FRAMES)) > printf("%s", json->item_sep); > if (!json->compact) > JSON_INDENT(); Will apply soon.
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index 2380417229..a95d74346d 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -1535,7 +1535,7 @@ static void json_print_section_header(WriterContext *wctx) if (parent_section && parent_section->id == SECTION_ID_PACKETS_AND_FRAMES) { if (!json->compact) JSON_INDENT(); - printf("\"type\": \"%s\"%s", section->name, json->item_sep); + printf("\"type\": \"%s\"", section->name); } } av_bprint_finalize(&buf, NULL); @@ -1579,8 +1579,10 @@ static inline void json_print_item_str(WriterContext *wctx, static void json_print_str(WriterContext *wctx, const char *key, const char *value) { JSONContext *json = wctx->priv; + const struct section *parent_section = wctx->level ? + wctx->section[wctx->level-1] : NULL; - if (wctx->nb_item[wctx->level]) + if (wctx->nb_item[wctx->level] || (parent_section && parent_section->id == SECTION_ID_PACKETS_AND_FRAMES)) printf("%s", json->item_sep); if (!json->compact) JSON_INDENT(); @@ -1590,9 +1592,11 @@ static void json_print_str(WriterContext *wctx, const char *key, const char *val static void json_print_int(WriterContext *wctx, const char *key, long long int value) { JSONContext *json = wctx->priv; + const struct section *parent_section = wctx->level ? + wctx->section[wctx->level-1] : NULL; AVBPrint buf; - if (wctx->nb_item[wctx->level]) + if (wctx->nb_item[wctx->level] || (parent_section && parent_section->id == SECTION_ID_PACKETS_AND_FRAMES)) printf("%s", json->item_sep); if (!json->compact) JSON_INDENT();
The "type" entry was hardcoded with an trailing comma, even if it was the only entry in the section. Fixes ticket #8228. Signed-off-by: James Almer <jamrial@gmail.com> --- fftools/ffprobe.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)