Sort sysd-rules-patterns by descending pattern length.

This commit is contained in:
Roland McGrath 2013-06-17 09:54:51 -07:00
parent 346d65b33a
commit 12086fb483
5 changed files with 32 additions and 9 deletions

View File

@ -1,5 +1,11 @@
2013-06-17 Roland McGrath <roland@hack.frob.com>
* scripts/sysd-rules.awk: Sort sysd_rules_patterns by descending
length of target pattern, then descending length of dependency pattern.
* configure.in (AWK): Require gawk 3.1.2 or newer.
* manual/install.texi (Tools for Compilation): Say that we do.
* configure: Regenerated.
* Makerules [inhibit-sysdep-asm] (check-inhibit-asm): Variable removed.
($(common-objpfx)sysd-rules): Replace shell logic with running ...
* scripts/sysd-rules.awk: ... this new script.

2
configure vendored
View File

@ -4993,7 +4993,7 @@ $as_echo_n "checking version of $AWK... " >&6; }
ac_prog_version=`$AWK --version 2>&1 | sed -n 's/^.*GNU Awk[^0-9]*\([0-9][0-9.]*\).*$/\1/p'`
case $ac_prog_version in
'') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
[3-9].*)
3.1.[2-9]*|3.[2-9]*|[4-9]*)
ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
*) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;

View File

@ -986,7 +986,7 @@ AC_CHECK_PROG_VER(SED, sed, --version,
SED=: aux_missing="$aux_missing sed")
AC_CHECK_PROG_VER(AWK, gawk, --version,
[GNU Awk[^0-9]*\([0-9][0-9.]*\)],
[[3-9].*], critic_missing="$critic_missing gawk")
[3.1.[2-9]*|3.[2-9]*|[4-9]*], critic_missing="$critic_missing gawk")
AC_CHECK_TOOL(NM, nm, false)

View File

@ -379,10 +379,11 @@ understand all the tags used in the document, and the installation
mechanism for the info files is not present or works differently.
@item
GNU @code{awk} 3.0, or higher
GNU @code{awk} 3.1.2, or higher
@code{Awk} is used in several places to generate files.
@code{gawk} 3.0 is known to work.
@code{awk} is used in several places to generate files.
Some @code{gawk} extensions are used, including the @code{asorti}
function, which was introduced in version 3.1.2 of @code{gawk}.
@item
Perl 5

View File

@ -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 == "%") {