From owner-p4-projects@FreeBSD.ORG Wed Aug 16 13:34:54 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 8380A16A4EB; Wed, 16 Aug 2006 13:34:54 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 617DD16A4E1 for ; Wed, 16 Aug 2006 13:34:54 +0000 (UTC) (envelope-from millert@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 23C6C43D4C for ; Wed, 16 Aug 2006 13:34:54 +0000 (GMT) (envelope-from millert@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k7GDYsU5069960 for ; Wed, 16 Aug 2006 13:34:54 GMT (envelope-from millert@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k7GDYr5d069957 for perforce@freebsd.org; Wed, 16 Aug 2006 13:34:53 GMT (envelope-from millert@freebsd.org) Date: Wed, 16 Aug 2006 13:34:53 GMT Message-Id: <200608161334.k7GDYr5d069957@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to millert@freebsd.org using -f From: Todd Miller To: Perforce Change Reviews Cc: Subject: PERFORCE change 104221 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Aug 2006 13:34:54 -0000 http://perforce.freebsd.org/chv.cgi?CH=104221 Change 104221 by millert@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;