summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2015-02-02 03:33:43 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2015-02-02 03:33:43 +0100
commita3d6648fa6c0138e1d02408a117f87cbd3407e80 (patch)
tree034565465a770e53359a04addfcbc5009c9187a2
parentbedd81dce673a693e61e81e85ef0b2870e22e5c1 (diff)
downloadMinedMap-a3d6648fa6c0138e1d02408a117f87cbd3407e80.tar
MinedMap-a3d6648fa6c0138e1d02408a117f87cbd3407e80.zip
Workaround for old libraries without regex support
-rw-r--r--src/MinedMap.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/MinedMap.cpp b/src/MinedMap.cpp
index 7e7d249..6207306 100644
--- a/src/MinedMap.cpp
+++ b/src/MinedMap.cpp
@@ -33,7 +33,6 @@
#include <cstring>
#include <cstdlib>
#include <iostream>
-#include <regex>
#include <system_error>
#include <sys/types.h>
@@ -134,8 +133,6 @@ static void doRegion(const std::string &input, const std::string &output) {
}
int main(int argc, char *argv[]) {
- static const std::regex re("r\\.(-?\\d+)\\.(-?\\d+)\\.mca");
-
if (argc < 3) {
std::fprintf(stderr, "Usage: %s <data directory> <output directory>\n", argv[0]);
return 1;
@@ -156,15 +153,19 @@ int main(int argc, char *argv[]) {
struct dirent *entry;
while ((entry = readdir(dir)) != nullptr) {
- std::cmatch m;
- if (std::regex_match(entry->d_name, m, re)) {
- int x = std::atoi(m[1].str().c_str());
+ int x, z;
+ if (std::sscanf(entry->d_name, "r.%i.%i.mca", &x, &z) == 2) {
+ size_t l = strlen(entry->d_name) + 1;
+ char buf[l];
+ std::snprintf(buf, l, "r.%i.%i.mca", x, z);
+ if (std::memcmp(entry->d_name, buf, l))
+ continue;
+
if (x < minX)
minX = x;
if (x > maxX)
maxX = x;
- int z = std::atoi(m[2].str().c_str());
if (z < minZ)
minZ = z;
if (z > maxZ)