aboutsummaryrefslogtreecommitdiff
path: root/scripts/sysd-rules.awk
diff options
context:
space:
mode:
authorRoland McGrath <roland@hack.frob.com>2013-06-17 09:54:51 -0700
committerRoland McGrath <roland@hack.frob.com>2013-06-17 09:55:49 -0700
commit12086fb4835639d1762622d80980a7500799b63e (patch)
tree65052b7d36b27b4fa95213dba2e6e0fb4be5e587 /scripts/sysd-rules.awk
parent346d65b33a3958c72faab6f675314cbef7963ace (diff)
downloadglibc-12086fb4835639d1762622d80980a7500799b63e.tar
glibc-12086fb4835639d1762622d80980a7500799b63e.tar.gz
glibc-12086fb4835639d1762622d80980a7500799b63e.tar.bz2
glibc-12086fb4835639d1762622d80980a7500799b63e.zip
Sort sysd-rules-patterns by descending pattern length.
Diffstat (limited to 'scripts/sysd-rules.awk')
-rw-r--r--scripts/sysd-rules.awk24
1 files changed, 20 insertions, 4 deletions
diff --git a/scripts/sysd-rules.awk b/scripts/sysd-rules.awk
index 2fb044eacb..cc143345c6 100644
--- a/scripts/sysd-rules.awk
+++ b/scripts/sysd-rules.awk
@@ -14,6 +14,25 @@ BEGIN {
nsysdirs = split(config_sysdirs, sysdirs);
npatterns = split(sysd_rules_patterns, patterns);
+ # Each element of $(sysd-rules-patterns) is a pair TARGET:DEP.
+ # They are no in particular order. We need to sort them so that
+ # the longest TARGET is first, and, among elements with the same
+ # TARGET, the longest DEP is first.
+ for (i = 1; i <= npatterns; ++i) {
+ if (split(patterns[i], td, ":") != 2) {
+ msg = "bad sysd-rules-patterns element '" patterns[i] "'";
+ print msg > "/dev/stderr";
+ exit 2;
+ }
+ target_order = sprintf("%09d", npatterns + 1 - length(td[1]));
+ dep_order = sprintf("%09d", npatterns - length(td[2]));
+ sort_patterns[target_order SUBSEP dep_order] = patterns[i];
+ }
+ asorti(sort_patterns, map_patterns);
+ for (i in map_patterns) {
+ patterns[i] = sort_patterns[map_patterns[i]];
+ }
+
for (sysdir_idx = 1; sysdir_idx <= nsysdirs; ++sysdir_idx) {
dir = sysdirs[sysdir_idx];
if (dir !~ /^\//) dir = "$(..)" dir;
@@ -28,10 +47,7 @@ BEGIN {
o = suffixes[suffix_idx];
for (pattern_idx = 1; pattern_idx <= npatterns; ++pattern_idx) {
pattern = patterns[pattern_idx];
- if (split(pattern, td, ":") != 2) {
- print "bad sysd-rules-patterns element '" pattern "'" > "/dev/stderr";
- exit 2;
- }
+ split(pattern, td, ":");
target_pattern = td[1];
dep_pattern = td[2];
if (target_pattern == "%") {