kolibrios-fun/programs/develop/metcc/trunk/libc/string/atoib.cpp
victor 1391dd1d1d 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
2006-11-21 12:36:25 +00:00

23 lines
511 B
C++

#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);
}