@@ -6,6 +6,7 @@
*/
#include "libcflat.h"
+#include "ctype.h"
#include "argv.h"
#include "auxinfo.h"
@@ -19,10 +20,6 @@ char **environ = __environ;
static char args_copy[1000];
static char *copy_ptr = args_copy;
-#define isblank(c) ((c) == ' ' || (c) == '\t')
-#define isalpha(c) (((c) >= 'A' && (c) <= 'Z') || ((c) >= 'a' && (c) <= 'z') || (c) == '_')
-#define isalnum(c) (isalpha(c) || ((c) >= '0' && (c) <= '9'))
-
static const char *skip_blanks(const char *p)
{
while (isblank(*p))
@@ -92,12 +89,12 @@ static char *env_next(char *env)
if (!*env)
return env;
- if (isalpha(*env)) {
+ if (isalpha(*env) || *env == '_') {
bool invalid = false;
p = env + 1;
while (*p && *p != '=' && *p != '\n') {
- if (!isalnum(*p))
+ if (!(isalnum(*p) || *p == '_'))
invalid = true;
++p;
}
new file mode 100644
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+#ifndef _CTYPE_H_
+#define _CTYPE_H_
+
+static inline int isblank(int c)
+{
+ return c == ' ' || c == '\t';
+}
+
+static inline int islower(int c)
+{
+ return c >= 'a' && c <= 'z';
+}
+
+static inline int isupper(int c)
+{
+ return c >= 'A' && c <= 'Z';
+}
+
+static inline int isalpha(int c)
+{
+ return isupper(c) || islower(c);
+}
+
+static inline int isdigit(int c)
+{
+ return c >= '0' && c <= '9';
+}
+
+static inline int isalnum(int c)
+{
+ return isalpha(c) || isdigit(c);
+}
+
+static inline int isspace(int c)
+{
+ return c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == '\v' || c == '\f';
+}
+
+#endif /* _CTYPE_H_ */
@@ -6,6 +6,7 @@
*/
#include "libcflat.h"
+#include "ctype.h"
#include "stdlib.h"
#include "linux/compiler.h"
@@ -163,11 +164,6 @@ void *memchr(const void *s, int c, size_t n)
return NULL;
}
-static int isspace(int c)
-{
- return c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == '\v' || c == '\f';
-}
-
static unsigned long long __strtoll(const char *nptr, char **endptr,
int base, bool is_signed, bool is_longlong)
{