Skip to content

Commit

Permalink
init: ported Scan_Any_{String,Unicode} primitive function
Browse files Browse the repository at this point in the history
Since there are a number of level 1 libraries using the string
function, we have to port its primitive ones into HestiaKERNEL
library. Let's do this.

This patch ports Scan_Any_{String,Unicode} primitive function
into HestiaKERNEL library into init/ directory.

Co-authored-by: Shuralyov, Jean <[email protected]>
Co-authored-by: Galyna, Cory <[email protected]>
Co-authored-by: (Holloway) Chew, Kean Ho <[email protected]>
Signed-off-by: (Holloway) Chew, Kean Ho <[email protected]>
  • Loading branch information
4 people committed Nov 13, 2024
1 parent 95a0ce4 commit 64c2d87
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 0 deletions.
39 changes: 39 additions & 0 deletions init/services/HestiaKERNEL/String/Scan_Any_String.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright 2024 (Holloway) Chew, Kean Ho <[email protected]>
#
#
# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License").
# You must comply with the license to use the content. Get the License at:
#
# https://doi.org/10.5281/zenodo.13770769
#
# You MUST ensure any interaction with the content STRICTLY COMPLIES with
# the permissions and limitations set forth in the license.
. "${env:LIBS_HESTIA}\HestiaKERNEL\Unicode\Scan_Any_Unicode.ps1"
. "${env:LIBS_HESTIA}\HestiaKERNEL\Unicode\To_Unicode_From_String.ps1"




function HestiaKERNEL-Scan-Any-String {
param (
[string]$___input,
[string]$___target,
[int32]$___count,
[int32]$___ignore,
[string]$___from_right
)


# execute
$___content = HestiaKERNEL-To-Unicode-From-String $___input
$___chars = HestiaKERNEL-To-Unicode-From-String $___target


# report status
return HestiaKERNEL-Scan-Any-Unicode `
$___content `
$___chars `
$___count `
$___ignore `
$___from_right
}
34 changes: 34 additions & 0 deletions init/services/HestiaKERNEL/String/Scan_Any_String.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh
# Copyright 2024 (Holloway) Chew, Kean Ho <[email protected]>
#
#
# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License").
# You must comply with the license to use the content. Get the License at:
#
# https://doi.org/10.5281/zenodo.13770769
#
# You MUST ensure any interaction with the content STRICTLY COMPLIES with
# the permissions and limitations set forth in the license.
. "${LIBS_HESTIA}/HestiaKERNEL/Unicode/Scan_Any_Unicode.sh"
. "${LIBS_HESTIA}/HestiaKERNEL/Unicode/To_Unicode_From_String.sh"




HestiaKERNEL_Scan_Any_String() {
#___input="$1"
#___target="$2"
#___count="$3"
#___ignore="$4"
#___from_right="$5"


# execute
___content="$(HestiaKERNEL_To_Unicode_From_String "$1")"
___chars="$(HestiaKERNEL_To_Unicode_From_String "$2")"
printf -- "%b" "$(HestiaKERNEL_Scan_Any_Unicode "$___content" "$___chars" "$3" "$4" "$5")"


# report status
return $?
}
42 changes: 42 additions & 0 deletions init/services/HestiaKERNEL/Unicode/Scan_Any_Unicode.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright 2024 (Holloway) Chew, Kean Ho <[email protected]>
#
#
# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License").
# You must comply with the license to use the content. Get the License at:
#
# https://doi.org/10.5281/zenodo.13770769
#
# You MUST ensure any interaction with the content STRICTLY COMPLIES with
# the permissions and limitations set forth in the license.
. "${env:LIBS_HESTIA}\HestiaKERNEL\Unicode\Scan_Any_Left_Unicode.ps1"
. "${env:LIBS_HESTIA}\HestiaKERNEL\Unicode\Scan_Any_Right_Unicode.ps1"




function HestiaKERNEL-Scan-Any-Unicode {
param (
[uint32[]]$___content_unicode,
[uint32[]]$___target_unicode,
[int32]$___count,
[int32]$___ignore,
[string]$___from_right
)


# execute
if ($___from_right -ne "") {
# from right
return HestiaKERNEL-Scan-Any-Right-Unicode `
$___content_unicode `
$___target_unicode `
$___count `
$___ignore
} else {
return HestiaKERNEL-Scan-Any-Left-Unicode `
$___content_unicode `
$___target_unicode `
$___count `
$___ignore
}
}
36 changes: 36 additions & 0 deletions init/services/HestiaKERNEL/Unicode/Scan_Any_Unicode.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/sh
# Copyright 2024 (Holloway) Chew, Kean Ho <[email protected]>
#
#
# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License").
# You must comply with the license to use the content. Get the License at:
#
# https://doi.org/10.5281/zenodo.13770769
#
# You MUST ensure any interaction with the content STRICTLY COMPLIES with
# the permissions and limitations set forth in the license.
. "${LIBS_HESTIA}/HestiaKERNEL/Unicode/Scan_Any_Left_Unicode.sh"
. "${LIBS_HESTIA}/HestiaKERNEL/Unicode/Scan_Any_Right_Unicode.sh"




HestiaKERNEL_Scan_Any_Unicode() {
#___content_unicode="$1"
#___target_unicode="$2"
#___count="$3"
#___ignore="$4"
#___from_right="$5"


# execute
if [ ! "$5" = "" ]; then
printf -- "%b" "$(HestiaKERNEL_Scan_Any_Right_Unicode "$1" "$2" "$3" "$4")"
else
printf -- "%b" "$(HestiaKERNEL_Scan_Any_Left_Unicode "$1" "$2" "$3" "$4")"
fi


# report status
return $?
}
4 changes: 4 additions & 0 deletions init/services/HestiaKERNEL/Vanilla.sh.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ echo \" <<'RUN_AS_POWERSHELL' >/dev/null # " | Out-Null
. "${env:LIBS_HESTIA}\HestiaKERNEL\String\Is_Whitespace_String.ps1"
. "${env:LIBS_HESTIA}\HestiaKERNEL\String\Scan_Any_Left_String.ps1"
. "${env:LIBS_HESTIA}\HestiaKERNEL\String\Scan_Any_Right_String.ps1"
. "${env:LIBS_HESTIA}\HestiaKERNEL\String\Scan_Any_String.ps1"
. "${env:LIBS_HESTIA}\HestiaKERNEL\String\Scan_Left_String.ps1"
. "${env:LIBS_HESTIA}\HestiaKERNEL\String\Scan_Right_String.ps1"
. "${env:LIBS_HESTIA}\HestiaKERNEL\String\Scan_String.ps1"
Expand Down Expand Up @@ -81,6 +82,7 @@ echo \" <<'RUN_AS_POWERSHELL' >/dev/null # " | Out-Null
. "${env:LIBS_HESTIA}\HestiaKERNEL\Unicode\Is_Whitespace_Unicode.ps1"
. "${env:LIBS_HESTIA}\HestiaKERNEL\Unicode\Scan_Any_Left_Unicode.ps1"
. "${env:LIBS_HESTIA}\HestiaKERNEL\Unicode\Scan_Any_Right_Unicode.ps1"
. "${env:LIBS_HESTIA}\HestiaKERNEL\Unicode\Scan_Any_Unicode.ps1"
. "${env:LIBS_HESTIA}\HestiaKERNEL\Unicode\Scan_Left_Unicode.ps1"
. "${env:LIBS_HESTIA}\HestiaKERNEL\Unicode\Scan_Right_Unicode.ps1"
. "${env:LIBS_HESTIA}\HestiaKERNEL\Unicode\Scan_Unicode.ps1"
Expand Down Expand Up @@ -135,6 +137,7 @@ RUN_AS_POWERSHELL
. "${LIBS_HESTIA}/HestiaKERNEL/String/Is_Whitespace_String.sh"
. "${LIBS_HESTIA}/HestiaKERNEL/String/Scan_Any_Left_String.sh"
. "${LIBS_HESTIA}/HestiaKERNEL/String/Scan_Any_Right_String.sh"
. "${LIBS_HESTIA}/HestiaKERNEL/String/Scan_Any_String.sh"
. "${LIBS_HESTIA}/HestiaKERNEL/String/Scan_Left_String.sh"
. "${LIBS_HESTIA}/HestiaKERNEL/String/Scan_Right_String.sh"
. "${LIBS_HESTIA}/HestiaKERNEL/String/Scan_String.sh"
Expand Down Expand Up @@ -164,6 +167,7 @@ RUN_AS_POWERSHELL
. "${LIBS_HESTIA}/HestiaKERNEL/Unicode/Is_Whitespace_Unicode.sh"
. "${LIBS_HESTIA}/HestiaKERNEL/Unicode/Scan_Any_Left_Unicode.sh"
. "${LIBS_HESTIA}/HestiaKERNEL/Unicode/Scan_Any_Right_Unicode.sh"
. "${LIBS_HESTIA}/HestiaKERNEL/Unicode/Scan_Any_Unicode.sh"
. "${LIBS_HESTIA}/HestiaKERNEL/Unicode/Scan_Left_Unicode.sh"
. "${LIBS_HESTIA}/HestiaKERNEL/Unicode/Scan_Right_Unicode.sh"
. "${LIBS_HESTIA}/HestiaKERNEL/Unicode/Scan_Unicode.sh"
Expand Down
6 changes: 6 additions & 0 deletions init/start.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ Write-Host "|$(HestiaKERNEL-Scan-String "e你feeeff你你aerg aegE你F" "a" "-1"
Write-Host "|$(HestiaKERNEL-Scan-String "e你feeeff你你aerg aegE你F" "a" "-1" "-1")|"
Write-Host "----"

Write-Host "---- Scan-Any-String ----"
. "${env:LIBS_HESTIA}\HestiaKERNEL\String\Scan_Any_String.ps1"
Write-Host "|$(HestiaKERNEL-Scan-Any-String "e你feeeff你你aerg aegE你F" "a" "-1" "-1" "right")|"
Write-Host "|$(HestiaKERNEL-Scan-Any-String "e你feeeff你你aerg aegE你F" "a" "-1" "-1")|"
Write-Host "----"

Write-Host "---- Scan-Any-Right-String ----"
. "${env:LIBS_HESTIA}\HestiaKERNEL\String\Scan_Any_Right_String.ps1"
Write-Host "|$(HestiaKERNEL-Scan-Any-Right-String "e你feeeff你你aerg aegE你F" '')|"
Expand Down
5 changes: 5 additions & 0 deletions init/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ LIBS_HESTIA="${LIBS_UPSCALER}/services"
1>&2 printf -- "|%s|\n" "$(HestiaKERNEL_Scan_String "e你feeeff你你aerg aegE你F" "a" "-1" "-1" "right")"
1>&2 printf -- "|%s|\n" "$(HestiaKERNEL_Scan_String "e你feeeff你你aerg aegE你F" "a" "-1" "-1")"

1>&2 printf -- "---- Scan_Any_String ----\n"
. "${LIBS_HESTIA}/HestiaKERNEL/String/Scan_Any_String.sh"
1>&2 printf -- "|%s|\n" "$(HestiaKERNEL_Scan_Any_String "e你feeeff你你aerg aegE你F" "a" "-1" "-1" "right")"
1>&2 printf -- "|%s|\n" "$(HestiaKERNEL_Scan_Any_String "e你feeeff你你aerg aegE你F" "a" "-1" "-1")"

1>&2 printf -- "---- Scan_Any_Right_String ----\n"
. "${LIBS_HESTIA}/HestiaKERNEL/String/Scan_Any_Right_String.sh"
1>&2 printf -- "|%s|\n" "$(HestiaKERNEL_Scan_Any_Right_String "e你feeeff你你aerg aegE你F" "")"
Expand Down

0 comments on commit 64c2d87

Please sign in to comment.