提交 70cee4b8 编写于 作者: qiuyiuestc's avatar qiuyiuestc

add atol and isspace to minilibc.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2218 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 ae3c1800
......@@ -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
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册