Skip to content

Commit

Permalink
init: backported Replace_Right_Unicode corrections to Left functions
Browse files Browse the repository at this point in the history
There were some functional errors discovered in Replace_Right_Unicode
functions implementations. Hence, let's backport them back to
Replace_Left_Unicode variants.

This patch backports Replace_Right_Unicode corrections to
Replace_Left_Unicode within string components of HestiaKERNEL inside
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 24, 2024
1 parent 1e6bf7b commit 8ca5f22
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
20 changes: 6 additions & 14 deletions init/services/HestiaKERNEL/Unicode/Replace_Left_Unicode.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#
# You MUST ensure any interaction with the content STRICTLY COMPLIES with
# the permissions and limitations set forth in the license.
. "${env:LIBS_HESTIA}\HestiaKERNEL\Errors\Error_Codes.ps1"
. "${env:LIBS_HESTIA}\HestiaKERNEL\Unicode\Is_Unicode.ps1"
. "${env:LIBS_HESTIA}\HestiaKERNEL\Number\Is_Number.ps1"

Expand Down Expand Up @@ -67,6 +68,11 @@ function HestiaKERNEL-Replace-Left-Unicode {
# get current character
$___current = $___content_unicode[$___index]

if ($___is_replacing -ne 0) {
$___converted.Add($___current)
continue
}


# get target character
$___from = $___from_unicode[$___from_index]
Expand Down Expand Up @@ -107,13 +113,6 @@ function HestiaKERNEL-Replace-Left-Unicode {
if ($___count -le 0) {
$___is_replacing = 1

if ($___buffer.Length -gt 0) {
foreach ($___char in $___buffer) {
$___converted.Add($___char)
}
[System.Collections.Generic.List[uint32]]$___buffer = @()
}

continue
}
}
Expand All @@ -132,13 +131,6 @@ function HestiaKERNEL-Replace-Left-Unicode {
$___from_index = 0
}

if ($___buffer.Length -gt 0) {
foreach ($___char in $___buffer) {
$___converted.Add($___char)
}
[System.Collections.Generic.List[uint32]]$___buffer = @()
}


# report status
return [uint32[]]$___converted
Expand Down
7 changes: 1 addition & 6 deletions init/services/HestiaKERNEL/Unicode/Replace_Left_Unicode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,6 @@ HestiaKERNEL_Replace_Left_Unicode() {
if [ $___count -le 0 ]; then
___is_replacing=1

if [ ! "$___buffer" = "" ]; then
___converted="${___converted}${___buffer%, }, "
___buffer=""
fi

continue
fi
fi
Expand All @@ -135,7 +130,7 @@ HestiaKERNEL_Replace_Left_Unicode() {
___from_unicode="$2"
done

if [ ! "$___buffer" = "" ]; then
if [ ! "$___to_unicode" = "" ] && [ ! "$___buffer" = "" ]; then
___converted="${___converted}${___buffer%, }, "
___buffer=""
fi
Expand Down

0 comments on commit 8ca5f22

Please sign in to comment.