Fixed almost all CLang bugs: (mem leaks?, parsing, key system, etc)

Warning - caching is still broken!
Fixed bug in ucfirst()
This commit is contained in:
David Anderson
2004-08-15 13:49:59 +00:00
parent 3bbfca6d08
commit 46adfaedd3
3 changed files with 75 additions and 30 deletions

View File

@@ -169,6 +169,8 @@ public:
{
if (!v)
return npos;
if (index >= (int)cSize || index < 0)
return npos;
unsigned int i = 0;
for (i=index; i<cSize; i++)
{
@@ -284,29 +286,30 @@ public:
}
}
}
v[i] = 0;
cSize -= num;
v[cSize] = 0;
return (*this);
}
String substr(unsigned int index, int num = npos)
{
unsigned int rnum = (unsigned int)((num<0)?(cSize):(num));
String ns;
if (index >= cSize || !v)
return ns;
if (index+rnum >= cSize)
if (num == npos)
{
rnum = cSize - index+1;
num = cSize - index;
} else if (index+num >= cSize) {
num = cSize - index;
}
unsigned int i = 0, j=0;
char *s = new char[cSize+1];
for (i=index; i<index+rnum; i++)
for (i=index; i<index+num; i++)
{
s[j++] = v[i];
}
@@ -354,6 +357,24 @@ public:
}
}
int at(int a)
{
if (at < 0 || at >= (int)cSize)
return -1;
return v[a];
}
bool at(int at, char c)
{
if (at < 0 || at >= (int)cSize)
return false;
v[at] = c;
return true;
}
private:
void Grow(unsigned int d)
{