From 7035a79e56cba77ad91c8b5c4f3587d850cd82b5 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 13 Aug 2004 13:01:45 +0000 Subject: [PATCH] Fixed some string stuff --- amxmodx/string.cpp | 57 ++++++++++++++-------------------------------- 1 file changed, 17 insertions(+), 40 deletions(-) diff --git a/amxmodx/string.cpp b/amxmodx/string.cpp index 386f9f89..237ddd89 100755 --- a/amxmodx/string.cpp +++ b/amxmodx/string.cpp @@ -55,41 +55,6 @@ const char* stristr(const char* str,const char* substr) char* format_amxstring(AMX *amx, cell *params, int parm,int& len) { - /* - static char buffer[2][3072]; - static char format[16]; - char *ptr,*arg; - char *dest = *buffer; - cell *src = get_amxaddr(amx, params[parm++]); - int numparam = *params/sizeof(cell); - while(*src) { - if (*src=='%'&&*(src+1)) { - ptr = format; - *ptr++ = *src++; - if (*src=='%'){ - *dest++=*src++; - continue; - } - while (!isalpha(*ptr++=*src++)) - ; - *ptr=0; - if (numparam < parm) continue; - arg = buffer[1]; - switch(*(ptr-1)){ - case 's': sprintf(arg,format,get_amxstring(amx, params[parm++],2,len)); break; - case 'f': case 'g': sprintf(arg,format,(float)*(REAL*)get_amxaddr(amx, params[parm++])); break; - default: sprintf(arg,format,(int)*get_amxaddr(amx, params[parm++])); - } - while(*arg) *dest++=*arg++; - continue; - } - *dest++=*src++; - - } - *dest=0; - len = dest - *buffer; - return *buffer; - */ return g_langMngr.FormatAmxString(amx, params, parm, len); } @@ -574,23 +539,34 @@ static cell AMX_NATIVE_CALL is_alpha(AMX *amx, cell *params) return isalpha( params[1] ); } +static cell AMX_NATIVE_CALL amx_ucfirst(AMX *amx, cell *params) +{ + int len = 0; + cell *str = get_amxaddr(amx, params[1]); + if (!isalpha((char)str[0]) || (str[0]&(1<<5))) + return 0; + str[0] |= (1<<5); + return 1; +} + static cell AMX_NATIVE_CALL amx_trim(AMX *amx, cell *params) { - int len; - char *asdf = get_amxstring(amx, params[1], 0, len); + cell *asdf = get_amxaddr(amx, params[1]); + cell *cptr = asdf; + int len = 0; + while (*cptr++) len++; int flag = 0, incr = 0; register int i = 0; - for (i=strlen(asdf)-1; i>=0; i--) + for (i=len-1; i>=0; i--) { if (!isspace(asdf[i])) { break; } else { asdf[i] = 0; + len--; } } - - len = strlen(asdf); for (i=0; i