summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2019-11-01 11:02:28 -0400
committerJakob Kaivo <jkk@ung.org>2019-11-01 11:02:28 -0400
commit4624994d43dc4727e42ab30cacfeb4a5b17e3b06 (patch)
treec3b479f131d249d1a92a6cebae32276b7dba32d2
parent6fc86b5a299baa57f3a5f59ff1dbac663e464235 (diff)
simplify print_id() a bit
-rw-r--r--id.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/id.c b/id.c
index 60824ce..97bd6f2 100644
--- a/id.c
+++ b/id.c
@@ -55,19 +55,15 @@ static char *get_name(enum type type, id_t id)
static void print_id(const char *prefix, const char *name, id_t id, enum display mode)
{
printf("%s", prefix);
- if (mode == NAMES) {
- if (name) {
- printf("%s", name);
- } else {
- printf("%ju", (uintmax_t)id);
- }
- } else if (mode == NUMBERS) {
+ if (mode == FULL || mode == NUMBERS || name == NULL) {
printf("%ju", (uintmax_t)id);
- } else {
- if (name) {
- printf("%ju(%s)", (uintmax_t)id, name);
- } else {
- printf("%ju", (uintmax_t)id);
+ }
+
+ if (name != NULL) {
+ if (mode == FULL) {
+ printf("(%s)", name);
+ } else if (mode == NAMES) {
+ printf("%s", name);
}
}
}