summaryrefslogtreecommitdiff
path: root/src/item.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-03 18:46:19 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-03 19:06:53 -0400
commit2ce7ae376c1e3de0b952d6bb8125f68fc99813d0 (patch)
tree05b79eea2f8d21ec77f19f33f85f0515a17111b3 /src/item.cc
parent8948e161cd64bbd9ed3e3dfccae5fdb03e8e8251 (diff)
downloadfork-ledger-2ce7ae376c1e3de0b952d6bb8125f68fc99813d0.tar.gz
fork-ledger-2ce7ae376c1e3de0b952d6bb8125f68fc99813d0.tar.bz2
fork-ledger-2ce7ae376c1e3de0b952d6bb8125f68fc99813d0.zip
Removed used of src_idx.
Diffstat (limited to 'src/item.cc')
-rw-r--r--src/item.cc62
1 files changed, 28 insertions, 34 deletions
diff --git a/src/item.cc b/src/item.cc
index 175797ff..02983ba1 100644
--- a/src/item.cc
+++ b/src/item.cc
@@ -310,44 +310,38 @@ bool item_t::valid() const
string item_context(const item_t& item)
{
- unsigned short x = 0;
- foreach (const path& path, item.journal->sources) {
- if (x++ == item.src_idx) {
- std::size_t len = item.end_pos - item.beg_pos;
- assert(len > 0);
- assert(len < 2048);
- ifstream in(path);
- in.seekg(item.beg_pos, std::ios::beg);
+ std::size_t len = item.end_pos - item.beg_pos;
+ assert(len > 0);
+ assert(len < 2048);
+
+ ifstream in(item.pathname);
+ in.seekg(item.beg_pos, std::ios::beg);
- scoped_array<char> buf(new char[len + 1]);
- in.read(buf.get(), len);
+ scoped_array<char> buf(new char[len + 1]);
+ in.read(buf.get(), len);
- std::ostringstream out;
+ std::ostringstream out;
- out << "While balancing item from \"" << path.string()
- << "\"";
-
- if (item.beg_line != (item.end_line - 1))
- out << ", lines " << item.beg_line << "-"
- << (item.end_line - 1) << ":\n";
- else
- out << ", line " << item.beg_line << ":\n";
-
- bool first = true;
- for (char * p = std::strtok(buf.get(), "\n");
- p;
- p = std::strtok(NULL, "\n")) {
- if (first)
- first = false;
- else
- out << '\n';
- out << "> " << p;
- }
- return out.str();
- }
+ out << "While balancing item from \"" << item.pathname.string()
+ << "\"";
+
+ if (item.beg_line != (item.end_line - 1))
+ out << ", lines " << item.beg_line << "-"
+ << (item.end_line - 1) << ":\n";
+ else
+ out << ", line " << item.beg_line << ":\n";
+
+ bool first = true;
+ for (char * p = std::strtok(buf.get(), "\n");
+ p;
+ p = std::strtok(NULL, "\n")) {
+ if (first)
+ first = false;
+ else
+ out << '\n';
+ out << "> " << p;
}
- assert(false);
- return empty_string;
+ return out.str();
}
} // namespace ledger