Source-Changes-HG archive

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

[src/trunk]: src/distrib/sets Adapt the sortlists target to deal with comment...



details:   https://anonhg.NetBSD.org/src/rev/96edae60eefb
branches:  trunk
changeset: 331735:96edae60eefb
user:      apb <apb%NetBSD.org@localhost>
date:      Fri Aug 22 10:51:18 2014 +0000

description:
Adapt the sortlists target to deal with commented file names, like
"#./dir/file".  Such lines now compare equal to their uncommented
counterparts like "./dir/file".

diffstat:

 distrib/sets/Makefile |  21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)

diffs (40 lines):

diff -r 0d7f7b136d30 -r 96edae60eefb distrib/sets/Makefile
--- a/distrib/sets/Makefile     Fri Aug 22 09:58:55 2014 +0000
+++ b/distrib/sets/Makefile     Fri Aug 22 10:51:18 2014 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.97 2014/08/05 15:45:49 apb Exp $
+#      $NetBSD: Makefile,v 1.98 2014/08/22 10:51:18 apb Exp $
 
 # Experimental RCS METALOG versioning
 # (Needs host's rcs(1) commands)
@@ -304,15 +304,26 @@
 makedeps: .PHONY
        ${SETSCMD} ./syspkgdeps all >${.CURDIR}/deps
 
-# Sort the lists files
+# Sort the lists files.
+#
+# The tricky stuff with awk and sort -k options is to ensure that the
+# heading remains undisturbed, and on non-heading lines anything before
+# the first "." is ignored, so that "./dir/file" and "#./dir/file" are
+# sorted together.
+#
 sortlists: .PHONY
        find ${.CURDIR}/lists \! \( -name CVS -prune \) \! -name .#\* \
            -type f -print \
        | while read f ; do \
            ${_MKSHMSG} "sorting $${f#${.CURDIR}/}" ; \
-           { grep '^#' "$$f" ; \
-             grep -v '^#' "$$f" | sort ; \
-           } | cat -s >"$$f".tmp; \
+           awk 'BEGIN { inheader = 1 } \
+                /^#*\.\// { inheader = 0 } \
+                // { tag = (inheader ? NR : 999999); \
+                     print tag "." $$0 }' \
+               <"$$f" \
+           | sort -t . -k 1n,2 -k 3 \
+           | cut -d . -f 2- \
+           | cat -s >"$$f".tmp; \
            if cmp "$$f" "$$f".tmp >/dev/null; then \
              : "$$f is unchanged" ; \
              rm "$$f".tmp ; \



Home | Main Index | Thread Index | Old Index