]> granicus.if.org Git - neomutt/commitdiff
rename mapping functions
authorRichard Russon <rich@flatcap.org>
Thu, 16 Nov 2017 01:36:21 +0000 (01:36 +0000)
committerRichard Russon <rich@flatcap.org>
Thu, 16 Nov 2017 03:39:56 +0000 (03:39 +0000)
color.c
help.c
init.c
keymap.c
mutt/mapping.c
mutt/mapping.h
status.c
url.c

diff --git a/color.c b/color.c
index f4b8de56e08c3ccfe9a4242436cb6d8e071fa86f..a82f0f722738b09a456e37053d874ded81ca7d1b 100644 (file)
--- a/color.c
+++ b/color.c
@@ -406,7 +406,7 @@ static int parse_color_name(const char *s, int *col, int *attr, int is_fg, struc
       return -1;
     }
   }
-  else if ((*col = mutt_getvaluebyname(s, Colors)) == -1)
+  else if ((*col = mutt_map_get_value(s, Colors)) == -1)
   {
     snprintf(err->data, err->dsize, _("%s: no such color"), s);
     return -1;
@@ -497,7 +497,7 @@ static int parse_uncolor(struct Buffer *buf, struct Buffer *s, unsigned long dat
 
   mutt_extract_token(buf, s, 0);
 
-  object = mutt_getvaluebyname(buf->data, Fields);
+  object = mutt_map_get_value(buf->data, Fields);
   if (object == -1)
   {
     snprintf(err->data, err->dsize, _("%s: no such object"), buf->data);
@@ -715,14 +715,14 @@ static int parse_object(struct Buffer *buf, struct Buffer *s, int *o, int *ql,
 
     mutt_extract_token(buf, s, 0);
 
-    *o = mutt_getvaluebyname(buf->data, ComposeFields);
+    *o = mutt_map_get_value(buf->data, ComposeFields);
     if (*o == -1)
     {
       snprintf(err->data, err->dsize, _("%s: no such object"), buf->data);
       return (-1);
     }
   }
-  else if ((*o = mutt_getvaluebyname(buf->data, Fields)) == -1)
+  else if ((*o = mutt_map_get_value(buf->data, Fields)) == -1)
   {
     snprintf(err->data, err->dsize, _("%s: no such object"), buf->data);
     return -1;
diff --git a/help.c b/help.c
index f5deea8173e4b391b8f2f82b88b9992712e463e5..daf722962ba0377b9d83d237cf4f6b8fab6453b4 100644 (file)
--- a/help.c
+++ b/help.c
@@ -352,7 +352,7 @@ void mutt_help(int menu)
   mutt_mktemp(t, sizeof(t));
 
   funcs = km_get_table(menu);
-  desc = mutt_getnamebyvalue(menu, Menus);
+  desc = mutt_map_get_name(menu, Menus);
   if (!desc)
     desc = _("<UNKNOWN>");
 
diff --git a/init.c b/init.c
index e59b98591e537f210813c35a067bb85cbcb2ba87..40eb855c671d9db34fa0a39f7542fa9e60bae9de 100644 (file)
--- a/init.c
+++ b/init.c
@@ -351,7 +351,7 @@ static int parse_sort(short *val, const char *s, const struct Mapping *map, stru
     flags |= SORT_LAST;
   }
 
-  i = mutt_getvaluebyname(s, map);
+  i = mutt_map_get_value(s, map);
   if (i == -1)
   {
     snprintf(err->data, err->dsize, _("%s: unknown sorting method"), s);
@@ -3018,7 +3018,7 @@ static int parse_set(struct Buffer *tmp, struct Buffer *s, unsigned long data,
 
       if (query || *s->dptr != '=')
       {
-        p = mutt_getnamebyvalue(*((short *) MuttVars[idx].data) & SORT_MASK, map);
+        p = mutt_map_get_name(*((short *) MuttVars[idx].data) & SORT_MASK, map);
 
         snprintf(err->data, err->dsize, "%s=%s%s%s", MuttVars[idx].option,
                  (*((short *) MuttVars[idx].data) & SORT_REVERSE) ? "reverse-" : "",
@@ -3831,7 +3831,7 @@ int var_to_string(int idx, char *val, size_t len)
         map = SortMethods;
         break;
     }
-    p = mutt_getnamebyvalue(*((short *) MuttVars[idx].data) & SORT_MASK, map);
+    p = mutt_map_get_name(*((short *) MuttVars[idx].data) & SORT_MASK, map);
     snprintf(tmp, sizeof(tmp), "%s%s%s",
              (*((short *) MuttVars[idx].data) & SORT_REVERSE) ? "reverse-" : "",
              (*((short *) MuttVars[idx].data) & SORT_LAST) ? "last-" : "", p);
index 8dba8843c15b51c3eb205b32dc193caf16d1dca6..ebc9ea3d2ef0abc1239ecf069de8f3ee614047f0 100644 (file)
--- a/keymap.c
+++ b/keymap.c
@@ -202,7 +202,7 @@ static int parsekeys(const char *str, keycode_t *d, int max)
       c = *t;
       *t = '\0';
 
-      n = mutt_getvaluebyname(s, KeyNames);
+      n = mutt_map_get_value(s, KeyNames);
       if (n != -1)
       {
         s = t;
@@ -280,7 +280,7 @@ int km_bind_err(char *s, int menu, int op, char *macro, char *descr, struct Buff
                 _("Binding '%s' will alias '%s'  Before, try: 'bind %s %s "
                   "noop'  "
                   "https://neomutt.org/guide/configuration.html#bind-warnings"),
-                old_binding, new_binding, mutt_getnamebyvalue(menu, Menus), new_binding);
+                old_binding, new_binding, mutt_map_get_name(menu, Menus), new_binding);
           }
           else
           {
@@ -288,7 +288,7 @@ int km_bind_err(char *s, int menu, int op, char *macro, char *descr, struct Buff
                 _("Binding '%s' will alias '%s'  Before, try: 'bind %s %s "
                   "noop'  "
                   "https://neomutt.org/guide/configuration.html#bind-warnings"),
-                old_binding, new_binding, mutt_getnamebyvalue(menu, Menus), new_binding);
+                old_binding, new_binding, mutt_map_get_name(menu, Menus), new_binding);
           }
           retval = -2;
         }
@@ -615,7 +615,7 @@ static const char *km_keyname(int c)
   static char buf[10];
   const char *p = NULL;
 
-  if ((p = mutt_getnamebyvalue(c, KeyNames)))
+  if ((p = mutt_map_get_name(c, KeyNames)))
     return p;
 
   if (c < 256 && c > -128 && iscntrl((unsigned char) c))
@@ -987,7 +987,7 @@ char *parse_keymap(int *menu, struct Buffer *s, int maxmenus, int *nummenus, str
       if (q)
         *q = '\0';
 
-      menu[i] = mutt_getvaluebyname(p, Menus);
+      menu[i] = mutt_map_get_value(p, Menus);
       if (menu[i] == -1)
       {
         snprintf(err->data, err->dsize, _("%s: no such menu"), p);
@@ -1033,7 +1033,7 @@ static int try_bind(char *key, int menu, char *func,
   {
     snprintf(err->data, err->dsize,
              _("Function '%s' not available for menu '%s'"), func,
-             mutt_getnamebyvalue(menu, Menus));
+             mutt_map_get_name(menu, Menus));
   }
   return -1; /* Couldn't find an existing function with this name */
 }
index 94cea01a6da15c6847e07135ab4fb7fdf3c42334..fe6b560c2708a39031e9665af5565943812fde04 100644 (file)
  *
  * Map a string to a constant and vice versa.
  *
- * | Function              | Description
- * | :-------------------- | :-------------------------------
- * | mutt_getnamebyvalue() | Lookup a string for a constant
- * | mutt_getvaluebyname() | Lookup the constant for a string
+ * | Function             | Description
+ * | :------------------- | :-------------------------------
+ * | mutt_map_get_name()  | Lookup a string for a constant
+ * | mutt_map_get_value() | Lookup the constant for a string
  */
 
 #include "mapping.h"
 #include "string2.h"
 
 /**
- * mutt_getnamebyvalue - Lookup a string for a constant
+ * mutt_map_get_name - Lookup a string for a constant
  * @param val ID to locate in map
  * @param map NULL-terminated map of strings and constants
  * @retval str  String matching ID
  * @retval NULL ID not found
  */
-const char *mutt_getnamebyvalue(int val, const struct Mapping *map)
+const char *mutt_map_get_name(int val, const struct Mapping *map)
 {
   for (int i = 0; map[i].name; i++)
     if (map[i].value == val)
@@ -51,13 +51,13 @@ const char *mutt_getnamebyvalue(int val, const struct Mapping *map)
 }
 
 /**
- * mutt_getvaluebyname - Lookup the constant for a string
+ * mutt_map_get_value - Lookup the constant for a string
  * @param name String to locate in map
  * @param map  NULL-terminated map of strings and constants
  * @retval num  ID matching string
  * @retval -1   String not found
  */
-int mutt_getvaluebyname(const char *name, const struct Mapping *map)
+int mutt_map_get_value(const char *name, const struct Mapping *map)
 {
   for (int i = 0; map[i].name; i++)
     if (mutt_strcasecmp(map[i].name, name) == 0)
index b5af668c5d1b9633e8fa9c5de68af40e59877d4f..f636a097570ba8706821915aaf19e8c25a7bcf36 100644 (file)
@@ -34,7 +34,7 @@ struct Mapping
   int value;
 };
 
-const char *mutt_getnamebyvalue(int val, const struct Mapping *map);
-int         mutt_getvaluebyname(const char *name, const struct Mapping *map);
+const char *mutt_map_get_name(int val, const struct Mapping *map);
+int         mutt_map_get_value(const char *name, const struct Mapping *map);
 
 #endif /* _MUTT_MAPPING_H */
index 10f77d1047b4b387a1312826da1c65432ec4b619..c5e29e4cdacb916d3d80a7ad6670d6aef09d1b69 100644 (file)
--- a/status.c
+++ b/status.c
@@ -41,7 +41,7 @@ static char *get_sort_str(char *buf, size_t buflen, int method)
 {
   snprintf(buf, buflen, "%s%s%s", (method & SORT_REVERSE) ? "reverse-" : "",
            (method & SORT_LAST) ? "last-" : "",
-           mutt_getnamebyvalue(method & SORT_MASK, SortMethods));
+           mutt_map_get_name(method & SORT_MASK, SortMethods));
   return buf;
 }
 
diff --git a/url.c b/url.c
index a905650080174d5fba7869e6dcf38b8a78066b4c..37567d274462531464740a52334bea14d5c8d208 100644 (file)
--- a/url.c
+++ b/url.c
@@ -90,7 +90,7 @@ enum UrlScheme url_check_scheme(const char *s)
   for (t = sbuf; *t; t++)
     *t = tolower(*t);
 
-  i = mutt_getvaluebyname(sbuf, UrlMap);
+  i = mutt_map_get_value(sbuf, UrlMap);
   if (i == -1)
     return U_UNKNOWN;
   else
@@ -289,7 +289,7 @@ int url_tostring(struct Url *u, char *dest, size_t len, int flags)
   if (u->scheme == U_UNKNOWN)
     return -1;
 
-  snprintf(dest, len, "%s:", mutt_getnamebyvalue(u->scheme, UrlMap));
+  snprintf(dest, len, "%s:", mutt_map_get_name(u->scheme, UrlMap));
 
   if (u->host)
   {