diff --git a/.github/workflows/make.pas b/.github/workflows/make.pas index bc2c5f9..f6612af 100644 --- a/.github/workflows/make.pas +++ b/.github/workflows/make.pas @@ -14,202 +14,185 @@ Process; const - Src: string = 'SimpleBaseLib.Benchmark/FreePascal.Benchmark'; - Use: string = 'SimpleBaseLib/src/Packages/FPC/'; - Tst: string = 'SimpleBaseLibConsole.Tests.lpi'; - Pkg: array of string = (); + Target: string = '.'; + Dependencies: array of string = (); type Output = record - Code: integer; + Code: boolean; Output: ansistring; end; -var - Each, Item, PackagePath, TempFile, Url: string; - Line: ansistring; - Answer: Output; - List: TStringList; - Zip: TStream; - - procedure CheckModules; + function CheckModules: Output; begin if FileExists('.gitmodules') then if RunCommand('git', ['submodule', 'update', '--init', '--recursive', - '--force', '--remote'], Answer.Output) then - Writeln(stderr, #27'[33m', Answer.Output, #27'[0m') - else - begin - ExitCode += 1; - Writeln(stderr, #27'[31m', Answer.Output, #27'[0m'); - end; + '--force', '--remote'], Result.Output) then + Writeln(stderr, #27'[33m', Result.Output, #27'[0m'); end; - procedure AddPackage(Path: string); + function AddPackage(Path: string): Output; begin - List := FindAllFiles(Use, '*.lpk', True); - try - for Each in List do - if RunCommand('lazbuild', ['--add-package-link', Each], Answer.Output) then - Writeln(stderr, #27'[33m', 'added ', Each, #27'[0m') - else - begin - ExitCode += 1; - Writeln(stderr, #27'[31m', 'added ', Each, #27'[0m'); - end; - finally - List.Free; + with TRegExpr.Create do + begin + Expression := + {$IFDEF MSWINDOWS} + '(cocoa|x11|_template)' + {$ELSE} + '(cocoa|gdi|_template)' + {$ENDIF} + ; + if not Exec(Path) and RunCommand('lazbuild', ['--add-package-link', Path], + Result.Output) then + Writeln(stderr, #27'[33m', 'added ', Path, #27'[0m'); + Free; end; end; - procedure AddOPM; + function BuildProject(Path: string): Output; + var + Line: string; begin - InitSSLInterface; - for Each in Pkg do - begin - PackagePath := - {$IFDEF MSWINDOWS} - GetEnvironmentVariable('APPDATA') + '\.lazarus\onlinepackagemanager\packages\' - {$ELSE} - GetEnvironmentVariable('HOME') + '/.lazarus/onlinepackagemanager/packages/' - {$ENDIF} - + Each; - TempFile := GetTempFileName; - Url := 'https://packages.lazarus-ide.org/' + Each + '.zip'; - if not DirectoryExists(PackagePath) then - begin - Zip := TFileStream.Create(TempFile, fmCreate or fmOpenWrite); - with TFPHttpClient.Create(nil) do + Write(stderr, #27'[33m', 'build from ', Path, #27'[0m'); + try + Result.Code := RunCommand('lazbuild', ['--build-all', '--recursive', + '--no-write-project', Path], Result.Output); + if Result.Code then + for Line in SplitString(Result.Output, LineEnding) do begin - try - AddHeader('User-Agent', 'Mozilla/5.0 (compatible; fpweb)'); - AllowRedirect := True; - Get(Url, Zip); - WriteLn(stderr, 'Download from ', Url, ' to ', TempFile); - finally - Free; + if ContainsStr(Line, 'Linking') then + begin + Result.Output := SplitString(Line, ' ')[2]; + Writeln(stderr, #27'[32m', ' to ', Result.Output, #27'[0m'); + break; end; - end; - Zip.Free; - CreateDir(PackagePath); - with TUnZipper.Create do - begin - try - FileName := TempFile; - OutputPath := PackagePath; - Examine; - UnZipAllFiles; - WriteLn(stderr, 'Unzip from ', TempFile, ' to ', PackagePath); - finally + end + else + begin + ExitCode += 1; + for Line in SplitString(Result.Output, LineEnding) do + with TRegExpr.Create do + begin + Expression := '(Fatal|Error):'; + if Exec(Line) then + begin + WriteLn(stderr); + Writeln(stderr, #27'[31m', Line, #27'[0m'); + end; Free; end; - end; - DeleteFile(TempFile); - AddPackage(PackagePath); end; + except + on E: Exception do + WriteLn(stderr, 'Error: ' + E.ClassName + #13#10 + E.Message); end; end; - procedure BuildProject(Path: string); + function RunTest(Path: string): Output; + var + Temp: string; begin - Write(stderr, #27'[33m', 'build from ', Each, #27'[0m'); - try - if RunCommand('lazbuild', ['--build-all', '--recursive', - '--no-write-project', Each], Answer.Output) then - Answer.Code := 0 - else + Result := BuildProject(Path); + Temp:= Result.Output; + if Result.Code then + try + if not RunCommand(Temp, ['--all', '--format=plain', '--progress'], Result.Output) then + ExitCode += 1; + WriteLn(stderr, Result.Output); + except + on E: Exception do + WriteLn(stderr, 'Error: ' + E.ClassName + #13#10 + E.Message); + end; + end; + + function AddOPM(Each: string): string; + var + TempFile, Url: string; + Zip: TStream; + begin + Result := + {$IFDEF MSWINDOWS} + GetEnvironmentVariable('APPDATA') + '\.lazarus\onlinepackagemanager\packages\' + {$ELSE} + GetEnvironmentVariable('HOME') + '/.lazarus/onlinepackagemanager/packages/' + {$ENDIF} + + Each; + TempFile := GetTempFileName; + Url := 'https://packages.lazarus-ide.org/' + Each + '.zip'; + if not DirectoryExists(Result) then + begin + Zip := TFileStream.Create(TempFile, fmCreate or fmOpenWrite); + with TFPHttpClient.Create(nil) do begin - Answer.Code := 1; - ExitCode += Answer.Code; + try + AddHeader('User-Agent', 'Mozilla/5.0 (compatible; fpweb)'); + AllowRedirect := True; + Get(Url, Zip); + WriteLn(stderr, 'Download from ', Url, ' to ', TempFile); + finally + Free; + end; end; - except - on E: Exception do - WriteLn(stderr, 'Error: ' + E.ClassName + #13#10 + E.Message); + Zip.Free; + CreateDir(Result); + with TUnZipper.Create do + begin + try + FileName := TempFile; + OutputPath := Result; + Examine; + UnZipAllFiles; + WriteLn(stderr, 'Unzip from ', TempFile, ' to ', Result); + finally + Free; + end; + end; + DeleteFile(TempFile); end; end; - procedure RunTest; + function Main: Output; + var + Each, Item: string; + List: TStringList; begin - List := FindAllFiles('.', Tst, True); + CheckModules; + InitSSLInterface; + for Each in Dependencies do + begin + List := FindAllFiles(AddOPM(Each), '*.lpk', True); + try + for Item in List do + AddPackage(Item); + finally + List.Free; + end; + end; + List := FindAllFiles(GetCurrentDir, '*.lpk', True); try for Each in List do - begin - BuildProject(Each); - if Answer.Code <> 0 then - begin - for Line in SplitString(Answer.Output, LineEnding) do - with TRegExpr.Create do - begin - Expression := '(Fatal|Error):'; - if Exec(Line) then - begin - WriteLn(stderr); - Writeln(stderr, #27'[31m', Line, #27'[0m'); - end; - Free; - end; - end + AddPackage(Each); + finally + List.Free; + end; + List := FindAllFiles(Target, '*.lpi', True); + try + for Each in List do + if ContainsStr(ReadFileToString(ReplaceStr(Each, '.lpi', '.lpr')), + 'consoletestrunner') then + RunTest(Each) else - for Line in SplitString(Answer.Output, LineEnding) do - if Pos('Linking', Line) <> 0 then - try - begin - Writeln(stderr, #27'[32m', ' to ', SplitString(Line, ' ')[2], #27'[0m'); - if not RunCommand(ReplaceStr(SplitString(Line, ' ')[2], - SplitString(Tst, '.')[0], './' + SplitString(Tst, '.')[0]), - ['--all', '--format=plain', '--progress'], Answer.Output) then - ExitCode += 1; - WriteLn(stderr, Answer.Output); - break; - end; - except - on E: Exception do - WriteLn(stderr, 'Error: ' + E.ClassName + #13#10 + E.Message); - end; - end; + BuildProject(Each); finally List.Free; end; + WriteLn(stderr); + if ExitCode <> 0 then + WriteLn(stderr, #27'[31m', 'Errors: ', ExitCode, #27'[0m') + else + WriteLn(stderr, #27'[32m', 'Errors: ', ExitCode, #27'[0m'); end; begin - CheckModules; - AddPackage(Use); - AddOPM; - {$IFDEF LINUX} - RunTest; - {$ENDIF} - List := FindAllFiles(Src, '*.lpi', True); - try - for Each in List do - if Pos(Tst, Each) = 0 then - begin - BuildProject(Each); - if Answer.Code <> 0 then - begin - for Line in SplitString(Answer.Output, LineEnding) do - with TRegExpr.Create do - begin - Expression := '(Fatal|Error):'; - if Exec(Line) then - begin - WriteLn(stderr); - Writeln(stderr, #27'[31m', Line, #27'[0m'); - end; - Free; - end; - end - else - for Line in SplitString(Answer.Output, LineEnding) do - if Pos('Linking', Line) <> 0 then - Writeln(stderr, #27'[32m', ' to ', SplitString(Line, ' ')[2], #27'[0m'); - end; - finally - List.Free; - end; - WriteLn(stderr); - if ExitCode <> 0 then - WriteLn(stderr, #27'[31m', 'Errors: ', ExitCode, #27'[0m') - else - WriteLn(stderr, #27'[32m', 'Errors: ', ExitCode, #27'[0m'); + Main; end. diff --git a/.github/workflows/make.yml b/.github/workflows/make.yml index b53f3b4..a02cde4 100644 --- a/.github/workflows/make.yml +++ b/.github/workflows/make.yml @@ -1,9 +1,8 @@ ---- name: Make on: schedule: - - cron: '0 0 1 * *' + - cron: '0 0 1 * *' push: branches: - "**" @@ -25,32 +24,43 @@ jobs: os: - ubuntu-latest - windows-latest + steps: - - name: Checkout - uses: actions/checkout@v4 - with: - submodules: true - - - name: Build on Linux - if: runner.os == 'Linux' - shell: bash - run: | - set -xeuo pipefail - sudo bash -c 'apt-get update; apt-get install -y lazarus' >/dev/null - instantfpc -Fu/usr/lib/lazarus/*/components/lazutils .github/workflows/make.pas - - - name: Build on Windows - if: runner.os == 'Windows' - shell: powershell - run: | - New-Variable -Option Constant -Name VAR -Value @{ - Uri = 'https://fossies.org/windows/misc/lazarus-3.8-fpc-3.2.2-win64.exe' - OutFile = (New-TemporaryFile).FullName + '.exe' - } - Invoke-WebRequest @VAR - & $VAR.OutFile.Replace('Temp', 'Temp\.') /SP- /VERYSILENT /SUPPRESSMSGBOXES /NORESTART | Out-Null - $Env:PATH+=';C:\Lazarus' - $Env:PATH+=';C:\Lazarus\fpc\3.2.2\bin\x86_64-win64' - (Get-Command 'lazbuild').Source | Out-Host - (Get-Command 'instantfpc').Source | Out-Host - instantfpc '-FuC:\Lazarus\components\lazutils' .github/workflows/make.pas + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: true + + - name: Build on Linux + if: runner.os == 'Linux' + shell: bash + run: | + set -xeuo pipefail + sudo bash -c 'apt-get update; apt-get install -y lazarus' >/dev/null + instantfpc -Fu/usr/lib/lazarus/*/components/lazutils .github/workflows/make.pas + + - name: Build on Windows + if: runner.os == 'Windows' + shell: powershell + run: | + $ErrorActionPreference = 'stop' + Set-PSDebug -Strict + + Write-Host "Installing Lazarus and OpenSSL 1.1 via Chocolatey..." + choco upgrade chocolatey -y + choco install lazarus -y + choco install openssl.light --version=1.1.1.20181020 -y + + Write-Host "Verifying installed packages..." + choco list + + # Lazarus installs to C:\Lazarus by default + # Add Lazarus and OpenSSL paths for instantfpc + $env:Path += ';C:\Lazarus;C:\Lazarus\fpc\3.2.2\bin\x86_64-win64;C:\ProgramData\chocolatey\lib\openssl.light\tools' + + Write-Host "Checking lazbuild and instantfpc availability..." + Get-Command lazbuild + Get-Command instantfpc + + Write-Host "Building make.pas..." + instantfpc '-FuC:\Lazarus\components\lazutils' .github/workflows/make.pas diff --git a/SimpleBaseLib.Benchmark/src/uBase64.pas b/SimpleBaseLib.Benchmark/src/uBase64.pas index 1a606a7..4c1a4d4 100644 --- a/SimpleBaseLib.Benchmark/src/uBase64.pas +++ b/SimpleBaseLib.Benchmark/src/uBase64.pas @@ -2,77 +2,11 @@ (* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) {$IFDEF FPC} {$UNDEF DELPHI} -{$MODE delphi} -{$DEFINE USE_UNROLLED_VARIANT} -// Disable Overflow and RangeChecks. -{$OVERFLOWCHECKS OFF} -{$RANGECHECKS OFF} -// Enable Pointer Math -{$POINTERMATH ON} -// Disable Warnings and Hints. -{$WARNINGS OFF} -{$HINTS OFF} -{$NOTES OFF} -// Optimizations -{$OPTIMIZATION LEVEL3} -{$OPTIMIZATION PEEPHOLE} -{$OPTIMIZATION REGVAR} -{$OPTIMIZATION LOOPUNROLL} -{$OPTIMIZATION STRENGTH} -{$OPTIMIZATION CSE} -{$OPTIMIZATION DFA} -{$IFDEF CPUI386} -{$OPTIMIZATION USEEBP} -{$ENDIF} -{$IFDEF CPUX86_64} -{$OPTIMIZATION USERBP} -{$ENDIF} +{$MODE DELPHI} {$ENDIF FPC} (* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) {$IFDEF DELPHI} -{$DEFINE USE_UNROLLED_VARIANT} -// This option is needed to enable code browsing (aka Ctrl+Click) -// It does not affect the binary size or generated code -{$DEFINITIONINFO ON} -// Disable Hints. -{$HINTS OFF} -// Disable Overflow and RangeChecks. -{$OVERFLOWCHECKS OFF} -{$RANGECHECKS OFF} -// Enable Pointer Math -{$POINTERMATH ON} -// Disable String Checks -{$STRINGCHECKS OFF} -// Disable Duplicate Constructor Warnings -{$WARN DUPLICATE_CTOR_DTOR OFF} -// 2010 only -{$IF CompilerVersion = 21.0} -{$DEFINE DELPHI2010} -{$IFEND} -// 2010 and Above -{$IF CompilerVersion >= 21.0} -{$DEFINE DELPHI2010_UP} -{$IFEND} -// XE and Above -{$IF CompilerVersion >= 22.0} -{$DEFINE DELPHIXE_UP} -{$IFEND} -// XE2 and Above -{$IF CompilerVersion >= 23.0} -{$DEFINE DELPHIXE2_UP} -{$DEFINE HAS_UNITSCOPE} -{$IFEND} -// XE3 and Below -{$IF CompilerVersion <= 24.0} -{$DEFINE DELPHIXE3_DOWN} -{$IFEND} -// XE3 and Above -{$IF CompilerVersion >= 24.0} -{$DEFINE DELPHIXE3_UP} -{$LEGACYIFEND ON} -{$ZEROBASEDSTRINGS OFF} -{$IFEND} // XE7 and Above {$IF CompilerVersion >= 28.0} {$DEFINE DELPHIXE7_UP} @@ -81,10 +15,7 @@ {$IF CompilerVersion >= 32.0} {$DEFINE DELPHI10.2_TOKYO_UP} {$IFEND} -// 2010 and Above -{$IFNDEF DELPHI2010_UP} -{$MESSAGE ERROR 'This Library requires Delphi 2010 or higher.'} -{$ENDIF} + // 10.2 Tokyo and Above {$IFDEF DELPHI10.2_TOKYO_UP} {$WARN COMBINING_SIGNED_UNSIGNED OFF} diff --git a/SimpleBaseLib.Tests/Delphi.Tests/SimpleBaseLib.Tests.dpr b/SimpleBaseLib.Tests/Delphi.Tests/SimpleBaseLib.Tests.dpr index 4b59d1e..44cf46f 100644 --- a/SimpleBaseLib.Tests/Delphi.Tests/SimpleBaseLib.Tests.dpr +++ b/SimpleBaseLib.Tests/Delphi.Tests/SimpleBaseLib.Tests.dpr @@ -50,7 +50,8 @@ uses Base58AlphabetTests in '..\src\Base58\Base58AlphabetTests.pas', Base64Tests in '..\src\Base64\Base64Tests.pas', BaseZ85Tests in '..\src\Base85\BaseZ85Tests.pas', - Ascii85Tests in '..\src\Base85\Ascii85Tests.pas'; + Ascii85Tests in '..\src\Base85\Ascii85Tests.pas', + SimpleBaseLibTestBase in '..\src\SimpleBaseLibTestBase.pas'; begin Application.Initialize; diff --git a/SimpleBaseLib.Tests/FreePascal.Tests/SimpleBaseLib.Tests.lpi b/SimpleBaseLib.Tests/FreePascal.Tests/SimpleBaseLib.Tests.lpi index 1726a7b..96c0305 100644 --- a/SimpleBaseLib.Tests/FreePascal.Tests/SimpleBaseLib.Tests.lpi +++ b/SimpleBaseLib.Tests/FreePascal.Tests/SimpleBaseLib.Tests.lpi @@ -21,7 +21,7 @@ - + @@ -69,7 +69,7 @@ - + @@ -111,6 +111,10 @@ + + + + @@ -121,7 +125,7 @@ - + diff --git a/SimpleBaseLib.Tests/FreePascal.Tests/SimpleBaseLibConsole.Tests.lpi b/SimpleBaseLib.Tests/FreePascal.Tests/SimpleBaseLibConsole.Tests.lpi deleted file mode 100644 index a7bf5b1..0000000 --- a/SimpleBaseLib.Tests/FreePascal.Tests/SimpleBaseLibConsole.Tests.lpi +++ /dev/null @@ -1,133 +0,0 @@ - - - - - - - - - - <ResourceType Value="res"/> - </General> - <i18n> - <EnableI18N LFM="False"/> - </i18n> - <BuildModes Count="2"> - <Item1 Name="Default" Default="True"/> - <Item2 Name="Debug"> - <CompilerOptions> - <Version Value="11"/> - <PathDelim Value="\"/> - <SearchPaths> - <IncludeFiles Value="$(ProjOutDir)"/> - <OtherUnitFiles Value="..\src\Base16;..\src\Base32;..\src\Base58;..\src\Base64;..\src\Base85"/> - </SearchPaths> - <Parsing> - <SyntaxOptions> - <IncludeAssertionCode Value="True"/> - </SyntaxOptions> - </Parsing> - <CodeGeneration> - <Checks> - <IOChecks Value="True"/> - <RangeChecks Value="True"/> - <OverflowChecks Value="True"/> - <StackChecks Value="True"/> - </Checks> - </CodeGeneration> - <Linking> - <Debugging> - <DebugInfoType Value="dsDwarf2Set"/> - <UseHeaptrc Value="True"/> - <UseExternalDbgSyms Value="True"/> - </Debugging> - </Linking> - </CompilerOptions> - </Item2> - </BuildModes> - <PublishOptions> - <Version Value="2"/> - </PublishOptions> - <RunParams> - <local> - <FormatVersion Value="1"/> - <CommandLineParams Value="--format=plain --all --progress"/> - </local> - </RunParams> - <RequiredPackages Count="2"> - <Item1> - <PackageName Value="SimpleBaseLib4PascalPackage"/> - </Item1> - <Item2> - <PackageName Value="FCL"/> - </Item2> - </RequiredPackages> - <Units Count="10"> - <Unit0> - <Filename Value="SimpleBaseLibConsole.lpr"/> - <IsPartOfProject Value="True"/> - <UnitName Value="SimpleBaseLib.Tests"/> - </Unit0> - <Unit1> - <Filename Value="..\src\Base16\Base16Tests.pas"/> - <IsPartOfProject Value="True"/> - </Unit1> - <Unit2> - <Filename Value="..\src\Base32\CrockfordTests.pas"/> - <IsPartOfProject Value="True"/> - </Unit2> - <Unit3> - <Filename Value="..\src\Base32\ExtendedHexTests.pas"/> - <IsPartOfProject Value="True"/> - </Unit3> - <Unit4> - <Filename Value="..\src\Base32\Rfc4648Tests.pas"/> - <IsPartOfProject Value="True"/> - </Unit4> - <Unit5> - <Filename Value="..\src\Base58\Base58AlphabetTests.pas"/> - <IsPartOfProject Value="True"/> - </Unit5> - <Unit6> - <Filename Value="..\src\Base58\Base58Tests.pas"/> - <IsPartOfProject Value="True"/> - </Unit6> - <Unit7> - <Filename Value="..\src\Base64\Base64Tests.pas"/> - <IsPartOfProject Value="True"/> - </Unit7> - <Unit8> - <Filename Value="..\src\Base85\Ascii85Tests.pas"/> - <IsPartOfProject Value="True"/> - </Unit8> - <Unit9> - <Filename Value="..\src\Base85\BaseZ85Tests.pas"/> - <IsPartOfProject Value="True"/> - </Unit9> - </Units> - </ProjectOptions> - <CompilerOptions> - <Version Value="11"/> - <PathDelim Value="\"/> - <Target> - <Filename Value=".\bin\SimpleBaseLib"/> - </Target> - <SearchPaths> - <IncludeFiles Value="$(ProjOutDir)"/> - <OtherUnitFiles Value="..\src\Base16;..\src\Base32;..\src\Base58;..\src\Base64;..\src\Base85"/> - </SearchPaths> - </CompilerOptions> - <Debugging> - <Exceptions Count="3"> - <Item1> - <Name Value="EAbort"/> - </Item1> - <Item2> - <Name Value="ECodetoolError"/> - </Item2> - <Item3> - <Name Value="EFOpenError"/> - </Item3> - </Exceptions> - </Debugging> -</CONFIG> diff --git a/SimpleBaseLib.Tests/FreePascal.Tests/SimpleBaseLibConsole.lpi b/SimpleBaseLib.Tests/FreePascal.Tests/SimpleBaseLibConsole.lpi new file mode 100644 index 0000000..f8f063b --- /dev/null +++ b/SimpleBaseLib.Tests/FreePascal.Tests/SimpleBaseLibConsole.lpi @@ -0,0 +1,105 @@ +<?xml version="1.0" encoding="UTF-8"?> +<CONFIG> + <ProjectOptions> + <Version Value="12"/> + <PathDelim Value="\"/> + <General> + <Flags> + <MainUnitHasCreateFormStatements Value="False"/> + <MainUnitHasTitleStatement Value="False"/> + <MainUnitHasScaledStatement Value="False"/> + <UseDefaultCompilerOptions Value="True"/> + </Flags> + <SessionStorage Value="InProjectDir"/> + <Title Value="SimpleBaseLibConsole"/> + <UseAppBundle Value="False"/> + <ResourceType Value="res"/> + </General> + <BuildModes> + <Item Name="Default" Default="True"/> + </BuildModes> + <PublishOptions> + <Version Value="2"/> + <UseFileFilters Value="True"/> + </PublishOptions> + <RunParams> + <FormatVersion Value="2"/> + </RunParams> + <RequiredPackages> + <Item> + <PackageName Value="SimpleBaseLib4PascalPackage"/> + </Item> + </RequiredPackages> + <Units> + <Unit> + <Filename Value="SimpleBaseLibConsole.lpr"/> + <IsPartOfProject Value="True"/> + <UnitName Value="SimpleBaseLib.Tests"/> + </Unit> + <Unit> + <Filename Value="..\src\Base58\Base58AlphabetTests.pas"/> + <IsPartOfProject Value="True"/> + </Unit> + <Unit> + <Filename Value="..\src\Base58\Base58Tests.pas"/> + <IsPartOfProject Value="True"/> + </Unit> + <Unit> + <Filename Value="..\src\Base32\Rfc4648Tests.pas"/> + <IsPartOfProject Value="True"/> + </Unit> + <Unit> + <Filename Value="..\src\Base32\ExtendedHexTests.pas"/> + <IsPartOfProject Value="True"/> + </Unit> + <Unit> + <Filename Value="..\src\Base32\CrockfordTests.pas"/> + <IsPartOfProject Value="True"/> + </Unit> + <Unit> + <Filename Value="..\src\Base16\Base16Tests.pas"/> + <IsPartOfProject Value="True"/> + </Unit> + <Unit> + <Filename Value="..\src\Base85\BaseZ85Tests.pas"/> + <IsPartOfProject Value="True"/> + </Unit> + <Unit> + <Filename Value="..\src\Base85\Ascii85Tests.pas"/> + <IsPartOfProject Value="True"/> + </Unit> + <Unit> + <Filename Value="..\src\Base64\Base64Tests.pas"/> + <IsPartOfProject Value="True"/> + </Unit> + <Unit> + <Filename Value="..\src\SimpleBaseLibTestBase.pas"/> + <IsPartOfProject Value="True"/> + </Unit> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="11"/> + <PathDelim Value="\"/> + <Target> + <Filename Value="SimpleBaseLibConsole"/> + </Target> + <SearchPaths> + <OtherUnitFiles Value="..\src\Base58;..\src\Base32;..\src\Base16;..\src\Base85;..\src\Base64;..\src"/> + <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> + </SearchPaths> + </CompilerOptions> + <Debugging> + <Exceptions> + <Item> + <Name Value="EAbort"/> + </Item> + <Item> + <Name Value="ECodetoolError"/> + </Item> + <Item> + <Name Value="EFOpenError"/> + </Item> + </Exceptions> + </Debugging> +</CONFIG> diff --git a/SimpleBaseLib.Tests/src/Base16/Base16Tests.pas b/SimpleBaseLib.Tests/src/Base16/Base16Tests.pas index 6aeb9c4..fbc6093 100644 --- a/SimpleBaseLib.Tests/src/Base16/Base16Tests.pas +++ b/SimpleBaseLib.Tests/src/Base16/Base16Tests.pas @@ -18,21 +18,15 @@ interface SbpUtilities, SbpSimpleBaseLibTypes, SbpBase16, - SbpBase58; + SimpleBaseLibTestBase; type - TCryptoLibTestCase = class abstract(TTestCase) - - end; - -type - - TTestBase16 = class(TCryptoLibTestCase) + TTestBase16 = class(TSimpleBaseLibTestCase) private var - FtestDataBytes: TSimpleBaseLibMatrixByteArray; - FtestDataString: TSimpleBaseLibStringArray; + FTestDataBytes: TSimpleBaseLibMatrixByteArray; + FTestDataString: TSimpleBaseLibStringArray; protected procedure SetUp; override; procedure TearDown; override; @@ -50,14 +44,14 @@ implementation procedure TTestBase16.SetUp; begin inherited; - FtestDataBytes := TSimpleBaseLibMatrixByteArray.Create(Nil, + FTestDataBytes := TSimpleBaseLibMatrixByteArray.Create(Nil, TSimpleBaseLibByteArray.Create($AB), TSimpleBaseLibByteArray.Create($00, $01, $02, $03), TSimpleBaseLibByteArray.Create($10, $11, $12, $13), TSimpleBaseLibByteArray.Create($AB, $CD, $EF, $BA) ); - FtestDataString := TSimpleBaseLibStringArray.Create('', 'AB', '00010203', + FTestDataString := TSimpleBaseLibStringArray.Create('', 'AB', '00010203', '10111213', 'ABCDEFBA' ); @@ -158,10 +152,10 @@ procedure TTestBase16.Test_Decode_LowerCase; Idx: Int32; result: TSimpleBaseLibByteArray; begin - for Idx := System.Low(FtestDataBytes) to System.High(FtestDataBytes) do + for Idx := System.Low(FTestDataBytes) to System.High(FTestDataBytes) do begin - result := TBase16.Decode(FtestDataString[Idx]); - CheckTrue(TUtilities.AreArraysEqual(FtestDataBytes[Idx], result), + result := TBase16.Decode(FTestDataString[Idx]); + CheckTrue(TUtilities.AreArraysEqual(FTestDataBytes[Idx], result), Format('Decode_LowerCase Failed at Index %d', [Idx])); end; end; @@ -171,10 +165,10 @@ procedure TTestBase16.Test_Encode_Lower; Idx: Int32; result: String; begin - for Idx := System.Low(FtestDataBytes) to System.High(FtestDataBytes) do + for Idx := System.Low(FTestDataBytes) to System.High(FTestDataBytes) do begin - result := TBase16.EncodeLower(FtestDataBytes[Idx]); - CheckEquals(LowerCase(FtestDataString[Idx]), result, + result := TBase16.EncodeLower(FTestDataBytes[Idx]); + CheckEquals(LowerCase(FTestDataString[Idx]), result, Format('EncodeLower Failed at Index %d', [Idx])); end; end; @@ -184,10 +178,10 @@ procedure TTestBase16.Test_Encode_Upper; Idx: Int32; result: String; begin - for Idx := System.Low(FtestDataBytes) to System.High(FtestDataBytes) do + for Idx := System.Low(FTestDataBytes) to System.High(FTestDataBytes) do begin - result := TBase16.EncodeUpper(FtestDataBytes[Idx]); - CheckEquals(FtestDataString[Idx], result, + result := TBase16.EncodeUpper(FTestDataBytes[Idx]); + CheckEquals(FTestDataString[Idx], result, Format('EncodeUpper Failed at Index %d', [Idx])); end; end; diff --git a/SimpleBaseLib.Tests/src/Base32/CrockfordTests.pas b/SimpleBaseLib.Tests/src/Base32/CrockfordTests.pas index 815c9da..3befa87 100644 --- a/SimpleBaseLib.Tests/src/Base32/CrockfordTests.pas +++ b/SimpleBaseLib.Tests/src/Base32/CrockfordTests.pas @@ -12,17 +12,12 @@ interface {$ENDIF FPC} SbpUtilities, SbpSimpleBaseLibTypes, - SbpBase32; + SbpBase32, + SimpleBaseLibTestBase; type - TCryptoLibTestCase = class abstract(TTestCase) - - end; - -type - - TTestCrockford = class(TCryptoLibTestCase) + TTestCrockford = class(TSimpleBaseLibTestCase) private var FRawData, FEncodedData, FSpecialRaw, FSpecialEncoded diff --git a/SimpleBaseLib.Tests/src/Base32/ExtendedHexTests.pas b/SimpleBaseLib.Tests/src/Base32/ExtendedHexTests.pas index b0a9d12..fc52b21 100644 --- a/SimpleBaseLib.Tests/src/Base32/ExtendedHexTests.pas +++ b/SimpleBaseLib.Tests/src/Base32/ExtendedHexTests.pas @@ -11,17 +11,12 @@ interface TestFramework, {$ENDIF FPC} SbpSimpleBaseLibTypes, - SbpBase32; + SbpBase32, + SimpleBaseLibTestBase; type - TCryptoLibTestCase = class abstract(TTestCase) - - end; - -type - - TTestExtendedHex = class(TCryptoLibTestCase) + TTestExtendedHex = class(TSimpleBaseLibTestCase) private var FRawData, FEncodedData: TSimpleBaseLibStringArray; diff --git a/SimpleBaseLib.Tests/src/Base32/Rfc4648Tests.pas b/SimpleBaseLib.Tests/src/Base32/Rfc4648Tests.pas index 9a404af..d57c1a5 100644 --- a/SimpleBaseLib.Tests/src/Base32/Rfc4648Tests.pas +++ b/SimpleBaseLib.Tests/src/Base32/Rfc4648Tests.pas @@ -11,17 +11,12 @@ interface TestFramework, {$ENDIF FPC} SbpSimpleBaseLibTypes, - SbpBase32; + SbpBase32, + SimpleBaseLibTestBase; type - TCryptoLibTestCase = class abstract(TTestCase) - - end; - -type - - TTestRfc4648 = class(TCryptoLibTestCase) + TTestRfc4648 = class(TSimpleBaseLibTestCase) private var FRawData, FEncodedData: TSimpleBaseLibStringArray; diff --git a/SimpleBaseLib.Tests/src/Base58/Base58AlphabetTests.pas b/SimpleBaseLib.Tests/src/Base58/Base58AlphabetTests.pas index 6d57caf..acb63f3 100644 --- a/SimpleBaseLib.Tests/src/Base58/Base58AlphabetTests.pas +++ b/SimpleBaseLib.Tests/src/Base58/Base58AlphabetTests.pas @@ -11,17 +11,12 @@ interface TestFramework, {$ENDIF FPC} SbpSimpleBaseLibTypes, - SbpBase58Alphabet; + SbpBase58Alphabet, + SimpleBaseLibTestBase; type - TCryptoLibTestCase = class abstract(TTestCase) - - end; - -type - - TTestBase58Alphabet = class(TCryptoLibTestCase) + TTestBase58Alphabet = class(TSimpleBaseLibTestCase) protected procedure SetUp; override; diff --git a/SimpleBaseLib.Tests/src/Base58/Base58Tests.pas b/SimpleBaseLib.Tests/src/Base58/Base58Tests.pas index f3d741d..fbc4d8e 100644 --- a/SimpleBaseLib.Tests/src/Base58/Base58Tests.pas +++ b/SimpleBaseLib.Tests/src/Base58/Base58Tests.pas @@ -12,17 +12,12 @@ interface {$ENDIF FPC} SbpSimpleBaseLibTypes, SbpBase16, - SbpBase58; + SbpBase58, + SimpleBaseLibTestBase; type - TCryptoLibTestCase = class abstract(TTestCase) - - end; - -type - - TTestBase58 = class(TCryptoLibTestCase) + TTestBase58 = class(TSimpleBaseLibTestCase) private var FRawDataInHex, FBase58EncodedData: TSimpleBaseLibStringArray; diff --git a/SimpleBaseLib.Tests/src/Base64/Base64Tests.pas b/SimpleBaseLib.Tests/src/Base64/Base64Tests.pas index 0d4ccb4..b0ccbeb 100644 --- a/SimpleBaseLib.Tests/src/Base64/Base64Tests.pas +++ b/SimpleBaseLib.Tests/src/Base64/Base64Tests.pas @@ -12,17 +12,12 @@ interface {$ENDIF FPC} SbpSimpleBaseLibTypes, SbpUtilities, - SbpBase64; + SbpBase64, + SimpleBaseLibTestBase; type - TCryptoLibTestCase = class abstract(TTestCase) - - end; - -type - - TTestBase64 = class(TCryptoLibTestCase) + TTestBase64 = class(TSimpleBaseLibTestCase) private var FRawData, FEncodedDataBase64Default: TSimpleBaseLibStringArray; diff --git a/SimpleBaseLib.Tests/src/Base85/Ascii85Tests.pas b/SimpleBaseLib.Tests/src/Base85/Ascii85Tests.pas index 976d429..331358e 100644 --- a/SimpleBaseLib.Tests/src/Base85/Ascii85Tests.pas +++ b/SimpleBaseLib.Tests/src/Base85/Ascii85Tests.pas @@ -16,17 +16,12 @@ interface {$ENDIF FPC} SbpUtilities, SbpSimpleBaseLibTypes, - SbpBase85; + SbpBase85, + SimpleBaseLibTestBase; type - TCryptoLibTestCase = class abstract(TTestCase) - - end; - -type - - TTestAscii85 = class(TCryptoLibTestCase) + TTestAscii85 = class(TSimpleBaseLibTestCase) private var FBytes: TSimpleBaseLibMatrixByteArray; diff --git a/SimpleBaseLib.Tests/src/Base85/BaseZ85Tests.pas b/SimpleBaseLib.Tests/src/Base85/BaseZ85Tests.pas index a25ddea..c9834ae 100644 --- a/SimpleBaseLib.Tests/src/Base85/BaseZ85Tests.pas +++ b/SimpleBaseLib.Tests/src/Base85/BaseZ85Tests.pas @@ -16,17 +16,12 @@ interface {$ENDIF FPC} SbpUtilities, SbpSimpleBaseLibTypes, - SbpBase85; + SbpBase85, + SimpleBaseLibTestBase; type - TCryptoLibTestCase = class abstract(TTestCase) - - end; - -type - - TTestBaseZ85 = class(TCryptoLibTestCase) + TTestBaseZ85 = class(TSimpleBaseLibTestCase) private var FBytes: TSimpleBaseLibMatrixByteArray; diff --git a/SimpleBaseLib.Tests/src/SimpleBaseLibTestBase.pas b/SimpleBaseLib.Tests/src/SimpleBaseLibTestBase.pas new file mode 100644 index 0000000..c9cc4bc --- /dev/null +++ b/SimpleBaseLib.Tests/src/SimpleBaseLibTestBase.pas @@ -0,0 +1,22 @@ +unit SimpleBaseLibTestBase; + +interface + +uses +{$IFDEF FPC} + fpcunit, + testregistry +{$ELSE} + TestFramework +{$ENDIF FPC}; + +type + + TSimpleBaseLibTestCase = class abstract(TTestCase) + + end; + +implementation + +end. + diff --git a/SimpleBaseLib/src/Bases/SbpBase32Alphabet.pas b/SimpleBaseLib/src/Bases/SbpBase32Alphabet.pas index 7009d2a..c67abed 100644 --- a/SimpleBaseLib/src/Bases/SbpBase32Alphabet.pas +++ b/SimpleBaseLib/src/Bases/SbpBase32Alphabet.pas @@ -56,13 +56,9 @@ procedure TBase32Alphabet.MapLowerCaseCounterParts(const alphabet: String); LowPoint, HighPoint, I: Int32; c: Char; begin -{$IFDEF DELPHIXE3_UP} - LowPoint := System.Low(alphabet); - HighPoint := System.High(alphabet); -{$ELSE} LowPoint := 1; HighPoint := System.Length(alphabet); -{$ENDIF DELPHIXE3_UP} + for I := LowPoint to HighPoint do begin c := alphabet[I]; diff --git a/SimpleBaseLib/src/Bases/SbpBase58.pas b/SimpleBaseLib/src/Bases/SbpBase58.pas index 13a9205..c326de2 100644 --- a/SimpleBaseLib/src/Bases/SbpBase58.pas +++ b/SimpleBaseLib/src/Bases/SbpBase58.pas @@ -113,11 +113,8 @@ function TBase58.Decode(const text: TSimpleBaseLibCharArray) pEnd := inputPtr + textLen; pInput := inputPtr; -{$IFDEF DELPHIXE3_UP} - LowPoint := System.Low(String); -{$ELSE} LowPoint := 1; -{$ENDIF DELPHIXE3_UP} + Value := Falphabet.Value; FirstChar := Value[LowPoint]; while ((pInput^ = FirstChar) and (pInput <> pEnd)) do diff --git a/SimpleBaseLib/src/Bases/SbpEncodingAlphabet.pas b/SimpleBaseLib/src/Bases/SbpEncodingAlphabet.pas index 7f7fee5..e89c425 100644 --- a/SimpleBaseLib/src/Bases/SbpEncodingAlphabet.pas +++ b/SimpleBaseLib/src/Bases/SbpEncodingAlphabet.pas @@ -86,12 +86,8 @@ constructor TEncodingAlphabet.Create(length: Int32; const alphabet: String); System.SetLength(FReverseLookupTable, lookupLength); FLength := length; FValue := alphabet; - -{$IFDEF DELPHIXE3_UP} - LowPoint := System.Low(alphabet); -{$ELSE} LowPoint := 1; -{$ENDIF DELPHIXE3_UP} + for I := LowPoint to length do begin Map(alphabet[I], I - 1); diff --git a/SimpleBaseLib/src/Include/SimpleBaseLib.inc b/SimpleBaseLib/src/Include/SimpleBaseLib.inc index dc2df4a..a8aac77 100644 --- a/SimpleBaseLib/src/Include/SimpleBaseLib.inc +++ b/SimpleBaseLib/src/Include/SimpleBaseLib.inc @@ -1,103 +1,31 @@ -{ *********************************************************************************** } -{ * SimpleBaseLib Library * } -{ * Copyright (c) 2018 - 2019 Ugochukwu Mmaduekwe * } -{ * Github Repository <https://github.com/Xor-el> * } +{ * ************************************************************************ * } +{ * SimpleBaseLib Library * } +{ * Author - Ugochukwu Mmaduekwe * } +{ * Github Repository <https://github.com/Xor-el> * } +{ * * } +{ * Distributed under the MIT software license, see the accompanying file * } +{ * LICENSE * } +{ * or visit http://www.opensource.org/licenses/mit-license. * } +{ * * } +{ * ************************************************************************ * } -{ * Distributed under the MIT software license, see the accompanying file LICENSE * } -{ * or visit http://www.opensource.org/licenses/mit-license.php. * } +(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) -{ * ******************************************************************************* * } -(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) - -{$DEFINE DELPHI} - -(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) +{---------------------------- Compiler Family Switch --------------------------} {$IFDEF FPC} -{$I SimpleBaseLibHelper.inc} // Had to Include this Since Delphi Does not allow "FPC_FULLVERSION" to Compile. -{$UNDEF DELPHI} -{$MODE delphi} - -{$DEFINE USE_UNROLLED_VARIANT} + {$I SimpleBaseLibFPC.inc} // FPC-specific settings +{$ELSE} + {$DEFINE DELPHI} + {$I ../../SimpleBaseLib/src/Include/SimpleBaseLibDelphi.inc} // Delphi-specific settings +{$ENDIF} -// Disable Overflow and RangeChecks. +{-------------------------- Common Compiler Settings --------------------------} +{$SCOPEDENUMS ON} {$OVERFLOWCHECKS OFF} {$RANGECHECKS OFF} - -// Enable Pointer Math {$POINTERMATH ON} - -// Disable Warnings and Hints. {$WARNINGS OFF} {$HINTS OFF} -{$NOTES OFF} - -// Optimizations -{$OPTIMIZATION LEVEL3} -{$OPTIMIZATION PEEPHOLE} -{$OPTIMIZATION REGVAR} -{$OPTIMIZATION LOOPUNROLL} -{$OPTIMIZATION STRENGTH} -{$OPTIMIZATION CSE} -{$OPTIMIZATION DFA} - -{$IFDEF CPUI386} - {$OPTIMIZATION USEEBP} -{$ENDIF} - -{$IFDEF CPUX86_64} - {$OPTIMIZATION USERBP} -{$ENDIF} - -{$ENDIF FPC} - -(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) - -{$IFDEF DELPHI} - -{$DEFINE USE_UNROLLED_VARIANT} - -// This option is needed to enable code browsing (aka Ctrl+Click) -// It does not affect the binary size or generated code -{$DEFINITIONINFO ON} - -// Disable Overflow and RangeChecks. -{$OVERFLOWCHECKS OFF} -{$RANGECHECKS OFF} - - // Enable Pointer Math -{$POINTERMATH ON} - -// Disable String Checks -{$STRINGCHECKS OFF} - -// Disable Duplicate Constructor Warnings -{$WARN DUPLICATE_CTOR_DTOR OFF} - - // XE3 and Above -{$IF CompilerVersion >= 24.0} - {$DEFINE DELPHIXE3_UP} - {$LEGACYIFEND ON} - {$ZEROBASEDSTRINGS OFF} -{$IFEND} - - // 2010 and Above -{$IF CompilerVersion >= 21.0} - {$DEFINE DELPHI2010_UP} -{$IFEND} - - // XE and Above -{$IF CompilerVersion >= 22.0} - {$DEFINE DELPHIXE_UP} -{$IFEND} - - // 2010 and Above -{$IFNDEF DELPHI2010_UP} - {$MESSAGE ERROR 'This Library requires Delphi 2010 or higher.'} -{$ENDIF} - - -{$ENDIF DELPHI} - -(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) +(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) diff --git a/SimpleBaseLib/src/Include/SimpleBaseLibDelphi.inc b/SimpleBaseLib/src/Include/SimpleBaseLibDelphi.inc new file mode 100644 index 0000000..4d8be39 --- /dev/null +++ b/SimpleBaseLib/src/Include/SimpleBaseLibDelphi.inc @@ -0,0 +1,28 @@ +{ * ************************************************************************ * } +{ * SimpleBaseLib Library * } +{ * Author - Ugochukwu Mmaduekwe * } +{ * Github Repository <https://github.com/Xor-el> * } +{ * * } +{ * Distributed under the MIT software license, see the accompanying file * } +{ * LICENSE * } +{ * or visit http://www.opensource.org/licenses/mit-license. * } +{ * * } +{ * ************************************************************************ * } + +(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) + +{$IFDEF DELPHI} + {$DEFINITIONINFO ON} // IDE navigation; no binary impact + {$STRINGCHECKS OFF} + {$WARN DUPLICATE_CTOR_DTOR OFF} + + // XE and Above +{$IF CompilerVersion >= 22.0} + {$DEFINE DELPHIXE_UP} +{$IFEND} + + {$IF CompilerVersion < 21.0} + {$MESSAGE ERROR 'This Library requires Delphi 2010 or higher.'} + {$IFEND} +{$ENDIF} + diff --git a/SimpleBaseLib/src/Include/SimpleBaseLibFPC.inc b/SimpleBaseLib/src/Include/SimpleBaseLibFPC.inc new file mode 100644 index 0000000..0753288 --- /dev/null +++ b/SimpleBaseLib/src/Include/SimpleBaseLibFPC.inc @@ -0,0 +1,37 @@ +{ * ************************************************************************ * } +{ * SimpleBaseLib Library * } +{ * Author - Ugochukwu Mmaduekwe * } +{ * Github Repository <https://github.com/Xor-el> * } +{ * * } +{ * Distributed under the MIT software license, see the accompanying file * } +{ * LICENSE * } +{ * or visit http://www.opensource.org/licenses/mit-license. * } +{ * * } +{ * ************************************************************************ * } + +(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) + +{$IFDEF FPC} + {$IFDEF ENDIAN_BIG} + {$MESSAGE FATAL 'This Library does not support "Big Endian" processors yet.'} + {$ENDIF} + + // FPC 3.0.0 and Above + {$IF FPC_FULLVERSION < 30000} + {$MESSAGE ERROR 'This Library requires FreePascal 3.0.0 or higher.'} + {$IFEND} + + {$MODE DELPHI} + {$MACRO ON} + {$NOTES OFF} + {$OPTIMIZATION LEVEL3} + {$OPTIMIZATION PEEPHOLE} + {$OPTIMIZATION REGVAR} + {$OPTIMIZATION LOOPUNROLL} + {$OPTIMIZATION STRENGTH} + {$OPTIMIZATION CSE} + {$OPTIMIZATION DFA} + {$IFDEF CPUI386} {$OPTIMIZATION USEEBP} {$ENDIF} + {$IFDEF CPUX86_64} {$OPTIMIZATION USERBP} {$ENDIF} +{$ENDIF} + diff --git a/SimpleBaseLib/src/Include/SimpleBaseLibHelper.inc b/SimpleBaseLib/src/Include/SimpleBaseLibHelper.inc deleted file mode 100644 index 4657673..0000000 --- a/SimpleBaseLib/src/Include/SimpleBaseLibHelper.inc +++ /dev/null @@ -1,21 +0,0 @@ -{ *********************************************************************************** } -{ * SimpleBaseLib Library * } -{ * Copyright (c) 2018 - 2019 Ugochukwu Mmaduekwe * } -{ * Github Repository <https://github.com/Xor-el> * } - -{ * Distributed under the MIT software license, see the accompanying file LICENSE * } -{ * or visit http://www.opensource.org/licenses/mit-license.php. * } - -{ * ******************************************************************************* * } - -(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) - -{$MACRO ON} -{$IFDEF ENDIAN_BIG} - {$MESSAGE FATAL 'This Library does not support "Big Endian" processors yet.'} -{$ENDIF} -// FPC 3.0.0 and Above -// Had to Include this here since Delphi does not allow it Compile in "SimpleBaseLib.inc". -{$IF FPC_FULLVERSION < 30000} - {$MESSAGE ERROR 'This Library requires FreePascal 3.0.0 or higher.'} -{$IFEND} diff --git a/SimpleBaseLib/src/Packages/FPC/SimpleBaseLib4PascalPackage.lpk b/SimpleBaseLib/src/Packages/FPC/SimpleBaseLib4PascalPackage.lpk index 17133e7..b851f06 100644 --- a/SimpleBaseLib/src/Packages/FPC/SimpleBaseLib4PascalPackage.lpk +++ b/SimpleBaseLib/src/Packages/FPC/SimpleBaseLib4PascalPackage.lpk @@ -21,7 +21,7 @@ </CompilerOptions> <Description Value="SimpleBaseLib4Pascal as the name implies is a simple to use Base Encoding Package for Delphi/FreePascal Compilers that provides at the moment support for encoding and decoding various bases such as Base16, Base32 (various variants), Base58 (various variants), Base64 (various variants) and Base85 (various variants)."/> <License Value="MIT License"/> - <Version Major="2" Minor="5"/> + <Version Major="2" Minor="6"/> <Files Count="24"> <Item1> <Filename Value="..\..\Bases\SbpBase16.pas"/> @@ -52,7 +52,7 @@ <UnitName Value="SbpBase64Alphabet"/> </Item7> <Item8> - <Filename Value="..\..\Include\SimpleBaseLibHelper.inc"/> + <Filename Value="..\..\Include\SimpleBaseLibFPC.inc"/> <Type Value="Include"/> </Item8> <Item9> diff --git a/SimpleBaseLib/src/Utils/SbpUtilities.pas b/SimpleBaseLib/src/Utils/SbpUtilities.pas index ca3c744..6d49c1c 100644 --- a/SimpleBaseLib/src/Utils/SbpUtilities.pas +++ b/SimpleBaseLib/src/Utils/SbpUtilities.pas @@ -114,11 +114,9 @@ class function TUtilities.TrimRight(const S: String; begin System.Dec(I); end; -{$IFDEF DELPHIXE3_UP} - LowPoint := System.Low(S); -{$ELSE} + LowPoint := 1; -{$ENDIF DELPHIXE3_UP} + if I < LowPoint then begin Result := ''