summaryrefslogtreecommitdiffstats
path: root/demux/demux_mf.c
diff options
context:
space:
mode:
authorJan Ekström <jeebjp@gmail.com>2021-04-05 19:07:46 +0300
committersfan5 <sfan5@live.de>2023-08-20 20:25:28 +0200
commit034eeaa8d734e914e6065a16323254b5ac039794 (patch)
tree049e4ba47532454917e2bf867d2bfbf3f5b68f8d /demux/demux_mf.c
parentf88ed1416841aa01b7ebf69e4cbfb4c1dbf078eb (diff)
downloadmpv-034eeaa8d734e914e6065a16323254b5ac039794.tar.bz2
mpv-034eeaa8d734e914e6065a16323254b5ac039794.tar.xz
demux_mf: early exit with the '%%' case
Diffstat (limited to 'demux/demux_mf.c')
-rw-r--r--demux/demux_mf.c34
1 files changed, 23 insertions, 11 deletions
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++;
}