diff --git a/components/libc/minilibc/ctype.c b/components/libc/minilibc/ctype.c index 786ff472f8c3d19e2556eb63498e7c735a362f7e..4fd2dc8fb5425bd19a760197595e138c61d90c96 100644 --- a/components/libc/minilibc/ctype.c +++ b/components/libc/minilibc/ctype.c @@ -31,7 +31,23 @@ int isalpha(int ch) int isdigit (int ch) { - return (unsigned int)(ch - '0') < 10u; + return (unsigned int)(ch - '0') < 10u; +} + +int isspace(int ch) +{ + switch(ch) + { + case ' ': + case '\n': + case '\f': + case '\r': + case '\t': + case '\v': + return 1; + default: + return 0; + } } #endif diff --git a/components/libc/minilibc/ctype.h b/components/libc/minilibc/ctype.h index 9a773b69abffbeb0a547c59b5f3ee791bdb6ab00..9909b4a0b0998ec5b631bc8be3f23ce7abdb0403 100644 --- a/components/libc/minilibc/ctype.h +++ b/components/libc/minilibc/ctype.h @@ -17,5 +17,6 @@ int isprint(int c) __attribute__ ((__const__)); int isalpha (int c) __attribute__ ((__const__)); int isdigit (int ch) __attribute__ ((__const__)); +int isspace(int ch) __attribute__ ((__const__)); #endif diff --git a/components/libc/minilibc/stdlib.c b/components/libc/minilibc/stdlib.c index cac4ae5691fa2def5080643308b503f825e6ee49..7185f56bb745f8a10bf7944b31b1a3c36fb368f2 100644 --- a/components/libc/minilibc/stdlib.c +++ b/components/libc/minilibc/stdlib.c @@ -37,6 +37,23 @@ int atoi(const char* s) return sign==-1?-v:v; } +long int atol(const char* s) +{ + long int v=0; + int sign=0; + while ( *s == ' ' || (unsigned int)(*s - 9) < 5u) ++s; + switch (*s) + { + case '-': sign=-1; + case '+': ++s; + } + while ((unsigned int) (*s - '0') < 10u) + { + v=v*10+*s-'0'; ++s; + } + return sign?-v:v; +} + void *malloc(size_t size) { return rt_malloc(size); diff --git a/components/libc/minilibc/stdlib.h b/components/libc/minilibc/stdlib.h index 9ff5cdd86cb29dc0082e290d3202051fe204c438..08f7e0d07b48c69442ebe29a81211fcdf1b9e60f 100644 --- a/components/libc/minilibc/stdlib.h +++ b/components/libc/minilibc/stdlib.h @@ -19,6 +19,7 @@ #if !defined (RT_USING_NEWLIB) && defined (RT_USING_MINILIBC) int atoi(const char *nptr); +long int atol(const char *nptr); int rand(void); int rand_r(unsigned int *seed);