summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Alfredsen <loki_val@gentoo.org>2008-08-07 22:00:08 +0000
committerPeter Alfredsen <loki_val@gentoo.org>2008-08-07 22:00:08 +0000
commit332fde7733b4cbf62e564a139eb348db8ad1dc39 (patch)
treec274cfe565312b3c1f0052fec8830fc9f65a9431 /net-p2p/rtorrent/files
parentStable on alpha, bug #232054 (diff)
downloadgentoo-2-332fde7733b4cbf62e564a139eb348db8ad1dc39.tar.gz
gentoo-2-332fde7733b4cbf62e564a139eb348db8ad1dc39.tar.bz2
gentoo-2-332fde7733b4cbf62e564a139eb348db8ad1dc39.zip
Add new revision with fix for upstream ticket 1416 and quick autoconf fix to avoid segfault when execinfo.h exists, by Josef Drexler. Remove enable-aligned from rtorrent ebuild, since that is only used by libtorrent ebuild. Add ewarn w.r.t. bug #212299.
(Portage version: 2.2_rc6/cvs/Linux 2.6.25.8 i686)
Diffstat (limited to 'net-p2p/rtorrent/files')
-rw-r--r--net-p2p/rtorrent/files/rtorrent-0.8.2-fix-configure-execinfo.patch14
-rw-r--r--net-p2p/rtorrent/files/rtorrent-0.8.2-fix_utf8_filenames.patch238
2 files changed, 252 insertions, 0 deletions
diff --git a/net-p2p/rtorrent/files/rtorrent-0.8.2-fix-configure-execinfo.patch b/net-p2p/rtorrent/files/rtorrent-0.8.2-fix-configure-execinfo.patch
new file mode 100644
index 000000000000..4df674759d02
--- /dev/null
+++ b/net-p2p/rtorrent/files/rtorrent-0.8.2-fix-configure-execinfo.patch
@@ -0,0 +1,14 @@
+# Fixes a segfault when configure finds execinfo.h
+Index: rtorrent/scripts/common.m4
+===================================================================
+--- rtorrent/scripts/common.m4 (revision 1062)
++++ rtorrent/scripts/common.m4 (working copy)
+@@ -183,7 +183,7 @@
+ AC_DEFUN([TORRENT_CHECK_EXECINFO], [
+ AC_MSG_CHECKING(for execinfo.h)
+
+- AC_RUN_IFELSE(
++ AC_LINK_IFELSE(
+ [[#include <execinfo.h>
+ int main() { backtrace((void**)0, 0); backtrace_symbols((char**)0, 0); return 0;}
+ ]],
diff --git a/net-p2p/rtorrent/files/rtorrent-0.8.2-fix_utf8_filenames.patch b/net-p2p/rtorrent/files/rtorrent-0.8.2-fix_utf8_filenames.patch
new file mode 100644
index 000000000000..bf73527c79ed
--- /dev/null
+++ b/net-p2p/rtorrent/files/rtorrent-0.8.2-fix_utf8_filenames.patch
@@ -0,0 +1,238 @@
+# Fix display of multi-byte characters with attributes
+# (i.e. utf-8 filenames in the file list), and make the
+# list aware of characters occupying two screen positions.
+Index: rtorrent/src/display/window_file_list.cc
+===================================================================
+--- rtorrent/src/display/window_file_list.cc (revision 1063)
++++ rtorrent/src/display/window_file_list.cc (working copy)
+@@ -57,22 +57,61 @@
+ m_element(element) {
+ }
+
+-/*
++// Convert std::string to std::wstring of given width (in screen positions),
++// taking into account that some characters may be occupying two screen positions.
+ std::wstring
+-hack_wstring(const std::string& src) {
+- size_t length = ::mbstowcs(NULL, src.c_str(), src.size());
++wstring_width(const std::string& i_str, int width) {
++ wchar_t result[width + 1];
++ size_t length = std::mbstowcs(result, i_str.c_str(), width);
+
+- if (length == (size_t)-1)
+- return std::wstring(L"<invalid>");
++ // If not valid UTF-8 encoding, at least copy the printable characters.
++ if (length == (size_t)-1) {
++ wchar_t* out = result;
+
+- std::wstring dest;
+- dest.resize(length);
+-
+- ::mbstowcs(&*dest.begin(), src.c_str(), src.size());
++ for (std::string::const_iterator itr = i_str.begin(); itr != i_str.end(); ++itr)
++ if (!std::isprint(*itr, std::locale::classic()))
++ *out++ = '?';
++ else
++ *out++ = *itr;
+
+- return dest;
++ *out = 0;
++ }
++
++ int swidth = wcswidth(result, width);
++
++ // Limit to width if it's too wide already.
++ if (swidth == -1 || swidth > width) {
++ length = swidth = 0;
++
++ while (result[length]) {
++ int next = ::wcwidth(result[length]);
++
++ // Unprintable character?
++ if (next == -1) {
++ result[length] = '?';
++ next = 1;
++ }
++
++ if (swidth + next > width) {
++ result[length] = 0;
++ break;
++ }
++
++ length++;
++ swidth += next;
++ }
++ }
++
++ // Pad with spaces to given width.
++ while (swidth < width && length <= (unsigned int)width) {
++ result[length++] = ' ';
++ swidth++;
++ }
++
++ result[length] = 0;
++
++ return result;
+ }
+-*/
+
+ void
+ WindowFileList::redraw() {
+@@ -115,6 +154,8 @@
+ }
+
+ unsigned int pos = 0;
++ int filenameWidth = m_canvas->width() - 16;
++
+ m_canvas->print(0, pos++, "Cmp Pri Size Filename");
+
+ while (pos != m_canvas->height()) {
+@@ -123,20 +164,19 @@
+ if (itr == iterator(fl->end()))
+ break;
+
++ m_canvas->set_default_attributes(itr == m_element->selected() ? is_focused() ? A_REVERSE : A_BOLD : A_NORMAL);
++
+ if (itr.is_empty()) {
+- m_canvas->print(16, pos, "EMPTY");
++ m_canvas->print(0, pos, "%*c%-*s", 16, ' ', filenameWidth, "EMPTY");
+
+ } else if (itr.is_entering()) {
+- m_canvas->print(16 + itr.depth(), pos, "\\ %s",
+- itr.depth() < (*itr)->path()->size() ? (*itr)->path()->at(itr.depth()).c_str() : "UNKNOWN");
++ m_canvas->print(0, pos, "%*c %ls", 16 + itr.depth(), '\\',
++ itr.depth() < (*itr)->path()->size() ? wstring_width((*itr)->path()->at(itr.depth()), filenameWidth - itr.depth() - 1).c_str() : L"UNKNOWN");
+
+ } else if (itr.is_leaving()) {
+- m_canvas->print(16 + itr.depth() - 1, pos, "/");
++ m_canvas->print(0, pos, "%*c %-*s", 16 + (itr.depth() - 1), '/', filenameWidth - (itr.depth() - 1), "");
+
+ } else if (itr.is_file()) {
+- char buffer[std::max<unsigned int>(m_canvas->width() + 1, 256)];
+- Canvas::attributes_list attributes;
+-
+ torrent::File* e = *itr;
+
+ const char* priority;
+@@ -148,34 +188,27 @@
+ default: priority = "BUG"; break;
+ };
+
+- sprintf(buffer, "%3d %s ", done_percentage(e), priority);
++ m_canvas->print(0, pos, "%3d %s ", done_percentage(e), priority);
+
+ int64_t val = e->size_bytes();
+
+- if (val < (int64_t(1000) << 20))
+- sprintf(buffer + 8, "%5.1f M", (double)val / (int64_t(1) << 20));
++ if (val < (int64_t(1000) << 10))
++ m_canvas->print(8, pos, "%5.1f K", (double)val / (int64_t(1) << 10));
++ else if (val < (int64_t(1000) << 20))
++ m_canvas->print(8, pos, "%5.1f M", (double)val / (int64_t(1) << 20));
+ else if (val < (int64_t(1000) << 30))
+- sprintf(buffer + 8, "%5.1f G", (double)val / (int64_t(1) << 30));
++ m_canvas->print(8, pos, "%5.1f G", (double)val / (int64_t(1) << 30));
+ else
+- sprintf(buffer + 8, "%5.1f T", (double)val / (int64_t(1) << 40));
++ m_canvas->print(8, pos, "%5.1f T", (double)val / (int64_t(1) << 40));
+
+- std::fill_n(buffer + 15, 64, ' ');
++ m_canvas->print(15, pos, "%*c %ls", 1 + itr.depth(), '|',
++ itr.depth() < (*itr)->path()->size() ? wstring_width((*itr)->path()->at(itr.depth()), filenameWidth - itr.depth() - 1).c_str() : L"UNKNOWN");
+
+- int first = 16 + std::min<unsigned int>(itr.depth(), 8);
+- int last = std::max<unsigned int>(m_canvas->width() + 1, 16 + 12);
+-
+- snprintf(buffer + first, last - first, "| %s",
+- itr.depth() < (*itr)->path()->size() ? (*itr)->path()->at(itr.depth()).c_str() : "UNKNOWN");
+-
+- m_canvas->print_attributes(0, pos, buffer, buffer + std::strlen(buffer), &attributes);
+-
+ } else {
+ m_canvas->print(0, pos, "BORK BORK");
+ }
++ m_canvas->set_default_attributes(A_NORMAL);
+
+- if (itr == m_element->selected())
+- m_canvas->set_attr(0, pos, m_canvas->width(), is_focused() ? A_REVERSE : A_BOLD, COLOR_PAIR(0));
+-
+ pos++;
+ first = (first + 1) % (m_canvas->height() - 1);
+ }
+Index: rtorrent/src/display/canvas.cc
+===================================================================
+--- rtorrent/src/display/canvas.cc (revision 1063)
++++ rtorrent/src/display/canvas.cc (working copy)
+@@ -57,17 +57,31 @@
+ Canvas::print_attributes(unsigned int x, unsigned int y, const char* first, const char* last, const attributes_list* attributes) {
+ move(x, y);
+
++ attr_t org_attr;
++ short org_pair;
++ wattr_get(m_window, &org_attr, &org_pair, NULL);
++
+ attributes_list::const_iterator attrItr = attributes->begin();
+- Attributes current = Attributes(first, Attributes::a_normal, Attributes::color_default);
++ wattr_set(m_window, Attributes::a_normal, Attributes::color_default, NULL);
+
+ while (first != last) {
+- if (attrItr != attributes->end() && first >= attrItr->position())
+- current = *attrItr++;
++ const char* next = last;
+
+- waddch(m_window, *first++ | current.attributes());
++ if (attrItr != attributes->end()) {
++ next = attrItr->position();
++
++ if (first >= next) {
++ wattr_set(m_window, attrItr->attributes(), attrItr->colors(), NULL);
++ ++attrItr;
++ }
++ }
++
++ print("%.*s", next - first, first);
++ first = next;
+ }
+
+ // Reset the color.
++ wattr_set(m_window, org_attr, org_pair, NULL);
+ }
+
+ void
+Index: rtorrent/src/display/canvas.h
+===================================================================
+--- rtorrent/src/display/canvas.h (revision 1063)
++++ rtorrent/src/display/canvas.h (working copy)
+@@ -86,6 +86,7 @@
+ // since the string shall always be a C string choosen at
+ // compiletime. Might cause extra copying of the string?
+
++ void print(const char* str, ...);
+ void print(unsigned int x, unsigned int y, const char* str, ...);
+
+ void print_attributes(unsigned int x, unsigned int y, const char* first, const char* last, const attributes_list* attributes);
+@@ -95,6 +96,8 @@
+
+ void set_attr(unsigned int x, unsigned int y, unsigned int n, int attr, int color) { mvwchgat(m_window, y, x, n, attr, color, NULL); }
+
++ void set_default_attributes(int attr) { wattrset(m_window, attr); }
++
+ // Initialize stdscr.
+ static void initialize();
+ static void cleanup();
+@@ -116,6 +119,15 @@
+ };
+
+ inline void
++Canvas::print(const char* str, ...) {
++ va_list arglist;
++
++ va_start(arglist, str);
++ vw_printw(m_window, const_cast<char*>(str), arglist);
++ va_end(arglist);
++}
++
++inline void
+ Canvas::print(unsigned int x, unsigned int y, const char* str, ...) {
+ va_list arglist;
+