From owner-svn-src-all@FreeBSD.ORG Sat Nov 30 23:47:18 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B7961D83; Sat, 30 Nov 2013 23:47:18 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 8AC6511C7; Sat, 30 Nov 2013 23:47:18 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rAUNlIbj068006; Sat, 30 Nov 2013 23:47:18 GMT (envelope-from dteske@svn.freebsd.org) Received: (from dteske@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id rAUNlIoe068005; Sat, 30 Nov 2013 23:47:18 GMT (envelope-from dteske@svn.freebsd.org) Message-Id: <201311302347.rAUNlIoe068005@svn.freebsd.org> From: Devin Teske Date: Sat, 30 Nov 2013 23:47:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r258785 - head/usr.sbin/bsdconfig/includes X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 Nov 2013 23:47:18 -0000 Author: dteske Date: Sat Nov 30 23:47:18 2013 New Revision: 258785 URL: http://svnweb.freebsd.org/changeset/base/258785 Log: Sort function output on name of the function. Modified: head/usr.sbin/bsdconfig/includes/includes Modified: head/usr.sbin/bsdconfig/includes/includes ============================================================================== --- head/usr.sbin/bsdconfig/includes/includes Sat Nov 30 23:08:32 2013 (r258784) +++ head/usr.sbin/bsdconfig/includes/includes Sat Nov 30 23:47:18 2013 (r258785) @@ -69,16 +69,36 @@ show_include() -v use_color=${USE_COLOR:-0} \ -v re="$pattern" \ -v show_desc=${SHOW_DESC:-0} ' + function asorti(src, dest) + { + # Copy src indices to dest and calculate array length + nitems = 0; for (i in src) dest[++nitems] = i + + # Sort the array of indices (dest) using insertion sort method + for (i = 1; i <= nitems; k = i++) + { + idx = dest[i] + while ((k > 0) && (dest[k] > idx)) + { + dest[k+1] = dest[k] + k-- + } + dest[k+1] = idx + } + + return nitems + } /^$/,/^#/ { if ($0 ~ /^# f_/) { if (!match($2, re)) next + fn = $2 if (use_color) - printf "+%s%s%s\n", + syntax[fn] = sprintf("+%s%s%s\n", substr($0, 2, RSTART), substr($0, 2 + RSTART, RLENGTH), - substr($0, 2 + RSTART + RLENGTH) + substr($0, 2 + RSTART + RLENGTH)) else - print "+" substr($0, 2) + syntax[fn] = "+" substr($0, 2) "\n" if (show_desc) print_more = 1 else @@ -87,15 +107,20 @@ show_include() if (show_desc && print_more) { getline while ($0 ~ /^#/) { - print " " substr($0, 2) + syntax[fn] = syntax[fn] " " substr($0, 2) "\n" getline } print_more = 0 } else while (print_more) { getline - print " " substr($0, 2) + syntax[fn] = syntax[fn] " " substr($0, 2) "\n" print_more = substr($0, length($0)) == "\\" } + } + END { + n = asorti(syntax, sorted_indices) + for (i = 1; i <= n; i++) + printf "%s", syntax[sorted_indices[i]] }' "$file" ) if [ "$output" ]; then if [ ! "$SHOW_FUNCS" ]; then