]> git.pond.sub.org Git - empserver/commitdiff
(lookup): Rename lookup() to symbol_by_value(), make it public
authorRon Koenderink <rkoenderink@yahoo.ca>
Tue, 22 Nov 2005 22:57:06 +0000 (22:57 +0000)
committerRon Koenderink <rkoenderink@yahoo.ca>
Tue, 22 Nov 2005 22:57:06 +0000 (22:57 +0000)
and move it to nstr.c.

include/nsc.h
src/lib/subs/nstr.c
src/lib/subs/show.c

index a55972748ea9b4e678b7c3f892a5e4ec69f935d7..caf06da3bf4eed81d63a274f620bc5ca732f3184 100644 (file)
@@ -240,5 +240,6 @@ extern char *nstr_comp_val(char *, struct valstr*, int);
 extern int nstr_coerce_val(struct valstr *, nsc_type, char *);
 extern int nstr_exec(struct nscstr *, int, void *);
 extern void nstr_exec_val(struct valstr *, natid, void *, nsc_type);
+extern char *symbol_by_value(int, struct symbol *);
 
 #endif /* _NSC_H_ */
index 5cf70aac8726fafca5e369b82116197992fbee58..78853dcb0f4e7487d1e45a54d64ba82e6a237a18 100644 (file)
@@ -680,3 +680,15 @@ nstr_exec_val(struct valstr *val, natid cnum, void *ptr, nsc_type want)
 
     val->val_type = valtype;
 }
+
+char *
+symbol_by_value(int key, struct symbol *table)
+{
+    int i;
+
+    for (i = 0; table[i].name; i++)
+       if (key == table[i].value)
+           return table[i].name;
+
+    return NULL;
+}
index d8ca82f7c218a4d35088b7995f7e344a04ac1ff6..dd0cde22bee1ab794e579c68713381cbfd2e7e89 100644 (file)
@@ -54,6 +54,7 @@
 #include "file.h"
 #include "nat.h"
 #include "prototypes.h"
+#include "nsc.h"
 
 struct look_list {
     union {
@@ -125,18 +126,6 @@ make_new_list(int tlev, int type)
     sort_lookup_list();
 }
 
-static char *
-lookup(int key, struct symbol *table)
-{
-    int i;
-
-    for (i = 0; table[i].name; i++)
-       if (key == table[i].value)
-           return table[i].name;
-
-    return NULL;
-}
-
 void
 show_bridge(int tlev)
 {
@@ -224,7 +213,7 @@ show_nuke_capab(int tlev)
        for (i = j = 0; i < 32; i++) {
            if (!(np->n_flags & bit(i)))
                continue;
-           if (NULL != (p = lookup(bit(i), nuke_chr_flags))) {
+           if (NULL != (p = symbol_by_value(bit(i), nuke_chr_flags))) {
                if (j++ > 0)
                    pr(" ");
                pr(p);
@@ -338,7 +327,7 @@ show_ship_capab(int tlev)
        for (j = n = 0; j < 32; j++) {
            if (!(mp->m_flags & bit(j)))
                continue;
-           if (NULL != (p = lookup(bit(j), ship_chr_flags))) {
+           if (NULL != (p = symbol_by_value(bit(j), ship_chr_flags))) {
                if (n++ > 0)
                    pr(" ");
                pr(p);
@@ -389,7 +378,7 @@ show_plane_capab(int tlev)
        for (i = n = 0; i < 32; i++) {
            if (!(pp->pl_flags & bit(i)))
                continue;
-           if (NULL != (p = lookup(bit(i), plane_chr_flags))) {
+           if (NULL != (p = symbol_by_value(bit(i), plane_chr_flags))) {
                if (n++ > 0)
                    pr(" ");
                pr(p);
@@ -462,7 +451,7 @@ show_land_capab(int tlev)
        for (j = n = 0; j < 32; j++) {
            if (!(lcp->l_flags & bit(j)))
                continue;
-           if (NULL != (p = lookup(bit(j), land_chr_flags))) {
+           if (NULL != (p = symbol_by_value(bit(j), land_chr_flags))) {
                if (n++ > 0)
                    pr(" ");
                pr(p);