Skip to content

Commit

Permalink
init: ported Scan_{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_{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 12, 2024
1 parent 402bebf commit 29a5615
Show file tree
Hide file tree
Showing 7 changed files with 161 additions and 0 deletions.
34 changes: 34 additions & 0 deletions init/services/HestiaKERNEL/String/Scan_String.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# 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_Unicode.ps1"
. "${env:LIBS_HESTIA}\HestiaKERNEL\Unicode\To_Unicode_From_String.ps1"




function HestiaKERNEL-Scan-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-Unicode $___content $___chars $___count $___ignore $___from_right
}
34 changes: 34 additions & 0 deletions init/services/HestiaKERNEL/String/Scan_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_Unicode.sh"
. "${LIBS_HESTIA}/HestiaKERNEL/Unicode/To_Unicode_From_String.sh"




HestiaKERNEL_Scan_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_Unicode "$___content" "$___chars" "$3" "$4" "$5")"


# report status
return $?
}
42 changes: 42 additions & 0 deletions init/services/HestiaKERNEL/Unicode/Scan_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_Left_Unicode.ps1"
. "${env:LIBS_HESTIA}\HestiaKERNEL\Unicode\Scan_Right_Unicode.ps1"




function HestiaKERNEL-Scan-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-Right-Unicode `
$___content_unicode `
$___target_unicode `
$___count `
$___ignore
} else {
return HestiaKERNEL-Scan-Left-Unicode `
$___content_unicode `
$___target_unicode `
$___count `
$___ignore
}
}
36 changes: 36 additions & 0 deletions init/services/HestiaKERNEL/Unicode/Scan_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_Left_Unicode.sh"
. "${LIBS_HESTIA}/HestiaKERNEL/Unicode/Scan_Right_Unicode.sh"




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


# execute
if [ ! "$5" = "" ]; then
printf -- "%b" "$(HestiaKERNEL_Scan_Right_Unicode "$1" "$2" "$3" "$4")"
else
printf -- "%b" "$(HestiaKERNEL_Scan_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_Left_String.ps1"
. "${env:LIBS_HESTIA}\HestiaKERNEL\String\Scan_Right_String.ps1"
. "${env:LIBS_HESTIA}\HestiaKERNEL\String\Scan_String.ps1"
. "${env:LIBS_HESTIA}\HestiaKERNEL\String\To_Lowercase_String.ps1"
. "${env:LIBS_HESTIA}\HestiaKERNEL\String\To_String_From_Unicode.ps1"
. "${env:LIBS_HESTIA}\HestiaKERNEL\String\To_Titlecase_String.ps1"
Expand All @@ -78,6 +79,7 @@ echo \" <<'RUN_AS_POWERSHELL' >/dev/null # " | Out-Null
. "${env:LIBS_HESTIA}\HestiaKERNEL\Unicode\Is_Whitespace_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"
. "${env:LIBS_HESTIA}\HestiaKERNEL\Unicode\To_Lowercase_Unicode.ps1"
. "${env:LIBS_HESTIA}\HestiaKERNEL\Unicode\To_Titlecase_Unicode.ps1"
. "${env:LIBS_HESTIA}\HestiaKERNEL\Unicode\To_Unicode_From_String.ps1"
Expand Down Expand Up @@ -129,6 +131,7 @@ RUN_AS_POWERSHELL
. "${LIBS_HESTIA}/HestiaKERNEL/String/Is_Whitespace_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"
. "${LIBS_HESTIA}/HestiaKERNEL/String/To_Lowercase_String.sh"
. "${LIBS_HESTIA}/HestiaKERNEL/String/To_String_From_Unicode.sh"
. "${LIBS_HESTIA}/HestiaKERNEL/String/To_Titlecase_String.sh"
Expand All @@ -155,6 +158,7 @@ RUN_AS_POWERSHELL
. "${LIBS_HESTIA}/HestiaKERNEL/Unicode/Is_Whitespace_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"
. "${LIBS_HESTIA}/HestiaKERNEL/Unicode/To_Lowercase_Unicode.sh"
. "${LIBS_HESTIA}/HestiaKERNEL/Unicode/To_Titlecase_Unicode.sh"
. "${LIBS_HESTIA}/HestiaKERNEL/Unicode/To_Unicode_From_String.sh"
Expand Down
6 changes: 6 additions & 0 deletions init/start.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ ${env:LIBS_HESTIA} = "${env:LIBS_UPSCALER}\services"
. "${env:LIBS_UPSCALER}\services\i18n\report-success.ps1"

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

Write-Host "---- Scan-Right-String ----"
. "${env:LIBS_HESTIA}\HestiaKERNEL\String\Scan_Right_String.ps1"
Write-Host "|$(HestiaKERNEL-Scan-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 @@ -102,6 +102,11 @@ LIBS_HESTIA="${LIBS_UPSCALER}/services"
. "${LIBS_UPSCALER}/services/i18n/report-success.sh"

### TEST ZONE
1>&2 printf -- "---- Scan_String ----\n"
. "${LIBS_HESTIA}/HestiaKERNEL/String/Scan_String.sh"
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_Right_String ----\n"
. "${LIBS_HESTIA}/HestiaKERNEL/String/Scan_Right_String.sh"
1>&2 printf -- "|%s|\n" "$(HestiaKERNEL_Scan_Right_String "e你feeeff你你aerg aegE你F" "")"
Expand Down

0 comments on commit 29a5615

Please sign in to comment.