From d0596131ca890bc76e8327cc2937ff251ab6c963 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 6 Jul 2025 10:15:43 +0200 Subject: [PATCH] close/algorithm --- sh/main.awk | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sh/main.awk b/sh/main.awk index d12e61d..911a4c1 100644 --- a/sh/main.awk +++ b/sh/main.awk @@ -13,7 +13,9 @@ function output(name, type) { } function reset() { - doc = "" + if (f == "") { + doc = "" + } } BEGIN { @@ -38,6 +40,7 @@ BEGIN { RE_VARIABLE = RE_BEGIN RE_VAR RE_SET RE_END alias = 0 + f = "" reset() module = 0 } @@ -86,16 +89,17 @@ BEGIN { module = 1 } } else if (match($0, RE_FUNCTION, m)) { + f = m[1] + } else if (match($0, RE_CLOSE, m)) { if (alias) { print "= " target - output(m[1], "function") - } else if (m[1] == target) { - output(target, "function") + output(f, "function") + } else if (f == target) { + output(f, "function") } else { + f = "" reset() } - } else if (match($0, RE_CLOSE, m)) { - # TODO } else { if (module) { output(target, "module")