fixed two bugs

This commit is contained in:
David Anderson 2005-08-02 07:46:41 +00:00
parent 5cbcd34bec
commit 688c12ac8b
2 changed files with 14 additions and 2 deletions

View File

@ -130,7 +130,7 @@ public:
bool empty() bool empty()
{ {
if (!v) if (!v)
return false; return true;
if (v[0] == '\0') if (v[0] == '\0')
return true; return true;
@ -369,6 +369,8 @@ private:
strcpy(n, v); strcpy(n, v);
if (v) if (v)
delete [] v; delete [] v;
else
strcpy(n, "");
v = n; v = n;
a_size = d + 1; a_size = d + 1;
} }

View File

@ -33,6 +33,7 @@
#define _INCLUDE_CSTRING_H #define _INCLUDE_CSTRING_H
#include <string.h> #include <string.h>
#include <stdio.h>
//by David "BAILOPAN" Anderson //by David "BAILOPAN" Anderson
class String class String
@ -58,6 +59,13 @@ public:
assign(src); assign(src);
} }
const char * _fread(FILE *fp)
{
Grow(512, false);
char *ret = fgets(v, 511, fp);
return ret;
}
String(String &src) String(String &src)
{ {
v = NULL; v = NULL;
@ -122,7 +130,7 @@ public:
bool empty() bool empty()
{ {
if (!v) if (!v)
return false; return true;
if (v[0] == '\0') if (v[0] == '\0')
return true; return true;
@ -361,6 +369,8 @@ private:
strcpy(n, v); strcpy(n, v);
if (v) if (v)
delete [] v; delete [] v;
else
strcpy(n, "");
v = n; v = n;
a_size = d + 1; a_size = d + 1;
} }