summaryrefslogtreecommitdiff
blob: a4130ac31afd6c336a1a857a73a68b7601f2005f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
--- krystaldrop/Sources/KDpp/Resources/ArchiveReader.h.old	2008-07-30 22:05:18.000000000 -0500
+++ krystaldrop/Sources/KDpp/Resources/ArchiveReader.h	2008-07-30 22:27:20.000000000 -0500
@@ -2,7 +2,26 @@
 #define ArchiveReader_H
 
 #include <map>
-#include <string>
+#include <cstring>
+#include <locale>
+
+/* 
+ * structs needed for std::transform() 
+ * See: http://gcc.gnu.org/onlinedocs/libstdc++/22_locale/howto.html#7 
+ */ 
+struct ToUpper { 
+	ToUpper(std::locale const& l) : loc(l) {;} 
+	char operator() (char c) const  { return std::toupper(c,loc); } 
+private: 
+	std::locale const& loc; 
+}; 
+	 
+struct ToLower { 
+	ToLower(std::locale const& l) : loc(l) {;} 
+	char operator() (char c) const  { return std::tolower(c,loc); } 
+private: 
+	std::locale const& loc; 
+}; 
 
 /** \c KD_ArchiveReader is a generic abstract class which reads a specific kind of archive
     (`.zip' for instance)
--- krystaldrop/Sources/KDpp/Resources/ArchiveManager.cpp.old	2008-07-30 20:53:19.000000000 -0500
+++ krystaldrop/Sources/KDpp/Resources/ArchiveManager.cpp	2008-07-30 22:35:54.000000000 -0500
@@ -1,10 +1,11 @@
-#include <assert.h>
+#include <cassert>
+#include <algorithm>
 
 #include "ArchiveManager.h"
 #include "../Tools/Logfile.h"
 
 #ifndef _WIN32
-#include <ctype.h>
+#include <cctype>
 #endif
 
 std::map<std::string,KD_ArchiveReader*> KD_ArchiveManager::opened_archives;
@@ -25,7 +26,6 @@
   opened_archives.clear();
 }
 
-
 void KD_ArchiveManager::RegisterArchiveFormat (std::string suffix, T_ArchiveReaderFactory reader_factory)
 {
   NormalizeSuffix (suffix);
@@ -36,9 +36,10 @@
 
 
 void KD_ArchiveManager::NormalizeSuffix (std::string& suffix)
-{
+{  
+  ToLower __tolower(std::locale::classic());
   // stores the suffix lower-case
-  transform (suffix.begin(), suffix.end(), suffix.begin(), tolower);
+  transform (suffix.begin(), suffix.end(), suffix.begin(), __tolower);
 
    // add the dot character `.' if it is missing
   if (suffix[0]!= '.') suffix= '.'+ suffix;
--- krystaldrop/Sources/KDpp/Tools/FilePath.cpp.old	2008-07-30 20:55:13.000000000 -0500
+++ krystaldrop/Sources/KDpp/Tools/FilePath.cpp	2008-07-30 22:37:05.000000000 -0500
@@ -1,12 +1,12 @@
 #include "FilePath.h"
 
-#include <stdio.h>
+#include <cstdio>
+#include <algorithm>
 
 #ifndef _WIN32
-#include <ctype.h>
+#include <cctype>
 #endif
 
-
 KD_FilePath::KD_FilePath() : fileName("") , filePath(""), archiveName(""), archiveSuffix("")
 {
 }
@@ -165,8 +165,9 @@
 	// (*not* the first one found scanning from left to right)
 
 	// the search is case-insensitive -> lower-casificator in action
+	ToLower __tolower(std::locale::classic());
 	string copy_directory = directory;
-	transform (copy_directory.begin(), copy_directory.end(), copy_directory.begin(), tolower);
+	transform (copy_directory.begin(), copy_directory.end(), copy_directory.begin(), __tolower);
 
 	map<string,T_ArchiveReaderFactory>::iterator suffix_iter=
 		KD_ArchiveManager::known_suffixes.begin();
@@ -271,6 +272,7 @@
 
 string KD_FilePath::GetFileExtension() const
 {
+	ToLower __tolower(std::locale::classic());
 	size_t pos = fileName.rfind('.');
 	if (pos == fileName.npos)
 		return "";
@@ -280,7 +282,7 @@
 	for (unsigned int i=0; i<ext.size(); i++)
 		ext[i] = tolower(ext[i]);
 */
-	transform (ext.begin(), ext.end(), ext.begin(), tolower);
+	transform (ext.begin(), ext.end(), ext.begin(), __tolower);
 	return ext;
 }