aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bdep/diagnostics.cxx15
-rw-r--r--bdep/diagnostics.hxx9
2 files changed, 22 insertions, 2 deletions
diff --git a/bdep/diagnostics.cxx b/bdep/diagnostics.cxx
index 0861056..e1f5f6a 100644
--- a/bdep/diagnostics.cxx
+++ b/bdep/diagnostics.cxx
@@ -51,7 +51,20 @@ namespace bdep
void location_prologue_base::
operator() (const diag_record& r) const
{
- r << loc_.file << ':' << loc_.line << ':' << loc_.column << ": ";
+ if (!loc_.empty ())
+ {
+ r << loc_.file << ':';
+
+ if (loc_.line != 0)
+ {
+ r << loc_.line << ':';
+
+ if (loc_.column != 0)
+ r << loc_.column << ':';
+ }
+
+ r << ' ';
+ }
if (type_ != nullptr)
r << type_ << ": ";
diff --git a/bdep/diagnostics.hxx b/bdep/diagnostics.hxx
index b094457..521af23 100644
--- a/bdep/diagnostics.hxx
+++ b/bdep/diagnostics.hxx
@@ -95,10 +95,17 @@ namespace bdep
class location
{
public:
- location () {}
+ // Zero lines or columns are not printed.
+ //
+ explicit
location (string f, uint64_t l, uint64_t c)
: file (move (f)), line (l), column (c) {}
+ location () = default;
+
+ bool
+ empty () const {return file.empty ();}
+
string file;
uint64_t line;
uint64_t column;