mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-01-18 13:03:31 +08:00
add atol and isspace to minilibc.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2218 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
ae3c1800d4
commit
70cee4b82e
@ -34,4 +34,20 @@ int isdigit (int ch)
|
||||
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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user