[Scummvm-cvs-logs] CVS: scummvm/common config-file.cpp,1.4,1.5 str.cpp,1.8,1.9 str.h,1.5,1.6

Max Horn fingolfin at users.sourceforge.net
Mon Oct 7 17:12:16 CEST 2002


Update of /cvsroot/scummvm/scummvm/common
In directory usw-pr-cvs1:/tmp/cvs-serv2639/common

Modified Files:
	config-file.cpp str.cpp str.h 
Log Message:
added methods to String class that convert a string to upper/lower case; changed config class to keep all domains as lower case (fixes bug #scummvm)

Index: config-file.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/config-file.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- config-file.cpp	29 Sep 2002 23:08:24 -0000	1.4
+++ config-file.cpp	8 Oct 2002 00:11:41 -0000	1.5
@@ -164,6 +164,7 @@
 void Config::set_domain(const String &d)
 {
 	defaultDomain = d;
+	defaultDomain.toLowercase();
 }
 
 bool Config::has_domain(const String &d) const

Index: str.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/str.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- str.cpp	28 Sep 2002 19:25:09 -0000	1.8
+++ str.cpp	8 Oct 2002 00:11:41 -0000	1.9
@@ -21,6 +21,7 @@
 #include "stdafx.h"
 #include "str.h"
 
+#include <ctype.h>
 
 #ifdef _MSC_VER
 #	pragma warning( disable : 4068 ) // unknown pragmas
@@ -169,6 +170,24 @@
 		_len = 0;
 		_str = 0;
 	}
+}
+
+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)

Index: str.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/str.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- str.h	26 Sep 2002 12:29:10 -0000	1.5
+++ str.h	8 Oct 2002 00:11:41 -0000	1.6
@@ -83,10 +83,12 @@
 	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 @@
 
 	void deleteLastChar();
 	void clear();
+	
+	void toLowercase();
+	void toUppercase();
 
 protected:
 	void ensureCapacity(int new_len, bool keep_old);





More information about the Scummvm-git-logs mailing list