diff --git a/configure.ac b/configure.ac index e4e0dc4c4..bebbde7f6 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/rak/algorithm.h b/rak/algorithm.h index 2eace265f..7937d9658 100644 --- a/rak/algorithm.h +++ b/rak/algorithm.h @@ -115,7 +115,7 @@ advance_backward(_InputIter __first, _InputIter __last, _Distance __distance) { } template -struct compare_base : public std::binary_function<_Value, _Value, bool> { +struct compare_base : public std::function { bool operator () (const _Value& complete, const _Value& base) const { return !complete.compare(0, base.size(), base); } diff --git a/rak/priority_queue.h b/rak/priority_queue.h index 9a8b67dad..3d08992eb 100644 --- a/rak/priority_queue.h +++ b/rak/priority_queue.h @@ -10,10 +10,10 @@ namespace rak { -template > -class priority_queue : public std::vector { +template +class priority_queue : public std::vector { public: - typedef std::vector base_type; + typedef std::vector base_type; typedef typename base_type::reference reference; typedef typename base_type::const_reference const_reference; typedef typename base_type::iterator iterator; diff --git a/rak/priority_queue_default.h b/rak/priority_queue_default.h index 40fc09fe3..bacfc5d14 100644 --- a/rak/priority_queue_default.h +++ b/rak/priority_queue_default.h @@ -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 -// -// Skomakerveien 33 -// 3185 Skoppum, NORWAY - #ifndef RAK_PRIORITY_QUEUE_DEFAULT_H #define RAK_PRIORITY_QUEUE_DEFAULT_H +#include #include -#include #include #include @@ -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(); @@ -85,8 +48,7 @@ struct priority_compare { }; typedef std::equal_to priority_equal; -typedef priority_queue > priority_queue_default; +typedef priority_queue priority_queue_default; inline void priority_queue_perform(priority_queue_default* queue, timer t) { @@ -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()) diff --git a/scripts/common.m4 b/scripts/common.m4 index 2f54402e0..e6ed8f5b6 100644 --- a/scripts/common.m4 +++ b/scripts/common.m4 @@ -13,7 +13,7 @@ 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 @@ -21,6 +21,19 @@ AC_DEFUN([TORRENT_WITH_SYSROOT], [ ]) +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], diff --git a/src/command_events.cc b/src/command_events.cc index a602298ac..f8fc1c03f 100644 --- a/src/command_events.cc +++ b/src/command_events.cc @@ -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] @@ -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::iterator itr = downloads.begin(), last = downloads.end(); itr != last; itr++) { // rpc::commands.call("print", rpc::make_target(*itr), "Calling ratio command."); diff --git a/src/core/range_map.h b/src/core/range_map.h index 2df028fdf..38b9b42e1 100644 --- a/src/core/range_map.h +++ b/src/core/range_map.h @@ -49,10 +49,12 @@ namespace core { template, typename Alloc = std::allocator > > class RangeMap : private std::map, Compare, - typename Alloc::template rebind > >::other> { + typename std::allocator_traits::template rebind_alloc>>> { typedef std::map, Compare, - typename Alloc::template rebind > >::other> base_type; + typename std::allocator_traits::template rebind_alloc>>> base_type; + + //std::allocator_traits::template rebind_alloc>> public: RangeMap() {} diff --git a/src/core/view.cc b/src/core/view.cc index c53b09a2f..7626cd409 100644 --- a/src/core/view.cc +++ b/src/core/view.cc @@ -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)); diff --git a/src/display/window_string_list.cc b/src/display/window_string_list.cc index 419434c2a..15c787932 100644 --- a/src/display/window_string_list.cc +++ b/src/display/window_string_list.cc @@ -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 -// -// Skomakerveien 33 -// 3185 Skoppum, NORWAY - #include "config.h" #include "canvas.h" @@ -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; diff --git a/src/ui/download.cc b/src/ui/download.cc index 856bffa45..32aa3aebe 100644 --- a/src/ui/download.cc +++ b/src/ui/download.cc @@ -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 -// -// Skomakerveien 33 -// 3185 Skoppum, NORWAY - #include "config.h" +#include + #include #include #include @@ -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; }); @@ -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."); diff --git a/src/ui/download_list.cc b/src/ui/download_list.cc index 96bb5074a..9ebe9bba6 100644 --- a/src/ui/download_list.cc +++ b/src/ui/download_list.cc @@ -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 -// -// Skomakerveien 33 -// 3185 Skoppum, NORWAY - #include "config.h" +#include #include #include @@ -82,8 +47,7 @@ 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; }); @@ -91,7 +55,7 @@ DownloadList::~DownloadList() { } 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");