Browse code

Various changes:

* Use enum class instead of enum (except for the enums for the resource IDs, not really necessary there).
* For NCSF specifically, included a function to convert an enum class to its underlying integral type (as this is needed for use with the std::bitset class).
* Cleanup headers so all the ones needed in a file are explicitly included even if they may possibly be included in another header.
* Used forward declarations in a few spots.
* Explicitly namespaced all (u)int*_t uses (this might seem like overkill, but it helps me see when the standard types are being used with a simple search for std::).
* Made sure it all builds with MinGW-w64 as well (both gcc and clang).
* Removed some std::move from DialogBuilder.cpp based on clang's warnings for that.
* Replaced use of std::copy_n on strings in DialogBuilder.cpp with my CopyToString functions that use wcscpy.
* Replaced CHAR_MIN/CHAR_MAX in eqstr.h and ltstr.h with std::numeric_limits<char>::min/max().

Naram Qashat authored on 2021/03/21 03:16:45
Showing 1 changed files
... ...
@@ -8,11 +8,10 @@
8 8
 
9 9
 #pragma once
10 10
 
11
-#include <functional>
11
+#include <algorithm>
12
+#include <limits>
12 13
 #include <locale>
13 14
 #include <string>
14
-#include <algorithm>
15
-#include <climits>
16 15
 
17 16
 struct eq_str
18 17
 {
... ...
@@ -20,16 +19,16 @@ struct eq_str
20 19
 	{
21 20
 		const char *tab;
22 21
 		eq_char(const char *t) : tab(t) { }
23
-		bool operator()(char x, char y) const { return this->tab[x - CHAR_MIN] == this->tab[y - CHAR_MIN]; }
22
+		bool operator()(char x, char y) const { return this->tab[x - std::numeric_limits<char>::min()] == this->tab[y - std::numeric_limits<char>::min()]; }
24 23
 	};
25 24
 
26
-	char tab[CHAR_MAX - CHAR_MIN + 1];
25
+	char tab[std::numeric_limits<char>::max() - std::numeric_limits<char>::min() + 1];
27 26
 
28 27
 	eq_str(const std::locale &L = std::locale::classic())
29 28
 	{
30
-		for (int i = CHAR_MIN; i <= CHAR_MAX; ++i)
31
-			this->tab[i - CHAR_MIN] = static_cast<char>(i);
32
-		std::use_facet<std::ctype<char>>(L).toupper(this->tab, this->tab + (CHAR_MAX - CHAR_MIN + 1));
29
+		for (int i = std::numeric_limits<char>::min(); i <= std::numeric_limits<char>::max(); ++i)
30
+			this->tab[i - std::numeric_limits<char>::min()] = static_cast<char>(i);
31
+		std::use_facet<std::ctype<char>>(L).toupper(this->tab, this->tab + (std::numeric_limits<char>::max() - std::numeric_limits<char>::min() + 1));
33 32
 	}
34 33
 
35 34
 	bool operator()(const std::string &x, const std::string &y) const
Browse code

Remove last modification date from files.

(I never remember to update these and besides, GitHub history can show when they were last modified.)

Naram Qashat authored on 2021/03/19 10:58:12
Showing 1 changed files
... ...
@@ -1,6 +1,5 @@
1 1
 /*
2 2
  * Case-insensitive string equality
3
- * Last modification on 2014-09-08
4 3
  *
5 4
  * Based on "How to do case-insensitive string comparison"
6 5
  * By Matt Austern
Browse code

update for C++17 compliance, update to latest 2sf, add WINE cross-compile makefiles

Adam Higerd authored on 2021/02/11 15:36:17
Showing 1 changed files
... ...
@@ -15,9 +15,9 @@
15 15
 #include <algorithm>
16 16
 #include <climits>
17 17
 
18
-struct eq_str : std::binary_function<std::string, std::string, bool>
18
+struct eq_str
19 19
 {
20
-	struct eq_char : std::binary_function<char, char, bool>
20
+	struct eq_char
21 21
 	{
22 22
 		const char *tab;
23 23
 		eq_char(const char *t) : tab(t) { }
Browse code

Use #pragma once instead of include guards.

Naram Qashat authored on 2014/09/08 14:47:36
Showing 1 changed files
... ...
@@ -1,14 +1,13 @@
1 1
 /*
2 2
  * Case-insensitive string equality
3
- * Last modification on 2013-03-30
3
+ * Last modification on 2014-09-08
4 4
  *
5 5
  * Based on "How to do case-insensitive string comparison"
6 6
  * By Matt Austern
7 7
  * http://lafstern.org/matt/col2_new.pdf
8 8
  */
9 9
 
10
-#ifndef EQSTR_H
11
-#define EQSTR_H
10
+#pragma once
12 11
 
13 12
 #include <functional>
14 13
 #include <locale>
... ...
@@ -39,5 +38,3 @@ struct eq_str : std::binary_function<std::string, std::string, bool>
39 38
 		return x.length() == y.length() && std::equal(x.begin(), x.end(), y.begin(), eq_char(this->tab));
40 39
 	}
41 40
 };
42
-
43
-#endif
Browse code

Cleanup of some warnings, updating modification dates, using nullptr instead of NULL in some cases.

Naram Qashat authored on 2013/03/30 16:17:42
Showing 1 changed files
... ...
@@ -1,6 +1,6 @@
1 1
 /*
2 2
  * Case-insensitive string equality
3
- * Last modification on 2013-03-21
3
+ * Last modification on 2013-03-30
4 4
  *
5 5
  * Based on "How to do case-insensitive string comparison"
6 6
  * By Matt Austern
Browse code

Utilized more C++11 constructs. Also attempted to fix issue with the Info Box not wanting to come up anymore if the file doesn't exist.

Naram Qashat authored on 2013/03/30 07:36:38
Showing 1 changed files
... ...
@@ -31,7 +31,7 @@ struct eq_str : std::binary_function<std::string, std::string, bool>
31 31
 	{
32 32
 		for (int i = CHAR_MIN; i <= CHAR_MAX; ++i)
33 33
 			this->tab[i - CHAR_MIN] = static_cast<char>(i);
34
-		std::use_facet<std::ctype<char> >(L).toupper(this->tab, this->tab + (CHAR_MAX - CHAR_MIN + 1));
34
+		std::use_facet<std::ctype<char>>(L).toupper(this->tab, this->tab + (CHAR_MAX - CHAR_MIN + 1));
35 35
 	}
36 36
 
37 37
 	bool operator()(const std::string &x, const std::string &y) const
Browse code

Import actual code.

Naram Qashat authored on 2013/03/26 02:41:19
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,43 @@
1
+/*
2
+ * Case-insensitive string equality
3
+ * Last modification on 2013-03-21
4
+ *
5
+ * Based on "How to do case-insensitive string comparison"
6
+ * By Matt Austern
7
+ * http://lafstern.org/matt/col2_new.pdf
8
+ */
9
+
10
+#ifndef EQSTR_H
11
+#define EQSTR_H
12
+
13
+#include <functional>
14
+#include <locale>
15
+#include <string>
16
+#include <algorithm>
17
+#include <climits>
18
+
19
+struct eq_str : std::binary_function<std::string, std::string, bool>
20
+{
21
+	struct eq_char : std::binary_function<char, char, bool>
22
+	{
23
+		const char *tab;
24
+		eq_char(const char *t) : tab(t) { }
25
+		bool operator()(char x, char y) const { return this->tab[x - CHAR_MIN] == this->tab[y - CHAR_MIN]; }
26
+	};
27
+
28
+	char tab[CHAR_MAX - CHAR_MIN + 1];
29
+
30
+	eq_str(const std::locale &L = std::locale::classic())
31
+	{
32
+		for (int i = CHAR_MIN; i <= CHAR_MAX; ++i)
33
+			this->tab[i - CHAR_MIN] = static_cast<char>(i);
34
+		std::use_facet<std::ctype<char> >(L).toupper(this->tab, this->tab + (CHAR_MAX - CHAR_MIN + 1));
35
+	}
36
+
37
+	bool operator()(const std::string &x, const std::string &y) const
38
+	{
39
+		return x.length() == y.length() && std::equal(x.begin(), x.end(), y.begin(), eq_char(this->tab));
40
+	}
41
+};
42
+
43
+#endif