Fix for build errors with g++ 4.0.1

This commit is contained in:
ridiculousfish 2012-12-11 13:18:40 -08:00
parent eec6db0a23
commit d43c803bfe
2 changed files with 14 additions and 7 deletions

View File

@ -85,6 +85,8 @@ public:
} }
}; };
static const file_id_t kInvalidFileID((dev_t)(-1), (ino_t)(-1));
/* Lock a file via fcntl; returns true on success, false on failure. */ /* Lock a file via fcntl; returns true on success, false on failure. */
static bool history_file_lock(int fd, short type) static bool history_file_lock(int fd, short type)
{ {
@ -99,7 +101,7 @@ static bool history_file_lock(int fd, short type)
/* Get a file_id_t corresponding to the given fd */ /* Get a file_id_t corresponding to the given fd */
static file_id_t history_file_identify(int fd) static file_id_t history_file_identify(int fd)
{ {
file_id_t result(-1, -1); file_id_t result = kInvalidFileID;
struct stat buf = {}; struct stat buf = {};
if (0 == fstat(fd, &buf)) if (0 == fstat(fd, &buf))
{ {
@ -473,7 +475,7 @@ history_t::history_t(const wcstring &pname) :
first_unwritten_new_item_index(0), first_unwritten_new_item_index(0),
mmap_start(NULL), mmap_start(NULL),
mmap_length(0), mmap_length(0),
mmap_file_id(-1, -1), mmap_file_id(kInvalidFileID),
birth_timestamp(time(NULL)), birth_timestamp(time(NULL)),
countdown_to_vacuum(-1), countdown_to_vacuum(-1),
loaded_old(false), loaded_old(false),
@ -569,8 +571,8 @@ void history_t::get_string_representation(wcstring &result, const wcstring &sepa
bool first = true; bool first = true;
/* Append new items */ /* Append new items. Note that in principle we could use const_reverse_iterator, but we do not because reverse_iterator is not convertible to const_reverse_iterator ( http://github.com/fish-shell/fish-shell/issues/431 ) */
for (std::vector<history_item_t>::const_reverse_iterator iter=new_items.rbegin(); iter < new_items.rend(); ++iter) for (std::vector<history_item_t>::reverse_iterator iter=new_items.rbegin(); iter < new_items.rend(); ++iter)
{ {
if (! first) if (! first)
result.append(separator); result.append(separator);
@ -580,7 +582,7 @@ void history_t::get_string_representation(wcstring &result, const wcstring &sepa
/* Append old items */ /* Append old items */
load_old_if_needed(); load_old_if_needed();
for (std::vector<size_t>::const_reverse_iterator iter = old_item_offsets.rbegin(); iter != old_item_offsets.rend(); ++iter) for (std::vector<size_t>::reverse_iterator iter = old_item_offsets.rbegin(); iter != old_item_offsets.rend(); ++iter)
{ {
size_t offset = *iter; size_t offset = *iter;
const history_item_t item = history_t::decode_item(mmap_start + offset, mmap_length - offset, mmap_type); const history_item_t item = history_t::decode_item(mmap_start + offset, mmap_length - offset, mmap_type);

9
lru.h
View File

@ -97,6 +97,11 @@ private:
evict_node((node_type_t *)mouth.prev); evict_node((node_type_t *)mouth.prev);
} }
static lru_node_t *get_previous(lru_node_t *node)
{
return node->prev;
}
protected: protected:
/** Head of the linked list */ /** Head of the linked list */
@ -218,11 +223,11 @@ public:
iterator(lru_node_t *val) : node(val) { } iterator(lru_node_t *val) : node(val) { }
void operator++() void operator++()
{ {
node = node->prev; node = lru_cache_t::get_previous(node);
} }
void operator++(int x) void operator++(int x)
{ {
node = node->prev; node = lru_cache_t::get_previous(node);
} }
bool operator==(const iterator &other) bool operator==(const iterator &other)
{ {