From 40498772a2f2096484f28646db0125f12bb64024 Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Sat, 19 Mar 2011 20:08:51 +0000 Subject: [PATCH] strcaps cleanup, init overreadval to 0 git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@6133 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/tools.h | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/source/src/tools.h b/source/src/tools.h index 25a5fb98..dc96ab82 100644 --- a/source/src/tools.h +++ b/source/src/tools.h @@ -134,16 +134,11 @@ struct stringformatter inline char *strcaps(const char *s, bool on) { - int (*caps)(int t) = (on ? toupper : tolower); - static char r[128]; - char *c = (char *)s, *o = r; - int n = 0; - while( *c!='\0' && n < 127) - { - *o = caps(*c); - n++; o++; c++; - } - *o='\0'; + static string r; + char *o = r; + if(on) while(*s && o < &r[sizeof(r)-1]) *o++ = toupper(*s++); + else while(*s && o < &r[sizeof(r)-1]) *o++ = tolower(*s++); + *o = '\0'; return r; } @@ -216,7 +211,7 @@ struct databuf const T &get() { - static T overreadval; + static T overreadval = 0; if(len