summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--amount.cc11
-rw-r--r--amount.h11
-rw-r--r--balance.cc1
-rw-r--r--binary.cc11
-rw-r--r--configure.in18
-rw-r--r--datetime.cc4
-rw-r--r--format.cc1
-rw-r--r--journal.h11
-rw-r--r--mask.cc1
-rw-r--r--quotes.cc4
-rw-r--r--textual.cc19
-rw-r--r--util.h18
12 files changed, 67 insertions, 43 deletions
diff --git a/amount.cc b/amount.cc
index 4489db5f..37c5b887 100644
--- a/amount.cc
+++ b/amount.cc
@@ -1107,6 +1107,17 @@ bool amount_t::valid() const
}
+void commodity_t::set_symbol(const std::string& sym)
+{
+ *(const_cast<std::string *>(&symbol)) = sym;
+ quote = false;
+ for (const char * p = symbol.c_str(); *p; p++)
+ if (std::isspace(*p) || std::isdigit(*p) || *p == '-' || *p == '.') {
+ quote = true;
+ return;
+ }
+}
+
void commodity_t::add_price(const std::time_t date, const amount_t& price)
{
if (! history)
diff --git a/amount.h b/amount.h
index 90447e09..d5d6ec11 100644
--- a/amount.h
+++ b/amount.h
@@ -380,16 +380,7 @@ class commodity_t
return this != &comm;
}
- void set_symbol(const std::string& sym) {
- *(const_cast<std::string *>(&symbol)) = sym;
- quote = false;
- for (const char * p = symbol.c_str(); *p; p++)
- if (std::isspace(*p) || std::isdigit(*p) || *p == '-' || *p == '.') {
- quote = true;
- return;
- }
-
- }
+ void set_symbol(const std::string& sym);
void add_price(const std::time_t date, const amount_t& price);
bool remove_price(const std::time_t date) {
diff --git a/balance.cc b/balance.cc
index e829d268..4af87626 100644
--- a/balance.cc
+++ b/balance.cc
@@ -1,4 +1,5 @@
#include "balance.h"
+#include "util.h"
#include <deque>
#include <algorithm>
diff --git a/binary.cc b/binary.cc
index a9425fa7..5270ca79 100644
--- a/binary.cc
+++ b/binary.cc
@@ -547,8 +547,8 @@ void write_binary_transaction(std::ostream& out, transaction_t * xact)
void write_binary_entry_base(std::ostream& out, entry_base_t * entry)
{
write_binary_number<unsigned long>(out, entry->src_idx);
- write_binary_number<std::istream::pos_type>(out, entry->beg_pos);
- write_binary_number<std::istream::pos_type>(out, entry->end_pos);
+ write_binary_number<istream_pos_type>(out, entry->beg_pos);
+ write_binary_number<istream_pos_type>(out, entry->end_pos);
write_binary_number<unsigned long>(out, entry->transactions.size());
for (transactions_list::const_iterator i = entry->transactions.begin();
@@ -682,7 +682,7 @@ void write_binary_journal(std::ostream& out, journal_t * journal)
write_binary_string(out, journal->price_db);
}
- std::ostream::pos_type data_val = out.tellp();
+ ostream_pos_type data_val = out.tellp();
write_binary_number<unsigned long>(out, 0);
// Write out the accounts
@@ -696,9 +696,10 @@ void write_binary_journal(std::ostream& out, journal_t * journal)
write_binary_number<unsigned long>(out, journal->auto_entries.size());
write_binary_number<unsigned long>(out, journal->period_entries.size());
- std::ostream::pos_type xacts_val = out.tellp();
+ ostream_pos_type xacts_val = out.tellp();
+
write_binary_number<unsigned long>(out, 0);
- std::ostream::pos_type bigints_val = out.tellp();
+ ostream_pos_type bigints_val = out.tellp();
write_binary_number<unsigned long>(out, 0);
bigints_count = 0;
diff --git a/configure.in b/configure.in
index 3ea18391..0e2e84aa 100644
--- a/configure.in
+++ b/configure.in
@@ -14,24 +14,6 @@ AC_PROG_RANLIB
#AC_PROG_LIBTOOL
#AM_PROG_LIBTOOL
-# check for C++ compiler compatibility
-AC_CACHE_CHECK(
- [if C++ compiler is compatible],
- [cc_compat],
- [AC_LANG_PUSH(C++)
- AC_TRY_LINK(
- [#include <cctype>
- #include <iostream>],
- [if (std::isspace(' ') || std::isdigit(' '))
- std::cout << std::left << std::right << "Hello";],
- [cc_compat=true],
- [cc_compat=false])
- AC_LANG_POP])
-
-if [test x$cc_compat = xfalse ]; then
- AC_MSG_FAILURE("System's C++ compiler is not compatible (need to use gcc3?)")
-fi
-
# check for gmp
AC_CACHE_CHECK(
[if libgmp is available],
diff --git a/datetime.cc b/datetime.cc
index be4a3026..18e67501 100644
--- a/datetime.cc
+++ b/datetime.cc
@@ -1,3 +1,7 @@
+#if defined(__GNUG__) && __GNUG__ < 3
+#define _XOPEN_SOURCE
+#endif
+
#include "datetime.h"
#include "error.h"
diff --git a/format.cc b/format.cc
index c3f31a3e..c8d07cd8 100644
--- a/format.cc
+++ b/format.cc
@@ -1,5 +1,6 @@
#include "format.h"
#include "error.h"
+#include "util.h"
#ifdef USE_BOOST_PYTHON
#include "py_eval.h"
#endif
diff --git a/journal.h b/journal.h
index 733540c1..7b288d33 100644
--- a/journal.h
+++ b/journal.h
@@ -12,6 +12,7 @@
#include "value.h"
#include "error.h"
#include "debug.h"
+#include "util.h"
namespace ledger {
@@ -81,11 +82,11 @@ typedef std::list<transaction_t *> transactions_list;
class entry_base_t
{
public:
- journal_t * journal;
- unsigned long src_idx;
- std::istream::pos_type beg_pos;
- std::istream::pos_type end_pos;
- transactions_list transactions;
+ journal_t * journal;
+ unsigned long src_idx;
+ istream_pos_type beg_pos;
+ istream_pos_type end_pos;
+ transactions_list transactions;
entry_base_t() {
DEBUG_PRINT("ledger.memory.ctors", "ctor entry_base_t");
diff --git a/mask.cc b/mask.cc
index 35a24022..33dcf93b 100644
--- a/mask.cc
+++ b/mask.cc
@@ -1,5 +1,6 @@
#include "mask.h"
#include "debug.h"
+#include "util.h"
#include <cstdlib>
diff --git a/quotes.cc b/quotes.cc
index 1b53f38f..2c1f3723 100644
--- a/quotes.cc
+++ b/quotes.cc
@@ -65,7 +65,11 @@ void quotes_by_script::operator()(commodity_t& commodity,
if (price && ! price_db.empty()) {
strftime(buf, 127, "%Y/%m/%d %H:%M:%S", localtime(&now));
+#if defined(__GNUG__) && __GNUG__ < 3
+ ofstream database(price_db.c_str(), ios::out | ios::app);
+#else
ofstream database(price_db.c_str(), ios_base::out | ios_base::app);
+#endif
database << "P " << buf << " " << commodity.symbol
<< " " << price << endl;
}
diff --git a/textual.cc b/textual.cc
index aabdbd3b..1982d29d 100644
--- a/textual.cc
+++ b/textual.cc
@@ -1,3 +1,7 @@
+#if defined(__GNUG__) && __GNUG__ < 3
+#define _XOPEN_SOURCE
+#endif
+
#include "journal.h"
#include "textual.h"
#include "datetime.h"
@@ -18,6 +22,11 @@
#include <ctime>
#include <cctype>
#include <cstdio>
+#include <cstdlib>
+
+#if defined(__GNUG__) && __GNUG__ < 3
+extern "C" char *realpath(const char *, char resolved_path[]);
+#endif
#define TIMELOG_SUPPORT 1
@@ -310,7 +319,7 @@ unsigned int textual_parser_t::parse(std::istream& in,
while (in.good() && ! in.eof()) {
try {
- std::istream::pos_type beg_pos = in.tellg();
+ istream_pos_type beg_pos = in.tellg();
in.getline(line, MAX_LINE);
if (in.eof())
@@ -609,11 +618,11 @@ void write_textual_journal(journal_t& journal, std::string path,
char buf2[PATH_MAX];
#ifdef HAVE_REALPATH
- realpath(path.c_str(), buf1);
+ ::realpath(path.c_str(), buf1);
for (strings_list::iterator i = journal.sources.begin();
i != journal.sources.end();
i++) {
- realpath((*i).c_str(), buf2);
+ ::realpath((*i).c_str(), buf2);
if (std::strcmp(buf1, buf2) == 0) {
found = *i;
break;
@@ -640,8 +649,8 @@ void write_textual_journal(journal_t& journal, std::string path,
auto_entries_list::iterator al = journal.auto_entries.begin();
period_entries_list::iterator pl = journal.period_entries.begin();
- std::istream::pos_type pos = 0;
- std::istream::pos_type jump_to;
+ istream_pos_type pos = 0;
+ istream_pos_type jump_to;
format_t hdr_fmt(config.write_hdr_format);
diff --git a/util.h b/util.h
index 8ab841de..0ed3e81f 100644
--- a/util.h
+++ b/util.h
@@ -1,6 +1,24 @@
#ifndef _UTIL_H
#define _UTIL_H
+#if defined(__GNUG__) && __GNUG__ < 3
+namespace std {
+ inline ostream & right (ostream & i) {
+ i.setf(i.right, i.adjustfield);
+ return i;
+ }
+ inline ostream & left (ostream & i) {
+ i.setf(i.left, i.adjustfield);
+ return i;
+ }
+}
+typedef unsigned long istream_pos_type;
+typedef unsigned long ostream_pos_type;
+#else
+typedef std::istream::pos_type istream_pos_type;
+typedef std::ostream::pos_type ostream_pos_type;
+#endif // g++ version 2
+
inline char * skip_ws(char * ptr) {
while (*ptr == ' ' || *ptr == '\t' || *ptr == '\n')
ptr++;