Revision: 2638
          http://tmux.svn.sourceforge.net/tmux/?rev=2638&view=rev
Author:   tcunha
Date:     2011-11-25 13:30:45 +0000 (Fri, 25 Nov 2011)
Log Message:
-----------
Sync OpenBSD patchset 979:

Make window_pane_index work the same as window_index, from Ben Boeckel.

Modified Paths:
--------------
    trunk/cmd-respawn-pane.c
    trunk/cmd-split-window.c
    trunk/screen-redraw.c
    trunk/status.c
    trunk/tmux.h
    trunk/window.c

Modified: trunk/cmd-respawn-pane.c
===================================================================
--- trunk/cmd-respawn-pane.c    2011-11-15 23:12:28 UTC (rev 2637)
+++ trunk/cmd-respawn-pane.c    2011-11-25 13:30:45 UTC (rev 2638)
@@ -49,15 +49,18 @@
        struct session          *s;
        struct environ           env;
        const char              *cmd;
-       char                    *cause;
+       char                    *cause;
+       u_int                    idx;
 
        if ((wl = cmd_find_pane(ctx, args_get(args, 't'), &s, &wp)) == NULL)
                return (-1);
        w = wl->window;
 
        if (!args_has(self->args, 'k') && wp->fd != -1) {
+               if (window_pane_index(wp, &idx) != 0)
+                       fatalx("index not found");
                ctx->error(ctx, "pane still active: %s:%u.%u",
-                   s->name, wl->idx, window_pane_index(w, wp));
+                   s->name, wl->idx, idx);
                return (-1);
        }
 

Modified: trunk/cmd-split-window.c
===================================================================
--- trunk/cmd-split-window.c    2011-11-15 23:12:28 UTC (rev 2637)
+++ trunk/cmd-split-window.c    2011-11-25 13:30:45 UTC (rev 2638)
@@ -139,7 +139,8 @@
        environ_free(&env);
 
        if (args_has(args, 'P')) {
-               paneidx = window_pane_index(wl->window, new_wp);
+               if (window_pane_index(new_wp, &paneidx) != 0)
+                       fatalx("index not found");
                ctx->print(ctx, "%s:%u.%u", s->name, wl->idx, paneidx);
        }
        return (0);

Modified: trunk/screen-redraw.c
===================================================================
--- trunk/screen-redraw.c       2011-11-15 23:12:28 UTC (rev 2637)
+++ trunk/screen-redraw.c       2011-11-25 13:30:45 UTC (rev 2638)
@@ -264,7 +264,7 @@
 {
        struct tty              *tty = &c->tty;
        struct session          *s = c->session;
-       struct options          *oo = &s->options;
+       struct options          *oo = &s->options;
        struct window           *w = wp->window;
        struct grid_cell         gc;
        u_int                    idx, px, py, i, j, xoff, yoff;
@@ -272,7 +272,8 @@
        char                     buf[16], *ptr;
        size_t                   len;
 
-       idx = window_pane_index(w, wp);
+       if (window_pane_index(wp, &idx) != 0)
+               fatalx("index not found");
        len = xsnprintf(buf, sizeof buf, "%u", idx);
 
        if (wp->sx < len)

Modified: trunk/status.c
===================================================================
--- trunk/status.c      2011-11-15 23:12:28 UTC (rev 2637)
+++ trunk/status.c      2011-11-25 13:30:45 UTC (rev 2638)
@@ -372,6 +372,7 @@
        char    ch, tmp[256], *ptr, *endptr, *freeptr;
        size_t  ptrlen;
        long    limit;
+       u_int   idx;
 
        if (s == NULL)
                s = c->session;
@@ -422,8 +423,10 @@
                ptr = tmp;
                goto do_replace;
        case 'P':
+               if (window_pane_index(wp, &idx) != 0)
+                       fatalx("index not found");
                xsnprintf(
-                   tmp, sizeof tmp, "%u", window_pane_index(wl->window, wp));
+                   tmp, sizeof tmp, "%u", idx);
                ptr = tmp;
                goto do_replace;
        case 'S':

Modified: trunk/tmux.h
===================================================================
--- trunk/tmux.h        2011-11-15 23:12:28 UTC (rev 2637)
+++ trunk/tmux.h        2011-11-25 13:30:45 UTC (rev 2638)
@@ -1927,7 +1927,7 @@
                        struct window_pane *, u_int);
 struct window_pane *window_pane_previous_by_number(struct window *,
                        struct window_pane *, u_int);
-u_int           window_pane_index(struct window *, struct window_pane *);
+int             window_pane_index(struct window_pane *, u_int *);
 u_int           window_count_panes(struct window *);
 void            window_destroy_panes(struct window *);
 struct window_pane *window_pane_find_by_id(u_int);

Modified: trunk/window.c
===================================================================
--- trunk/window.c      2011-11-15 23:12:28 UTC (rev 2637)
+++ trunk/window.c      2011-11-25 13:30:45 UTC (rev 2638)
@@ -483,19 +483,21 @@
        return (wp);
 }
 
-u_int
-window_pane_index(struct window *w, struct window_pane *wp)
+int
+window_pane_index(struct window_pane *wp, u_int *i)
 {
        struct window_pane      *wq;
-       u_int                    n;
+       struct window           *w = wp->window;
 
-       n = options_get_number(&w->options, "pane-base-index");
+       *i = options_get_number(&w->options, "pane-base-index");
        TAILQ_FOREACH(wq, &w->panes, entry) {
-               if (wp == wq)
-                       break;
-               n++;
+               if (wp == wq) {
+                       return (0);
+               }
+               (*i)++;
        }
-       return (n);
+
+       return (-1);
 }
 
 u_int

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
tmux-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-cvs

Reply via email to