From 11bf45f50739afb923829b3cc32efb9c8c009613 Mon Sep 17 00:00:00 2001 From: Pixel Date: Sat, 17 Aug 2002 01:48:34 +0000 Subject: Working with Baltisot now.... --- generic/String.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'generic/String.cpp') 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; +} -- cgit v1.2.3