aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--common/config-file.cpp1
-rw-r--r--common/str.cpp19
-rw-r--r--common/str.h9
4 files changed, 28 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 7a24c903b2..2f4b7e6ab2 100644
--- a/Makefile
+++ b/Makefile
@@ -13,7 +13,7 @@ RM_REC = $(RM) -r
ZIP = zip -q
CP = cp
-CFLAGS = -g -O -Wall -Wstrict-prototypes -Wuninitialized -Wno-long-long -Wno-multichar -Wno-unknown-pragmas
+CFLAGS = -g -Wall -Wstrict-prototypes -Wuninitialized -Wno-long-long -Wno-multichar -Wno-unknown-pragmas
DEFINES =
LDFLAGS :=
INCLUDES:= -I. -Icommon
diff --git a/common/config-file.cpp b/common/config-file.cpp
index bcc7537741..5ac3988e13 100644
--- a/common/config-file.cpp
+++ b/common/config-file.cpp
@@ -164,6 +164,7 @@ void Config::setBool(const String &key, bool value_b, const String &d)
void Config::set_domain(const String &d)
{
defaultDomain = d;
+ defaultDomain.toLowercase();
}
bool Config::has_domain(const String &d) const
diff --git a/common/str.cpp b/common/str.cpp
index 7b33b29c30..ea35b665af 100644
--- a/common/str.cpp
+++ b/common/str.cpp
@@ -21,6 +21,7 @@
#include "stdafx.h"
#include "str.h"
+#include <ctype.h>
#ifdef _MSC_VER
# pragma warning( disable : 4068 ) // unknown pragmas
@@ -171,6 +172,24 @@ void String::clear()
}
}
+void String::toLowercase()
+{
+ if (_str == 0 || _len == 0)
+ return;
+
+ for (int i = 0; i < _len; ++i)
+ _str[i] = tolower(_str[i]);
+}
+
+void String::toUppercase()
+{
+ if (_str == 0 || _len == 0)
+ return;
+
+ for (int i = 0; i < _len; ++i)
+ _str[i] = toupper(_str[i]);
+}
+
void String::ensureCapacity(int new_len, bool keep_old)
{
// If there is not enough space, or if we are not the only owner
diff --git a/common/str.h b/common/str.h
index c7c533d952..41227192b0 100644
--- a/common/str.h
+++ b/common/str.h
@@ -83,10 +83,12 @@ public:
virtual ~String();
String& operator =(const char* str);
-// TODO - We should use RTTI here - that is, not real C++ RTTI but some magic
+// TODO - We should use RTTI here - that is, not real C++ RTTI but maybe some magic
// constant in each string object. We want to be able to optimize the case when
// a real 'String' object is passed to a function as a ConstString obj and then
-// assigned to a 'String' object
+// assigned to a 'String' object.
+// An alternative would be to add private clone() and cloneMutable methods that
+// would do the right thing.
String& operator =(const String& str);
String& operator +=(const char* str);
String& operator +=(const String& str);
@@ -106,6 +108,9 @@ public:
void deleteLastChar();
void clear();
+
+ void toLowercase();
+ void toUppercase();
protected:
void ensureCapacity(int new_len, bool keep_old);