diff options
author | Pixel <Pixel> | 2002-08-17 01:48:34 +0000 |
---|---|---|
committer | Pixel <Pixel> | 2002-08-17 01:48:34 +0000 |
commit | 11bf45f50739afb923829b3cc32efb9c8c009613 (patch) | |
tree | 1a9a691cdd3a466d55259aa31fff1bfc0fcd8e7a /generic/String.cpp | |
parent | 08ecf5aae1c7276bb1e78a288cba3a731604758e (diff) |
Working with Baltisot now....
Diffstat (limited to 'generic/String.cpp')
-rw-r--r-- | generic/String.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/generic/String.cpp b/generic/String.cpp index 49b4e4d..0f4da24 100644 --- a/generic/String.cpp +++ b/generic/String.cpp @@ -23,7 +23,19 @@ String::String(char c) : siz(1) { str = t; } -String::String(const char * s) : str(s ? Base::strdup(s) : Base::strdup("")) { +String::String(const char * s, ...) : str(s ? Base::strdup(s) : Base::strdup("")) { + va_list ap; + + if (!s) + return; + +/* This causes a warning: cannot pass objects of type `const String' through `...' + but it is not really a problem. */ + va_start(ap, s); + vsnprintf(t, BUFSIZ, s, ap); + free(str); + str = Base::strdup(t); + va_end(ap); siz = ::strlen(str); } @@ -78,6 +90,13 @@ String::~String() { const char * String::set(const char * s, ...) { va_list ap; + if (!s) { + free(str); + str = Base::strdup(""); + t[0] = 0; + return t; + } + /* This causes a warning: cannot pass objects of type `const String' through `...' but it is not really a problem. */ va_start(ap, s); @@ -354,3 +373,7 @@ bool String::is_time(void) const { return (extract(p + 1).to_int() < 60) ? true : false; } + +String operator+(const char * a, const String & b) { + return String(a) + b; +} |