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

Diff for /src/usr.bin/tmux/window-copy.c between version 1.288 and 1.289

version 1.288, 2020/05/16 16:10:28 version 1.289, 2020/05/25 09:32:10
Line 2551 
Line 2551 
 }  }
   
 static const char *  static const char *
 window_copy_cellstring(const struct grid_line *gl, u_int px, size_t *size)  window_copy_cellstring(const struct grid_line *gl, u_int px, size_t *size,
       int *allocated)
 {  {
           static struct utf8_data  ud;
         struct grid_cell_entry  *gce;          struct grid_cell_entry  *gce;
           char                    *copy;
   
         if (px >= gl->cellsize) {          if (px >= gl->cellsize) {
                 *size = 1;                  *size = 1;
                   *allocated = 0;
                 return (" ");                  return (" ");
         }          }
   
         gce = &gl->celldata[px];          gce = &gl->celldata[px];
         if (~gce->flags & GRID_FLAG_EXTENDED) {          if (~gce->flags & GRID_FLAG_EXTENDED) {
                 *size = 1;                  *size = 1;
                   *allocated = 0;
                 return (&gce->data.data);                  return (&gce->data.data);
         }          }
   
         *size = gl->extddata[gce->offset].data.size;          utf8_get_big(gl->extddata[gce->offset].data, &ud);
         return (gl->extddata[gce->offset].data.data);          *size = ud.size;
           *allocated = 1;
   
           copy = xmalloc(ud.size);
           memcpy(copy, ud.data, ud.size);
           return (copy);
 }  }
   
 /* Find last match in given range. */  /* Find last match in given range. */
Line 2630 
Line 2640 
         const struct grid_line  *gl;          const struct grid_line  *gl;
         const char              *d;          const char              *d;
         size_t                   bufsize = 1024, dlen;          size_t                   bufsize = 1024, dlen;
           int                      allocated;
   
         while (bufsize < newsize)          while (bufsize < newsize)
                 bufsize *= 2;                  bufsize *= 2;
Line 2638 
Line 2649 
         gl = grid_peek_line(gd, py);          gl = grid_peek_line(gd, py);
         bx = *size - 1;          bx = *size - 1;
         for (ax = first; ax < last; ax++) {          for (ax = first; ax < last; ax++) {
                 d = window_copy_cellstring(gl, ax, &dlen);                  d = window_copy_cellstring(gl, ax, &dlen, &allocated);
                 newsize += dlen;                  newsize += dlen;
                 while (bufsize < newsize) {                  while (bufsize < newsize) {
                         bufsize *= 2;                          bufsize *= 2;
Line 2650 
Line 2661 
                         memcpy(buf + bx, d, dlen);                          memcpy(buf + bx, d, dlen);
                         bx += dlen;                          bx += dlen;
                 }                  }
                   if (allocated)
                           free((void *)d);
         }          }
         buf[newsize - 1] = '\0';          buf[newsize - 1] = '\0';
   
Line 2670 
Line 2683 
         struct {          struct {
                 const char      *d;                  const char      *d;
                 size_t           dlen;                  size_t           dlen;
                   int              allocated;
         } *cells;          } *cells;
   
         /* Populate the array of cell data. */          /* Populate the array of cell data. */
Line 2680 
Line 2694 
         gl = grid_peek_line(gd, pywrap);          gl = grid_peek_line(gd, pywrap);
         while (cell < ncells) {          while (cell < ncells) {
                 cells[cell].d = window_copy_cellstring(gl, px,                  cells[cell].d = window_copy_cellstring(gl, px,
                     &cells[cell].dlen);                      &cells[cell].dlen, &cells[cell].allocated);
                 cell++;                  cell++;
                 px++;                  px++;
                 if (px == gd->sx) {                  if (px == gd->sx) {
Line 2738 
Line 2752 
         *ppy = pywrap;          *ppy = pywrap;
   
         /* Free cell data. */          /* Free cell data. */
           for (cell = 0; cell < ncells; cell++) {
                   if (cells[cell].allocated)
                           free((void *)cells[cell].d);
           }
         free(cells);          free(cells);
 }  }
   

Legend:
Removed from v.1.288  
changed lines
  Added in v.1.289