Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 7 Mar 2014 20:29:19 +0000 (UTC)
From:      Devin Teske <dteske@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r262901 - head/usr.sbin/bsdconfig/share
Message-ID:  <201403072029.s27KTKU2031405@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dteske
Date: Fri Mar  7 20:29:19 2014
New Revision: 262901
URL: http://svnweb.freebsd.org/changeset/base/262901

Log:
  s/__number/__num/ for code clarify but more to prevent localization of
  __number if passed as the var_to_set argument.

Modified:
  head/usr.sbin/bsdconfig/share/strings.subr

Modified: head/usr.sbin/bsdconfig/share/strings.subr
==============================================================================
--- head/usr.sbin/bsdconfig/share/strings.subr	Fri Mar  7 20:24:59 2014	(r262900)
+++ head/usr.sbin/bsdconfig/share/strings.subr	Fri Mar  7 20:29:19 2014	(r262901)
@@ -34,6 +34,12 @@ BSDCFG_SHARE="/usr/share/bsdconfig"
 ############################################################ GLOBALS
 
 #
+# A Literal newline (for use with f_replace_all(), or IFS, or whatever)
+#
+NL="
+" # END-QUOTE
+
+#
 # Valid characters that can appear in an sh(1) variable name
 #
 # Please note that the character ranges A-Z and a-z should be avoided because
@@ -369,14 +375,16 @@ f_shell_unescape()
 f_expand_number()
 {
 	local __string="$1" __var_to_set="$2"
-	local __cp __number __bshift __maxinput
+	local __cp __num __bshift __maxinput
 
-	# Remove any leading non-digits and store numbers (sans suffix)
+	# Remove any leading non-digits
 	__string="${__string#${__string%%[0-9]*}}"
-	__number="${__string%%[!0-9]*}"
+
+	# Store the numbers (no trailing suffix)
+	__num="${__string%%[!0-9]*}"
 
 	# Produce `-1' if string didn't contain any digits
-	if [ ! "$__number" ]; then
+	if [ ! "$__num" ]; then
 		if [ "$__var_to_set" ]; then
 			setvar "$__var_to_set" -1
 		else
@@ -386,7 +394,7 @@ f_expand_number()
 	fi
 
 	# Remove all the leading numbers from the string to get at the prefix
-	__string="${__string#"$__number"}"
+	__string="${__string#"$__num"}"
 
 	#
 	# Test for invalid prefix (and determine bitshift length)
@@ -394,9 +402,9 @@ f_expand_number()
 	case "$__string" in
 	""|[[:space:]]*) # Shortcut
 		if [ "$__var_to_set" ]; then
-			setvar "$__var_to_set" $__number
+			setvar "$__var_to_set" $__num
 		else
-			echo $__number
+			echo $__num
 		fi
 		return $SUCCESS ;;
 	[Kk]*) __bshift=10 ;;
@@ -417,7 +425,7 @@ f_expand_number()
 
 	# Determine if the wheels fall off
 	__maxinput=$(( 0x7fffffffffffffff >> $__bshift ))
-	if [ $__number -gt $__maxinput ]; then
+	if [ $__num -gt $__maxinput ]; then
 		# Input (before expanding) would exceed 64-bit signed int
 		if [ "$__var_to_set" ]; then
 			setvar "$__var_to_set" -1
@@ -428,11 +436,11 @@ f_expand_number()
 	fi
 
 	# Shift the number out and produce it
-	__number=$(( $__number << $__bshift ))
+	__num=$(( $__num << $__bshift ))
 	if [ "$__var_to_set" ]; then
-		setvar "$__var_to_set" $__number
+		setvar "$__var_to_set" $__num
 	else
-		echo $__number
+		echo $__num
 	fi
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201403072029.s27KTKU2031405>