[BACK]Return to paste.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / tmux

Diff for /src/usr.bin/tmux/paste.c between version 1.6 and 1.7

version 1.6, 2009/11/03 17:17:24 version 1.7, 2009/11/26 22:28:24
Line 23 
Line 23 
   
 #include "tmux.h"  #include "tmux.h"
   
   /*
    * Stack of paste buffers. Note that paste buffer data is not necessarily a C
    * string!
    */
   
 void  void
 paste_init_stack(struct paste_stack *ps)  paste_init_stack(struct paste_stack *ps)
 {  {
Line 36 
Line 41 
                 ;                  ;
 }  }
   
   /* Return each item of the stack in turn. */
 struct paste_buffer *  struct paste_buffer *
 paste_walk_stack(struct paste_stack *ps, uint *idx)  paste_walk_stack(struct paste_stack *ps, uint *idx)
 {  {
Line 46 
Line 52 
         return (pb);          return (pb);
 }  }
   
   /* Get the top item on the stack. */
 struct paste_buffer *  struct paste_buffer *
 paste_get_top(struct paste_stack *ps)  paste_get_top(struct paste_stack *ps)
 {  {
Line 54 
Line 61 
         return (ARRAY_FIRST(ps));          return (ARRAY_FIRST(ps));
 }  }
   
   /* Get an item by its index. */
 struct paste_buffer *  struct paste_buffer *
 paste_get_index(struct paste_stack *ps, u_int idx)  paste_get_index(struct paste_stack *ps, u_int idx)
 {  {
Line 62 
Line 70 
         return (ARRAY_ITEM(ps, idx));          return (ARRAY_ITEM(ps, idx));
 }  }
   
   /* Free the top item on the stack. */
 int  int
 paste_free_top(struct paste_stack *ps)  paste_free_top(struct paste_stack *ps)
 {  {
Line 79 
Line 88 
         return (0);          return (0);
 }  }
   
   /* Free an item by index. */
 int  int
 paste_free_index(struct paste_stack *ps, u_int idx)  paste_free_index(struct paste_stack *ps, u_int idx)
 {  {
Line 96 
Line 106 
         return (0);          return (0);
 }  }
   
   /*
    * Add an item onto the top of the stack, freeing the bottom if at limit. Note
    * that the caller is responsible for allocating data.
    */
 void  void
 paste_add(struct paste_stack *ps, u_char *data, size_t size, u_int limit)  paste_add(struct paste_stack *ps, char *data, size_t size, u_int limit)
 {  {
         struct paste_buffer     *pb;          struct paste_buffer     *pb;
   
         if (*data == '\0')          if (size == 0)
                 return;                  return;
   
         while (ARRAY_LENGTH(ps) >= limit) {          while (ARRAY_LENGTH(ps) >= limit) {
Line 118 
Line 132 
         pb->size = size;          pb->size = size;
 }  }
   
   
   /*
    * Replace an item on the stack. Note that the caller is responsible for
    * allocating data.
    */
 int  int
 paste_replace(struct paste_stack *ps, u_int idx, u_char *data, size_t size)  paste_replace(struct paste_stack *ps, u_int idx, char *data, size_t size)
 {  {
         struct paste_buffer     *pb;          struct paste_buffer     *pb;
   
           if (size == 0)
                   return (0);
   
         if (idx >= ARRAY_LENGTH(ps))          if (idx >= ARRAY_LENGTH(ps))
                 return (-1);                  return (-1);

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7