Skip to content

Commit c01e386

Browse files
lemireanonrig
authored andcommitted
Patching for Windows.
1 parent 88605ea commit c01e386

File tree

3 files changed

+7
-15
lines changed

3 files changed

+7
-15
lines changed

src/unicode.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
#include <algorithm>
66
#if ADA_HAS_ICU
7-
// We are god.
7+
// We are good.
88
#else
99

10-
#ifdef _WIN32 // let us hope that we are linking with the proper libraries.
10+
#if defined(_WIN32) && ADA_WINDOWS_TO_ASCII_FALLBACK
1111

1212
#ifndef __wtypes_h__
1313
#include <wtypes.h>
@@ -18,7 +18,7 @@
1818
#endif // __WINDEF_
1919

2020
#include <winnls.h>
21-
#endif // _WIN32
21+
#endif //defined(_WIN32) && ADA_WINDOWS_TO_ASCII_FALLBACK
2222

2323
#endif // ADA_HAS_ICU
2424

tests/basic_fuzzer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@ size_t roller_fuzz(size_t N) {
112112
int main() {
113113
std::cout << "Running basic fuzzer.\n";
114114
std::cout << "[fancy] Executed " << fancy_fuzz(100000) << " mutations.\n";
115+
#if ADA_HAS_ICU
115116
std::cout << "[simple] Executed " << simple_fuzz(40000) << " mutations.\n";
117+
#endif
116118
std::cout << "[roller] Executed " << roller_fuzz(40000) << " correct cases.\n";
117119
return EXIT_SUCCESS;
118120
}

tests/wpt_tests.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@
1414
// We think that these examples have bad domains.
1515
std::set<std::string> bad_domains = {"http://./", "http://../", "http://foo.09.."};
1616

17-
#ifdef _WIN32
18-
// Under Windows, we use get transitional IDN, but the spec is based on non-transitional.
19-
std::set<std::string> exceptions = {"\x68\x74\x74\x70\x73\x3a\x2f\x2f\x66\x61\xc3\x9f\x2e\x45\x78\x41\x6d\x50\x6c\x45\x2f"};
20-
#endif
21-
2217
// This function copies your input onto a memory buffer that
2318
// has just the necessary size. This will entice tools to detect
2419
// an out-of-bound access.
@@ -311,9 +306,6 @@ bool urltestdata_encoding(const char* source) {
311306
return false;
312307
}
313308
std::cout << "input='" << input << "' [" << input.size() << " bytes]" << std::endl;
314-
#ifdef _WIN32
315-
if(exceptions.find(std::string(input)) != exceptions.end()) { std::cerr << "skipping "+element_string << std::endl; continue; }
316-
#endif
317309
std::string_view base;
318310
ada::result base_url;
319311
if (!object["base"].get(base)) {
@@ -458,13 +450,13 @@ int main(int argc, char** argv) {
458450
if(all_tests || name.find(filter) != std::string::npos) {
459451
results[name] = toascii_encoding();
460452
}
461-
#endif // _WIN32
453+
#endif // ADA_HAS_ICU
462454
name = "setters_tests_encoding("+std::string(SETTERS_TESTS_JSON)+")";
463455
if(all_tests || name.find(filter) != std::string::npos) {
464456
results[name] = setters_tests_encoding(SETTERS_TESTS_JSON);
465457
#if !ADA_HAS_ICU
466458
results[name] = true; // we pretend. The setters fail under Windows due to IDN issues.
467-
#endif // _WIN32
459+
#endif // !ADA_HAS_ICU
468460
}
469461
name = "setters_tests_encoding("+std::string(ADA_SETTERS_TESTS_JSON)+")";
470462
if(all_tests || name.find(filter) != std::string::npos) {
@@ -493,8 +485,6 @@ int main(int argc, char** argv) {
493485
std::cout << "==============="<< std::endl;
494486
#if ADA_HAS_ICU
495487
std::cout << "We are using ICU."<< std::endl;
496-
#elif defined(_WIN32)
497-
std::cout << "We are using Microsoft's Normaliz."<< std::endl;
498488
#else
499489
std::cout << "ICU is unavailable and we have no feedback."<< std::endl;
500490
#endif

0 commit comments

Comments
 (0)