From e626ba2688571ccd4d4748fee8bb11fe2f44e6ee Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Thu, 21 Oct 2021 18:22:53 +0200 Subject: [PATCH] replace _WINDOWS with _WIN32 --- CMakePresets.json | 5 ++++- include/mapnik/config.hpp | 2 +- include/mapnik/timer.hpp | 4 ++-- include/mapnik/util/file_io.hpp | 2 +- include/mapnik/util/utf_conv_win.hpp | 4 ++-- plugins/input/csv/csv_datasource.cpp | 4 ++-- plugins/input/csv/csv_featureset.cpp | 2 +- plugins/input/csv/csv_index_featureset.cpp | 2 +- plugins/input/geojson/geojson_index_featureset.cpp | 2 +- .../geojson/geojson_memory_index_featureset.cpp | 2 +- plugins/input/ogr/ogr_datasource.cpp | 2 +- plugins/input/postgis/numeric2string.hpp | 2 +- plugins/input/shape/dbfile.cpp | 2 +- plugins/input/shape/shapefile.hpp | 2 +- src/fs.cpp | 14 +++++++------- src/plugin.cpp | 4 ++-- src/rapidxml_loader.cpp | 2 +- src/svg/svg_parser.cpp | 2 +- src/util/utf_conv_win.cpp | 4 ++-- test/unit/datasource/ds_test_util.hpp | 4 ++-- test/unit/datasource/postgis.cpp | 2 +- test/unit/datasource/shapeindex.cpp | 4 ++-- utils/mapnik-index/process_csv_file.cpp | 2 +- utils/pgsql2sqlite/pgsql2sqlite.hpp | 2 +- utils/shapeindex/shapeindex.cpp | 7 ++++--- 25 files changed, 44 insertions(+), 40 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index 5f2a874f0..1206a07b8 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -14,7 +14,10 @@ { "name": "default-build-dir", "hidden": true, - "binaryDir": "${sourceDir}/build/${presetName}" + "binaryDir": "${sourceDir}/build/${presetName}", + "cacheVariables": { + "CMAKE_EXPORT_COMPILE_COMMANDS": "ON" + } }, { "name": "debug-build", diff --git a/include/mapnik/config.hpp b/include/mapnik/config.hpp index b337f1663..99f2bae3c 100644 --- a/include/mapnik/config.hpp +++ b/include/mapnik/config.hpp @@ -25,7 +25,7 @@ // Windows DLL support -#ifdef _WINDOWS +#ifdef _WIN32 # define MAPNIK_EXP __declspec (dllexport) # define MAPNIK_IMP __declspec (dllimport) # ifdef MAPNIK_EXPORTS diff --git a/include/mapnik/timer.hpp b/include/mapnik/timer.hpp index ccfd7648b..05097458c 100644 --- a/include/mapnik/timer.hpp +++ b/include/mapnik/timer.hpp @@ -30,7 +30,7 @@ #include #include -#ifdef _WINDOWS +#ifdef _WIN32 #define NOMINMAX #include #else @@ -45,7 +45,7 @@ namespace mapnik { // Try to return the time now inline double time_now() { -#ifdef _WINDOWS +#ifdef _WIN32 LARGE_INTEGER t, f; QueryPerformanceCounter(&t); QueryPerformanceFrequency(&f); diff --git a/include/mapnik/util/file_io.hpp b/include/mapnik/util/file_io.hpp index dd1262e7f..8bb39f1fb 100644 --- a/include/mapnik/util/file_io.hpp +++ b/include/mapnik/util/file_io.hpp @@ -42,7 +42,7 @@ public: using data_type = std::unique_ptr; explicit file(std::string const& filename) -#ifdef _WINDOWS +#ifdef _WIN32 : file_(_wfopen(mapnik::utf8_to_utf16(filename).c_str(), L"rb"), std::fclose), #else : file_(std::fopen(filename.c_str(),"rb"), std::fclose), diff --git a/include/mapnik/util/utf_conv_win.hpp b/include/mapnik/util/utf_conv_win.hpp index 04ee069a8..1a1f27a44 100644 --- a/include/mapnik/util/utf_conv_win.hpp +++ b/include/mapnik/util/utf_conv_win.hpp @@ -23,7 +23,7 @@ #ifndef MAPNIK_UTIL_UTF_CONV_WIN_HPP #define MAPNIK_UTIL_UTF_CONV_WIN_HPP -#ifdef _WINDOWS +#ifdef _WIN32 // mapnik #include // stl @@ -38,6 +38,6 @@ namespace mapnik MAPNIK_DECL std::wstring utf8_to_utf16(std::string const& str); } -#endif // _WINDOWS +#endif // _WIN32 #endif // MAPNIK_UTIL_UTF_CONV_WIN_HPP diff --git a/plugins/input/csv/csv_datasource.cpp b/plugins/input/csv/csv_datasource.cpp index 1eb94f121..9ae7d755a 100644 --- a/plugins/input/csv/csv_datasource.cpp +++ b/plugins/input/csv/csv_datasource.cpp @@ -136,7 +136,7 @@ csv_datasource::csv_datasource(parameters const& params) { throw std::runtime_error("could not create file mapping for " + filename_); } -#elif defined (_WINDOWS) +#elif defined (_WIN32) std::ifstream in(mapnik::utf8_to_utf16(filename_),std::ios_base::in | std::ios_base::binary); if (!in.is_open()) { @@ -368,7 +368,7 @@ boost::optional csv_datasource::get_geometry_type { if (inline_string_.empty()) { -#if defined (_WINDOWS) +#if defined (_WIN32) std::ifstream in(mapnik::utf8_to_utf16(filename_),std::ios_base::in | std::ios_base::binary); #else std::ifstream in(filename_.c_str(),std::ios_base::in | std::ios_base::binary); diff --git a/plugins/input/csv/csv_featureset.cpp b/plugins/input/csv/csv_featureset.cpp index 35db8ccb7..c0d6412bf 100644 --- a/plugins/input/csv/csv_featureset.cpp +++ b/plugins/input/csv/csv_featureset.cpp @@ -36,7 +36,7 @@ csv_featureset::csv_featureset(std::string const& filename, locator_type const& : #if defined(MAPNIK_MEMORY_MAPPED_FILE) // -#elif defined( _WINDOWS) +#elif defined( _WIN32) file_(_wfopen(mapnik::utf8_to_utf16(filename).c_str(), L"rb"), std::fclose), #else file_(std::fopen(filename.c_str(),"rb"), std::fclose), diff --git a/plugins/input/csv/csv_index_featureset.cpp b/plugins/input/csv/csv_index_featureset.cpp index 84b418d2a..0ca1cb305 100644 --- a/plugins/input/csv/csv_index_featureset.cpp +++ b/plugins/input/csv/csv_index_featureset.cpp @@ -49,7 +49,7 @@ csv_index_featureset::csv_index_featureset(std::string const& filename, tr_("utf8") #if defined(MAPNIK_MEMORY_MAPPED_FILE) // -#elif defined( _WINDOWS) +#elif defined( _WIN32) ,file_(_wfopen(mapnik::utf8_to_utf16(filename).c_str(), L"rb"), std::fclose) #else ,file_(std::fopen(filename.c_str(),"rb"), std::fclose) diff --git a/plugins/input/geojson/geojson_index_featureset.cpp b/plugins/input/geojson/geojson_index_featureset.cpp index ddace5311..2f0645d6f 100644 --- a/plugins/input/geojson/geojson_index_featureset.cpp +++ b/plugins/input/geojson/geojson_index_featureset.cpp @@ -39,7 +39,7 @@ geojson_index_featureset::geojson_index_featureset(std::string const& filename, : #if defined(MAPNIK_MEMORY_MAPPED_FILE) // -#elif defined _WINDOWS +#elif defined(_WIN32) file_(_wfopen(mapnik::utf8_to_utf16(filename).c_str(), L"rb"), std::fclose), #else file_(std::fopen(filename.c_str(),"rb"), std::fclose), diff --git a/plugins/input/geojson/geojson_memory_index_featureset.cpp b/plugins/input/geojson/geojson_memory_index_featureset.cpp index 5f43b8407..f510f4594 100644 --- a/plugins/input/geojson/geojson_memory_index_featureset.cpp +++ b/plugins/input/geojson/geojson_memory_index_featureset.cpp @@ -36,7 +36,7 @@ geojson_memory_index_featureset::geojson_memory_index_featureset(std::string const& filename, array_type && index_array) : -#ifdef _WINDOWS +#ifdef _WIN32 file_(_wfopen(mapnik::utf8_to_utf16(filename).c_str(), L"rb"), std::fclose), #else file_(std::fopen(filename.c_str(),"rb"), std::fclose), diff --git a/plugins/input/ogr/ogr_datasource.cpp b/plugins/input/ogr/ogr_datasource.cpp index 186be5d1e..bf2652690 100644 --- a/plugins/input/ogr/ogr_datasource.cpp +++ b/plugins/input/ogr/ogr_datasource.cpp @@ -301,7 +301,7 @@ void ogr_datasource::init(mapnik::parameters const& params) } index_name_ = dataset_name_.substr(0, breakpoint) + ".ogrindex"; -#if defined (_WINDOWS) +#if defined (_WIN32) std::ifstream index_file(mapnik::utf8_to_utf16(index_name_), std::ios::in | std::ios::binary); #else std::ifstream index_file(index_name_.c_str(), std::ios::in | std::ios::binary); diff --git a/plugins/input/postgis/numeric2string.hpp b/plugins/input/postgis/numeric2string.hpp index 1c6ec8d7d..c95f00d0c 100644 --- a/plugins/input/postgis/numeric2string.hpp +++ b/plugins/input/postgis/numeric2string.hpp @@ -61,7 +61,7 @@ static inline std::string numeric2string(const char* buf) // All digits after the first must be padded to make the field 4 characters long if (d != 0) { -#ifdef _WINDOWS +#ifdef _WIN32 int dig = digits[d]; if (dig < 10) { diff --git a/plugins/input/shape/dbfile.cpp b/plugins/input/shape/dbfile.cpp index 7f41edc01..5bc46c3e2 100644 --- a/plugins/input/shape/dbfile.cpp +++ b/plugins/input/shape/dbfile.cpp @@ -56,7 +56,7 @@ dbf_file::dbf_file(std::string const& file_name) record_length_(0), #if defined(MAPNIK_MEMORY_MAPPED_FILE) file_(), -#elif defined(_WINDOWS) +#elif defined(_WIN32) file_(mapnik::utf8_to_utf16(file_name), std::ios::in | std::ios::binary), #else file_(file_name.c_str() ,std::ios::in | std::ios::binary), diff --git a/plugins/input/shape/shapefile.hpp b/plugins/input/shape/shapefile.hpp index 615a018c7..72ad4be7f 100644 --- a/plugins/input/shape/shapefile.hpp +++ b/plugins/input/shape/shapefile.hpp @@ -163,7 +163,7 @@ public: shape_file(std::string const& file_name) : #if defined(MAPNIK_MEMORY_MAPPED_FILE) file_() -#elif defined (_WINDOWS) +#elif defined(_WIN32) file_(mapnik::utf8_to_utf16(file_name), std::ios::in | std::ios::binary) #else file_(file_name.c_str(), std::ios::in | std::ios::binary) diff --git a/src/fs.cpp b/src/fs.cpp index b0921276e..52fac8754 100644 --- a/src/fs.cpp +++ b/src/fs.cpp @@ -41,7 +41,7 @@ namespace util { bool exists(std::string const& filepath) { -#ifdef _WINDOWS +#ifdef _WIN32 return boost::filesystem::exists(mapnik::utf8_to_utf16(filepath)); #else return boost::filesystem::exists(filepath); @@ -50,7 +50,7 @@ namespace util { bool is_directory(std::string const& filepath) { -#ifdef _WINDOWS +#ifdef _WIN32 return boost::filesystem::is_directory(mapnik::utf8_to_utf16(filepath)); #else return boost::filesystem::is_directory(filepath); @@ -59,7 +59,7 @@ namespace util { bool is_regular_file(std::string const& filepath) { -#ifdef _WINDOWS +#ifdef _WIN32 return boost::filesystem::is_regular_file(mapnik::utf8_to_utf16(filepath)); #else return boost::filesystem::is_regular_file(filepath); @@ -68,7 +68,7 @@ namespace util { bool remove(std::string const& filepath) { -#ifdef _WINDOWS +#ifdef _WIN32 return boost::filesystem::remove(mapnik::utf8_to_utf16(filepath)); #else return boost::filesystem::remove(filepath); @@ -78,7 +78,7 @@ namespace util { bool is_relative(std::string const& filepath) { -#ifdef _WINDOWS +#ifdef _WIN32 boost::filesystem::path child_path(mapnik::utf8_to_utf16(filepath)); #else boost::filesystem::path child_path(filepath); @@ -88,7 +88,7 @@ namespace util { std::string make_relative(std::string const& filepath, std::string const& base) { -#ifdef _WINDOWS +#ifdef _WIN32 boost::filesystem::path absolute_path(mapnik::utf8_to_utf16(base)); #else boost::filesystem::path absolute_path(base); @@ -123,7 +123,7 @@ namespace util { { std::vector listing; boost::filesystem::directory_iterator end_itr; -#ifdef _WINDOWS +#ifdef _WIN32 std::wstring wide_dir(mapnik::utf8_to_utf16(dir)); for (boost::filesystem::directory_iterator itr(wide_dir); itr != end_itr; ++itr) { diff --git a/src/plugin.cpp b/src/plugin.cpp index 22e0c54a2..281bc02f8 100644 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -23,7 +23,7 @@ #include #include -#ifdef _WINDOWS +#ifdef _WIN32 #define NOMINMAX #include #define handle HMODULE @@ -54,7 +54,7 @@ PluginInfo::PluginInfo(std::string const& filename, name_(), module_(new mapnik_lib_t) { -#ifdef _WINDOWS +#ifdef _WIN32 if (module_) module_->dl = LoadLibraryA(filename.c_str()); if (module_ && module_->dl) { diff --git a/src/rapidxml_loader.cpp b/src/rapidxml_loader.cpp index 192f4d880..c20e7c885 100644 --- a/src/rapidxml_loader.cpp +++ b/src/rapidxml_loader.cpp @@ -62,7 +62,7 @@ public: throw config_error(std::string("Could not load map file: File does not exist"), 0, filename); } filename_ = filename; -#ifdef _WINDOWS +#ifdef _WIN32 std::basic_ifstream stream(mapnik::utf8_to_utf16(filename)); #else std::basic_ifstream stream(filename.c_str()); diff --git a/src/svg/svg_parser.cpp b/src/svg/svg_parser.cpp index 64b2e425d..9c03c2253 100644 --- a/src/svg/svg_parser.cpp +++ b/src/svg/svg_parser.cpp @@ -1604,7 +1604,7 @@ svg_parser::~svg_parser() {} void svg_parser::parse(std::string const& filename) { -#ifdef _WINDOWS +#ifdef _WIN32 std::basic_ifstream stream(mapnik::utf8_to_utf16(filename)); #else std::basic_ifstream stream(filename.c_str()); diff --git a/src/util/utf_conv_win.cpp b/src/util/utf_conv_win.cpp index 9cb47a7b7..8ca563de4 100644 --- a/src/util/utf_conv_win.cpp +++ b/src/util/utf_conv_win.cpp @@ -20,7 +20,7 @@ * *****************************************************************************/ -#ifdef _WINDOWS +#ifdef _WIN32 // windows specific methods for UTF8 from/to UTF16 #include #include @@ -58,4 +58,4 @@ std::wstring utf8_to_utf16 (std::string const& str) } // namespace mapnik -#endif // _WINDOWS +#endif // _WIN32 diff --git a/test/unit/datasource/ds_test_util.hpp b/test/unit/datasource/ds_test_util.hpp index 09237b067..7a8ab126c 100644 --- a/test/unit/datasource/ds_test_util.hpp +++ b/test/unit/datasource/ds_test_util.hpp @@ -200,13 +200,13 @@ inline int create_disk_index(std::string const& filename, bool silent = true) cmd += std::string("DYLD_LIBRARY_PATH=") + std::getenv("DYLD_LIBRARY_PATH") + " "; } cmd += "mapnik-index"; -#ifdef _WINDOWS +#ifdef _WIN32 cmd += ".exe"; #endif cmd += " " + filename; if (silent) { -#ifndef _WINDOWS +#ifndef _WIN32 cmd += " 2>/dev/null"; #else cmd += " 2> nul"; diff --git a/test/unit/datasource/postgis.cpp b/test/unit/datasource/postgis.cpp index 5812563df..45191971e 100644 --- a/test/unit/datasource/postgis.cpp +++ b/test/unit/datasource/postgis.cpp @@ -50,7 +50,7 @@ bool run(std::string const& command, bool okay_to_fail = false) // silence output unless MAPNIK_TEST_DEBUG is defined if (std::getenv("MAPNIK_TEST_DEBUG") == nullptr) { -#ifndef _WINDOWS +#ifndef _WIN32 cmd += " 2>/dev/null"; #else cmd += " 2> nul"; diff --git a/test/unit/datasource/shapeindex.cpp b/test/unit/datasource/shapeindex.cpp index 6ebd253a0..22d391ad1 100644 --- a/test/unit/datasource/shapeindex.cpp +++ b/test/unit/datasource/shapeindex.cpp @@ -75,7 +75,7 @@ int create_shapefile_index(std::string const& filename, bool index_parts, bool s cmd += std::string("DYLD_LIBRARY_PATH=") + std::getenv("DYLD_LIBRARY_PATH") + " "; } cmd += "shapeindex"; -#ifdef _WINDOWS +#ifdef _WIN32 cmd += ".exe"; #endif cmd += " "; @@ -83,7 +83,7 @@ int create_shapefile_index(std::string const& filename, bool index_parts, bool s cmd += filename; if (silent) { -#ifndef _WINDOWS +#ifndef _WIN32 cmd += " 2>/dev/null"; #else cmd += " 2> nul"; diff --git a/utils/mapnik-index/process_csv_file.cpp b/utils/mapnik-index/process_csv_file.cpp index 1f703fb4a..11739073a 100644 --- a/utils/mapnik-index/process_csv_file.cpp +++ b/utils/mapnik-index/process_csv_file.cpp @@ -70,7 +70,7 @@ std::pair process_csv_file(T & boxes, s return std::make_pair(false, box_type(p.extent_)); } #else - #if defined(_WINDOWS) + #if defined(_WIN32) std::ifstream csv_file(mapnik::utf8_to_utf16(filename),std::ios_base::in | std::ios_base::binary); #else std::ifstream csv_file(filename.c_str(),std::ios_base::in | std::ios_base::binary); diff --git a/utils/pgsql2sqlite/pgsql2sqlite.hpp b/utils/pgsql2sqlite/pgsql2sqlite.hpp index 072869881..67cd18845 100644 --- a/utils/pgsql2sqlite/pgsql2sqlite.hpp +++ b/utils/pgsql2sqlite/pgsql2sqlite.hpp @@ -79,7 +79,7 @@ static std::string numeric2string(const char* buf) // All digits after the first must be padded to make the field 4 characters long if (d != 0) { -#ifdef _WINDOWS +#ifdef _WIN32 int dig = digits[d]; if (dig < 10) { diff --git a/utils/shapeindex/shapeindex.cpp b/utils/shapeindex/shapeindex.cpp index 8c8fa5ccf..cc6fd7315 100644 --- a/utils/shapeindex/shapeindex.cpp +++ b/utils/shapeindex/shapeindex.cpp @@ -41,7 +41,8 @@ MAPNIK_DISABLE_WARNING_POP const int DEFAULT_DEPTH = 8; const double DEFAULT_RATIO = 0.55; -#ifdef _WINDOWS +#ifdef _WIN32 +#define NOMINMAX #include int main () #else @@ -73,7 +74,7 @@ int main (int argc,char** argv) po::positional_options_description p; p.add("shape_files",-1); po::variables_map vm; -#ifdef _WINDOWS +#ifdef _WIN32 std::vector args; const auto wargs = po::split_winmain(GetCommandLineW()); for( auto it = wargs.begin() + 1; it != wargs.end(); ++it ) @@ -292,7 +293,7 @@ int main (int argc,char** argv) if (count > 0) { std::clog << " number shapes=" << count << std::endl; -#ifdef _WINDOWS +#ifdef _WIN32 std::ofstream file(mapnik::utf8_to_utf16(shapename+".index").c_str(), std::ios::trunc | std::ios::binary); #else std::ofstream file((shapename+".index").c_str(), std::ios::trunc | std::ios::binary);