Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix various macos issues. #1390

Merged
merged 3 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ AC_CONFIG_MACRO_DIRS([scripts])
AM_INIT_AUTOMAKE([foreign subdir-objects])
AM_PROG_AR

AC_DEFINE([API_VERSION], [10], [api version])
LT_INIT

AC_PROG_CXX
AC_SYS_LARGEFILE
LT_INIT
AC_DEFINE([API_VERSION], [10], [api version])

# Filter out unwanted flags added by autoconf on some systems, e.g. MacOS.
TORRENT_REMOVE_UNWANTED(CXX, $CXX, -std=c++11 -std=gnu++11)

AX_CXX_COMPILE_STDCXX([17], [noext], [mandatory])

AC_SYS_LARGEFILE

RAK_CHECK_CFLAGS
RAK_CHECK_CXXFLAGS
RAK_ENABLE_DEBUG
Expand Down
2 changes: 1 addition & 1 deletion rak/algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ advance_backward(_InputIter __first, _InputIter __last, _Distance __distance) {
}

template <typename _Value>
struct compare_base : public std::binary_function<_Value, _Value, bool> {
struct compare_base : public std::function<bool(_Value, _Value)> {
bool operator () (const _Value& complete, const _Value& base) const {
return !complete.compare(0, base.size(), base);
}
Expand Down
6 changes: 3 additions & 3 deletions rak/priority_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

namespace rak {

template <typename Value, typename Compare, typename Equal, typename Alloc = std::allocator<Value> >
class priority_queue : public std::vector<Value, Alloc> {
template <typename Value, typename Compare, typename Equal>
class priority_queue : public std::vector<Value> {
public:
typedef std::vector<Value, Alloc> base_type;
typedef std::vector<Value> base_type;
typedef typename base_type::reference reference;
typedef typename base_type::const_reference const_reference;
typedef typename base_type::iterator iterator;
Expand Down
48 changes: 5 additions & 43 deletions rak/priority_queue_default.h
Original file line number Diff line number Diff line change
@@ -1,44 +1,8 @@
// rak - Rakshasa's toolbox
// Copyright (C) 2005-2007, Jari Sundell
//
// 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
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// In addition, as a special exception, the copyright holders give
// permission to link the code of portions of this program with the
// OpenSSL library under certain conditions as described in each
// individual source file, and distribute linked combinations
// including the two.
//
// You must obey the GNU General Public License in all respects for
// all of the code used other than OpenSSL. If you modify file(s)
// with this exception, you may extend this exception to your version
// of the file(s), but you are not obligated to do so. If you do not
// wish to do so, delete this exception statement from your version.
// If you delete this exception statement from all source files in the
// program, then also delete it here.
//
// Contact: Jari Sundell <jaris@ifi.uio.no>
//
// Skomakerveien 33
// 3185 Skoppum, NORWAY

#ifndef RAK_PRIORITY_QUEUE_DEFAULT_H
#define RAK_PRIORITY_QUEUE_DEFAULT_H

#include <cassert>
#include <functional>
#include <rak/allocators.h>
#include <rak/priority_queue.h>
#include <rak/timer.h>

Expand All @@ -52,8 +16,7 @@ class priority_item {

priority_item() {}
~priority_item() {
if (is_queued())
throw torrent::internal_error("priority_item::~priority_item() called on a queued item.");
assert(!is_queued() && "priority_item::~priority_item() called on a queued item.");

m_time = timer();
m_slot = slot_void();
Expand Down Expand Up @@ -85,8 +48,7 @@ struct priority_compare {
};

typedef std::equal_to<priority_item*> priority_equal;
typedef priority_queue<priority_item*, priority_compare, priority_equal,
cacheline_allocator<priority_item*> > priority_queue_default;
typedef priority_queue<priority_item*, priority_compare, priority_equal> priority_queue_default;

inline void
priority_queue_perform(priority_queue_default* queue, timer t) {
Expand Down Expand Up @@ -137,10 +99,10 @@ priority_queue_erase(priority_queue_default* queue, priority_item* item) {
inline void
priority_queue_update(priority_queue_default* queue, priority_item* item, timer t) {
if (t == timer())
throw torrent::internal_error("priority_queue_update(...) received a bad timer.");
throw torrent::internal_error("priority_queue_insert(...) received a bad timer.");

if (!item->is_valid())
throw torrent::internal_error("priority_queue_update(...) called on an invalid item.");
throw torrent::internal_error("priority_queue_insert(...) called on an invalid item.");

if (queue->find(item) == queue->end()) {
if (item->is_queued())
Expand Down
15 changes: 14 additions & 1 deletion scripts/common.m4
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,27 @@ AC_DEFUN([TORRENT_WITH_SYSROOT], [
AC_MSG_ERROR(The sysroot option must point to a directory, like f.ex "/Developer/SDKs/MacOSX10.4u.sdk".)
else
AC_MSG_RESULT($withval)

CXXFLAGS="$CXXFLAGS -isysroot $withval"
LDFLAGS="$LDFLAGS -Wl,-syslibroot,$withval"
fi
])
])


AC_DEFUN([TORRENT_REMOVE_UNWANTED],
[
values_to_check=`for i in $2; do echo $i; done`
unwanted_values=`for i in $3; do echo $i; done`
if test -z "${unwanted_values}"; then
$1="$2"
else
result=`echo "${values_to_check}" | $GREP -Fvx -- "${unwanted_values}" | $GREP -v '^$'`
$1=${result//$'\n'/ }
fi
])


AC_DEFUN([TORRENT_ENABLE_ARCH], [
AC_ARG_ENABLE(arch,
AS_HELP_STRING([--enable-arch=ARCH],
Expand Down
6 changes: 3 additions & 3 deletions src/command_events.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ apply_on_ratio(const torrent::Object& rawArgs) {
const std::string& groupName = rawArgs.as_string();

char buffer[32 + groupName.size()];
sprintf(buffer, "group2.%s.view", groupName.c_str());
snprintf(buffer, sizeof(buffer), "group2.%s.view", groupName.c_str());

core::ViewManager::iterator viewItr = control->view_manager()->find(rpc::commands.call(buffer, rpc::make_target()).as_string());

if (viewItr == control->view_manager()->end())
throw torrent::input_error("Could not find view.");

char* bufferStart = buffer + sprintf(buffer, "group2.%s.ratio.", groupName.c_str());
char* bufferStart = buffer + snprintf(buffer, sizeof(buffer), "group2.%s.ratio.", groupName.c_str());

// first argument: minimum ratio to reach
// second argument: minimum upload amount to reach [optional]
Expand Down Expand Up @@ -67,7 +67,7 @@ apply_on_ratio(const torrent::Object& rawArgs) {
downloads.push_back(*itr);
}

sprintf(buffer, "group.%s.ratio.command", groupName.c_str());
snprintf(buffer, sizeof(buffer), "group.%s.ratio.command", groupName.c_str());

for (std::vector<core::Download*>::iterator itr = downloads.begin(), last = downloads.end(); itr != last; itr++) {
// rpc::commands.call("print", rpc::make_target(*itr), "Calling ratio command.");
Expand Down
6 changes: 4 additions & 2 deletions src/core/range_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@ namespace core {
template<typename Key, typename T, typename Compare = std::less<Key>,
typename Alloc = std::allocator<std::pair<const Key, T> > >
class RangeMap : private std::map<Key, std::pair<Key, T>, Compare,
typename Alloc::template rebind<std::pair<const Key, std::pair<Key, T> > >::other> {
typename std::allocator_traits<Alloc>::template rebind_alloc<std::pair<const Key, std::pair<Key, T>>>> {

typedef std::map<Key, std::pair<Key, T>, Compare,
typename Alloc::template rebind<std::pair<const Key, std::pair<Key, T> > >::other> base_type;
typename std::allocator_traits<Alloc>::template rebind_alloc<std::pair<const Key, std::pair<Key, T>>>> base_type;

//std::allocator_traits<Alloc>::template rebind_alloc<std::pair<const Key, std::pair<Key, T>>>

public:
RangeMap() {}
Expand Down
2 changes: 1 addition & 1 deletion src/core/view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ View::clear_filter_on() {

inline void
View::insert_visible(Download* d) {
iterator itr = std::find_if(begin_visible(), end_visible(), std::bind1st(view_downloads_compare(m_sortNew), d));
iterator itr = std::find_if(begin_visible(), end_visible(), [&d, this](Download* d2) { return view_downloads_compare(m_sortNew)(d, d2); });

m_size++;
m_focus += (m_focus >= position(itr));
Expand Down
38 changes: 1 addition & 37 deletions src/display/window_string_list.cc
Original file line number Diff line number Diff line change
@@ -1,39 +1,3 @@
// rTorrent - BitTorrent client
// Copyright (C) 2005-2011, Jari Sundell
//
// 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
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// In addition, as a special exception, the copyright holders give
// permission to link the code of portions of this program with the
// OpenSSL library under certain conditions as described in each
// individual source file, and distribute linked combinations
// including the two.
//
// You must obey the GNU General Public License in all respects for
// all of the code used other than OpenSSL. If you modify file(s)
// with this exception, you may extend this exception to your version
// of the file(s), but you are not obligated to do so. If you do not
// wish to do so, delete this exception statement from your version.
// If you delete this exception statement from all source files in the
// program, then also delete it here.
//
// Contact: Jari Sundell <jaris@ifi.uio.no>
//
// Skomakerveien 33
// 3185 Skoppum, NORWAY

#include "config.h"

#include "canvas.h"
Expand Down Expand Up @@ -64,7 +28,7 @@ WindowStringList::redraw() {
if (ypos == (size_t)m_canvas->height()) {
ypos = 0;
xpos += width + 2;

if (xpos + 20 >= (size_t)m_canvas->width())
break;

Expand Down
43 changes: 4 additions & 39 deletions src/ui/download.cc
Original file line number Diff line number Diff line change
@@ -1,41 +1,7 @@
// rTorrent - BitTorrent client
// Copyright (C) 2005-2011, Jari Sundell
//
// 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
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// In addition, as a special exception, the copyright holders give
// permission to link the code of portions of this program with the
// OpenSSL library under certain conditions as described in each
// individual source file, and distribute linked combinations
// including the two.
//
// You must obey the GNU General Public License in all respects for
// all of the code used other than OpenSSL. If you modify file(s)
// with this exception, you may extend this exception to your version
// of the file(s), but you are not obligated to do so. If you do not
// wish to do so, delete this exception statement from your version.
// If you delete this exception statement from all source files in the
// program, then also delete it here.
//
// Contact: Jari Sundell <jaris@ifi.uio.no>
//
// Skomakerveien 33
// 3185 Skoppum, NORWAY

#include "config.h"

#include <cassert>

#include <rak/string_manip.h>
#include <torrent/exceptions.h>
#include <torrent/chunk_manager.h>
Expand Down Expand Up @@ -96,8 +62,7 @@ Download::Download(core::Download* d) :
}

Download::~Download() {
if (is_active())
throw torrent::internal_error("ui::Download::~Download() called on an active object.");
assert(!is_active() && "ui::Download::~Download() called on an active object.");

std::for_each(m_uiArray, m_uiArray + DISPLAY_MAX_SIZE, [](ElementBase* eb) { delete eb; });

Expand Down Expand Up @@ -202,7 +167,7 @@ Download::create_info() {
}

void
Download::activate(display::Frame* frame, bool focus) {
Download::activate(display::Frame* frame, [[maybe_unused]] bool focus) {
if (is_active())
throw torrent::internal_error("ui::Download::activate() called on an already activated object.");

Expand Down
42 changes: 3 additions & 39 deletions src/ui/download_list.cc
Original file line number Diff line number Diff line change
@@ -1,41 +1,6 @@
// rTorrent - BitTorrent client
// Copyright (C) 2005-2011, Jari Sundell
//
// 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
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// In addition, as a special exception, the copyright holders give
// permission to link the code of portions of this program with the
// OpenSSL library under certain conditions as described in each
// individual source file, and distribute linked combinations
// including the two.
//
// You must obey the GNU General Public License in all respects for
// all of the code used other than OpenSSL. If you modify file(s)
// with this exception, you may extend this exception to your version
// of the file(s), but you are not obligated to do so. If you do not
// wish to do so, delete this exception statement from your version.
// If you delete this exception statement from all source files in the
// program, then also delete it here.
//
// Contact: Jari Sundell <jaris@ifi.uio.no>
//
// Skomakerveien 33
// 3185 Skoppum, NORWAY

#include "config.h"

#include <cassert>
#include <sstream>

#include <rak/string_manip.h>
Expand Down Expand Up @@ -82,16 +47,15 @@ DownloadList::DownloadList() :
}

DownloadList::~DownloadList() {
if (is_active())
throw std::logic_error("ui::DownloadList::~DownloadList() called on an active object");
assert(!is_active() && "ui::DownloadList::~DownloadList() called on an active object");

std::for_each(m_uiArray, m_uiArray + DISPLAY_MAX_SIZE, [](ElementBase* eb) { delete eb; });

delete m_windowLog;
}

void
DownloadList::activate(display::Frame* frame, bool focus) {
DownloadList::activate(display::Frame* frame, [[maybe_unused]] bool focus) {
if (is_active())
throw torrent::internal_error("ui::DownloadList::activate() called on an already activated object");

Expand Down