Skip to content

Commit

Permalink
Regenerate examples
Browse files Browse the repository at this point in the history
  • Loading branch information
laurenthuberdeau committed Feb 20, 2025
1 parent 4f6e1da commit af6c727
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 42 deletions.
22 changes: 11 additions & 11 deletions examples/compiled/base64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ defarr() { _malloc $1 $2; }
defarr _buf 1024

unpack_escaped_string() { # $1 = string, $2 = size (optional)
__buf="$1"
__str="$1"
# Allocates enough space for all characters, assuming that no character is escaped
_malloc __addr $((${2:-${#__buf} + 1}))
_malloc __addr $((${2:-${#__str} + 1}))
__ptr=$__addr
__end=$((__ptr + ${2:-${#__buf} + 1})) # End of allocated memory
while [ -n "$__buf" ] ; do
case "$__buf" in
__end=$((__ptr + ${2:-${#__str} + 1})) # End of allocated memory
while [ -n "$__str" ] ; do
case "$__str" in
'\'*)
__buf="${__buf#?}" # Remove the current char from $__buf
case "$__buf" in
__str="${__str#?}" # Remove the current char from $__str
case "$__str" in
'0'*) __c=0 ;;
'a'*) __c=7 ;;
'b'*) __c=8 ;;
Expand All @@ -38,13 +38,13 @@ unpack_escaped_string() { # $1 = string, $2 = size (optional)
"'"*) __c=39 ;;
'?'*) __c=63 ;;
'$'*) __c=36 ;; # Not in C, used to escape variable expansion between double quotes
*) echo "invalid escape in string: $__buf"; exit 1 ;;
*) echo "invalid escape in string: $__str"; exit 1 ;;
esac
__buf="${__buf#?}" # Remove the current char from $__buf
__str="${__str#?}" # Remove the current char from $__str
;;
*)
__c=$(printf "%d" "'${__buf%"${__buf#?}"}"); __c=$((__c > 0 ? __c : 256 + __c))
__buf="${__buf#?}" # Remove the current char from $__buf
__c=$(printf "%d" "'${__str%"${__str#?}"}"); __c=$((__c > 0 ? __c : 256 + __c))
__str="${__str#?}" # Remove the current char from $__str
;;
esac
: $((_$__ptr = __c))
Expand Down
20 changes: 10 additions & 10 deletions examples/compiled/c4.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1354,13 +1354,13 @@ char_to_int() {
next_sub_buffer() {
if [ -z "$__us_buf256" ]; then
if [ ${#__buf} -ge 256 ]; then
__temp="${__buf#????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????}"
__us_buf256="${__buf%"$__temp"}"
__buf="$__temp"
if [ ${#__str} -ge 256 ]; then
__temp="${__str#????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????}"
__us_buf256="${__str%"$__temp"}"
__str="$__temp"
else
__us_buf256="$__buf"
__buf=
__us_buf256="$__str"
__str=
fi
fi
if [ -z "$__us_buf16" ]; then
Expand All @@ -1375,14 +1375,14 @@ next_sub_buffer() {
fi
}
unpack_escaped_string() { # $1 = string, $2 = size (optional)
__buf="$1"
__str="$1"
# Allocates enough space for all characters, assuming that no character is escaped
_malloc __addr $((${2:-${#__buf} + 1}))
_malloc __addr $((${2:-${#__str} + 1}))
__ptr=$__addr
__end=$((__ptr + ${2:-${#__buf} + 1})) # End of allocated memory
__end=$((__ptr + ${2:-${#__str} + 1})) # End of allocated memory
__us_buf16=
__us_buf256=
while [ ! -z "$__buf" ] || [ ! -z "$__us_buf256" ] ; do
while [ ! -z "$__str" ] || [ ! -z "$__us_buf256" ] ; do
next_sub_buffer
while [ ! -z "$__us_buf16" ]; do
case "$__us_buf16" in
Expand Down
20 changes: 10 additions & 10 deletions examples/compiled/repl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ char_to_int() {

next_sub_buffer() {
if [ -z "$__us_buf256" ]; then
if [ ${#__buf} -ge 256 ]; then
__temp="${__buf#????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????}"
__us_buf256="${__buf%"$__temp"}"
__buf="$__temp"
if [ ${#__str} -ge 256 ]; then
__temp="${__str#????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????}"
__us_buf256="${__str%"$__temp"}"
__str="$__temp"
else
__us_buf256="$__buf"
__buf=
__us_buf256="$__str"
__str=
fi
fi
if [ -z "$__us_buf16" ]; then
Expand All @@ -136,14 +136,14 @@ next_sub_buffer() {
fi
}
unpack_escaped_string() { # $1 = string, $2 = size (optional)
__buf="$1"
__str="$1"
# Allocates enough space for all characters, assuming that no character is escaped
_malloc __addr $((${2:-${#__buf} + 1}))
_malloc __addr $((${2:-${#__str} + 1}))
__ptr=$__addr
__end=$((__ptr + ${2:-${#__buf} + 1})) # End of allocated memory
__end=$((__ptr + ${2:-${#__str} + 1})) # End of allocated memory
__us_buf16=
__us_buf256=
while [ ! -z "$__buf" ] || [ ! -z "$__us_buf256" ] ; do
while [ ! -z "$__str" ] || [ ! -z "$__us_buf256" ] ; do
next_sub_buffer
while [ ! -z "$__us_buf16" ]; do
case "$__us_buf16" in
Expand Down
22 changes: 11 additions & 11 deletions examples/compiled/sha256sum.sh
Original file line number Diff line number Diff line change
Expand Up @@ -236,16 +236,16 @@ readonly __NEWLINE__=10
# Runtime library
unpack_escaped_string() { # $1 = string, $2 = size (optional)
__buf="$1"
__str="$1"
# Allocates enough space for all characters, assuming that no character is escaped
_malloc __addr $((${2:-${#__buf} + 1}))
_malloc __addr $((${2:-${#__str} + 1}))
__ptr=$__addr
__end=$((__ptr + ${2:-${#__buf} + 1})) # End of allocated memory
while [ -n "$__buf" ] ; do
case "$__buf" in
__end=$((__ptr + ${2:-${#__str} + 1})) # End of allocated memory
while [ -n "$__str" ] ; do
case "$__str" in
'\'*)
__buf="${__buf#?}" # Remove the current char from $__buf
case "$__buf" in
__str="${__str#?}" # Remove the current char from $__str
case "$__str" in
'0'*) __c=0 ;;
'a'*) __c=7 ;;
'b'*) __c=8 ;;
Expand All @@ -259,13 +259,13 @@ unpack_escaped_string() { # $1 = string, $2 = size (optional)
"'"*) __c=39 ;;
'?'*) __c=63 ;;
'$'*) __c=36 ;; # Not in C, used to escape variable expansion between double quotes
*) echo "invalid escape in string: $__buf"; exit 1 ;;
*) echo "invalid escape in string: $__str"; exit 1 ;;
esac
__buf="${__buf#?}" # Remove the current char from $__buf
__str="${__str#?}" # Remove the current char from $__str
;;
*)
__c=$(printf "%d" "'${__buf%"${__buf#?}"}"); __c=$((__c > 0 ? __c : 256 + __c))
__buf="${__buf#?}" # Remove the current char from $__buf
__c=$(printf "%d" "'${__str%"${__str#?}"}"); __c=$((__c > 0 ? __c : 256 + __c))
__str="${__str#?}" # Remove the current char from $__str
;;
esac
: $((_$__ptr = __c))
Expand Down

0 comments on commit af6c727

Please sign in to comment.