X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FKernel%2Flibc.c;h=58c2e1af5d697d3fbd43bb1d20441e7f37153abc;hb=04a050f42807686dc119838c82372409246d55bb;hp=c6df2cd6d2ad293e3820e468dfc233b99c49c52f;hpb=c1b768104a3458d08e7c7240aaac82fc7e70e3df;p=tpg%2Facess2.git diff --git a/KernelLand/Kernel/libc.c b/KernelLand/Kernel/libc.c index c6df2cd6..58c2e1af 100644 --- a/KernelLand/Kernel/libc.c +++ b/KernelLand/Kernel/libc.c @@ -15,6 +15,10 @@ #define RANDOM_SPRUCE 0xf12b039 // === PROTOTYPES === +unsigned long long strtoull(const char *str, char **end, int base); +unsigned long strtoul(const char *str, char **end, int base); +signed long long strtoll(const char *str, char **end, int base); +signed long strtol(const char *str, char **end, int base); #if 0 int atoi(const char *string); int ParseInt(const char *string, int *Val); @@ -67,15 +71,10 @@ EXPORT(CheckString); EXPORT(CheckMem); // === CODE === -/** - * \brief Convert a string into an integer - */ -int atoi(const char *string) -{ - int ret = 0; - ParseInt(string, &ret); - return ret; -} +// - Import userland stroi.c file +#define _LIB_H_ +#include "../../Usermode/Libraries/libc.so_src/strtoi.c" + int ParseInt(const char *string, int *Val) { int ret = 0; @@ -228,8 +227,12 @@ int vsnprintf(char *__s, size_t __maxlen, const char *__format, va_list args) PUTCH('*'); PUTCH('0'); PUTCH('x'); for( len = BITS/4; len -- && ((ptr>>(len*4))&15) == 0; ) ; - for( len ++; len --; ) - PUTCH( cUCDIGITS[ (ptr>>(len*4))&15 ] ); + len ++; + if( len == 0 ) + PUTCH( '0' ); + else + while( len -- ) + PUTCH( cUCDIGITS[ (ptr>>(len*4))&15 ] ); continue ; } @@ -359,7 +362,7 @@ int vsnprintf(char *__s, size_t __maxlen, const char *__format, va_list args) if(!p) p = "(null)"; len = strlen(p); if( !bPadLeft ) while(len++ < minSize) PUTCH(pad); - while(*p && precision--) PUTCH(*p++); + while(*p && precision--) { PUTCH(*p); p++;} if( bPadLeft ) while(len++ < minSize) PUTCH(pad); break; @@ -367,7 +370,10 @@ int vsnprintf(char *__s, size_t __maxlen, const char *__format, va_list args) p = va_arg(args, char*); if( !CheckMem(p, minSize) ) continue; // No #PFs please if(!p) goto printString; - while(minSize--) PUTCH(*p++); + while(minSize--) { + PUTCH(*p); + p ++; + } break; // Single Character