[BACK]Return to cmd-show-buffer.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / tmux

Diff for /src/usr.bin/tmux/Attic/cmd-show-buffer.c between version 1.3 and 1.4

version 1.3, 2009/07/26 12:58:44 version 1.4, 2009/08/18 13:08:43
Line 18 
Line 18 
   
 #include <sys/types.h>  #include <sys/types.h>
   
 #include <stdlib.h>  #include <string.h>
   #include <vis.h>
   
 #include "tmux.h"  #include "tmux.h"
   
Line 45 
Line 46 
         struct cmd_buffer_data  *data = self->data;          struct cmd_buffer_data  *data = self->data;
         struct session          *s;          struct session          *s;
         struct paste_buffer     *pb;          struct paste_buffer     *pb;
         u_int                    size;          char                    *in, *buf, *ptr;
         char                    *buf, *ptr;          size_t                   size, len;
         size_t                   len;          u_int                    width;
   
         if ((s = cmd_find_session(ctx, data->target)) == NULL)          if ((s = cmd_find_session(ctx, data->target)) == NULL)
                 return (-1);                  return (-1);
Line 61 
Line 62 
                 ctx->error(ctx, "no buffer %d", data->buffer);                  ctx->error(ctx, "no buffer %d", data->buffer);
                 return (-1);                  return (-1);
         }          }
           if (pb == NULL)
                   return (0);
   
         if (pb != NULL) {          size = strlen(pb->data);
                 size = s->sx;          if (size > SIZE_MAX / 4 - 1)
                   size = SIZE_MAX / 4 - 1;
           in = xmalloc(size * 4 + 1);
           strvisx(in, pb->data, size, VIS_OCTAL|VIS_TAB);
   
                 buf = xmalloc(size + 1);          width = s->sx;
                 len = 0;          if (ctx->cmdclient != NULL)
                   width = ctx->cmdclient->tty.sx;
   
           buf = xmalloc(width + 1);
           len = 0;
   
           ptr = in;
           do {
                   buf[len++] = *ptr++;
   
                   if (len == width || buf[len - 1] == '\n') {
                           if (buf[len - 1] == '\n')
                                   len--;
                           buf[len] = '\0';
   
                 ptr = pb->data;                          ctx->print(ctx, "%s", buf);
                 do {                          len = 0;
                         buf[len++] = *ptr++;                  }
           } while (*ptr != '\0');
                         if (len == size) {  
                                 buf[len] = '\0';          if (len != 0) {
                                 ctx->print(ctx, buf);  
   
                                 len = 0;  
                         }  
                 } while (*ptr != '\0');  
                 buf[len] = '\0';                  buf[len] = '\0';
                 ctx->print(ctx, buf);                  ctx->print(ctx, buf);
         }          }
           xfree(buf);
   
           xfree(in);
   
         return (0);          return (0);
 }  }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4