X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FKernel%2Flibc.c;h=ea705795f33c1735d6fb5f3b06fba9b4c9c8075f;hb=ea8e0fad3dfc8bf735d41eedbad2a8e6198059aa;hp=08ebc623d0b81706342a789248d4fc2c2e9f4c25;hpb=31037f330a0fc04936a4a1c608e7fd8d377dea89;p=tpg%2Facess2.git diff --git a/KernelLand/Kernel/libc.c b/KernelLand/Kernel/libc.c index 08ebc623..ea705795 100644 --- a/KernelLand/Kernel/libc.c +++ b/KernelLand/Kernel/libc.c @@ -49,6 +49,7 @@ EXPORT(tolower); EXPORT(strucmp); EXPORT(strchr); +EXPORT(strrchr); EXPORT(strpos); EXPORT(strlen); EXPORT(strcpy); @@ -183,7 +184,12 @@ void itoa(char *buf, Uint64 num, int base, int minLength, char pad) /** * \brief Append a character the the vsnprintf output */ -#define PUTCH(c) _putch(c) +#define PUTCH(ch) do { \ + if(pos < __maxlen) { \ + if(__s) __s[pos] = ch; \ + } \ + pos ++; \ + } while(0) #define GETVAL() do {\ if(isLongLong) val = va_arg(args, Uint64);\ else val = va_arg(args, unsigned int);\ @@ -202,17 +208,6 @@ int vsnprintf(char *__s, size_t __maxlen, const char *__format, va_list args) size_t pos = 0; // Flags int bPadLeft = 0; - - auto void _putch(char ch); - - void _putch(char ch) - { - if(pos < __maxlen) - { - if(__s) __s[pos] = ch; - } - pos ++; - } while((c = *__format++) != 0) { @@ -529,6 +524,15 @@ char *strchr(const char *__s, int __c) return NULL; } +char *strrchr(const char *__s, int __c) +{ + size_t ofs = strlen(__s); + while(--ofs && __s[ofs] != __c); + if( __s[ofs] == __c ) + return (char*)__s + ofs; + return NULL; +} + /** * \fn int strpos(const char *Str, char Ch) * \brief Search a string for an ascii character