From 9ed5dae4804512d40b050007b282eef8daff8818 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 29 Jun 2016 18:09:30 +0200 Subject: options: add a deprecation warning printing mechanism We have a warning mechanism for removed and for replaced options, but none yet for options which have been simply deprecated. For the following commit. (Fun fact: just adding the m_option field increases binary size by 14KB.) --- options/m_config.c | 7 +++++++ options/m_option.h | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/options/m_config.c b/options/m_config.c index a3dcb30067..1cb01ebfdc 100644 --- a/options/m_config.c +++ b/options/m_config.c @@ -499,6 +499,13 @@ struct m_config_option *m_config_get_co(const struct m_config *config, co->warning_was_printed = true; } return NULL; + } else if (co->opt->deprecation_message) { + if (!co->warning_was_printed) { + MP_WARN(config, "Warning: option %s%s is deprecated " + "and might be removed in the future (%s).\n", + prefix, co->name, co->opt->deprecation_message); + co->warning_was_printed = true; + } } return co; } diff --git a/options/m_option.h b/options/m_option.h index 4066a36d81..e77452af69 100644 --- a/options/m_option.h +++ b/options/m_option.h @@ -333,6 +333,10 @@ struct m_option { // Initialize variable to given default before parsing options const void *defval; + + // Print a warning when this option is used (for options with no direct + // replacement.) + const char *deprecation_message; }; -- cgit v1.2.3