[Swan-dev] strip_prefix + enum_show + bitnamesof
D. Hugh Redelmeier
hugh at mimosa.com
Thu Jul 21 20:11:29 UTC 2016
| From: Andrew Cagney <andrew.cagney at gmail.com>
| then I can display a truncated value vis:
|
| strip_prefix("ESN_", enum_enum_show(ikev2_trans_type_esn_names,
| IKEv2_ESN_DISABLED))
| -> "DISABLED"
It seems that strip_prefix is used about 45 times. That's often
enough to be catered to.
Idea: introduce
1) a "prefix" field into struct enum names
2) add new functions "enum_showb_short" and "enum_name_short" that
suppress the prefix found in struct enum names
Don't bother with a version of enum_show: let's not make
another function with confusing storage for the result
3) we could add a shortbitnames function. That would take an extra
argument, prefix-to-be-suppressed. (There is no descriptor struct
to contain the prefix. I guess we could add one.)
Is that reasonable?
More information about the Swan-dev
mailing list