diff options
author | dteske <dteske@FreeBSD.org> | 2014-03-07 20:29:19 +0000 |
---|---|---|
committer | dteske <dteske@FreeBSD.org> | 2014-03-07 20:29:19 +0000 |
commit | 133f75adb511635261cb16e0abf8b607c0562ad8 (patch) | |
tree | ad71d96250f50128885306a91d5b2d10a4063ae1 /usr.sbin | |
parent | 7649b4db470f7a87bea4871dbb5703db99aa3905 (diff) | |
download | FreeBSD-src-133f75adb511635261cb16e0abf8b607c0562ad8.zip FreeBSD-src-133f75adb511635261cb16e0abf8b607c0562ad8.tar.gz |
s/__number/__num/ for code clarify but more to prevent localization of
__number if passed as the var_to_set argument.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bsdconfig/share/strings.subr | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/usr.sbin/bsdconfig/share/strings.subr b/usr.sbin/bsdconfig/share/strings.subr index 1bb42e3..5576468 100644 --- a/usr.sbin/bsdconfig/share/strings.subr +++ b/usr.sbin/bsdconfig/share/strings.subr @@ -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 } |