mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-24 11:29:10 +00:00
Add f_sprintf() and f_vsprintf() to go along with previously added
f_snprintf() and f_vsnprintf() (size-constraint) functions.
This commit is contained in:
parent
62c7db8a8a
commit
0efb8b7a98
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=257791
@ -77,6 +77,18 @@ f_snprintf()
|
||||
}'\' \)
|
||||
}
|
||||
|
||||
# f_sprintf $var_to_set $format [$arguments ...]
|
||||
#
|
||||
# Similar to sprintf(3), write a string into $var_to_set using printf(1) syntax
|
||||
# (`$format [$arguments ...]').
|
||||
#
|
||||
f_sprintf()
|
||||
{
|
||||
local __var_to_set="$1"
|
||||
shift 1 # var_to_set
|
||||
eval "$__var_to_set"=\$\( printf -- \"\$@\" \)
|
||||
}
|
||||
|
||||
# f_vsnprintf $var_to_set $size $format $format_args
|
||||
#
|
||||
# Similar to vsnprintf(3), write at most $size number of bytes into $var_to_set
|
||||
@ -112,6 +124,16 @@ f_vsnprintf()
|
||||
eval f_snprintf \"\$1\" \"\$2\" \"\$3\" $4
|
||||
}
|
||||
|
||||
# f_vsprintf $var_to_set $format $format_args
|
||||
#
|
||||
# Similar to vsprintf(3), write a string into $var_to_set using printf(1)
|
||||
# syntax (`$format $format_args').
|
||||
#
|
||||
f_vsprintf()
|
||||
{
|
||||
eval f_sprintf \"\$1\" \"\$2\" $3
|
||||
}
|
||||
|
||||
# f_longest_line_length
|
||||
#
|
||||
# Simple wrapper to an awk(1) script to print the length of the longest line of
|
||||
|
Loading…
Reference in New Issue
Block a user