aboutsummaryrefslogtreecommitdiff
path: root/src/lib/util.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/util.cc')
-rw-r--r--src/lib/util.cc15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/lib/util.cc b/src/lib/util.cc
index f754da5..ab877fd 100644
--- a/src/lib/util.cc
+++ b/src/lib/util.cc
@@ -21,6 +21,7 @@
#include <cctype>
#include <string>
#include <fst/util.h>
+#include <fst/mapped-file.h>
// Utility flag definitions
@@ -31,7 +32,7 @@ DEFINE_bool(fst_error_fatal, true,
namespace fst {
int64 StrToInt64(const string &s, const string &src, size_t nline,
- bool allow_negative = false, bool *error) {
+ bool allow_negative, bool *error) {
int64 n;
const char *cs = s.c_str();
char *p;
@@ -59,15 +60,15 @@ void ConvertToLegalCSymbol(string *s) {
// Skips over input characters to align to 'align' bytes. Returns
// false if can't align.
-bool AlignInput(istream &strm, int align) {
+bool AlignInput(istream &strm) {
char c;
- for (int i = 0; i < align; ++i) {
+ for (int i = 0; i < MappedFile::kArchAlignment; ++i) {
int64 pos = strm.tellg();
if (pos < 0) {
LOG(ERROR) << "AlignInput: can't determine stream position";
return false;
}
- if (pos % align == 0) break;
+ if (pos % MappedFile::kArchAlignment == 0) break;
strm.read(&c, 1);
}
return true;
@@ -75,14 +76,14 @@ bool AlignInput(istream &strm, int align) {
// Write null output characters to align to 'align' bytes. Returns
// false if can't align.
-bool AlignOutput(ostream &strm, int align) {
- for (int i = 0; i < align; ++i) {
+bool AlignOutput(ostream &strm) {
+ for (int i = 0; i < MappedFile::kArchAlignment; ++i) {
int64 pos = strm.tellp();
if (pos < 0) {
LOG(ERROR) << "AlignOutput: can't determine stream position";
return false;
}
- if (pos % align == 0) break;
+ if (pos % MappedFile::kArchAlignment == 0) break;
strm.write("", 1);
}
return true;