PERFORCE change 104221 for review
Todd Miller
millert at FreeBSD.org
Wed Aug 16 13:34:57 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=104221
Change 104221 by millert at millert_macbook on 2006/08/16 13:34:52
asort() is a gawk extension, use the qsort() function from
the awk book instead.
Affected files ...
.. //depot/projects/trustedbsd/sedarwin8/policies/sedarwin/refpolicy/policy/flask/mkaccess_vector.sh#2 edit
Differences ...
==== //depot/projects/trustedbsd/sedarwin8/policies/sedarwin/refpolicy/policy/flask/mkaccess_vector.sh#2 (text+ko) ====
@@ -15,6 +15,23 @@
av_perm_to_string="av_perm_to_string.h"
cat $* | $awk "
+ # Quicksort function for awk arrays, from The AWK Programming
+ # Language, by Aho, Kernighan and Weinberger.
+ # Call qsort(array, smallestindex, largestindex)
+ function qsort(a,left,right, i,last) {
+ if (left >= right) return
+ swap(a, left, left + int((right-left+1)*rand()))
+ last = left
+ for (i=left+1; i<=right; i++)
+ if (a[i] < a[left]) swap(a, ++last, i)
+ swap(a, left, last)
+ qsort(a, left, last-1)
+ qsort(a, last+1, right)
+ }
+ function swap(a,i,j, t) {
+ t = a[i]; a[i] = a[j]; a[j] = t;
+ }
+
BEGIN {
outfile = \"$av_permissions\"
inheritfile = \"$av_inherit\"
@@ -102,12 +119,12 @@
}
}
- j = 1;
+ n = 0;
for (i in inherited_perms) {
- ind[j] = i + 0;
- j++;
+ n++;
+ ind[n] = i + 0;
}
- n = asort(ind);
+ qsort(ind, 1, n);
for (i = 1; i <= n; i++) {
perm = inherited_perms[ind[i]];
printf("#define %s__%s", toupper(tclass), toupper(perm)) > outfile;
More information about the trustedbsd-cvs
mailing list