diff options
author | Thomas Haller <thaller@redhat.com> | 2021-07-16 07:46:23 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2021-07-19 08:59:33 +0200 |
commit | 5b6005d06ef55795afdbd7ea119b91cfac0faba3 (patch) | |
tree | 4945397020924439e36c4ac4d849cfaadd528f77 /config.h.meson | |
parent | bdfaa4520ea32e9b7065b8dcb450166d5d634a06 (diff) | |
download | NetworkManager-5b6005d06ef55795afdbd7ea119b91cfac0faba3.tar.gz |
glib-aux: add nm_ascii_is_ctrl() helper (and similar)
These functions have overlap with g_ascii_is*() functions.
However g_ascii_is*() (and the is* functions from <ctype.h>) are
always confusing to me, in the sense that it's not clearly stated
which characters qualify for a certain category. And review is not
easy either, because they are implemented via a table lookup.
E.g. were you aware that 127 is considered g_ascii_iscntrl()? Probably
you were, but it's not clear to see that anywhere.
The main point of our own functions is to have is easier to see how
characters get categorized, by using comparison instead of table lookup.
Also, several existing code did in fact not use the g_ascii_is*()
macros, possibly because of the (perceived) difficulty to understand
their exact meaning. As a consequence, several checks got wrong.
For example, (ch < ' ') is not a valid check for testing whether
the character is a ASCII control character, for two reasons:
- if char is a signed type (as likely it is), then this also evaluates
to TRUE for all non-ASCII, UTF-8 characters that are greater than
127.
- it does not consider DEL character (127) a control character.
Diffstat (limited to 'config.h.meson')
0 files changed, 0 insertions, 0 deletions