From 034eeaa8d734e914e6065a16323254b5ac039794 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Ekstr=C3=B6m?= Date: Mon, 5 Apr 2021 19:07:46 +0300 Subject: demux_mf: early exit with the '%%' case --- demux/demux_mf.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'demux/demux_mf.c') diff --git a/demux/demux_mf.c b/demux/demux_mf.c index d00072a39a..6a6c8c212a 100644 --- a/demux/demux_mf.c +++ b/demux/demux_mf.c @@ -158,18 +158,30 @@ static mf_t *open_mf_pattern(void *talloc_ctx, struct demuxer *d, char *filename while (nspec < 2 && (c = *f++)) { if (c != '%') continue; - if (*f != '%') { - nspec++; // conversion specifier which isn't %% - if (*f == '.') - f++; - for (int ndig = 0; mp_isdigit(*f) && ndig < MAXDIGS; ndig++, f++) - /* no-op */; - if (*f != 'd') { - bad_spec++; // not int, or beyond our validation capacity - break; - } + + if (*f == '%') { + // '%%', which ends up as an explicit % in the output. + // Skipping forwards as it doesn't require further attention. + f++; + continue; } - // *f is '%' or 'd' + + // Now c == '%' and *f != '%', thus we have entered territory of format + // specifiers which we are interested in. + nspec++; + + if (*f == '.') + f++; + + for (int ndig = 0; mp_isdigit(*f) && ndig < MAXDIGS; ndig++, f++) + /* no-op */; + + if (*f != 'd') { + bad_spec++; // not int, or beyond our validation capacity + break; + } + + // *f is 'd' f++; } -- cgit v1.2.3