tree-wide: add global ascii_isdigit() + ascii_isalpha()

We now have a local implementation in string-util-fundamental.c, but
it's useful at a lot of other places, hence let's give it a more
expressive name and share it across the tree.

Follow-up for: 8d9156660d
This commit is contained in:
Lennart Poettering
2022-07-05 14:25:07 +02:00
parent 82c3a0b74c
commit ff25d3385d
25 changed files with 68 additions and 89 deletions
+3 -5
View File
@@ -814,15 +814,13 @@ bool valid_user_group_name(const char *u, ValidUserFlags flags) {
* Note that other systems are even more restrictive, and don't permit underscores or uppercase characters.
*/
if (!(u[0] >= 'a' && u[0] <= 'z') &&
!(u[0] >= 'A' && u[0] <= 'Z') &&
if (!ascii_isalpha(u[0]) &&
u[0] != '_')
return false;
for (i = u+1; *i; i++)
if (!(*i >= 'a' && *i <= 'z') &&
!(*i >= 'A' && *i <= 'Z') &&
!(*i >= '0' && *i <= '9') &&
if (!ascii_isalpha(*i) &&
!ascii_isdigit(*i) &&
!IN_SET(*i, '_', '-'))
return false;