From 9aa206a90efcb6c2f21e460a6c5fcfdcc3b9f841 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 15 Sep 2013 19:07:35 +0200 Subject: screenshot: change %w format to be more like %t Instead of containing a format string within %w{...}, simply allow %w to specify one item of a time format string. This is simpler, more like other format specifiers (%t), and probably easier to use too. --- mpvcore/screenshot.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'mpvcore') diff --git a/mpvcore/screenshot.c b/mpvcore/screenshot.c index 0afa88182b..161bfac1e5 100644 --- a/mpvcore/screenshot.c +++ b/mpvcore/screenshot.c @@ -187,20 +187,16 @@ static char *create_fname(struct MPContext *mpctx, char *template, break; } case 'w': { - if (template[0] != '{') + char tfmt = *template; + if (!tfmt) goto error_exit; template++; - char *end = strchr(template, '}'); - if (!end) - goto error_exit; - char *fmt = talloc_strndup(res, template, end - template); - char *s = mp_format_time_fmt(fmt, get_current_time(mpctx)); + char fmtstr[] = {'%', tfmt, '\0'}; + char *s = mp_format_time_fmt(fmtstr, get_current_time(mpctx)); if (!s) goto error_exit; append_filename(&res, s); talloc_free(s); - talloc_free(fmt); - template = end + 1; break; } case 't': { -- cgit v1.2.3