;
target.key = 0;
- target.value = (char *)start;
- target.length = (size_t)(p - start);
+ target.value.string = start;
+ target.value.length = (size_t)(p - start);
// special cases:
// BufNewFile and BufRead are searched for ALOT (especially at startup)
for (i = cache_last_index; cache_tab[i] >= 0; )
{
if ((event_T)event_tab[cache_tab[i]].key == event)
- return (char_u *)event_tab[cache_tab[i]].value;
+ return event_tab[cache_tab[i]].value.string;
if (i == 0)
i = ARRAY_LENGTH(cache_tab) - 1;
}
}
- return (i == (int)ARRAY_LENGTH(event_tab)) ? (char_u *)"Unknown" : (char_u *)event_tab[i].value;
+ return (i == (int)ARRAY_LENGTH(event_tab)) ? (char_u *)"Unknown" :
+ event_tab[i].value.string;
}
/*
if (i < 0 || i >= (int)ARRAY_LENGTH(event_tab))
return NULL;
- return (char_u *)event_tab[i].value;
+ return event_tab[i].value.string;
}
/*
if (idx < 0 || idx >= (int)ARRAY_LENGTH(event_tab))
return NULL;
- return (char_u *)event_tab[idx].value;
+ return event_tab[idx].value.string;
}
keyvalue_T *entry;
target.key = 0;
- target.value = (char *)name;
- target.length = (int)STRLEN(target.value);
- entry = (keyvalue_T *)bsearch(&target, &event_tab, ARRAY_LENGTH(event_tab), sizeof(event_tab[0]), cmp_keyvalue_value_ni);
+ target.value.string = name;
+ target.value.length = STRLEN(target.value.string);
+ entry = (keyvalue_T *)bsearch(&target, &event_tab,
+ ARRAY_LENGTH(event_tab), sizeof(event_tab[0]),
+ cmp_keyvalue_value_ni);
if (entry == NULL)
{
semsg(_(e_no_such_event_str), name);
case '<':
target.key = 0;
- target.value = (char *)src + 1; // skip over '<'
- target.length = 0; // not used, see cmp_keyvalue_value_n()
+ target.value.string = src + 1; // skip over '<'
+ target.value.length = 0; // not used, see cmp_keyvalue_value_n()
- entry = (keyvalue_T *)bsearch(&target, &spec_str_tab, ARRAY_LENGTH(spec_str_tab), sizeof(spec_str_tab[0]), cmp_keyvalue_value_n);
+ entry = (keyvalue_T *)bsearch(&target, &spec_str_tab,
+ ARRAY_LENGTH(spec_str_tab), sizeof(spec_str_tab[0]),
+ cmp_keyvalue_value_n);
if (entry == NULL)
return -1;
- *usedlen = entry->length + 1;
+ *usedlen = entry->value.length + 1;
return entry->key;
default:
attr = 0;
off = 0;
target.key = 0;
- target.length = 0; // not used, see cmp_keyvalue_value_ni()
+ target.value.length = 0; // not used, see cmp_keyvalue_value_ni()
while (arg[off] != NUL)
{
- target.value = (char *)arg + off;
- entry = (keyvalue_T *)bsearch(&target, &highlight_tab, ARRAY_LENGTH(highlight_tab), sizeof(highlight_tab[0]), cmp_keyvalue_value_ni);
+ target.value.string = arg + off;
+ entry = (keyvalue_T *)bsearch(&target, &highlight_tab,
+ ARRAY_LENGTH(highlight_tab), sizeof(highlight_tab[0]),
+ cmp_keyvalue_value_ni);
if (entry == NULL)
{
semsg(_(e_illegal_value_str), arg);
}
attr |= entry->key;
- off += entry->length;
+ off += entry->value.length;
if (arg[off] == ',') // another one follows
++off;
}
keyvalue_T *entry;
target.key = 0;
- target.value = (char *)arg;
- target.length = 0; // not used, see cmp_keyvalue_value_i()
- entry = (keyvalue_T *)bsearch(&target, &color_name_tab, ARRAY_LENGTH(color_name_tab), sizeof(color_name_tab[0]), cmp_keyvalue_value_i);
+ target.value.string = arg;
+ target.value.length = 0; // not used, see cmp_keyvalue_value_i()
+ entry = (keyvalue_T *)bsearch(&target, &color_name_tab,
+ ARRAY_LENGTH(color_name_tab), sizeof(color_name_tab[0]),
+ cmp_keyvalue_value_i);
if (entry == NULL)
{
semsg(_(e_color_name_or_number_not_recognized_str), key_start);
return color;
target.key = 0;
- target.value = (char *)name;
- target.length = 0; // not used, see cmp_keyvalue_value_i()
- entry = (keyvalue_T *)bsearch(&target, &rgb_tab, ARRAY_LENGTH(rgb_tab), sizeof(rgb_tab[0]), cmp_keyvalue_value_i);
+ target.value.string = name;
+ target.value.length = 0; // not used, see cmp_keyvalue_value_i()
+ entry = (keyvalue_T *)bsearch(&target, &rgb_tab, ARRAY_LENGTH(rgb_tab),
+ sizeof(rgb_tab[0]), cmp_keyvalue_value_i);
if (entry != NULL)
return gui_adjust_rgb((guicolor_T)entry->key);
STRCPY(buf + buflen, (char_u *)",");
++buflen;
}
- STRCPY(buf + buflen, (char_u *)highlight_index_tab[i]->value);
- buflen += highlight_index_tab[i]->length;
+ STRCPY(buf + buflen, highlight_index_tab[i]->value.string);
+ buflen += highlight_index_tab[i]->value.length;
iarg &= ~highlight_index_tab[i]->key; // don't want "inverse"/"reverse"
}
}
{
if (hlattr & highlight_index_tab[i]->key)
{
- dict_add_bool(dict, highlight_index_tab[i]->value, VVAL_TRUE);
- hlattr &= ~highlight_index_tab[i]->key; // don't want "inverse"/"reverse"
+ dict_add_bool(dict, (char *)highlight_index_tab[i]->value.string,
+ VVAL_TRUE);
+ // don't want "inverse"/"reverse"
+ hlattr &= ~highlight_index_tab[i]->key;
}
}
p = attr_str;
for (i = 0; i < (int)ARRAY_LENGTH(highlight_tab); ++i)
{
- if (dict_get_bool(attrdict, highlight_tab[i].value, VVAL_FALSE) == VVAL_TRUE)
+ if (dict_get_bool(attrdict, (char *)highlight_tab[i].value.string,
+ VVAL_FALSE) == VVAL_TRUE)
{
if (p != attr_str && (size_t)(p - attr_str + 2) < len)
STRCPY(p, (char_u *)",");
- if (p - attr_str + highlight_tab[i].length + 1 < len)
+ if (p - attr_str + highlight_tab[i].value.length + 1 < len)
{
- STRCPY(p, highlight_tab[i].value);
- p += highlight_tab[i].length;
+ STRCPY(p, highlight_tab[i].value.string);
+ p += highlight_tab[i].value.length;
}
}
}
keyvalue_T *kv1 = (keyvalue_T *)a;
keyvalue_T *kv2 = (keyvalue_T *)b;
- return STRCMP(kv1->value, kv2->value);
+ return STRCMP(kv1->value.string, kv2->value.string);
}
// compare two keyvalue_T structs by value with length
keyvalue_T *kv1 = (keyvalue_T *)a;
keyvalue_T *kv2 = (keyvalue_T *)b;
- return STRNCMP(kv1->value, kv2->value, MAX(kv1->length, kv2->length));
+ return STRNCMP(kv1->value.string, kv2->value.string, MAX(kv1->value.length,
+ kv2->value.length));
}
// compare two keyvalue_T structs by case insensitive value
keyvalue_T *kv1 = (keyvalue_T *)a;
keyvalue_T *kv2 = (keyvalue_T *)b;
- return STRICMP(kv1->value, kv2->value);
+ return STRICMP(kv1->value.string, kv2->value.string);
}
// compare two keyvalue_T structs by case insensitive ASCII value
-// with length
+// with value.length
int
cmp_keyvalue_value_ni(const void *a, const void *b)
{
keyvalue_T *kv1 = (keyvalue_T *)a;
keyvalue_T *kv2 = (keyvalue_T *)b;
- return vim_strnicmp_asc(kv1->value, kv2->value, MAX(kv1->length, kv2->length));
+ return vim_strnicmp_asc((char *)kv1->value.string,
+ (char *)kv2->value.string, MAX(kv1->value.length,
+ kv2->value.length));
}
static keyvalue_T *last_entry = NULL;
target.key = 0;
- target.value = (char *)*pp + 2;
- target.length = 0; // not used, see cmp_keyvalue_value_n()
+ target.value.string = *pp + 2;
+ target.value.length = 0; // not used, see cmp_keyvalue_value_n()
if (last_entry != NULL && cmp_keyvalue_value_n(&target, last_entry) == 0)
entry = last_entry;
if (entry != NULL)
{
last_entry = entry;
- *pp += entry->length + 2;
+ *pp += entry->value.length + 2;
return entry->key;
}
}
// Return the length of a string literal
#define STRLEN_LITERAL(s) (sizeof(s) - 1)
-// Store a key/value pair
+// Store a key/value (string) pair
typedef struct
{
int key; // the key
- char *value; // the value string
- size_t length; // length of the value string
+ string_T value; // the value
} keyvalue_T;
#define KEYVALUE_ENTRY(k, v) \
- {(k), (v), STRLEN_LITERAL(v)}
+ {(k), {((char_u *)v), STRLEN_LITERAL(v)}}
for (i = 0; i < nr_entries; ++i)
if (flags & nlist[i].key)
{
- msg_puts_attr(nlist[i].value, attr);
+ msg_puts_attr((char *)nlist[i].value.string, attr);
msg_putchar(' ');
}
}
{
if (idx < 0 || idx >= (int)ARRAY_LENGTH(command_complete_tab))
return NULL;
- return (char_u *)command_complete_tab[idx].value;
+ return command_complete_tab[idx].value.string;
}
/*
kv = get_commandtype(expand);
- return (kv == NULL) ? NULL : (char_u *)kv->value;
+ return (kv == NULL) ? NULL : kv->value.string;
}
/*
return EXPAND_USER_LIST;
target.key = 0;
- target.value = (char *)complete_str;
- target.length = 0; // not used, see cmp_keyvalue_value()
+ target.value.string = complete_str;
+ target.value.length = 0; // not used, see cmp_keyvalue_value()
if (last_entry != NULL && cmp_keyvalue_value(&target, last_entry) == 0)
entry = last_entry;
entry = get_commandtype(cmd->uc_compl);
if (entry != NULL)
{
- STRCPY(IObuff + len, entry->value);
- len += entry->length;
+ STRCPY(IObuff + len, entry->value.string);
+ len += entry->value.length;
#ifdef FEAT_EVAL
if (p_verbose > 0 && cmd->uc_compl_arg != NULL)
{
}
target.key = 0;
- target.value = (char *)value;
- target.length = valend;
+ target.value.string = value;
+ target.value.length = valend;
if (last_entry != NULL && cmp_keyvalue_value_n(&target, last_entry) == 0)
entry = last_entry;
// the modifiers that are simple flags
for (i = 0; i < (int)ARRAY_LENGTH(mod_entry_tab); ++i)
if (cmod->cmod_flags & mod_entry_tab[i].key)
- buflen += add_cmd_modifier(buf, buflen, mod_entry_tab[i].value, mod_entry_tab[i].length, &multi_mods);
+ buflen += add_cmd_modifier(buf, buflen,
+ (char *)mod_entry_tab[i].value.string,
+ mod_entry_tab[i].value.length, &multi_mods);
// :silent
if (cmod->cmod_flags & CMOD_SILENT)
{
if (cmod->cmod_flags & CMOD_ERRSILENT)
- buflen += add_cmd_modifier(buf, buflen, "silent!", STRLEN_LITERAL("silent!"), &multi_mods);
+ buflen += add_cmd_modifier(buf, buflen, "silent!",
+ STRLEN_LITERAL("silent!"), &multi_mods);
else
- buflen += add_cmd_modifier(buf, buflen, "silent", STRLEN_LITERAL("silent"), &multi_mods);
+ buflen += add_cmd_modifier(buf, buflen, "silent",
+ STRLEN_LITERAL("silent"), &multi_mods);
}
// :verbose
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 828,
/**/
827,
/**/