From 1771f788a5b9e844f0a5315faee104648e3b7d88 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Tue, 31 Jan 2023 18:19:40 +0100 Subject: Fix build of v1.5 --- Makefile | 2 +- diff.cpp | 45 +++++---------------------------------------- tests/test-whiteboard.cpp | 1 + webassembly/Makefile | 4 +++- 4 files changed, 10 insertions(+), 42 deletions(-) diff --git a/Makefile b/Makefile index d0a4b31..27b9a6c 100755 --- a/Makefile +++ b/Makefile @@ -76,7 +76,7 @@ dist: clean rm -rf $(PROJECTNAME)-$(VERSION) ls -l ../$(PROJECTNAME)-$(VERSION).tar.xz -upload: +upload: dist scp ../$(TGZNAME) antcom.de:/var/www/reichwein.it-download/ scp -r result antcom.de: scp -r remote-install.sh antcom.de: diff --git a/diff.cpp b/diff.cpp index 35ff270..6ac24e7 100644 --- a/diff.cpp +++ b/diff.cpp @@ -5,44 +5,9 @@ #include #include -#include -#include -#include -#include namespace pt = boost::property_tree; -namespace { - -// prevent usage of same functions from libreichwein to keep unit self-contained - -std::string decode64(const std::string &val) -{ -#if 0 - using namespace boost::archive::iterators; - using It = transform_width, 8, 6>; - return boost::algorithm::trim_right_copy_if(std::string(It(std::begin(val)), It(std::end(val))), [](char c) { - return c == '\0'; - }); -#else - return val; -#endif -} - -std::string encode64(const std::string &val) -{ -#if 0 - using namespace boost::archive::iterators; - using It = base64_from_binary>; - auto tmp = std::string(It(std::begin(val)), It(std::end(val))); - return tmp.append((3 - val.size() % 3) % 3, '='); -#else - return val; -#endif -} - -} // namespace - Diff::Diff() { } @@ -58,7 +23,7 @@ std::string Diff::apply(const std::string& old_version) const if (m_pos0 <= m_pos1 && m_pos1 <= old_version.size()) { result.erase(m_pos0, m_pos1 - m_pos0); - result.insert(m_pos0, decode64(m_data)); + result.insert(m_pos0, m_data); } return result; @@ -82,7 +47,7 @@ void Diff::create(const std::string& old_version, const std::string& new_version if (old_pos0 == old_version.size()) { m_pos0 = old_pos0; m_pos1 = old_pos0; - m_data = encode64(new_version.substr(new_pos0)); + m_data = new_version.substr(new_pos0); return; } @@ -105,7 +70,7 @@ void Diff::create(const std::string& old_version, const std::string& new_version if (old_pos1 == 0) { m_pos0 = 0; m_pos1 = 0; - m_data = encode64(new_version.substr(0, new_pos1)); + m_data = new_version.substr(0, new_pos1); return; } @@ -131,7 +96,7 @@ void Diff::create(const std::string& old_version, const std::string& new_version if (old_pos0 == old_pos1) { m_pos0 = old_pos0; m_pos1 = old_pos0; - m_data = encode64(new_version.substr(new_pos0, new_pos1 - new_pos0)); + m_data = new_version.substr(new_pos0, new_pos1 - new_pos0); return; } @@ -146,7 +111,7 @@ void Diff::create(const std::string& old_version, const std::string& new_version // last resort: remove and add in the middle m_pos0 = old_pos0; m_pos1 = old_pos1; - m_data = encode64(new_version.substr(old_pos0, new_pos1 - new_pos0)); + m_data = new_version.substr(old_pos0, new_pos1 - new_pos0); } Diff::Diff(const boost::property_tree::ptree& ptree) diff --git a/tests/test-whiteboard.cpp b/tests/test-whiteboard.cpp index 9e6b7fb..bed2e5a 100644 --- a/tests/test-whiteboard.cpp +++ b/tests/test-whiteboard.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include diff --git a/webassembly/Makefile b/webassembly/Makefile index 49a5ed3..0487d2a 100644 --- a/webassembly/Makefile +++ b/webassembly/Makefile @@ -6,7 +6,7 @@ OBJS=diff.o CXX=em++ CXXFLAGS=-I./include -O2 -std=c++20 -LDFLAGS=-s WASM=1 -s EXPORTED_FUNCTIONS=_diff_create,_diff_apply,_free +LDFLAGS=-s WASM=1 -s EXPORTED_FUNCTIONS="['_diff_create', '_diff_apply', '_free']" # Note: Instead of the above explicit EXPORTED_FUNCTIONS, the following causes ~7x wasm file size: #-s LINKABLE=1 -s EXPORT_ALL=1 @@ -24,6 +24,8 @@ $(TARGET): $(OBJS) diff.o: ../diff.cpp $(CXX) -c $< $(CXXFLAGS) -o $@ + # run again in case em++ just asked to re-run (on pbuilder/buildd) + test -e $@ || $(CXX) -c $< $(CXXFLAGS) -o $@ clean: -rm -f *.o *.js *.wasm *.html -- cgit v1.2.3