summaryrefslogtreecommitdiff
path: root/generic/String.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'generic/String.cpp')
-rw-r--r--generic/String.cpp25
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;
+}