From 1a4568175c68f9ea4b8d5b2272832ffbedff1126 Mon Sep 17 00:00:00 2001 From: Julian Smith Date: Wed, 6 Nov 2019 19:07:50 +0000 Subject: [PATCH] simgear/environment/metar.*: getDescription() can now also use single spaces. If param is -1, all sequences of tabs are replaced by a single space. --- simgear/environment/metar.cxx | 8 ++++++++ simgear/environment/metar.hxx | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/simgear/environment/metar.cxx b/simgear/environment/metar.cxx index 898f76d4..9d9c944f 100644 --- a/simgear/environment/metar.cxx +++ b/simgear/environment/metar.cxx @@ -203,6 +203,14 @@ std::ostream& operator << (std::ostream& out, const Tab& t) std::ostringstream& out2 = *(std::ostringstream*) &out; std::string s = out2.str(); + + if (t._stops < 0) { + if (!s.size() || s[s.size()-1] != ' ') { + out << ' '; + } + return out; + } + auto nl = s.rfind('\n'); if (nl < 0) nl = 0; int column = 0; diff --git a/simgear/environment/metar.hxx b/simgear/environment/metar.hxx index 3b08602b..a92bf1a5 100644 --- a/simgear/environment/metar.hxx +++ b/simgear/environment/metar.hxx @@ -236,8 +236,8 @@ public: inline const std::vector getWeather2() const { return _weather2; } /* Returns human-readable description. If tabtops is 0, we use tab - characters, otherwise we use spaces to pad to multiple of . - */ + characters. If +ve we use spaces to pad to multiple of . If + -1 all sequences of tabs are represented by a single space. */ std::string getDescription(int tabstops) const; protected: