From 692c66a3921c8f4c16ac86211e202a61b5191ba3 Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Tue, 21 Aug 2018 19:24:31 +0100 Subject: [PATCH] drop unused functions --- init.c | 90 +++------------------------------------------------------ mutt.h | 1 - myvar.h | 2 -- 3 files changed, 4 insertions(+), 89 deletions(-) diff --git a/init.c b/init.c index 0d9e0cc0c..54353904c 100644 --- a/init.c +++ b/init.c @@ -455,7 +455,7 @@ static bool get_hostname(void) #endif } if (Hostname) - set_default_value("hostname", (intptr_t) mutt_str_strdup(Hostname)); + cs_str_initial_set(Config, "hostname", mutt_str_strdup(Hostname), NULL); return true; } @@ -1224,13 +1224,14 @@ bail: static int parse_ifdef(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err) { - bool res = 0; + bool res = false; struct Buffer token = { 0 }; mutt_extract_token(buf, s, 0); /* is the item defined as a variable? */ - res = (mutt_option_index(buf->data) != -1); + struct HashElem *he = cs_get_elem(Config, buf->data); + res = (he != NULL); /* is the item a compiled-in feature? */ if (!res) @@ -3131,26 +3132,6 @@ int mutt_init(bool skip_sys_rc, struct ListHead *commands) return 0; } -/** - * mutt_option_index - Find the index (in rc_vars) of a variable name - * @param s Variable name to search for - * @retval -1 Error - * @retval >0 Success - */ -int mutt_option_index(const char *s) -{ - for (int i = 0; MuttVars[i].name; i++) - { - if (mutt_str_strcmp(s, MuttVars[i].name) == 0) - { - return MuttVars[i].type == DT_SYNONYM ? - mutt_option_index((char *) MuttVars[i].initial) : - i; - } - } - return -1; -} - /** * mutt_parse_rc_line - Parse a line of user config * @param line config line to read @@ -3289,69 +3270,6 @@ int query_quadoption(int opt, const char *prompt) /* not reached */ } -/** - * set_default_value - Set a config item's default/initial value - * @param name Name of config item - * @param value Value to set - * @retval true Success, value set - * @retval false Error, config item doesn't exist - */ -bool set_default_value(const char *name, intptr_t value) -{ - if (!name) - return false; - - int idx = mutt_option_index(name); - if (idx < 0) - return false; - - MuttVars[idx].initial = value; - return true; -} - -/** - * var_to_string2 - Convert a config variable to a string - * @param name Name of config item - * @param quote If true, quote the result - * @param result Buffer for the result - * @param err Buffer for error messages - * @retval 0 Success - * @retval -1 Error - */ -int var_to_string2(const char *name, bool quote, struct Buffer *result, struct Buffer *err) -{ - if (!name || !result) - return -1; - - struct Buffer *value = mutt_buffer_alloc(STRING); - int rc = -1; - - struct HashElem *he = cs_get_elem(Config, name); - if (!he) - { - mutt_buffer_printf(err, _("%s: unknown variable"), name); - goto vts_out; - } - - int grc = cs_he_string_get(Config, he, value); - if (CSR_RESULT(grc) != CSR_SUCCESS) - { - mutt_buffer_printf(err, _("%s: unknown variable"), name); - goto vts_out; - } - - if (quote) - mutt_buffer_addch(result, '"'); - escape_string(result, value->data); - if (quote) - mutt_buffer_addch(result, '"'); - - rc = 0; -vts_out: - mutt_buffer_free(&value); - return rc; -} - /** * myvar_get - Get the value of a "my_" variable * @param var Variable name diff --git a/mutt.h b/mutt.h index b97f80b61..a740cd857 100644 --- a/mutt.h +++ b/mutt.h @@ -230,7 +230,6 @@ int mutt_dump_variables(bool hide_sensitive); int mutt_get_hook_type(const char *name); int mutt_parse_rc_line(/* const */ char *line, struct Buffer *token, struct Buffer *err); int mutt_query_variables(struct ListHead *queries); -bool set_default_value(const char *name, intptr_t value); void reset_value(const char *name); #endif /* _MUTT_H */ diff --git a/myvar.h b/myvar.h index 3c72ba4e8..b48e8535b 100644 --- a/myvar.h +++ b/myvar.h @@ -24,7 +24,5 @@ #include const char *myvar_get(const char *var); -int var_to_string2(const char *name, bool quote, struct Buffer *result, struct Buffer *err); -int mutt_option_index(const char *s); #endif /* _MUTT_MYVAR_H */ -- 2.40.0