forked from KolibriOS/kolibrios
Added several functions (to ctype.h, stdlib.h)
"Optimised" some functions in string.h Added dynamic libraries support based on sysfunction 68.19 (experimental) git-svn-id: svn://kolibrios.org@215 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
22
programs/develop/metcc/trunk/libc/string/atoib.cpp
Normal file
22
programs/develop/metcc/trunk/libc/string/atoib.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
#include "ctype.h"
|
||||
|
||||
/*
|
||||
** atoib(s,b) - Convert s to "unsigned" integer in base b.
|
||||
** NOTE: This is a non-standard function.
|
||||
*/
|
||||
int atoib(char *s,int b)
|
||||
{
|
||||
int n, digit;
|
||||
n = 0;
|
||||
while(isspace(*s)) ++s;
|
||||
while((digit = (127 & *s++)) >= '0') {
|
||||
if(digit >= 'a') digit -= 87;
|
||||
else if(digit >= 'A') digit -= 55;
|
||||
else digit -= '0';
|
||||
if(digit >= b) break;
|
||||
n = b * n + digit;
|
||||
}
|
||||
return (n);
|
||||
}
|
Reference in New Issue
Block a user