From eacf519cbb90d44399427c36b8c4e06114163b5d Mon Sep 17 00:00:00 2001 From: DomingoGP Date: Sat, 6 Jan 2024 11:45:27 +0100 Subject: [PATCH] Jedi code format: cleanup, remove compiler hints. --- components/jcf2/Parse/BuildTokenList.pas | 2 ++ components/jcf2/Parse/ParseTreeNodeType.pas | 2 +- components/jcf2/Process/Returns/LongLineBreaker.pas | 2 ++ components/jcf2/ReadWrite/CodeWriter.pas | 3 --- components/jcf2/ReadWrite/Converter.pas | 2 ++ components/jcf2/ReadWrite/StringsConverter.pas | 13 +++++-------- .../jcf2/Settings/Streams/RegistrySettings.pas | 5 ++++- components/jcf2/Utils/IntList.pas | 2 ++ components/jcf2/Utils/JcfMiscFunctions.pas | 3 +++ components/jcf2/Utils/JcfStringUtils.pas | 13 ++++++++----- components/jcf2/Utils/JcfUnicodeFiles.pas | 10 +++++++++- 11 files changed, 38 insertions(+), 19 deletions(-) diff --git a/components/jcf2/Parse/BuildTokenList.pas b/components/jcf2/Parse/BuildTokenList.pas index 540ab5013d..4a2ce87b5b 100644 --- a/components/jcf2/Parse/BuildTokenList.pas +++ b/components/jcf2/Parse/BuildTokenList.pas @@ -120,12 +120,14 @@ const CurlyLeft = '{'; //widechar(123); CurlyRight = '}'; //widechar(125); +{$push}{$warn 5024 off} function CheckMultiByte(const pcChar: char): boolean; begin Result := False; // if GetRegSettings.CheckMultiByteChars then // Result := IsMultiByte(pcChar); //IsMultiByte(pcChar)-->Result := IsDBCSLeadByte(Byte(pcChar)); end; +{$pop} function CharIsOctDigit(const c: Char): Boolean; const diff --git a/components/jcf2/Parse/ParseTreeNodeType.pas b/components/jcf2/Parse/ParseTreeNodeType.pas index 9d90ac763a..a6b6d7af0b 100644 --- a/components/jcf2/Parse/ParseTreeNodeType.pas +++ b/components/jcf2/Parse/ParseTreeNodeType.pas @@ -194,7 +194,7 @@ const MethodHeadings: TParseTreeNodeTypeSet = [nFunctionHeading, nProcedureHeading, nConstructorHeading, nDestructorHeading]; -function NodeTypeToString(const pe: TParseTreeNodeType): string; inline; +function NodeTypeToString(const pe: TParseTreeNodeType): string; implementation diff --git a/components/jcf2/Process/Returns/LongLineBreaker.pas b/components/jcf2/Process/Returns/LongLineBreaker.pas index 24b6ded540..41478d06f3 100644 --- a/components/jcf2/Process/Returns/LongLineBreaker.pas +++ b/components/jcf2/Process/Returns/LongLineBreaker.pas @@ -69,6 +69,8 @@ uses SourceToken, FormatFlags, JcfSettings, SetReturns, TokenUtils, JcfMiscFunctions, Tokens, ParseTreeNodeType; +{$WARN 6058 off} // supress note: function/procedure marked as inline is not inlined + function IsLineBreaker(const pcToken: TSourceToken): boolean; begin Result := (pcToken.TokenType in [ttReturn, ttConditionalCompilationRemoved]) or diff --git a/components/jcf2/ReadWrite/CodeWriter.pas b/components/jcf2/ReadWrite/CodeWriter.pas index 6cb6cd0528..913342c784 100644 --- a/components/jcf2/ReadWrite/CodeWriter.pas +++ b/components/jcf2/ReadWrite/CodeWriter.pas @@ -81,9 +81,6 @@ type implementation -const - MAX_TOKENS = 100000; - { TCodeWriter } constructor TCodeWriter.Create; diff --git a/components/jcf2/ReadWrite/Converter.pas b/components/jcf2/ReadWrite/Converter.pas index 3cc7a5eabc..e4e7731f6e 100644 --- a/components/jcf2/ReadWrite/Converter.pas +++ b/components/jcf2/ReadWrite/Converter.pas @@ -495,8 +495,10 @@ var begin //WRAPPING the inputCode in a fake unit sourceCodeLowerCase := LowerCase(fsInputCode); + {$push}{$warn 5057 off} hasInterface := HasStringAtLineStart(sourceCodeLowerCase, 'interface', liInterfacePos); hasImplementation := HasStringAtLineStart(sourceCodeLowerCase, 'implementation', liImplementationPos); + {$pop} sourceCode := ''; AddFakeUnit; if hasInterface = False then diff --git a/components/jcf2/ReadWrite/StringsConverter.pas b/components/jcf2/ReadWrite/StringsConverter.pas index 428441b7a0..c92e544812 100644 --- a/components/jcf2/ReadWrite/StringsConverter.pas +++ b/components/jcf2/ReadWrite/StringsConverter.pas @@ -30,9 +30,7 @@ See http://www.gnu.org/licenses/gpl.html interface uses - Classes, SysUtils, - { local } - Converter; + Classes, SysUtils; type TStringsConverter = class(TObject) @@ -44,10 +42,10 @@ type protected function OriginalFileName: string; - + {$push}{$warn 5024 off} procedure SendStatusMessage(const psFile, psMessage: string; const piY, piX: integer); - + {$pop} public constructor Create; @@ -90,6 +88,7 @@ begin fcMessageStrings := pcStrings; end; +{$push}{$warn 5024 off} procedure TStringsConverter.SendStatusMessage(const psFile, psMessage: string; const piY, piX: integer); var @@ -101,11 +100,9 @@ begin if (piY >= 0) and (piX >= 0) then lsWholeMessage := lsWholeMessage + ' at line ' + IntToStr(piY) + ' col ' + IntToStr(piX); - - fcMessageStrings.Add(lsWholeMessage); end; - end; +{$pop} end. diff --git a/components/jcf2/Settings/Streams/RegistrySettings.pas b/components/jcf2/Settings/Streams/RegistrySettings.pas index 44b6eb86cc..1be7c5c76a 100644 --- a/components/jcf2/Settings/Streams/RegistrySettings.pas +++ b/components/jcf2/Settings/Streams/RegistrySettings.pas @@ -56,8 +56,9 @@ type destructor Destroy; override; procedure OpenSection(const psName: string); override; + {$push}{$warn 5024 off} procedure CloseSection(const psName: string); override; - + {$pop} procedure Write(const psTagName, psValue: string); override; procedure Write(const psTagName: string; const piValue: integer); override; procedure Write(const psTagName: string; const pbValue: boolean); override; @@ -122,10 +123,12 @@ begin fsSection := psName; end; +{$push}{$warn 5024 off} procedure TSettingsRegistryOutput.CloseSection(const psName: string); begin fsSection := ''; end; +{$pop} procedure TSettingsRegistryOutput.Write(const psTagName, psValue: string); begin diff --git a/components/jcf2/Utils/IntList.pas b/components/jcf2/Utils/IntList.pas index de6561c4b8..b4975ef8f8 100644 --- a/components/jcf2/Utils/IntList.pas +++ b/components/jcf2/Utils/IntList.pas @@ -58,6 +58,8 @@ implementation { TIntList } +{$WARN 6058 off} // supress note: function/procedure marked as inline is not inlined + procedure TIntList.ChangeValue(const liIndex, liDelta: integer); begin { can fall out of bounds, easiest to ignore it here } diff --git a/components/jcf2/Utils/JcfMiscFunctions.pas b/components/jcf2/Utils/JcfMiscFunctions.pas index 56b259c4f0..8a09726160 100644 --- a/components/jcf2/Utils/JcfMiscFunctions.pas +++ b/components/jcf2/Utils/JcfMiscFunctions.pas @@ -313,12 +313,14 @@ begin Result := Length(AString) - (Pos1 + Length(NativeLineBreak)); end; +{$push}{$warn 5091 off} function ReadFileToUTF8String(AFilename: string): string; var lMs: TMemorystream; lS: string; begin lMs := TMemoryStream.Create; + Result := ''; try lMs.LoadFromFile(AFileName); SetLength(lS, lMs.Size); @@ -328,5 +330,6 @@ begin lMs.Free; end; end; +{$pop} end. diff --git a/components/jcf2/Utils/JcfStringUtils.pas b/components/jcf2/Utils/JcfStringUtils.pas index f0bb522539..6a560ad9f0 100644 --- a/components/jcf2/Utils/JcfStringUtils.pas +++ b/components/jcf2/Utils/JcfStringUtils.pas @@ -126,7 +126,7 @@ function StrCharCount(const S: string; C: Char): Integer; function StrStrCount(const S, SubS: string): Integer; function StrRepeat(const S: string; Count: Integer): string; procedure StrReplace(var S: string; const Search, Replace: string; Flags: TReplaceFlags = []); -function StrSearch(const Substr, S: string; const Index: Integer = 1): Integer; inline; +function StrSearch(const Substr, S: string; const Index: Integer = 1): Integer; inline; deprecated 'Use Pos instead'; function StrFind(const Substr, S: string; const Index: Integer = 1): Integer; function BooleanToStr(B: Boolean): string; @@ -294,7 +294,7 @@ function StrAfter(const SubStr, S: string): string; var P: Integer; begin - P := StrSearch(SubStr, S, 1); + P := Pos(SubStr, S, 1); if P > 0 then Result := Copy(S, P + Length(SubStr), Length(S)) else @@ -305,7 +305,7 @@ function StrBefore(const SubStr, S: string): string; var P: Integer; begin - P := StrSearch(SubStr, S, 1); + P := Pos(SubStr, S, 1); if P > 0 then Result := Copy(S, 1, P - 1) else @@ -324,7 +324,7 @@ begin Result := 0; while Result < Length(S) do begin - NewPos := StrSearch(SubStr, S, Result + 1); + NewPos := Pos(SubStr, S, Result + 1); if NewPos > 0 then Result := NewPos else @@ -383,7 +383,7 @@ begin P := 1; while P < Length(S) do begin - P := StrSearch(Subs, S, P); + P := Pos(Subs, S, P); if P > 0 then begin inc(Result); @@ -480,6 +480,7 @@ var S: TStream; begin S := nil; + Result := ''; try S := TFileStream.Create(FileName, fmOpenRead or fmShareDenyNone); SetLength(Result, S.Size); @@ -502,12 +503,14 @@ begin end; end; +{$push}{$warn 5094 off} function StrFillChar(const C: Char; Count: Integer): string; begin SetLength(Result, Count); if Count > 0 then FillChar(Result[1], Count, C); end; +{$pop} function IntToStrZeroPad(Value, Count: Integer): String; begin diff --git a/components/jcf2/Utils/JcfUnicodeFiles.pas b/components/jcf2/Utils/JcfUnicodeFiles.pas index 9f728df2c8..e8c4368a8e 100644 --- a/components/jcf2/Utils/JcfUnicodeFiles.pas +++ b/components/jcf2/Utils/JcfUnicodeFiles.pas @@ -161,6 +161,7 @@ var liBytesRemaining: integer; lsContents8bit: AnsiString; begin + {$push}{$warn 5091 off} liBytesRemaining := pcFileStream.Size - pcFileStream.Position; // read the bytes into a string SetLength(lsContents8bit, liBytesRemaining); @@ -169,6 +170,7 @@ begin pcFileStream.ReadBuffer(lsContents8bit[1], liBytesRemaining); end; Result := lsContents8bit; + {$pop} end; @@ -177,7 +179,8 @@ var liBytesRemaining: integer; lsContents: AnsiString; begin - liBytesRemaining := pcFileStream.Size - pcFileStream.Position; + {$push}{$warn 5091 off} + liBytesRemaining := pcFileStream.Size - pcFileStream.Position; // read the bytes into a string SetLength(lsContents, liBytesRemaining); if pcFileStream.Size > 0 then @@ -185,6 +188,7 @@ begin pcFileStream.ReadBuffer(lsContents[1], liBytesRemaining); end; Result := lsContents; + {$pop} end; @@ -194,6 +198,7 @@ var liLoop: integer; lsWideContents: WideString; begin + {$push}{$warn 5091 off} // read it liBytesRemaining := pcFileStream.Size - pcFileStream.Position; SetLength(lsWideContents, liBytesRemaining div 2); @@ -207,6 +212,7 @@ begin end; Result := lsWideContents; + {$pop} end; function SwapWords(const value: UCS4Char): UCS4Char; @@ -232,6 +238,7 @@ var ucs4Chars: UCS4String; liLoop: integer; begin + {$push}{$warn 5091 off} liBytesRemaining := pcFileStream.Size - pcFileStream.Position; charsRemaining := liBytesRemaining div 4; @@ -246,6 +253,7 @@ begin end; Result := UCS4StringToWideString(ucs4Chars); + {$pop} end; { read in a text file,