X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/eaf690a700e53258294d48145c1d5fa93147821e..7d1aa2d6365c103a4ae5e4c336b7c8bc3234df4f:/data/location.cc
diff --git a/data/location.cc b/data/location.cc
index b65bf490..987843b2 100644
--- a/data/location.cc
+++ b/data/location.cc
@@ -1,6 +1,6 @@
# C++ skeleton for Bison
-# Copyright (C) 2002-2012 Free Software Foundation, Inc.
+# Copyright (C) 2002-2013 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -16,7 +16,7 @@
# along with this program. If not, see .
m4_pushdef([b4_copyright_years],
- [2002-2012])
+ [2002-2013])
# b4_position_define
# ------------------
@@ -253,16 +253,17 @@ m4_define([b4_location_define],
inline std::basic_ostream&
operator<< (std::basic_ostream& ostr, const location& loc)
{
- position last = loc.end - 1;
- ostr << loc.begin;
- if (last.filename
+ unsigned int end_col = 0 < loc.end.column ? loc.end.column - 1 : 0;
+ ostr << loc.begin// << "(" << loc.end << ") "
+;
+ if (loc.end.filename
&& (!loc.begin.filename
- || *loc.begin.filename != *last.filename))
- ostr << '-' << last;
- else if (loc.begin.line != last.line)
- ostr << '-' << last.line << '.' << last.column;
- else if (loc.begin.column != last.column)
- ostr << '-' << last.column;
+ || *loc.begin.filename != *loc.end.filename))
+ ostr << '-' << loc.end.filename << ':' << loc.end.line << '.' << end_col;
+ else if (loc.begin.line < loc.end.line)
+ ostr << '-' << loc.end.line << '.' << end_col;
+ else if (loc.begin.column < end_col)
+ ostr << '-' << end_col;
return ostr;
}
]])