diff options
author | Lukas Fleischer <calcurse@cryptocrack.de> | 2012-03-01 23:15:38 +0100 |
---|---|---|
committer | Lukas Fleischer <calcurse@cryptocrack.de> | 2012-03-12 20:36:22 +0100 |
commit | 2c9499bf272e06a62902711c6c20621ef3f80e64 (patch) | |
tree | 6c71560531acf606557a586fa3cdf712e55b2960 /src/keys.c | |
parent | 7072c9c88a5d54b3f22256e6cf0015e1900374da (diff) | |
download | calcurse-2c9499bf272e06a62902711c6c20621ef3f80e64.zip |
Use strcmp() instead of strncmp()
strncmp() isn't intended to be a secure strcmp() replacement, it is
designed to be used if you want to compare the first n characters of two
strings. Since we always compare character pointers with string
literals, switch to using strcmp() everywhere.
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src/keys.c')
-rw-r--r-- | src/keys.c | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -322,25 +322,25 @@ keys_str2int (char *key) { if (key[0] == '^') return CTRL ((int)key[1]); - else if (!strncmp (key, CONTROL_KEY.str, CONTROL_KEY.len)) + else if (!strcmp (key, CONTROL_KEY.str)) return CTRL ((int)key[CONTROL_KEY.len]); - else if (!strncmp (key, TAB_KEY.str, TAB_KEY.len)) + else if (!strcmp (key, TAB_KEY.str)) return TAB; - else if (!strncmp (key, ESCAPE_KEY.str, ESCAPE_KEY.len)) + else if (!strcmp (key, ESCAPE_KEY.str)) return ESCAPE; - else if (!strncmp (key, SPACE_KEY.str, SPACE_KEY.len)) + else if (!strcmp (key, SPACE_KEY.str)) return SPACE; - else if (!strncmp (key, CURSES_KEY_UP.str, CURSES_KEY_UP.len)) + else if (!strcmp (key, CURSES_KEY_UP.str)) return KEY_UP; - else if (!strncmp (key, CURSES_KEY_DOWN.str, CURSES_KEY_DOWN.len)) + else if (!strcmp (key, CURSES_KEY_DOWN.str)) return KEY_DOWN; - else if (!strncmp (key, CURSES_KEY_LEFT.str, CURSES_KEY_LEFT.len)) + else if (!strcmp (key, CURSES_KEY_LEFT.str)) return KEY_LEFT; - else if (!strncmp (key, CURSES_KEY_RIGHT.str, CURSES_KEY_RIGHT.len)) + else if (!strcmp (key, CURSES_KEY_RIGHT.str)) return KEY_RIGHT; - else if (!strncmp (key, CURSES_KEY_HOME.str, CURSES_KEY_HOME.len)) + else if (!strcmp (key, CURSES_KEY_HOME.str)) return KEY_HOME; - else if (!strncmp (key, CURSES_KEY_END.str, CURSES_KEY_END.len)) + else if (!strcmp (key, CURSES_KEY_END.str)) return KEY_END; else return -1; |