Lines Matching +full:original +full:- +full:awk
3 # Copyright (c) 2006-2016 Devin Teske
39 " # END-QUOTE
44 # Please note that the character ranges A-Z and a-z should be avoided because
46 # For example, A-Z matches any character that sorts after A but before Z,
50 VALID_VARNAME_CHARS="0-9ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_"
60 local arg="${1#-}"
61 [ "${arg:-x}" = "${arg%[!0-9]*}" ]
64 # f_substr [-v $var_to_set] $string $start [$length]
66 # Similar to awk(1)'s substr(), return length substring of string that begins
75 -v) __var_to_set="$2"; shift 2 ;;
76 -v?*) __var_to_set="${2#-v}"; shift 1 ;;
78 local __tmp="$1" __start="${2:-1}" __len="$3"
79 [ "$__start" -gt 0 ] 2> /dev/null &&
80 __start=$(( $__start - 1 ))
102 shift $(( $OPTIND - 1 ))
104 local __tmp="$1" __start="${2:-1}" __size="$3"
109 return ${SUCCESS:-0}
111 [ "$__start" -ge 1 ] 2> /dev/null || __start=1
112 if ! [ "${__size:-1}" -ge 1 ] 2> /dev/null; then
114 return ${FAILURE:-1}
117 __trim=$(( $__start - 1 ))
118 while [ $__trim -gt 0 ]; do
121 while [ $__tbuf_len -lt $(( $__trim / $__tbuf_len )) ]
127 __trim=$(( $__trim - $__tbuf_len * $__trimq ))
128 while [ $__trimq -gt 0 ]; do
130 __trimq=$(( $__trimq - 1 ))
136 __trim=$(( $__tmp_size - ${__size:-$__tmp_size} ))
137 while [ $__trim -gt 0 ]; do
140 if [ $__trim -le $__size ]; then
141 while [ $__tbuf_len -lt $((
148 __trim=$(( $__trim - $__tbuf_len * $__trimq ))
149 while [ $__trimq -gt 0 ]; do
151 __trimq=$(( $__trimq - 1 ))
155 while [ $__tbuf_len -lt $((
162 if [ $__size -ne $((
169 $__tmp_size - $__tbuf_len * $__trimq
172 $__tmp_size - $__mask_len - $__size
174 while [ $__trimq -gt 0 ]; do
176 __trimq=$(( $__trimq - 1 ))
201 printf -v __tmp "$@"
211 eval "$__var_to_set"=\$\( printf -- \"\$@\" \)
244 # NULL unless at-least one byte is stored from the output.
249 # format_args="'abc 123'" # 3-spaces between abc and 123
256 # # even more spaces added to illustrate escape-method
263 # f_shell_escape arg2 "aaa'aaa" # arg2=[aaa'\''aaa] (escaped s-quote)
264 # format_args="'$arg1' '$arg2'" # use single-quotes to surround args
279 # capturing in a sub-shell (which is less recommended due to performance
310 # capturing in a sub-shell (which is less recommended due to performance
321 # Escape $string for shell eval statement(s) by replacing all single-quotes
323 # by eval with surrounding single-quotes.
334 # WARNING: Surrounding single-quotes are not added; this is the responsibility
375 # NOTE: Prefixes are case-insensitive.
378 # -1 is produced ($var_to_set set to -1 or if $var_to_set is NULL or missing)
391 # Remove any leading non-digits
392 __string="${__string#${__string%%[0-9]*}}"
395 __num="${__string%%[!0-9]*}"
397 # Produce `-1' if string didn't contain any digits
400 setvar "$__var_to_set" -1
402 echo -1
430 setvar "$__var_to_set" -1
432 echo -1
439 if [ $__num -gt $__maxinput ]; then
440 # Input (before expanding) would exceed 64-bit signed int
442 setvar "$__var_to_set" -1
444 echo -1
460 # Simple wrapper to an awk(1) script to print the length of the longest line of
461 # input (read from stdin). Supports the newline escape-sequence `\n' for
485 awk "$f_longest_line_length_awk"
490 # Simple wrapper to an awk(1) script to print the number of lines read from
491 # stdin. Supports newline escape-sequence `\n' for splitting a single line into
503 awk "$f_number_of_lines_awk"
508 # Encode $text for the purpose of embedding safely into a URL. Non-alphanumeric
509 # characters are converted to `%XX' sequence where XX represents the hexa-
510 # decimal ordinal of the non-alphanumeric character. If $text is missing, data
532 if [ $# -gt 0 ]; then
533 echo "$1" | awk "$f_uriencode_awk"
535 awk "$f_uriencode_awk"
542 # sequence into original unencoded ASCII sequences. If $text is missing, data
565 if [ $# -gt 0 ]; then
566 echo "$1" | awk "$f_uridecode_awk"
568 awk "$f_uridecode_awk"