Make some more things 'const' that should be
This commit is contained in:
parent
b4067d8afb
commit
89ac8b058c
|
@ -5,7 +5,7 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
TermKey *tk;
|
TermKey *tk;
|
||||||
TermKeySym sym;
|
TermKeySym sym;
|
||||||
char *end;
|
const char *end;
|
||||||
|
|
||||||
plan_tests(10);
|
plan_tests(10);
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
TermKey *tk;
|
TermKey *tk;
|
||||||
TermKeyKey key;
|
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)
|
#define CLEAR_KEY do { key.type = -1; key.code.codepoint = -1; key.modifiers = -1; key.utf8[0] = 0; } while(0)
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
TermKey *tk;
|
TermKey *tk;
|
||||||
TermKeyKey key;
|
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)
|
#define CLEAR_KEY do { key.type = -1; key.code.codepoint = -1; key.modifiers = -1; key.utf8[0] = 0; } while(0)
|
||||||
|
|
||||||
|
|
12
termkey.c
12
termkey.c
|
@ -1113,7 +1113,7 @@ const char *termkey_get_keyname(TermKey *tk, TermKeySym sym)
|
||||||
return "UNKNOWN";
|
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
|
/* 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 */
|
* 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 termkey_keyname2sym(TermKey *tk, const char *keyname)
|
||||||
{
|
{
|
||||||
TermKeySym sym;
|
TermKeySym sym;
|
||||||
char *endp = termkey_lookup_keyname(tk, keyname, &sym);
|
const char *endp = termkey_lookup_keyname(tk, keyname, &sym);
|
||||||
if(!endp || endp[0])
|
if(!endp || endp[0])
|
||||||
return TERMKEY_SYM_UNKNOWN;
|
return TERMKEY_SYM_UNKNOWN;
|
||||||
return sym;
|
return sym;
|
||||||
|
@ -1255,7 +1255,7 @@ size_t termkey_strfkey(TermKey *tk, char *buffer, size_t len, TermKeyKey *key, T
|
||||||
int line, col;
|
int line, col;
|
||||||
termkey_interpret_mouse(tk, key, &ev, &button, &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)",
|
l = snprintf(buffer + pos, len - pos, "Mouse%s(%d)",
|
||||||
evnames[ev], button);
|
evnames[ev], button);
|
||||||
|
@ -1297,7 +1297,7 @@ size_t termkey_strfkey(TermKey *tk, char *buffer, size_t len, TermKeyKey *key, T
|
||||||
return pos;
|
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) +
|
struct modnames *mods = &modnames[!!(format & TERMKEY_FORMAT_LONGMOD) +
|
||||||
!!(format & TERMKEY_FORMAT_ALTISMETA) * 2];
|
!!(format & TERMKEY_FORMAT_ALTISMETA) * 2];
|
||||||
|
@ -1340,7 +1340,7 @@ char *termkey_strpkey(TermKey *tk, const char *str, TermKeyKey *key, TermKeyForm
|
||||||
|
|
||||||
size_t nbytes;
|
size_t nbytes;
|
||||||
ssize_t snbytes;
|
ssize_t snbytes;
|
||||||
char *endstr;
|
const char *endstr;
|
||||||
|
|
||||||
if((endstr = termkey_lookup_keyname(tk, str, &key->code.sym))) {
|
if((endstr = termkey_lookup_keyname(tk, str, &key->code.sym))) {
|
||||||
key->type = TERMKEY_TYPE_KEYSYM;
|
key->type = TERMKEY_TYPE_KEYSYM;
|
||||||
|
@ -1351,7 +1351,7 @@ char *termkey_strpkey(TermKey *tk, const char *str, TermKeyKey *key, TermKeyForm
|
||||||
str += snbytes;
|
str += snbytes;
|
||||||
}
|
}
|
||||||
// Unicode must be last
|
// 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;
|
key->type = TERMKEY_TYPE_UNICODE;
|
||||||
fill_utf8(key);
|
fill_utf8(key);
|
||||||
str += nbytes;
|
str += nbytes;
|
||||||
|
|
|
@ -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);
|
TermKeySym termkey_register_keyname(TermKey *tk, TermKeySym sym, const char *name);
|
||||||
const char *termkey_get_keyname(TermKey *tk, TermKeySym sym);
|
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);
|
TermKeySym termkey_keyname2sym(TermKey *tk, const char *keyname);
|
||||||
|
|
||||||
|
@ -223,8 +223,8 @@ typedef enum {
|
||||||
|
|
||||||
#define TERMKEY_FORMAT_VIM (TERMKEY_FORMAT_ALTISMETA|TERMKEY_FORMAT_WRAPBRACKET)
|
#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);
|
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);
|
const char *termkey_strpkey(TermKey *tk, const char *str, TermKeyKey *key, TermKeyFormat format);
|
||||||
|
|
||||||
int termkey_keycmp(TermKey *tk, const TermKeyKey *key1, const TermKeyKey *key2);
|
int termkey_keycmp(TermKey *tk, const TermKeyKey *key1, const TermKeyKey *key2);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue