diff options
author | rillig <rillig@pkgsrc.org> | 2018-03-07 00:14:57 +0000 |
---|---|---|
committer | rillig <rillig@pkgsrc.org> | 2018-03-07 00:14:57 +0000 |
commit | ad358667f381c8f5cae13eb7beece2a2439476e6 (patch) | |
tree | 44bf71aec69d112defaa45feb854b363ada679b7 /mk | |
parent | aa2d6fd35d8f06471d7194c3a59af7194f50ac1d (diff) | |
download | pkgsrc-ad358667f381c8f5cae13eb7beece2a2439476e6.tar.gz |
mk/help: sort keywords
Diffstat (limited to 'mk')
-rw-r--r-- | mk/help/help.awk | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/mk/help/help.awk b/mk/help/help.awk index 12605970867..3061affce6d 100644 --- a/mk/help/help.awk +++ b/mk/help/help.awk @@ -1,4 +1,4 @@ -# $NetBSD: help.awk,v 1.29 2018/03/06 23:49:37 rillig Exp $ +# $NetBSD: help.awk,v 1.30 2018/03/07 00:14:57 rillig Exp $ # # This program extracts the inline documentation from *.mk files. @@ -56,10 +56,7 @@ function end_of_topic() { print ""; found_anything = yes; - kw = ""; - for (i in keywords) - kw = kw " " i; - print "===> "last_fname " (keywords:" kw "):"; + print "===> " last_fname " (keywords:" sorted_keys(keywords) "):"; for (i = 0; i < nlines; i++) { if (print_noncomment_lines || (lines[i] ~ /^#/)) @@ -69,6 +66,28 @@ function end_of_topic() { cleanup(); } +function sorted_keys(array, elem, list, listlen, i, j, tmp, joined) { + listlen = 0; + for (elem in array) + list[listlen++] = elem; + + for (i = 0; i < listlen; i++) { + for (j = i + 1; j < listlen; j++) { + if (list[j] < list[i]) { + tmp = list[i]; + list[i] = list[j]; + list[j] = tmp; + } + } + } + + joined = ""; + for (i = 0; i < listlen; i++) { + joined = joined " " list[i]; + } + return joined; +} + function cleanup() { ignore_next_empty_line = yes; delete lines; |