components/rtorrent/patches/rtorrent-04-sunpro.patch
changeset 6932 ae9e3811b2ec
parent 6931 f6f7269f85a9
child 6933 e1fa2aa7bad7
equal deleted inserted replaced
6931:f6f7269f85a9 6932:ae9e3811b2ec
     1 --- rtorrent-0.8.2.orig/rak/string_manip.h	2008-05-07 08:19:12.000000000 -0400
       
     2 +++ rtorrent-0.8.2/rak/string_manip.h	2008-06-25 02:14:10.028329996 -0400
       
     3 @@ -62,7 +62,7 @@
       
     4  
       
     5  template <typename Sequence>
       
     6  Sequence trim_end(const Sequence& seq) {
       
     7 -  if (seq.empty() || !std::isspace(*(--seq.end())))
       
     8 +  if (seq.empty() || !std::isspace(*(seq.end()-1)))
       
     9      return seq;
       
    10  
       
    11    typename Sequence::size_type pos = seq.size();
       
    12 @@ -93,7 +93,7 @@
       
    13  
       
    14  template <typename Sequence>
       
    15  Sequence trim_end_classic(const Sequence& seq) {
       
    16 -  if (seq.empty() || !std::isspace(*(--seq.end()), std::locale::classic()))
       
    17 +  if (seq.empty() || !std::isspace(*(seq.end()-1), std::locale::classic()))
       
    18      return seq;
       
    19  
       
    20    typename Sequence::size_type pos = seq.size();
       
    21 --- rtorrent-0.8.2.orig/rak/path.h	2008-05-07 08:19:12.000000000 -0400
       
    22 +++ rtorrent-0.8.2/rak/path.h	2008-06-25 01:57:52.656513911 -0400
       
    23 @@ -42,6 +42,7 @@
       
    24  
       
    25  #include <cstdlib>
       
    26  #include <string>
       
    27 +#include <algorithm>
       
    28  
       
    29  namespace rak {
       
    30  
       
    31 @@ -91,7 +92,7 @@
       
    32      if (home == NULL)
       
    33        return first;
       
    34  
       
    35 -    first += strlcpy(first, home, std::distance(first, last));
       
    36 +    first += strlcpy(first, home, last-first);
       
    37  
       
    38      if (first > last)
       
    39        return last;
       
    40 @@ -99,7 +100,7 @@
       
    41      src++;
       
    42    }
       
    43  
       
    44 -  return std::min(first + strlcpy(first, src, std::distance(first, last)), last);
       
    45 +  return std::min(first + strlcpy(first, src, last-first), last);
       
    46  }
       
    47  
       
    48  }
       
    49 --- rtorrent-0.8.2.orig/rak/unordered_vector.h	2008-05-07 08:19:12.000000000 -0400
       
    50 +++ rtorrent-0.8.2/rak/unordered_vector.h	2008-06-25 02:29:35.381434005 -0400
       
    51 @@ -90,7 +90,7 @@
       
    52  unordered_vector<_Tp>::insert(iterator position, const value_type& x) {
       
    53    Base::push_back(x);
       
    54  
       
    55 -  return --end();
       
    56 +  return end()-1;
       
    57  }
       
    58  
       
    59  template <typename _Tp>
       
    60 --- rtorrent-0.8.2.orig/rak/socket_address.h	2008-05-07 08:19:12.000000000 -0400
       
    61 +++ rtorrent-0.8.2/rak/socket_address.h	2008-06-25 01:58:48.126132462 -0400
       
    62 @@ -50,6 +50,7 @@
       
    63  #include <cstring>
       
    64  #include <string>
       
    65  #include <stdexcept>
       
    66 +#include <algorithm>
       
    67  #include <arpa/inet.h>
       
    68  #include <netinet/in.h>
       
    69  #include <sys/types.h>
       
    70 --- rtorrent-0.8.2.orig/rak/regex.h	2008-05-07 08:19:12.000000000 -0400
       
    71 +++ rtorrent-0.8.2/rak/regex.h	2008-06-25 02:10:05.332867456 -0400
       
    72 @@ -75,7 +75,7 @@
       
    73    std::list<unsigned int> paths;
       
    74    paths.push_front(0);
       
    75  
       
    76 -  for (std::string::const_iterator itrText = ++text.begin(), lastText = text.end(); itrText != lastText; ++itrText) {
       
    77 +  for (std::string::const_iterator itrText = text.begin()+1, lastText = text.end(); itrText != lastText; ++itrText) {
       
    78      
       
    79      for (std::list<unsigned int>::iterator itrPaths = paths.begin(), lastPaths = paths.end(); itrPaths != lastPaths; ) {
       
    80  
       
    81 --- rtorrent-0.8.2.orig/rak/algorithm.h	2008-05-07 08:19:12.000000000 -0400
       
    82 +++ rtorrent-0.8.2/rak/algorithm.h	2008-06-25 17:27:39.728352000 -0400
       
    83 @@ -40,6 +40,63 @@
       
    84  #include <algorithm>
       
    85  #include <functional>
       
    86  
       
    87 +#ifdef _RWSTD_NO_CLASS_PARTIAL_SPEC
       
    88 +namespace std {
       
    89 +  template <class Iterator> struct iterator_traits
       
    90 +  {
       
    91 +    typedef typename Iterator::value_type value_type;
       
    92 +    typedef typename Iterator::difference_type difference_type;
       
    93 +    typedef typename Iterator::pointer pointer;
       
    94 +    typedef typename Iterator::reference reference;
       
    95 +    typedef typename Iterator::iterator_category iterator_category;
       
    96 +  };
       
    97 +  template <class T> struct iterator_traits<T*>
       
    98 +  {
       
    99 +    typedef T value_type;
       
   100 +    typedef ptrdiff_t difference_type;
       
   101 +    typedef T* pointer;
       
   102 +    typedef T& reference;
       
   103 +    typedef random_access_iterator_tag iterator_category;
       
   104 +  };
       
   105 +  template <class T> struct iterator_traits<const T*>
       
   106 +  {
       
   107 +    typedef T value_type;
       
   108 +    typedef ptrdiff_t difference_type;
       
   109 +    typedef const T* pointer;
       
   110 +    typedef const T& reference;
       
   111 +    typedef random_access_iterator_tag iterator_category;
       
   112 +  };
       
   113 +
       
   114 +  template <class ForwardIterator>
       
   115 +  inline typename iterator_traits<ForwardIterator>::difference_type
       
   116 +  distance (ForwardIterator first, ForwardIterator last)
       
   117 +  {
       
   118 +    typename iterator_traits<ForwardIterator>::difference_type n = 0;
       
   119 +    __distance(first, last, n, 
       
   120 +               iterator_traits<ForwardIterator>::iterator_category());
       
   121 +    return n;
       
   122 +  }
       
   123 +
       
   124 +  template <class InputIterator, class T>
       
   125 +  inline typename iterator_traits<InputIterator>::difference_type
       
   126 +  count (InputIterator first, InputIterator last, const T& value)
       
   127 +  {
       
   128 +    typename iterator_traits<InputIterator>::difference_type n = 0;
       
   129 +    count(first, last, value, n);
       
   130 +    return n;
       
   131 +  }
       
   132 +
       
   133 +  template <class InputIterator, class Predicate>
       
   134 +  inline typename iterator_traits<InputIterator>::difference_type
       
   135 +  count_if (InputIterator first, InputIterator last, Predicate pred)
       
   136 +  {
       
   137 +    typename iterator_traits<InputIterator>::difference_type n = 0;
       
   138 +    count_if(first, last, pred, n);
       
   139 +    return n;
       
   140 +  }
       
   141 +}
       
   142 +#endif
       
   143 +
       
   144  namespace rak {
       
   145  
       
   146  template <typename _InputIter, typename _Function>
       
   147 --- rtorrent-0.8.2.orig/src/command_file.cc	2008-05-07 08:19:11.000000000 -0400
       
   148 +++ rtorrent-0.8.2/src/command_file.cc	2008-06-25 18:06:51.985365949 -0400
       
   149 @@ -64,7 +64,7 @@
       
   150    torrent::Object resultRaw(*file->path()->begin());
       
   151    torrent::Object::string_type& result = resultRaw.as_string();
       
   152  
       
   153 -  for (torrent::Path::const_iterator itr = ++file->path()->begin(), last = file->path()->end(); itr != last; itr++)
       
   154 +  for (torrent::Path::const_iterator itr = (file->path()->begin())+1, last = file->path()->end(); itr != last; itr++)
       
   155      result += '/' + *itr;
       
   156  
       
   157    return resultRaw;
       
   158 --- rtorrent-0.8.2.orig/src/display/window_download_list.cc	2008-05-07 08:19:11.000000000 -0400
       
   159 +++ rtorrent-0.8.2/src/display/window_download_list.cc	2008-06-25 03:05:03.087916943 -0400
       
   160 @@ -90,9 +90,9 @@
       
   161      ++range.second;
       
   162  
       
   163    int pos = 1;
       
   164 +  char* buffer = new char[m_canvas->width() + 1];
       
   165  
       
   166    while (range.first != range.second) {
       
   167 -    char buffer[m_canvas->width() + 1];
       
   168      char* position;
       
   169      char* last = buffer + m_canvas->width() - 2 + 1;
       
   170  
       
   171 @@ -107,6 +107,8 @@
       
   172  
       
   173      ++range.first;
       
   174    }    
       
   175 +
       
   176 +  delete buffer;
       
   177  }
       
   178  
       
   179  }
       
   180 --- rtorrent-0.8.2.orig/src/display/window_text.cc	2008-05-07 08:19:11.000000000 -0400
       
   181 +++ rtorrent-0.8.2/src/display/window_text.cc	2008-06-25 03:18:19.930779231 -0400
       
   182 @@ -93,8 +93,9 @@
       
   183    if (m_canvas->height() == 0)
       
   184      return;
       
   185  
       
   186 +  char* buffer = new char[m_canvas->width() + 1];
       
   187 +
       
   188    if (m_errorHandler != NULL && m_target.second == NULL) {
       
   189 -    char buffer[m_canvas->width() + 1];
       
   190  
       
   191      Canvas::attributes_list attributes;
       
   192      attributes.push_back(Attributes(buffer, Attributes::a_normal, Attributes::color_default));
       
   193 @@ -102,6 +103,9 @@
       
   194      char* last = m_errorHandler->print(buffer, buffer + m_canvas->width(), &attributes, m_target);
       
   195  
       
   196      m_canvas->print_attributes(0, position, buffer, last, &attributes);
       
   197 +
       
   198 +    delete buffer;
       
   199 +
       
   200      return;
       
   201    }
       
   202  
       
   203 @@ -109,8 +113,6 @@
       
   204      if (*itr == NULL)
       
   205        continue;
       
   206  
       
   207 -    char buffer[m_canvas->width() + 1];
       
   208 -
       
   209      Canvas::attributes_list attributes;
       
   210      attributes.push_back(Attributes(buffer, Attributes::a_normal, Attributes::color_default));
       
   211  
       
   212 @@ -118,6 +120,8 @@
       
   213  
       
   214      m_canvas->print_attributes(0, position, buffer, last, &attributes);
       
   215    }
       
   216 +
       
   217 +  delete buffer;
       
   218  }
       
   219  
       
   220  }
       
   221 --- rtorrent-0.8.2.orig/src/display/frame.h	2008-05-07 08:19:11.000000000 -0400
       
   222 +++ rtorrent-0.8.2/src/display/frame.h	2008-06-25 02:47:06.518734587 -0400
       
   223 @@ -92,9 +92,9 @@
       
   224  
       
   225    Window*             window() const                    { return m_window; }
       
   226  
       
   227 -  Frame*              frame(size_type idx)              { return m_container[idx]; }
       
   228 +  Frame*              frame(size_type idx)              { return m_container.frames[idx]; }
       
   229  
       
   230 -  size_type           container_size() const            { return m_containerSize; }
       
   231 +  size_type           container_size() const            { return m_container.size; }
       
   232    void                set_container_size(size_type size);
       
   233  
       
   234    void                initialize_window(Window* window);
       
   235 @@ -120,13 +120,14 @@
       
   236    uint32_t            m_width;
       
   237    uint32_t            m_height;
       
   238  
       
   239 +  typedef struct {
       
   240 +    size_type           size;
       
   241 +    Frame*              frames[max_size];
       
   242 +  } container_t;
       
   243 +
       
   244    union {
       
   245      Window*             m_window;
       
   246 -    
       
   247 -    struct {
       
   248 -      size_type           m_containerSize;
       
   249 -      Frame*              m_container[max_size];
       
   250 -    };
       
   251 +    container_t         m_container;
       
   252    };
       
   253  };
       
   254  
       
   255 --- rtorrent-0.8.2.orig/src/display/text_element_string.cc	2008-05-07 08:19:11.000000000 -0400
       
   256 +++ rtorrent-0.8.2/src/display/text_element_string.cc	2008-06-25 02:57:08.521853302 -0400
       
   257 @@ -36,6 +36,7 @@
       
   258  
       
   259  #include "config.h"
       
   260  
       
   261 +#include <rak/algorithm.h>
       
   262  #include <rak/string_manip.h>
       
   263  
       
   264  #include "rpc/parse_commands.h"
       
   265 @@ -52,17 +52,21 @@
       
   266      return first;
       
   267  
       
   268    if (m_flags & flag_escape_hex) {
       
   269 -    char buffer[last - first];
       
   270 +    char* buffer = new char[last - first];
       
   271      char* bufferLast = copy_string(buffer, buffer + (last - first), target);
       
   272  
       
   273      first = rak::transform_hex(buffer, bufferLast, first, last);
       
   274  
       
   275 +    delete buffer;
       
   276 +
       
   277    } else if (m_flags & flag_escape_html) {
       
   278 -    char buffer[last - first];
       
   279 +    char* buffer = new char[last - first];
       
   280      char* bufferLast = copy_string(buffer, buffer + (last - first), target);
       
   281  
       
   282      first = rak::copy_escape_html(buffer, bufferLast, first, last);
       
   283  
       
   284 +    delete buffer;
       
   285 +
       
   286    } else {
       
   287      first = copy_string(first, last, target);
       
   288    }  
       
   289 --- rtorrent-0.8.2.orig/src/display/window.h	2008-05-07 08:19:11.000000000 -0400
       
   290 +++ rtorrent-0.8.2/src/display/window.h	2008-06-26 00:42:49.975992333 -0400
       
   291 @@ -41,6 +41,7 @@
       
   292  #include <rak/functional.h>
       
   293  
       
   294  #include "canvas.h"
       
   295 +#include "manager.h"
       
   296  #include "globals.h"
       
   297  
       
   298  namespace display {
       
   299 --- rtorrent-0.8.2.orig/src/display/window_statusbar.cc	2008-05-07 08:19:11.000000000 -0400
       
   300 +++ rtorrent-0.8.2/src/display/window_statusbar.cc	2008-06-25 03:15:15.445557476 -0400
       
   301 @@ -53,7 +53,7 @@
       
   302    m_canvas->erase();
       
   303  
       
   304    // TODO: Make a buffer with size = get_width?
       
   305 -  char buffer[m_canvas->width() + 1];
       
   306 +  char* buffer = new char[m_canvas->width() + 1];
       
   307    char* position;
       
   308    char* last = buffer + m_canvas->width();
       
   309  
       
   310 @@ -68,6 +68,8 @@
       
   311    }
       
   312  
       
   313    m_lastTick = control->tick();
       
   314 +
       
   315 +  delete buffer;
       
   316  }
       
   317  
       
   318  }
       
   319 --- rtorrent-0.8.2.orig/src/display/window_file_list.cc	2008-05-07 08:19:11.000000000 -0400
       
   320 +++ rtorrent-0.8.2/src/display/window_file_list.cc	2008-06-25 03:08:33.655012018 -0400
       
   321 @@ -84,7 +84,7 @@
       
   322    if (fl->size_files() == 0 || m_canvas->height() < 2)
       
   323      return;
       
   324  
       
   325 -  iterator entries[m_canvas->height() - 1];
       
   326 +  iterator* entries = new iterator[m_canvas->height() - 1];
       
   327  
       
   328    unsigned int last = 0;
       
   329  
       
   330 @@ -134,7 +134,7 @@
       
   331        m_canvas->print(16 + itr.depth() - 1, pos, "/");
       
   332  
       
   333      } else if (itr.is_file()) {
       
   334 -      char buffer[std::max<unsigned int>(m_canvas->width() + 1, 256)];
       
   335 +      char* buffer = new char[std::max<unsigned int>(m_canvas->width() + 1, 256)];
       
   336        Canvas::attributes_list attributes;
       
   337  
       
   338        torrent::File* e = *itr;
       
   339 @@ -169,6 +169,8 @@
       
   340  
       
   341        m_canvas->print_attributes(0, pos, buffer, buffer + std::strlen(buffer), &attributes);
       
   342  
       
   343 +      delete buffer;
       
   344 +
       
   345      } else {
       
   346        m_canvas->print(0, pos, "BORK BORK");
       
   347      }
       
   348 @@ -179,6 +181,8 @@
       
   349      pos++;
       
   350      first = (first + 1) % (m_canvas->height() - 1);
       
   351    }
       
   352 +
       
   353 +  delete entries;
       
   354  }
       
   355  
       
   356  int
       
   357 --- rtorrent-0.8.2.orig/src/display/window_log.cc	2008-05-07 08:19:11.000000000 -0400
       
   358 +++ rtorrent-0.8.2/src/display/window_log.cc	2008-06-25 03:13:37.195603865 -0400
       
   359 @@ -37,6 +37,7 @@
       
   360  #include "config.h"
       
   361  
       
   362  #include <ctime>
       
   363 +#include <rak/algorithm.h>
       
   364  
       
   365  #include "canvas.h"
       
   366  #include "utils.h"
       
   367 --- rtorrent-0.8.2.orig/src/display/frame.cc	2008-05-07 08:19:11.000000000 -0400
       
   368 +++ rtorrent-0.8.2/src/display/frame.cc	2008-06-25 02:51:41.636803977 -0400
       
   369 @@ -41,6 +41,8 @@
       
   370  #include <rak/algorithm.h>
       
   371  #include <torrent/exceptions.h>
       
   372  
       
   373 +#include "manager.h"
       
   374 +
       
   375  #include "frame.h"
       
   376  #include "window.h"
       
   377  
       
   378 @@ -63,8 +65,8 @@
       
   379  
       
   380    case TYPE_ROW:
       
   381    case TYPE_COLUMN:
       
   382 -    for (size_type i = 0; i < m_containerSize; ++i)
       
   383 -      if (m_container[i]->is_width_dynamic())
       
   384 +    for (size_type i = 0; i < m_container.size; ++i)
       
   385 +      if (m_container.frames[i]->is_width_dynamic())
       
   386          return true;
       
   387  
       
   388      return false;
       
   389 @@ -81,8 +83,8 @@
       
   390  
       
   391    case TYPE_ROW:
       
   392    case TYPE_COLUMN:
       
   393 -    for (size_type i = 0; i < m_containerSize; ++i)
       
   394 -      if (m_container[i]->is_height_dynamic())
       
   395 +    for (size_type i = 0; i < m_container.size; ++i)
       
   396 +      if (m_container.frames[i]->is_height_dynamic())
       
   397          return true;
       
   398  
       
   399      return false;
       
   400 @@ -99,8 +101,8 @@
       
   401    case TYPE_WINDOW: return m_window->is_active() && m_window->is_left();
       
   402  
       
   403    case TYPE_COLUMN:
       
   404 -    for (size_type i = 0; i < m_containerSize; ++i)
       
   405 -      if (m_container[i]->has_left_frame())
       
   406 +    for (size_type i = 0; i < m_container.size; ++i)
       
   407 +      if (m_container.frames[i]->has_left_frame())
       
   408          return true;
       
   409  
       
   410      return false;
       
   411 @@ -117,8 +119,8 @@
       
   412    case TYPE_WINDOW: return m_window->is_active() && m_window->is_bottom();
       
   413  
       
   414    case TYPE_ROW:
       
   415 -    for (size_type i = 0; i < m_containerSize; ++i)
       
   416 -      if (m_container[i]->has_bottom_frame())
       
   417 +    for (size_type i = 0; i < m_container.size; ++i)
       
   418 +      if (m_container.frames[i]->has_bottom_frame())
       
   419          return true;
       
   420  
       
   421      return false;
       
   422 @@ -145,8 +147,8 @@
       
   423      {
       
   424        bounds_type accum(0, 0, 0, 0);
       
   425  
       
   426 -      for (size_type i = 0; i < m_containerSize; ++i) {
       
   427 -        bounds_type p = m_container[i]->preferred_size();
       
   428 +      for (size_type i = 0; i < m_container.size; ++i) {
       
   429 +        bounds_type p = m_container.frames[i]->preferred_size();
       
   430   
       
   431          accum.minWidth += p.minWidth;
       
   432          accum.minHeight += p.minHeight;
       
   433 @@ -174,13 +176,13 @@
       
   434    if ((m_type != TYPE_ROW && m_type != TYPE_COLUMN) || size >= max_size)
       
   435      throw torrent::internal_error("Frame::set_container_size(...) Bad state.");
       
   436  
       
   437 -  while (m_containerSize > size) {
       
   438 -    delete m_container[--m_containerSize];
       
   439 -    m_container[m_containerSize] = NULL;
       
   440 +  while (m_container.size > size) {
       
   441 +    delete m_container.frames[--m_container.size];
       
   442 +    m_container.frames[m_container.size] = NULL;
       
   443    }
       
   444  
       
   445 -  while (m_containerSize < size) {
       
   446 -    m_container[m_containerSize++] = new Frame();
       
   447 +  while (m_container.size < size) {
       
   448 +    m_container.frames[m_container.size++] = new Frame();
       
   449    }
       
   450  }
       
   451  
       
   452 @@ -202,10 +204,10 @@
       
   453      throw torrent::internal_error("Frame::initialize_container(...) size >= max_size.");
       
   454  
       
   455    m_type = TYPE_ROW;
       
   456 -  m_containerSize = size;
       
   457 +  m_container.size = size;
       
   458  
       
   459 -  for (size_type i = 0; i < m_containerSize; ++i)
       
   460 -    m_container[i] = new Frame();
       
   461 +  for (size_type i = 0; i < m_container.size; ++i)
       
   462 +    m_container.frames[i] = new Frame();
       
   463  }
       
   464  
       
   465  void
       
   466 @@ -217,10 +219,10 @@
       
   467      throw torrent::internal_error("Frame::initialize_container(...) size >= max_size.");
       
   468  
       
   469    m_type = TYPE_COLUMN;
       
   470 -  m_containerSize = size;
       
   471 +  m_container.size = size;
       
   472  
       
   473 -  for (size_type i = 0; i < m_containerSize; ++i)
       
   474 -    m_container[i] = new Frame();
       
   475 +  for (size_type i = 0; i < m_container.size; ++i)
       
   476 +    m_container.frames[i] = new Frame();
       
   477  }
       
   478  
       
   479  void
       
   480 @@ -234,9 +236,9 @@
       
   481      
       
   482    case TYPE_ROW:
       
   483    case TYPE_COLUMN:
       
   484 -    for (size_type i = 0; i < m_containerSize; ++i) {
       
   485 -      m_container[i]->clear();
       
   486 -      delete m_container[i];
       
   487 +    for (size_type i = 0; i < m_container.size; ++i) {
       
   488 +      m_container.frames[i]->clear();
       
   489 +      delete m_container.frames[i];
       
   490      }
       
   491      break;
       
   492  
       
   493 @@ -261,7 +263,7 @@
       
   494  
       
   495    case TYPE_ROW:
       
   496    case TYPE_COLUMN:
       
   497 -    for (Frame **itr = m_container, **last = m_container + m_containerSize; itr != last; ++itr)
       
   498 +    for (Frame **itr = m_container.frames, **last = m_container.frames + m_container.size; itr != last; ++itr)
       
   499        (*itr)->refresh();
       
   500  
       
   501      break;
       
   502 @@ -282,7 +284,7 @@
       
   503  
       
   504    case TYPE_ROW:
       
   505    case TYPE_COLUMN:
       
   506 -    for (Frame **itr = m_container, **last = m_container + m_containerSize; itr != last; ++itr)
       
   507 +    for (Frame **itr = m_container.frames, **last = m_container.frames + m_container.size; itr != last; ++itr)
       
   508        (*itr)->redraw();
       
   509  
       
   510      break;
       
   511 @@ -343,7 +345,7 @@
       
   512  
       
   513    int remaining = height;
       
   514    
       
   515 -  for (Frame **itr = m_container, **last = m_container + m_containerSize; itr != last; ++itr) {
       
   516 +  for (Frame **itr = m_container.frames, **last = m_container.frames + m_container.size; itr != last; ++itr) {
       
   517      bounds_type bounds = (*itr)->preferred_size();
       
   518      
       
   519      if ((*itr)->is_height_dynamic()) {
       
   520 @@ -391,7 +393,7 @@
       
   521    // the frame is too small, it will set the remaining windows to zero
       
   522    // extent which will flag them as offscreen.
       
   523  
       
   524 -  for (Frame **itr = m_container, **last = m_container + m_containerSize; itr != last; ++itr) {
       
   525 +  for (Frame **itr = m_container.frames, **last = m_container.frames + m_container.size; itr != last; ++itr) {
       
   526      // If there is any remaining space, check if we want to shift
       
   527      // the subsequent frames to the other side of this frame.
       
   528      if (remaining > 0 && (*itr)->has_bottom_frame()) {
       
   529 @@ -417,7 +419,7 @@
       
   530  
       
   531    int remaining = width;
       
   532    
       
   533 -  for (Frame **itr = m_container, **last = m_container + m_containerSize; itr != last; ++itr) {
       
   534 +  for (Frame **itr = m_container.frames, **last = m_container.frames + m_container.size; itr != last; ++itr) {
       
   535      bounds_type bounds = (*itr)->preferred_size();
       
   536      
       
   537      if ((*itr)->is_width_dynamic()) {
       
   538 @@ -465,7 +469,7 @@
       
   539    // the frame is too small, it will set the remaining windows to zero
       
   540    // extent which will flag them as offscreen.
       
   541  
       
   542 -  for (Frame **itr = m_container, **last = m_container + m_containerSize; itr != last; ++itr) {
       
   543 +  for (Frame **itr = m_container.frames, **last = m_container.frames + m_container.size; itr != last; ++itr) {
       
   544      // If there is any remaining space, check if we want to shift
       
   545      // the subsequent frames to the other side of this frame.
       
   546      if (remaining > 0 && (*itr)->has_left_frame()) {
       
   547 --- rtorrent-0.8.2.orig/src/display/window_download_statusbar.cc	2008-05-07 08:19:11.000000000 -0400
       
   548 +++ rtorrent-0.8.2/src/display/window_download_statusbar.cc	2008-06-25 03:05:11.110750771 -0400
       
   549 @@ -61,7 +61,7 @@
       
   550  
       
   551    m_canvas->erase();
       
   552  
       
   553 -  char buffer[m_canvas->width()];
       
   554 +  char* buffer = new char[m_canvas->width()];
       
   555    char* position;
       
   556    char* last = buffer + m_canvas->width() - 2;
       
   557  
       
   558 @@ -88,6 +88,8 @@
       
   559                    m_download->tracker_list()->has_active() ? 'C' : ' ',
       
   560                    (int)(m_download->download()->tracker_list()->time_next_connection()),
       
   561                    buffer);
       
   562 +
       
   563 +  delete buffer;
       
   564  }
       
   565  
       
   566  }
       
   567 --- rtorrent-0.8.2.orig/src/core/scheduler.cc	2008-05-07 08:19:11.000000000 -0400
       
   568 +++ rtorrent-0.8.2/src/core/scheduler.cc	2008-06-25 02:19:20.043037414 -0400
       
   569 @@ -37,6 +37,7 @@
       
   570  #include "config.h"
       
   571  
       
   572  #include <algorithm>
       
   573 +#include <rak/algorithm.h>
       
   574  #include <rak/functional.h>
       
   575  #include <torrent/exceptions.h>
       
   576  
       
   577 --- rtorrent-0.8.2.orig/src/core/view.cc	2008-05-07 08:19:11.000000000 -0400
       
   578 +++ rtorrent-0.8.2/src/core/view.cc	2008-06-25 02:28:36.651635274 -0400
       
   579 @@ -38,6 +38,7 @@
       
   580  
       
   581  #include <algorithm>
       
   582  #include <functional>
       
   583 +#include <rak/algorithm.h>
       
   584  #include <rak/functional.h>
       
   585  #include <rak/functional_fun.h>
       
   586  #include <rpc/parse_commands.h>
       
   587 --- rtorrent-0.8.2.orig/src/core/manager.cc	2008-06-25 01:44:38.134154000 -0400
       
   588 +++ rtorrent-0.8.2/src/core/manager.cc	2008-06-25 02:08:43.144712661 -0400
       
   589 @@ -352,19 +352,25 @@
       
   590    int port;
       
   591    rak::address_info* ai;
       
   592  
       
   593 -  char buf[addr.length() + 1];
       
   594 +  char* buf = new char[addr.length() + 1];
       
   595  
       
   596    int err = std::sscanf(addr.c_str(), "%[^:]:%i", buf, &port);
       
   597  
       
   598 -  if (err <= 0)
       
   599 +  if (err <= 0) {
       
   600 +    delete buf;
       
   601      throw torrent::input_error("Could not parse proxy address.");
       
   602 +  }
       
   603  
       
   604    if (err == 1)
       
   605      port = 80;
       
   606  
       
   607 -  if ((err = rak::address_info::get_address_info(buf, PF_INET, SOCK_STREAM, &ai)) != 0)
       
   608 +  if ((err = rak::address_info::get_address_info(buf, PF_INET, SOCK_STREAM, &ai)) != 0) {
       
   609 +    delete buf;
       
   610      throw torrent::input_error("Could not set proxy address: " + std::string(rak::address_info::strerror(err)) + ".");
       
   611 -  
       
   612 +  }
       
   613 +
       
   614 +  delete buf;
       
   615 +
       
   616    try {
       
   617  
       
   618      ai->address()->set_port(port);
       
   619 --- rtorrent-0.8.2.orig/src/rpc/parse.cc	2008-05-07 08:19:10.000000000 -0400
       
   620 +++ rtorrent-0.8.2/src/rpc/parse.cc	2008-06-25 17:30:55.775246860 -0400
       
   621 @@ -37,6 +37,7 @@
       
   622  #include "config.h"
       
   623  
       
   624  #include <locale>
       
   625 +#include <rak/algorithm.h>
       
   626  #include <rak/path.h>
       
   627  #include <torrent/exceptions.h>
       
   628  
       
   629 --- rtorrent-0.8.2.orig/src/rpc/xmlrpc.cc	2008-05-07 08:19:10.000000000 -0400
       
   630 +++ rtorrent-0.8.2/src/rpc/xmlrpc.cc	2008-06-25 17:54:04.404987582 -0400
       
   631 @@ -477,7 +477,8 @@
       
   632    xmlrpc_env_init(&localEnv);
       
   633  
       
   634    xmlrpc_registry_add_method_w_doc(&localEnv, (xmlrpc_registry*)m_registry, NULL, name,
       
   635 -                                   &xmlrpc_call_command, const_cast<char*>(name), parm, doc);
       
   636 +                                   (const xmlrpc_method)(&xmlrpc_call_command),
       
   637 +				   const_cast<char*>(name), parm, doc);
       
   638  
       
   639    if (localEnv.fault_occurred)
       
   640      throw torrent::internal_error("Fault occured while inserting xmlrpc call.");
       
   641 --- rtorrent-0.8.2.orig/src/rpc/scgi.cc	2008-06-25 01:44:38.128033000 -0400
       
   642 +++ rtorrent-0.8.2/src/rpc/scgi.cc	2008-06-25 17:32:13.998638901 -0400
       
   643 @@ -85,7 +85,7 @@
       
   644    if (filename.empty() || filename.size() > 4096)
       
   645      throw torrent::resource_error("Invalid filename length.");
       
   646  
       
   647 -  char buffer[sizeof(sockaddr_un) + filename.size()];
       
   648 +  char* buffer = new char[sizeof(sockaddr_un) + filename.size()];
       
   649    sockaddr_un* sa = reinterpret_cast<sockaddr_un*>(buffer);
       
   650  
       
   651    sa->sun_family = AF_UNIX;
       
   652 @@ -96,6 +96,7 @@
       
   653  
       
   654    open(sa, offsetof(struct sockaddr_un, sun_path) + filename.size() + 1);
       
   655    m_path = filename;
       
   656 +  delete buffer;
       
   657  }
       
   658  
       
   659  void
       
   660 --- rtorrent-0.8.2.orig/src/rpc/scgi_task.cc	2008-05-07 08:19:10.000000000 -0400
       
   661 +++ rtorrent-0.8.2/src/rpc/scgi_task.cc	2008-06-25 17:41:41.493886588 -0400
       
   662 @@ -134,7 +134,7 @@
       
   663      if (current == m_buffer || *current != ':' || headerSize < 17 || headerSize > max_header_size)
       
   664        goto event_read_failed;
       
   665  
       
   666 -    if (std::distance(++current, m_position) < headerSize + 1)
       
   667 +    if (m_position - (++current) < headerSize + 1)
       
   668        return;
       
   669  
       
   670      if (std::memcmp(current, "CONTENT_LENGTH", 15) != 0)
       
   671 @@ -147,7 +147,7 @@
       
   672        goto event_read_failed;
       
   673  
       
   674      m_body = current + headerSize + 1;
       
   675 -    headerSize = std::distance(m_buffer, m_body);
       
   676 +    headerSize = m_body - m_buffer;
       
   677  
       
   678      if ((unsigned int)(contentSize + headerSize) < m_bufferSize) {
       
   679        m_bufferSize = contentSize + headerSize;
       
   680 @@ -155,26 +155,26 @@
       
   681      } else if ((unsigned int)contentSize <= default_buffer_size) {
       
   682        m_bufferSize = contentSize;
       
   683  
       
   684 -      std::memmove(m_buffer, m_body, std::distance(m_body, m_position));
       
   685 -      m_position = m_buffer + std::distance(m_body, m_position);
       
   686 +      std::memmove(m_buffer, m_body, m_position - m_body);
       
   687 +      m_position = m_buffer + (m_position - m_body);
       
   688        m_body = m_buffer;
       
   689  
       
   690      } else {
       
   691 -      realloc_buffer((m_bufferSize = contentSize) + 1, m_body, std::distance(m_body, m_position));
       
   692 +      realloc_buffer((m_bufferSize = contentSize) + 1, m_body, m_position - m_body);
       
   693  
       
   694 -      m_position = m_buffer + std::distance(m_body, m_position);
       
   695 +      m_position = m_buffer + (m_position - m_body);
       
   696        m_body = m_buffer;
       
   697      }
       
   698    }
       
   699  
       
   700 -  if ((unsigned int)std::distance(m_buffer, m_position) != m_bufferSize)
       
   701 +  if ((unsigned int)(m_position - m_buffer) != m_bufferSize)
       
   702      return;
       
   703  
       
   704    control->poll()->remove_read(this);
       
   705    control->poll()->insert_write(this);
       
   706  
       
   707    // Close if the call failed, else stay open to write back data.
       
   708 -  if (!m_parent->receive_call(this, m_body, m_bufferSize - std::distance(m_buffer, m_body)))
       
   709 +  if (!m_parent->receive_call(this, m_body, m_bufferSize - (m_body - m_buffer)))
       
   710      close();
       
   711  
       
   712    return;