Skip to content

Commit 118a3dd

Browse files
committed
screenshot: use mp_stripext for %F
Reuse existing functionality, see previous commit introducing above function.
1 parent c733d34 commit 118a3dd

File tree

2 files changed

+2
-12
lines changed

2 files changed

+2
-12
lines changed

player/command.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,9 +534,7 @@ static int mp_property_filename(void *ctx, struct m_property *prop,
534534
if (strcmp(ka->key, "no-ext") == 0) {
535535
action = ka->action;
536536
arg = ka->arg;
537-
bstr root;
538-
if (mp_splitext(f, &root))
539-
f = bstrto0(filename, root);
537+
f = mp_stripext(filename, f);
540538
}
541539
}
542540
int r = m_property_strdup_ro(action, arg, f);

player/screenshot.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,6 @@ void screenshot_init(struct MPContext *mpctx)
6868
};
6969
}
7070

71-
static char *stripext(void *talloc_ctx, const char *s)
72-
{
73-
const char *end = strrchr(s, '.');
74-
if (!end)
75-
end = s + strlen(s);
76-
return talloc_asprintf(talloc_ctx, "%.*s", (int)(end - s), s);
77-
}
78-
7971
static bool write_screenshot(struct mp_cmd_ctx *cmd, struct mp_image *img,
8072
const char *filename, struct image_writer_opts *opts,
8173
bool overwrite)
@@ -179,7 +171,7 @@ static char *create_fname(struct MPContext *mpctx, char *template,
179171
char *name = video_file ? mp_basename_or_url(video_file) : "NO_FILE";
180172

181173
if (fmt == 'F')
182-
name = stripext(res, video_file);
174+
name = mp_stripext(res, name);
183175
append_filename(&res, name);
184176
break;
185177
}

0 commit comments

Comments
 (0)