From fb4e3c1b4c2aae6fd8a44e7727e6f73aa4db2ca8 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 21 Apr 2023 11:20:42 +0200 Subject: Add blank line between packages.manifest entries in bdep-new --- bdep/new.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bdep/new.cxx b/bdep/new.cxx index 753b8f3..2c954fc 100644 --- a/bdep/new.cxx +++ b/bdep/new.cxx @@ -3220,10 +3220,16 @@ cmd_new (cmd_new_options&& o, cli::group_scanner& args) bool e (exists (f)); try { + // Note: add an extra newline if appending to an existing file. While + // this will normally result in an extra blank line between entries + // which we don't really need, it will also make sure we don't generate + // invalid file if there is no newline at the end of file (which can + // happen if the file was edited manually). + // ofdstream os (f, (fdopen_mode::out | fdopen_mode::create | fdopen_mode::append)); - os << (e ? ":" : ": 1") << '\n' + os << (e ? "\n:" : ": 1") << '\n' << "location: " << pkg->posix_representation () << '\n'; os.close (); } -- cgit v1.1