summaryrefslogtreecommitdiff
path: root/textual.cc
diff options
context:
space:
mode:
Diffstat (limited to 'textual.cc')
-rw-r--r--textual.cc48
1 files changed, 27 insertions, 21 deletions
diff --git a/textual.cc b/textual.cc
index 7d205a7a..3786e4ed 100644
--- a/textual.cc
+++ b/textual.cc
@@ -882,32 +882,38 @@ void write_textual_journal(journal_t& journal, std::string path,
unsigned long index = 0;
std::string found;
+ if (path.empty()) {
+ if (! journal.sources.empty())
+ found = *journal.sources.begin();
+ } else {
#ifdef HAVE_REALPATH
- char buf1[PATH_MAX];
- char buf2[PATH_MAX];
-
- ::realpath(path.c_str(), buf1);
- for (strings_list::iterator i = journal.sources.begin();
- i != journal.sources.end();
- i++) {
- ::realpath((*i).c_str(), buf2);
- if (std::strcmp(buf1, buf2) == 0) {
- found = *i;
- break;
+ char buf1[PATH_MAX];
+ char buf2[PATH_MAX];
+
+ ::realpath(path.c_str(), buf1);
+
+ for (strings_list::iterator i = journal.sources.begin();
+ i != journal.sources.end();
+ i++) {
+ ::realpath((*i).c_str(), buf2);
+ if (std::strcmp(buf1, buf2) == 0) {
+ found = *i;
+ break;
+ }
+ index++;
}
- index++;
- }
#else
- for (strings_list::iterator i = journal.sources.begin();
- i != journal.sources.end();
- i++) {
- if (path == *i) {
- found = *i;
- break;
+ for (strings_list::iterator i = journal.sources.begin();
+ i != journal.sources.end();
+ i++) {
+ if (path == *i) {
+ found = *i;
+ break;
+ }
+ index++;
}
- index++;
- }
#endif
+ }
if (found.empty())
throw new error(std::string("Journal does not refer to file '") +