summaryrefslogtreecommitdiff
path: root/lib/String.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/String.cc')
-rw-r--r--lib/String.cc38
1 files changed, 31 insertions, 7 deletions
diff --git a/lib/String.cc b/lib/String.cc
index 39ea9d8..fa1db50 100644
--- a/lib/String.cc
+++ b/lib/String.cc
@@ -12,7 +12,7 @@ extern "C" {
char String::t[BUFSIZ + 1];
-String::String(const String & s) : str(::strdup(s.str)), siz(s.siz) { }
+String::String(const String & s) : str(Base::strdup(s.str)), siz(s.siz) { }
String::String(char c) : siz(1) {
char * t = (char *) malloc(2);
@@ -21,17 +21,41 @@ String::String(char c) : siz(1) {
str = t;
}
-String::String(const char * s) : str(s ? ::strdup(s) : ::strdup("")) {
+String::String(const char * s) : str(s ? Base::strdup(s) : Base::strdup("")) {
siz = ::strlen(str);
}
-String::String(int hs, const char * s) : str(s ? ::strdup(s) : ::strdup("")), siz(hs) { }
+String::String(int hs, const char * s) : str(s ? Base::strdup(s) : Base::strdup("")), siz(hs) { }
String::String(int i) {
char t[20];
sprintf(t, "%i", i);
- str = ::strdup(t);
+ str = Base::strdup(t);
+ siz = ::strlen(str);
+}
+
+String::String(unsigned int i) {
+ char t[20];
+
+ sprintf(t, "%u", i);
+ str = Base::strdup(t);
+ siz = ::strlen(str);
+}
+
+String::String(long long l) {
+ char t[40];
+
+ sprintf(t, "%lld", l);
+ str = Base::strdup(t);
+ siz = ::strlen(str);
+}
+
+String::String(unsigned long long l) {
+ char t[40];
+
+ sprintf(t, "%llu", l);
+ str = Base::strdup(t);
siz = ::strlen(str);
}
@@ -39,7 +63,7 @@ String::String(double d) {
char t[30];
sprintf(t, "%g", d);
- str = ::strdup(t);
+ str = Base::strdup(t);
siz = ::strlen(str);
}
@@ -53,7 +77,7 @@ const char * String::set(char * s, ...) {
va_start(ap, s);
vsnprintf(t, BUFSIZ, s, ap);
free(str);
- str = ::strdup(t);
+ str = Base::strdup(t);
va_end(ap);
siz = ::strlen(str);
return t;
@@ -89,7 +113,7 @@ String String::extract(size_t from, ssize_t to) const {
}
char * String::strdup(size_t from, ssize_t to) const {
- return ::strdup(to_charp(from, to));
+ return Base::strdup(to_charp(from, to));
}
int String::to_int(void) const {