From bf497c1f7716e6d904245409bfe65cb8970fe4ae Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 26 Jul 2017 11:51:45 +0200 Subject: Implement module map storage in .d, use -fmodule-file-map in GCC --- build2/depdb.cxx | 45 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) (limited to 'build2/depdb.cxx') diff --git a/build2/depdb.cxx b/build2/depdb.cxx index 5aa2970..c74536c 100644 --- a/build2/depdb.cxx +++ b/build2/depdb.cxx @@ -123,8 +123,41 @@ namespace build2 return &line_; } + bool depdb:: + skip () + { + if (state_ == state::read_eof) + return true; + + assert (state_ == state::read); + + // The rest is pretty similar in logic to read_() above. + // + pos_ = fs_.tellg (); + + // Keep reading lines checking for the end marker after each newline. + // + fstream::int_type c; + do + { + if ((c = fs_.get ()) == '\n') + { + if ((c = fs_.get ()) == '\0') + { + state_ = state::read_eof; + return true; + } + } + } while (c != fstream::traits_type::eof ()); + + // Invalid database so change over to writing. + // + change (); + return false; + } + void depdb:: - write (const char* s, size_t n) + write (const char* s, size_t n, bool nl) { // Switch to writing if we are still reading. // @@ -132,11 +165,13 @@ namespace build2 change (); fs_.write (s, static_cast (n)); - fs_.put ('\n'); + + if (nl) + fs_.put ('\n'); } void depdb:: - write (char c) + write (char c, bool nl) { // Switch to writing if we are still reading. // @@ -144,7 +179,9 @@ namespace build2 change (); fs_.put (c); - fs_.put ('\n'); + + if (nl) + fs_.put ('\n'); } void depdb:: -- cgit v1.1