version 1.34, 2009/12/01 18:42:38 |
version 1.35, 2009/12/03 22:50:10 |
|
|
int i; |
int i; |
|
|
if (argc == 0) |
if (argc == 0) |
return; |
return; |
for (i = 0; i < argc; i++) { |
for (i = 0; i < argc; i++) { |
if (argv[i] != NULL) |
if (argv[i] != NULL) |
xfree(argv[i]); |
xfree(argv[i]); |
|
|
* be unique so an exact match can't be ambigious and can just be |
* be unique so an exact match can't be ambigious and can just be |
* returned. |
* returned. |
*/ |
*/ |
for (i = 0; i < ARRAY_LENGTH(&sessions); i++) { |
for (i = 0; i < ARRAY_LENGTH(&sessions); i++) { |
if ((s = ARRAY_ITEM(&sessions, i)) == NULL) |
if ((s = ARRAY_ITEM(&sessions, i)) == NULL) |
continue; |
continue; |
if (strcmp(name, s->name) == 0) |
if (strcmp(name, s->name) == 0) |
|
|
* be ambiguous. |
* be ambiguous. |
*/ |
*/ |
sfound = NULL; |
sfound = NULL; |
for (i = 0; i < ARRAY_LENGTH(&sessions); i++) { |
for (i = 0; i < ARRAY_LENGTH(&sessions); i++) { |
if ((s = ARRAY_ITEM(&sessions, i)) == NULL) |
if ((s = ARRAY_ITEM(&sessions, i)) == NULL) |
continue; |
continue; |
if (strncmp(name, s->name, strlen(name)) == 0 || |
if (strncmp(name, s->name, strlen(name)) == 0 || |
|
|
sfound = s; |
sfound = s; |
} |
} |
} |
} |
return (sfound); |
return (sfound); |
} |
} |
|
|
/* |
/* |
|
|
if ((wl = winlink_find_by_index(&s->windows, idx)) != NULL) |
if ((wl = winlink_find_by_index(&s->windows, idx)) != NULL) |
return (wl); |
return (wl); |
} |
} |
|
|
/* Look for exact matches, error if more than one. */ |
/* Look for exact matches, error if more than one. */ |
wlfound = NULL; |
wlfound = NULL; |
RB_FOREACH(wl, winlinks, &s->windows) { |
RB_FOREACH(wl, winlinks, &s->windows) { |
|
|
} |
} |
wlfound = wl; |
wlfound = wl; |
} |
} |
} |
} |
if (wlfound != NULL) |
if (wlfound != NULL) |
return (wlfound); |
return (wlfound); |
|
|
|
|
wl = s->curw; |
wl = s->curw; |
else if ((wl = cmd_lookup_window(s, winptr, &ambiguous)) == NULL) |
else if ((wl = cmd_lookup_window(s, winptr, &ambiguous)) == NULL) |
goto not_found; |
goto not_found; |
|
|
if (sessptr != NULL) |
if (sessptr != NULL) |
xfree(sessptr); |
xfree(sessptr); |
return (wl); |
return (wl); |
|
|
ctx->error(ctx, "invalid index: %s", arg); |
ctx->error(ctx, "invalid index: %s", arg); |
idx = -2; |
idx = -2; |
} |
} |
|
|
if (sessptr != NULL) |
if (sessptr != NULL) |
xfree(sessptr); |
xfree(sessptr); |
return (idx); |
return (idx); |
|
|
|
|
no_session: |
no_session: |
if (ambiguous) |
if (ambiguous) |
ctx->error(ctx, "multiple sessions: %s", arg); |
ctx->error(ctx, "multiple sessions: %s", arg); |
else |
else |
ctx->error(ctx, "session not found: %s", arg); |
ctx->error(ctx, "session not found: %s", arg); |
if (sessptr != NULL) |
if (sessptr != NULL) |
|
|
/* Try index in the current session and window. */ |
/* Try index in the current session and window. */ |
if ((*wpp = window_pane_at_index(s->curw->window, idx)) == NULL) |
if ((*wpp = window_pane_at_index(s->curw->window, idx)) == NULL) |
goto lookup_window; |
goto lookup_window; |
|
|
return (s->curw); |
return (s->curw); |
|
|
lookup_window: |
lookup_window: |
|
|
if ((wl = cmd_find_window(ctx, arg, sp)) != NULL) |
if ((wl = cmd_find_window(ctx, arg, sp)) != NULL) |
*wpp = wl->window->active; |
*wpp = wl->window->active; |
return (wl); |
return (wl); |
|
|
error: |
error: |
xfree(winptr); |
xfree(winptr); |
return (NULL); |
return (NULL); |