device.subr (279609) | device.subr (279610) |
---|---|
1if [ ! "$_DEVICE_SUBR" ]; then _DEVICE_SUBR=1 2# 3# Copyright (c) 2012-2014 Devin Teske 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: --- 10 unchanged lines hidden (view full) --- 19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25# SUCH DAMAGE. 26# | 1if [ ! "$_DEVICE_SUBR" ]; then _DEVICE_SUBR=1 2# 3# Copyright (c) 2012-2014 Devin Teske 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: --- 10 unchanged lines hidden (view full) --- 19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25# SUCH DAMAGE. 26# |
27# $FreeBSD: stable/10/usr.sbin/bsdconfig/share/device.subr 279609 2015-03-05 00:29:58Z dteske $ | 27# $FreeBSD: stable/10/usr.sbin/bsdconfig/share/device.subr 279610 2015-03-05 00:32:54Z dteske $ |
28# 29############################################################ INCLUDES 30 31BSDCFG_SHARE="/usr/share/bsdconfig" 32. $BSDCFG_SHARE/common.subr || exit 1 33f_dprintf "%s: loading includes..." device.subr 34f_include $BSDCFG_SHARE/dialog.subr 35f_include $BSDCFG_SHARE/geom.subr --- 1075 unchanged lines hidden (view full) --- 1111# (newline to be specific) unless $var_to_set is present and non-NULL. 1112# 1113# This function is a two-parter. Below is the awk(1) portion of the function, 1114# afterward is the sh(1) function which utilizes the below awk script. 1115# 1116f_device_sort_by_awk=' 1117# Variables that should be defined on the invocation line: 1118# -v prop="property" | 28# 29############################################################ INCLUDES 30 31BSDCFG_SHARE="/usr/share/bsdconfig" 32. $BSDCFG_SHARE/common.subr || exit 1 33f_dprintf "%s: loading includes..." device.subr 34f_include $BSDCFG_SHARE/dialog.subr 35f_include $BSDCFG_SHARE/geom.subr --- 1075 unchanged lines hidden (view full) --- 1111# (newline to be specific) unless $var_to_set is present and non-NULL. 1112# 1113# This function is a two-parter. Below is the awk(1) portion of the function, 1114# afterward is the sh(1) function which utilizes the below awk script. 1115# 1116f_device_sort_by_awk=' 1117# Variables that should be defined on the invocation line: 1118# -v prop="property" |
1119function asorti(src, dest) | 1119function _asorti(src, dest) |
1120{ 1121 k = nitems = 0 1122 for (i in src) dest[++nitems] = i 1123 for (i = 1; i <= nitems; k = i++) { 1124 idx = dest[i] 1125 while ((k > 0) && (dest[k] > idx)) { 1126 dest[k+1] = dest[k]; k-- 1127 } --- 4 unchanged lines hidden (view full) --- 1132{ 1133 split($0, devs, FS) 1134 for (d in devs) { 1135 name = ENVIRON["_struct_value_" devs[d] "_" prop] 1136 devices[name] = devs[d] 1137 } 1138} 1139END { | 1120{ 1121 k = nitems = 0 1122 for (i in src) dest[++nitems] = i 1123 for (i = 1; i <= nitems; k = i++) { 1124 idx = dest[i] 1125 while ((k > 0) && (dest[k] > idx)) { 1126 dest[k+1] = dest[k]; k-- 1127 } --- 4 unchanged lines hidden (view full) --- 1132{ 1133 split($0, devs, FS) 1134 for (d in devs) { 1135 name = ENVIRON["_struct_value_" devs[d] "_" prop] 1136 devices[name] = devs[d] 1137 } 1138} 1139END { |
1140 nitems = asorti(devices, devices_sorted) | 1140 nitems = _asorti(devices, devices_sorted) |
1141 for (i = 1; i <= nitems; i++) print devices[devices_sorted[i]] 1142} 1143' 1144f_device_sort_by() 1145{ 1146 local __property="${1:-name}" __var_to_get="$2" __var_to_set="$3" 1147 1148 f_isset "$__var_to_get" || return $FAILURE --- 248 unchanged lines hidden --- | 1141 for (i = 1; i <= nitems; i++) print devices[devices_sorted[i]] 1142} 1143' 1144f_device_sort_by() 1145{ 1146 local __property="${1:-name}" __var_to_get="$2" __var_to_set="$3" 1147 1148 f_isset "$__var_to_get" || return $FAILURE --- 248 unchanged lines hidden --- |