uxndebug

uxn debugging suite
git clone git://bvnf.space/uxndebug.git
Log | Files | Refs | README

commit fa0145d959d999371e43009e932f9210b84c38c7
parent f0e320e64aa29b87ca23c86e0e2f1fc7acc0cb64
Author: phoebos <ben@bvnf.space>
Date:   Mon,  6 Jun 2022 10:46:36 +0100

uxnsolve: move scan into function

Diffstat:
Muxnsolve | 41+++++++++++++++++++++++------------------
1 file changed, 23 insertions(+), 18 deletions(-)

diff --git a/uxnsolve b/uxnsolve @@ -65,21 +65,26 @@ print_highlighted() { printf "\n" } -i=0 -lineno=0 -while read -r line; do - lineno="$((lineno + 1))" - # word splitting is desired. - # shellcheck disable=SC2086 - set -- $line - for op; do case "$op" in "~"*) - printf "\033[1;33mWARNING\033[m: include not followed, output probably incorrect\n" >&2 - ;; esac - done - i="$((i + $#))" - [ "$i" -ge "$token" ] && { - printf "line %d: " "$lineno" - print_highlighted "$(($# - i + token))" "$@" - break - } -done < "$source_file" +scan() { + i="$1" + lineno=0 + f="$2" + while read -r line; do + lineno="$((lineno + 1))" + # word splitting is desired. + # shellcheck disable=SC2086 + set -- $line + for op; do case "$op" in "~"*) + printf "\033[1;33mWARNING\033[m: include not followed, output probably incorrect\n" >&2 + ;; esac + done + i="$((i + $#))" + [ "$i" -ge "$token" ] && { + printf "line %d: " "$lineno" + print_highlighted "$(($# - i + token))" "$@" + break + } + done < "$f" +} + +scan 0 "$source_file"