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:
@@ -26,12 +26,10 @@ char *bus_label_escape(const char *s) {
|
||||
|
||||
for (f = s, t = r; *f; f++) {
|
||||
|
||||
/* Escape everything that is not a-zA-Z0-9. We also
|
||||
* escape 0-9 if it's the first character */
|
||||
/* Escape everything that is not a-zA-Z0-9. We also escape 0-9 if it's the first character */
|
||||
|
||||
if (!(*f >= 'A' && *f <= 'Z') &&
|
||||
!(*f >= 'a' && *f <= 'z') &&
|
||||
!(f > s && *f >= '0' && *f <= '9')) {
|
||||
if (!ascii_isalpha(*f) &&
|
||||
!(f > s && ascii_isdigit(*f))) {
|
||||
*(t++) = '_';
|
||||
*(t++) = hexchar(*f >> 4);
|
||||
*(t++) = hexchar(*f);
|
||||
|
||||
Reference in New Issue
Block a user