1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-23 17:34:00 +03:00

locale-util: make SpecialGlyph more like our usual enums

Let's define both an enum and a typedef named SpecialGlyph, the way we
usually do it.

Also, introduce an "invalid" special glyph, assigned to -EINVAL, also
like we always do it. (And handle it somewhat sanely in special_glyph()
This commit is contained in:
Lennart Poettering 2021-04-08 22:59:43 +02:00
parent d0b3039837
commit eff60d8cea
2 changed files with 5 additions and 2 deletions

View File

@ -427,8 +427,10 @@ const char *special_glyph(SpecialGlyph code) {
}, },
}; };
assert(code < _SPECIAL_GLYPH_MAX); if (code < 0)
return NULL;
assert(code < _SPECIAL_GLYPH_MAX);
return draw_table[code >= _SPECIAL_GLYPH_FIRST_EMOJI ? emoji_enabled() : is_locale_utf8()][code]; return draw_table[code >= _SPECIAL_GLYPH_FIRST_EMOJI ? emoji_enabled() : is_locale_utf8()][code];
} }

View File

@ -39,7 +39,7 @@ void init_gettext(void);
bool is_locale_utf8(void); bool is_locale_utf8(void);
typedef enum { typedef enum SpecialGlyph {
SPECIAL_GLYPH_TREE_VERTICAL, SPECIAL_GLYPH_TREE_VERTICAL,
SPECIAL_GLYPH_TREE_BRANCH, SPECIAL_GLYPH_TREE_BRANCH,
SPECIAL_GLYPH_TREE_RIGHT, SPECIAL_GLYPH_TREE_RIGHT,
@ -70,6 +70,7 @@ typedef enum {
SPECIAL_GLYPH_LOCK_AND_KEY, SPECIAL_GLYPH_LOCK_AND_KEY,
SPECIAL_GLYPH_TOUCH, SPECIAL_GLYPH_TOUCH,
_SPECIAL_GLYPH_MAX, _SPECIAL_GLYPH_MAX,
_SPECIAL_GLYPH_INVALID = -EINVAL,
} SpecialGlyph; } SpecialGlyph;
const char *special_glyph(SpecialGlyph code) _const_; const char *special_glyph(SpecialGlyph code) _const_;