From 89ac8b058cb7bb8f7bc47a4a42fa5642abc84dae Mon Sep 17 00:00:00 2001 From: Paul LeoNerd Evans Date: Mon, 15 Jul 2013 01:03:35 +0100 Subject: Make some more things 'const' that should be --- t/10keyname.c | 2 +- t/12strpkey.c | 2 +- t/20canon.c | 2 +- termkey.c | 12 ++++++------ termkey.h.in | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/t/10keyname.c b/t/10keyname.c index feedbc4..0872bbc 100644 --- a/t/10keyname.c +++ b/t/10keyname.c @@ -5,7 +5,7 @@ int main(int argc, char *argv[]) { TermKey *tk; TermKeySym sym; - char *end; + const char *end; plan_tests(10); diff --git a/t/12strpkey.c b/t/12strpkey.c index cb3d3c0..28c32f5 100644 --- a/t/12strpkey.c +++ b/t/12strpkey.c @@ -5,7 +5,7 @@ int main(int argc, char *argv[]) { TermKey *tk; TermKeyKey key; - char *endp; + const char *endp; #define CLEAR_KEY do { key.type = -1; key.code.codepoint = -1; key.modifiers = -1; key.utf8[0] = 0; } while(0) diff --git a/t/20canon.c b/t/20canon.c index 8d7b6ad..0460153 100644 --- a/t/20canon.c +++ b/t/20canon.c @@ -5,7 +5,7 @@ int main(int argc, char *argv[]) { TermKey *tk; TermKeyKey key; - char *endp; + const char *endp; #define CLEAR_KEY do { key.type = -1; key.code.codepoint = -1; key.modifiers = -1; key.utf8[0] = 0; } while(0) diff --git a/termkey.c b/termkey.c index 1ed92fc..5813b9e 100644 --- a/termkey.c +++ b/termkey.c @@ -1113,7 +1113,7 @@ const char *termkey_get_keyname(TermKey *tk, TermKeySym sym) return "UNKNOWN"; } -char *termkey_lookup_keyname(TermKey *tk, const char *str, TermKeySym *sym) +const char *termkey_lookup_keyname(TermKey *tk, const char *str, TermKeySym *sym) { /* We store an array, so we can't do better than a linear search. Doesn't * matter because user won't be calling this too often */ @@ -1133,7 +1133,7 @@ char *termkey_lookup_keyname(TermKey *tk, const char *str, TermKeySym *sym) TermKeySym termkey_keyname2sym(TermKey *tk, const char *keyname) { TermKeySym sym; - char *endp = termkey_lookup_keyname(tk, keyname, &sym); + const char *endp = termkey_lookup_keyname(tk, keyname, &sym); if(!endp || endp[0]) return TERMKEY_SYM_UNKNOWN; return sym; @@ -1255,7 +1255,7 @@ size_t termkey_strfkey(TermKey *tk, char *buffer, size_t len, TermKeyKey *key, T int line, col; termkey_interpret_mouse(tk, key, &ev, &button, &line, &col); - static char *evnames[] = { "Unknown", "Press", "Drag", "Release" }; + static const char *evnames[] = { "Unknown", "Press", "Drag", "Release" }; l = snprintf(buffer + pos, len - pos, "Mouse%s(%d)", evnames[ev], button); @@ -1297,7 +1297,7 @@ size_t termkey_strfkey(TermKey *tk, char *buffer, size_t len, TermKeyKey *key, T return pos; } -char *termkey_strpkey(TermKey *tk, const char *str, TermKeyKey *key, TermKeyFormat format) +const char *termkey_strpkey(TermKey *tk, const char *str, TermKeyKey *key, TermKeyFormat format) { struct modnames *mods = &modnames[!!(format & TERMKEY_FORMAT_LONGMOD) + !!(format & TERMKEY_FORMAT_ALTISMETA) * 2]; @@ -1340,7 +1340,7 @@ char *termkey_strpkey(TermKey *tk, const char *str, TermKeyKey *key, TermKeyForm size_t nbytes; ssize_t snbytes; - char *endstr; + const char *endstr; if((endstr = termkey_lookup_keyname(tk, str, &key->code.sym))) { key->type = TERMKEY_TYPE_KEYSYM; @@ -1351,7 +1351,7 @@ char *termkey_strpkey(TermKey *tk, const char *str, TermKeyKey *key, TermKeyForm str += snbytes; } // Unicode must be last - else if(parse_utf8((unsigned char *)str, strlen(str), &key->code.codepoint, &nbytes) == TERMKEY_RES_KEY) { + else if(parse_utf8((unsigned const char *)str, strlen(str), &key->code.codepoint, &nbytes) == TERMKEY_RES_KEY) { key->type = TERMKEY_TYPE_UNICODE; fill_utf8(key); str += nbytes; diff --git a/termkey.h.in b/termkey.h.in index 95f315b..677d5e7 100644 --- a/termkey.h.in +++ b/termkey.h.in @@ -198,7 +198,7 @@ size_t termkey_push_bytes(TermKey *tk, const char *bytes, size_t len); TermKeySym termkey_register_keyname(TermKey *tk, TermKeySym sym, const char *name); const char *termkey_get_keyname(TermKey *tk, TermKeySym sym); -char *termkey_lookup_keyname(TermKey *tk, const char *str, TermKeySym *sym); +const char *termkey_lookup_keyname(TermKey *tk, const char *str, TermKeySym *sym); TermKeySym termkey_keyname2sym(TermKey *tk, const char *keyname); @@ -223,8 +223,8 @@ typedef enum { #define TERMKEY_FORMAT_VIM (TERMKEY_FORMAT_ALTISMETA|TERMKEY_FORMAT_WRAPBRACKET) -size_t termkey_strfkey(TermKey *tk, char *buffer, size_t len, TermKeyKey *key, TermKeyFormat format); -char *termkey_strpkey(TermKey *tk, const char *str, TermKeyKey *key, TermKeyFormat format); +size_t termkey_strfkey(TermKey *tk, char *buffer, size_t len, TermKeyKey *key, TermKeyFormat format); +const char *termkey_strpkey(TermKey *tk, const char *str, TermKeyKey *key, TermKeyFormat format); int termkey_keycmp(TermKey *tk, const TermKeyKey *key1, const TermKeyKey *key2); -- cgit v1.2.3-70-g09d2