pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/mk/help



Module Name:    pkgsrc
Committed By:   rillig
Date:           Wed Mar  7 00:14:57 UTC 2018

Modified Files:
        pkgsrc/mk/help: help.awk

Log Message:
mk/help: sort keywords


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 pkgsrc/mk/help/help.awk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/mk/help/help.awk
diff -u pkgsrc/mk/help/help.awk:1.29 pkgsrc/mk/help/help.awk:1.30
--- pkgsrc/mk/help/help.awk:1.29        Tue Mar  6 23:49:37 2018
+++ pkgsrc/mk/help/help.awk     Wed Mar  7 00:14:57 2018
@@ -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;



Home | Main Index | Thread Index | Old Index