diff options
-rw-r--r-- | lm/Jamfile | 4 | ||||
-rw-r--r-- | lm/builder/Jamfile | 5 | ||||
-rw-r--r-- | util/exception.hh | 8 | ||||
-rw-r--r-- | util/read_compressed.cc | 11 | ||||
-rw-r--r-- | util/read_compressed.hh | 4 |
5 files changed, 22 insertions, 10 deletions
diff --git a/lm/Jamfile b/lm/Jamfile index 0f0297ffa..227b22014 100644 --- a/lm/Jamfile +++ b/lm/Jamfile @@ -37,6 +37,4 @@ for local p in [ glob *_main.cc ] { exes += $(name) ; } -#alias programs : $(exes) filter//filter builder//dump_counts : <threading>multi:<source>builder//lmplz ; -alias programs : $(exes) filter//filter : <threading>multi:<source>builder//lmplz ; - +alias programs : $(exes) filter//filter builder//dump_counts : <threading>multi:<source>builder//lmplz ; diff --git a/lm/builder/Jamfile b/lm/builder/Jamfile index 2e472e222..1e0e18b5f 100644 --- a/lm/builder/Jamfile +++ b/lm/builder/Jamfile @@ -4,10 +4,9 @@ fakelib builder : [ glob *.cc : *test.cc *main.cc ] exe lmplz : lmplz_main.cc builder /top//boost_program_options ; -#exe dump_counts : dump_counts_main.cc builder ; +exe dump_counts : dump_counts_main.cc builder ; -#alias programs : lmplz dump_counts ; -alias programs : lmplz ; +alias programs : lmplz dump_counts ; import testing ; unit-test corpus_count_test : corpus_count_test.cc builder /top//boost_unit_test_framework ; diff --git a/util/exception.hh b/util/exception.hh index 2fb00667f..4e50a6f3a 100644 --- a/util/exception.hh +++ b/util/exception.hh @@ -1,5 +1,5 @@ -#ifndef UTIL_EXCEPTION__ -#define UTIL_EXCEPTION__ +#ifndef UTIL_EXCEPTION_H +#define UTIL_EXCEPTION_H #include <exception> #include <limits> @@ -84,7 +84,7 @@ template <class Except, class Data> typename Except::template ExceptionTag<Excep UTIL_THROW_BACKEND(NULL, Exception, , Modify); #define UTIL_THROW2(Modify) \ - UTIL_THROW_BACKEND(NULL, util::Exception, , Modify); + UTIL_THROW_BACKEND(NULL, util::Exception, , Modify); #if __GNUC__ >= 3 #define UTIL_UNLIKELY(x) __builtin_expect (!!(x), 0) @@ -146,4 +146,4 @@ inline std::size_t CheckOverflow(uint64_t value) { } // namespace util -#endif // UTIL_EXCEPTION__ +#endif // UTIL_EXCEPTION_H diff --git a/util/read_compressed.cc b/util/read_compressed.cc index 71ef0e251..e1f4cd7e3 100644 --- a/util/read_compressed.cc +++ b/util/read_compressed.cc @@ -435,4 +435,15 @@ std::size_t ReadCompressed::Read(void *to, std::size_t amount) { return internal_->Read(to, amount, *this); } +std::size_t ReadCompressed::ReadOrEOF(void *const to_in, std::size_t amount) { + uint8_t *to = reinterpret_cast<uint8_t*>(to_in); + while (amount) { + std::size_t got = Read(to, amount); + if (!got) break; + to += got; + amount -= got; + } + return to - reinterpret_cast<uint8_t*>(to_in); +} + } // namespace util diff --git a/util/read_compressed.hh b/util/read_compressed.hh index 763e6bbd3..767ee94b2 100644 --- a/util/read_compressed.hh +++ b/util/read_compressed.hh @@ -62,6 +62,10 @@ class ReadCompressed { std::size_t Read(void *to, std::size_t amount); + // Repeatedly call read to fill a buffer unless EOF is hit. + // Return number of bytes read. + std::size_t ReadOrEOF(void *const to, std::size_t amount); + uint64_t RawAmount() const { return raw_amount_; } private: |