mie: add strict-naming support to mie_name_map
in strict mode, the hint is taken as the required name. if a value already exists with the given name, the operation fails.
This commit is contained in:
@@ -123,7 +123,8 @@ static b_status put_name(struct mie_name_map *map, struct mie_name *name)
|
||||
}
|
||||
|
||||
struct mie_name *mie_name_map_put(
|
||||
struct mie_name_map *map, struct mie_name *entry, const char *hint)
|
||||
struct mie_name_map *map, struct mie_name *entry, const char *hint,
|
||||
enum mie_name_map_flags flags)
|
||||
{
|
||||
memset(entry, 0x0, sizeof *entry);
|
||||
entry->n_base.e_type = MIE_NAME_MAP_E_NAME;
|
||||
@@ -149,6 +150,12 @@ struct mie_name *mie_name_map_put(
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & MIE_NAME_MAP_STRICT) {
|
||||
/* the caller insists that `hint` be used as the name.
|
||||
* such a name already exists, so we can't help them */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* that name already exists, use a suffix to make the name unique.
|
||||
* alternately, no hint was specified, so it's up to us to generate the name */
|
||||
b_rope dot = B_ROPE_CHAR('.');
|
||||
|
||||
Reference in New Issue
Block a user