From f5e2ee513862da957858be4963cd6535fa23f861 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 18 Nov 2012 18:02:14 +0100 Subject: options: support chapters for --start and --end The --start and --end switch now accept a chapter number. The chapter number is prefixed with '#', e.g. "--start=#2" jumps to chapter 2. The chapter support might be able to replace --chapter completely, but for now I am not sure how well this works out with e.g. DVDs and BDs, and a separate --chapter option is useful interface-wise. (This was supposed to be added in 51503a, but apparently the fixup commit adding it was lost in a rebase. This might also be the reason for the mess-up fixed in 394285.) --- core/m_option.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'core/m_option.c') diff --git a/core/m_option.c b/core/m_option.c index dcb849a34d..58e93dfff9 100644 --- a/core/m_option.c +++ b/core/m_option.c @@ -1268,6 +1268,16 @@ static int parse_rel_time(const m_option_t *opt, struct bstr name, } } + // Chapter pos + if (bstr_startswith0(param, "#")) { + int chapter = bstrtoll(bstr_cut(param, 1), ¶m, 10); + if (param.len == 0 && chapter >= 1) { + t.type = REL_TIME_CHAPTER; + t.pos = chapter - 1; + goto out; + } + } + bool sign = bstr_eatstart0(¶m, "-"); double time; if (parse_timestring(param, &time, 0)) { @@ -1277,7 +1287,7 @@ static int parse_rel_time(const m_option_t *opt, struct bstr name, } mp_msg(MSGT_CFGPARSER, MSGL_ERR, - "Option %.*s: invalid time or size: '%.*s'\n", + "Option %.*s: invalid time or position: '%.*s'\n", BSTR_P(name), BSTR_P(param)); return M_OPT_INVALID; -- cgit v1.2.3