=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/cmd-find-window.c,v retrieving revision 1.1 retrieving revision 1.2 diff -c -r1.1 -r1.2 *** src/usr.bin/tmux/cmd-find-window.c 2009/06/01 22:58:49 1.1 --- src/usr.bin/tmux/cmd-find-window.c 2009/06/24 22:49:56 1.2 *************** *** 1,4 **** ! /* $OpenBSD: cmd-find-window.c,v 1.1 2009/06/01 22:58:49 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: cmd-find-window.c,v 1.2 2009/06/24 22:49:56 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott *************** *** 18,23 **** --- 18,24 ---- #include + #include #include #include "tmux.h" *************** *** 58,65 **** struct window_pane *wp; ARRAY_DECL(, u_int) list_idx; ARRAY_DECL(, char *) list_ctx; ! char *sres, *sctx; ! u_int i; if (ctx->curclient == NULL) { ctx->error(ctx, "must be run interactively"); --- 59,66 ---- struct window_pane *wp; ARRAY_DECL(, u_int) list_idx; ARRAY_DECL(, char *) list_ctx; ! char *sres, *sctx, *searchstr; ! u_int i, line; if (ctx->curclient == NULL) { ctx->error(ctx, "must be run interactively"); *************** *** 73,89 **** ARRAY_INIT(&list_idx); ARRAY_INIT(&list_ctx); RB_FOREACH(wm, winlinks, &s->windows) { i = 0; TAILQ_FOREACH(wp, &wm->window->panes, entry) { i++; ! if (strstr(wm->window->name, data->arg) != NULL) sctx = xstrdup(""); else { ! sres = window_pane_search(wp, data->arg); if (sres == NULL && ! strstr(wp->base.title, data->arg) == NULL) continue; if (sres == NULL) { --- 74,91 ---- ARRAY_INIT(&list_idx); ARRAY_INIT(&list_ctx); + xasprintf(&searchstr, "*%s*", data->arg); RB_FOREACH(wm, winlinks, &s->windows) { i = 0; TAILQ_FOREACH(wp, &wm->window->panes, entry) { i++; ! if (fnmatch(searchstr, wm->window->name, 0) == 0) sctx = xstrdup(""); else { ! sres = window_pane_search(wp, data->arg, &line); if (sres == NULL && ! fnmatch(searchstr, wp->base.title, 0) != 0) continue; if (sres == NULL) { *************** *** 91,97 **** "pane %u title: \"%s\"", i - 1, wp->base.title); } else { ! xasprintf(&sctx, "\"%s\"", sres); xfree(sres); } } --- 93,101 ---- "pane %u title: \"%s\"", i - 1, wp->base.title); } else { ! xasprintf(&sctx, ! "pane %u line %u: \"%s\"", i - 1, ! line + 1, sres); xfree(sres); } } *************** *** 100,105 **** --- 104,110 ---- ARRAY_ADD(&list_ctx, sctx); } } + xfree(searchstr); if (ARRAY_LENGTH(&list_idx) == 0) { ctx->error(ctx, "no windows matching: %s", data->arg);