strings.subr (240783) | strings.subr (241700) |
---|---|
1if [ ! "$_STRINGS_SUBR" ]; then _STRINGS_SUBR=1 2# 3# Copyright (c) 2006-2012 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 (INLUDING, 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 [ ! "$_STRINGS_SUBR" ]; then _STRINGS_SUBR=1 2# 3# Copyright (c) 2006-2012 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 (INLUDING, 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: head/usr.sbin/bsdconfig/share/strings.subr 240783 2012-09-21 19:03:25Z dteske $ | 27# $FreeBSD: head/usr.sbin/bsdconfig/share/strings.subr 241700 2012-10-18 17:09:45Z dteske $ |
28 29# f_substr "$string" $start [ $length ] 30# 31# Simple wrapper to awk(1)'s `substr' function. 32# 33f_substr() 34{ 35 local string="$1" start="${2:-0}" len="${3:-0}" --- 34 unchanged lines hidden (view full) --- 70# 71# Simple wrapper to an awk(1) script to print the number of lines read from 72# stdin. Supports newline escape-sequence `\n' for splitting a single line into 73# multiple lines. 74# 75f_number_of_lines_awk=' 76BEGIN { num_lines = 0 } 77{ | 28 29# f_substr "$string" $start [ $length ] 30# 31# Simple wrapper to awk(1)'s `substr' function. 32# 33f_substr() 34{ 35 local string="$1" start="${2:-0}" len="${3:-0}" --- 34 unchanged lines hidden (view full) --- 70# 71# Simple wrapper to an awk(1) script to print the number of lines read from 72# stdin. Supports newline escape-sequence `\n' for splitting a single line into 73# multiple lines. 74# 75f_number_of_lines_awk=' 76BEGIN { num_lines = 0 } 77{ |
78 num_lines += split($0, unused, /\\n/) | 78 num_lines += split(" "$0, unused, /\\n/) |
79} 80END { print num_lines } 81' 82f_number_of_lines() 83{ 84 awk "$f_number_of_lines_awk" 85} 86 --- 18 unchanged lines hidden --- | 79} 80END { print num_lines } 81' 82f_number_of_lines() 83{ 84 awk "$f_number_of_lines_awk" 85} 86 --- 18 unchanged lines hidden --- |