X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/b80c5ebc4f6afd54597012583c6a1390db0ade9c..62e170072e6000b30c37792227dc34e71a31d797:/src/window.c diff --git a/src/window.c b/src/window.c index 461bb627df..0fcf82d43f 100644 --- a/src/window.c +++ b/src/window.c @@ -6527,11 +6527,17 @@ delete_all_child_windows (Lisp_Object window) static ptrdiff_t count_windows (struct window *window) { - return get_leaf_windows (window, NULL, 0); + ptrdiff_t count = 1; + if (!NILP (window->next)) + count += count_windows (XWINDOW (window->next)); + if (WINDOWP (window->contents)) + count += count_windows (XWINDOW (window->contents)); + return count; } -/* If vector FLAT is non-null, fill it with leaf windows under W, - starting at index I. Value is last index + 1. */ + +/* Fill vector FLAT with leaf windows under W, starting at index I. + Value is last index + 1. */ static ptrdiff_t get_leaf_windows (struct window *w, struct window **flat, ptrdiff_t i) { @@ -6540,11 +6546,7 @@ get_leaf_windows (struct window *w, struct window **flat, ptrdiff_t i) if (WINDOWP (w->contents)) i = get_leaf_windows (XWINDOW (w->contents), flat, i); else - { - if (flat) - flat[i] = w; - i++; - } + flat[i++] = w; w = NILP (w->next) ? 0 : XWINDOW (w->next); }