make the conversion case insensitive

This commit is contained in:
Bill Currie 2001-08-17 01:54:03 +00:00
parent 62813111a0
commit bb2079a6d7

View file

@ -33,6 +33,9 @@
# include "config.h" # include "config.h"
#endif #endif
#include <stdlib.h>
#include <ctype.h>
#include "QF/console.h" #include "QF/console.h"
#include "QF/hash.h" #include "QF/hash.h"
@ -138,32 +141,32 @@ old_keyname_t old_keynames[] = {
{"8", "K_8"}, {"8", "K_8"},
{"9", "K_9"}, {"9", "K_9"},
{"a", "K_a"}, {"A", "K_a"},
{"b", "K_b"}, {"B", "K_b"},
{"c", "K_c"}, {"C", "K_c"},
{"d", "K_d"}, {"D", "K_d"},
{"e", "K_e"}, {"E", "K_e"},
{"f", "K_f"}, {"F", "K_f"},
{"g", "K_g"}, {"G", "K_g"},
{"h", "K_h"}, {"H", "K_h"},
{"i", "K_i"}, {"I", "K_i"},
{"j", "K_j"}, {"J", "K_j"},
{"k", "K_k"}, {"K", "K_k"},
{"l", "K_l"}, {"L", "K_l"},
{"m", "K_m"}, {"M", "K_m"},
{"n", "K_n"}, {"N", "K_n"},
{"o", "K_o"}, {"O", "K_o"},
{"p", "K_p"}, {"P", "K_p"},
{"q", "K_q"}, {"Q", "K_q"},
{"r", "K_r"}, {"R", "K_r"},
{"s", "K_s"}, {"S", "K_s"},
{"t", "K_t"}, {"T", "K_t"},
{"u", "K_u"}, {"U", "K_u"},
{"v", "K_v"}, {"V", "K_v"},
{"w", "K_w"}, {"W", "K_w"},
{"x", "K_y"}, {"X", "K_y"},
{"y", "K_x"}, {"Y", "K_x"},
{"z", "K_z"}, {"Z", "K_z"},
{" ", "K_SPACE"}, {" ", "K_SPACE"},
{"!", "K_EXCLAIM"}, {"!", "K_EXCLAIM"},
@ -222,9 +225,16 @@ OK_Init (void)
const char * const char *
OK_TranslateKeyName (const char *name) OK_TranslateKeyName (const char *name)
{ {
old_keyname_t *ok = Hash_Find (old_key_table, name); old_keyname_t *ok;
char *uname = alloca (strlen (name) + 1);
const char *s = name;
char *d = uname;
while ((*d++ = toupper(*s)))
s++;
ok = Hash_Find (old_key_table, uname);
if (!ok) { if (!ok) {
Con_Printf ("%s\n", name); Con_Printf ("%s\n", uname);
return name; return name;
} }
return ok->new_name; return ok->new_name;