diff options
author | Roland Reichwein <mail@reichwein.it> | 2023-01-31 18:19:40 +0100 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2023-01-31 18:19:40 +0100 |
commit | 1771f788a5b9e844f0a5315faee104648e3b7d88 (patch) | |
tree | 6ed215805b1654060ef7ae4ad939fed306b1be58 | |
parent | 8d1b4f06375bf676c5cf825ba4b116271f3d44c5 (diff) |
Fix build of v1.5
-rwxr-xr-x | Makefile | 2 | ||||
-rw-r--r-- | diff.cpp | 45 | ||||
-rw-r--r-- | tests/test-whiteboard.cpp | 1 | ||||
-rw-r--r-- | webassembly/Makefile | 4 |
4 files changed, 10 insertions, 42 deletions
@@ -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: @@ -5,44 +5,9 @@ #include <sstream> #include <boost/property_tree/xml_parser.hpp> -#include <boost/archive/iterators/binary_from_base64.hpp> -#include <boost/archive/iterators/base64_from_binary.hpp> -#include <boost/archive/iterators/transform_width.hpp> -#include <boost/algorithm/string.hpp> 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<binary_from_base64<std::string::const_iterator>, 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<transform_width<std::string::const_iterator, 6, 8>>; - 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 <regex> #include <string> #include <system_error> +#include <thread> #include <boost/process/child.hpp> #include <boost/algorithm/string.hpp> 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 |