From 4e16799fd7f34260eacb51b531c5bcef2c486863 Mon Sep 17 00:00:00 2001 From: juha Date: Tue, 24 Mar 2015 17:50:59 +0000 Subject: [PATCH] SynEdit: Initialize variables based on compiler warnings. Contains ToDo items. git-svn-id: trunk@48478 - --- components/synedit/lazsynedittext.pas | 1 + components/synedit/lazsynimm.pas | 2 +- components/synedit/lazsyntextarea.pp | 8 ++++--- components/synedit/synbeautifier.pas | 2 ++ components/synedit/synedit.pp | 8 +++++-- components/synedit/syneditfoldedview.pp | 11 ++++++++- components/synedit/syneditmarks.pp | 2 +- components/synedit/syneditmarkuphighall.pp | 2 ++ components/synedit/syneditplugins.pas | 1 + components/synedit/syneditpointclasses.pas | 25 ++++++++++++--------- components/synedit/synedittextbuffer.pp | 2 ++ components/synedit/synedittexttrimmer.pas | 2 +- components/synedit/syngutter.pp | 5 ++++- components/synedit/synguttercodefolding.pp | 1 + components/synedit/syngutterlineoverview.pp | 4 +++- components/synedit/synhighlighterhtml.pp | 2 +- components/synedit/synhighlightermulti.pas | 9 ++++++-- components/synedit/synhighlighterpas.pp | 22 ++++++++++++++---- components/synedit/synhighlighterxml.pas | 2 +- components/synedit/synpluginmulticaret.pp | 8 +++++-- components/synedit/synregexpr.pas | 11 +++++---- 21 files changed, 94 insertions(+), 36 deletions(-) diff --git a/components/synedit/lazsynedittext.pas b/components/synedit/lazsynedittext.pas index 6c9dcc5b82..01ebe0cd3d 100644 --- a/components/synedit/lazsynedittext.pas +++ b/components/synedit/lazsynedittext.pas @@ -869,6 +869,7 @@ begin {$ENDIF} PrepareWidthsForLine(AIndex); + Result := 0; dec(ABytePos); if ABytePos < FCurrentWidthsLen then begin if (FCurrentWidths[ABytePos] and PCWMask) = 0 then begin diff --git a/components/synedit/lazsynimm.pas b/components/synedit/lazsynimm.pas index 86bcea4c2c..b0a21e5674 100644 --- a/components/synedit/lazsynimm.pas +++ b/components/synedit/lazsynimm.pas @@ -738,7 +738,7 @@ begin {$IFDEF WinIMEDebug} DebugLn(['--- GCS_CURSORPOS ', dbgs(ImeCount)]); {$ENDIF} - if ImeCount >= 0 then begin + if ImeCount >= 0 then begin // ToDo: Comparison is always True. ImeCount := ImeCount and $ffff; x := FImeBlockSelection.StartBytePos; x := x + CharToByte(x, ImeCount); diff --git a/components/synedit/lazsyntextarea.pp b/components/synedit/lazsyntextarea.pp index a3c530fd7f..0763513f9f 100644 --- a/components/synedit/lazsyntextarea.pp +++ b/components/synedit/lazsyntextarea.pp @@ -1551,7 +1551,6 @@ var LineBufferLen := Len + ATokenInfo.ExpandedExtraBytes + 1 + 128; ReAllocMem(LineBuffer, LineBufferLen); end; - pl := LineBuffer; end; // Prepare FETOBuf @@ -1561,9 +1560,12 @@ var FEtoBuf := FTextDrawer.Eto; FEtoBuf.SetMinLength(Len + ATokenInfo.ExpandedExtraBytes + 1); c := FTextDrawer.GetCharWidth; - e := 0; - end; + end + else + c := 0; + pl := LineBuffer; + e := 0; CWLen := Length(CharWidths); // Copy to LineBuffer (and maybe FetoBuf diff --git a/components/synedit/synbeautifier.pas b/components/synedit/synbeautifier.pas index 09e95583a0..d09f735154 100644 --- a/components/synedit/synbeautifier.pas +++ b/components/synedit/synbeautifier.pas @@ -805,6 +805,7 @@ end; function TSynBeautifierPascal.GetMatchStartColForIdx(AIndex: Integer): Integer; begin + Result := -1; if ToPos(AIndex) = GetFirstCommentLine then begin // Match on FirstLine case FMatchMode[FWorkFoldType] of @@ -1748,6 +1749,7 @@ var FoundLine: LongInt; begin Result := 1; + Temp := ''; FCurrentLines := Lines; // for GetCurrentIndent BackCounter := ACaret.LinePos - 1; if BackCounter > 0 then diff --git a/components/synedit/synedit.pp b/components/synedit/synedit.pp index 1d469dd0df..bda0032049 100644 --- a/components/synedit/synedit.pp +++ b/components/synedit/synedit.pp @@ -1895,7 +1895,9 @@ begin if eoFoldedCopyPaste in fOptions2 then FInfo := FFoldedLinesView.GetFoldDescription( FBlockSelection.FirstLineBytePos.Y - 1, FBlockSelection.FirstLineBytePos.X, - FBlockSelection.LastLineBytePos.Y - 1, FBlockSelection.LastLineBytePos.X); + FBlockSelection.LastLineBytePos.Y - 1, FBlockSelection.LastLineBytePos.X) + else + FInfo := ''; DoCopyToClipboard(SelText, FInfo); end; end; @@ -1908,7 +1910,9 @@ begin if eoFoldedCopyPaste in fOptions2 then FInfo := FFoldedLinesView.GetFoldDescription( FBlockSelection.FirstLineBytePos.Y - 1, FBlockSelection.FirstLineBytePos.X, - FBlockSelection.LastLineBytePos.Y - 1, FBlockSelection.LastLineBytePos.X); + FBlockSelection.LastLineBytePos.Y - 1, FBlockSelection.LastLineBytePos.X) + else + FInfo := ''; DoCopyToClipboard(SelText, FInfo); SetSelTextExternal(''); end; diff --git a/components/synedit/syneditfoldedview.pp b/components/synedit/syneditfoldedview.pp index b0748b19ca..ecbd61384d 100644 --- a/components/synedit/syneditfoldedview.pp +++ b/components/synedit/syneditfoldedview.pp @@ -2680,6 +2680,7 @@ begin if not OnlyNested then RemoveNode(ANode.fData); + NestedLine := 0; If ANode.fData.Nested <> nil then begin (*Todo: should we mark the tree as NO balancing needed ???*) @@ -4923,6 +4924,7 @@ var EndLvl, CurLvl: Array of integer; i, c, t, n, o: Integer; nd: TSynFoldNodeInfo; + procedure GetEndLvl(l: Integer); var i: integer; begin @@ -4939,11 +4941,18 @@ var CurLvl[0] := EndLvl[0]; end; end; + begin hl := TSynCustomFoldHighlighter(HighLighter); if not assigned(hl) then - exit; + exit; // ToDo: Initialize Result + nd.LogXStart := 0; + nd.LogXEnd := 0; + nd.FoldAction := []; + nd.FoldType := Nil; + nd.FoldGroup := 0; + n := 0; if AType <> 0 then TypeCnt := 1 else diff --git a/components/synedit/syneditmarks.pp b/components/synedit/syneditmarks.pp index ca57ba4890..f219d739e5 100644 --- a/components/synedit/syneditmarks.pp +++ b/components/synedit/syneditmarks.pp @@ -826,7 +826,7 @@ end; function TSynEditMarkLineList.RemoveMark(Item: TSynEditMark): Integer; begin if Item.MarkLine = nil then - exit; + exit(-1); Result := Item.MarkLine.GetSizesBeforeSum; Result := Result + Item.MarkLine.Remove(Item); end; diff --git a/components/synedit/syneditmarkuphighall.pp b/components/synedit/syneditmarkuphighall.pp index 3d5efce6b9..d9aa4e5019 100644 --- a/components/synedit/syneditmarkuphighall.pp +++ b/components/synedit/syneditmarkuphighall.pp @@ -1370,6 +1370,8 @@ var o: TSynSearchTerm; MatchBegin: PChar; begin + Len := 0; + MatchBegin := nil; while MatchIdx >= 0 do begin o := FTermDict[MatchIdx]; diff --git a/components/synedit/syneditplugins.pas b/components/synedit/syneditplugins.pas index 41849d960a..40a59aa8e0 100644 --- a/components/synedit/syneditplugins.pas +++ b/components/synedit/syneditplugins.pas @@ -433,6 +433,7 @@ var cCol: integer; iIdentChars: TSynIdentChars; begin + Result := ''; iString := CurrentEditor.LineText; if (CurrentEditor.CaretX > 1) and (CurrentEditor.CaretX -1 <= Length(iString)) then diff --git a/components/synedit/syneditpointclasses.pas b/components/synedit/syneditpointclasses.pas index f3302d7996..23cae91248 100644 --- a/components/synedit/syneditpointclasses.pas +++ b/components/synedit/syneditpointclasses.pas @@ -1038,7 +1038,9 @@ begin CharWidthsArr := FLines.GetPhysicalCharWidths(Pchar(L), length(L), FLinePos-1); LogLen := Length(CharWidthsArr); if LogLen > 0 then - CharWidths := @CharWidthsArr[0]; + CharWidths := @CharWidthsArr[0] + else + CharWidths := nil; end; ScreenPos := 1; @@ -1522,8 +1524,7 @@ function TSynEditSelection.GetSelText : string; end; end; - procedure CopyAndForward(const S: string; Index, Count: Integer; var P: - PChar); + procedure CopyAndForward(const S: string; Index, Count: Integer; var P: PChar); var pSrc: PChar; SrcLen: Integer; @@ -1540,8 +1541,7 @@ function TSynEditSelection.GetSelText : string; end; end; - procedure CopyPaddedAndForward(const S: string; Index, Count: Integer; - var P: PChar); + procedure CopyPaddedAndForward(const S: string; Index, Count: Integer; var P: PChar); var OldP: PChar; Len: Integer; @@ -1563,9 +1563,9 @@ var Col, Len: array of Integer; begin - if not SelAvail then - Result := '' - else begin + Result := ''; + if SelAvail then + begin if IsBackwardSel then begin ColFrom := FEndBytePos; First := FEndLinePos - 1; @@ -2009,6 +2009,7 @@ var begin // Insert string at current position Result := 0; + Str := ''; Start := PChar(Value); repeat P := GetEOL(Start); @@ -2701,7 +2702,9 @@ function TSynEditScreenCaretPainterSystem.HideCaret: Boolean; begin inherited HideCaret; if HandleAllocated then - Result := LCLIntf.HideCaret(Handle); + Result := LCLIntf.HideCaret(Handle) + else + Result := False; end; function TSynEditScreenCaretPainterSystem.ShowCaret: Boolean; @@ -3000,7 +3003,7 @@ begin if (not FCanPaint) and FIsDrawn then begin AddAfterPaint([psCleanOld, psRemoveTimer]); FIsDrawn := False; - exit; + exit(False); end; FOwner.PaintTimer.RemoveHandler(@DoTimer); @@ -3011,7 +3014,7 @@ end; function TSynEditScreenCaretPainterInternal.ShowCaret: Boolean; begin - if Showing then exit; + if Showing then exit(False); inherited ShowCaret; Exclude(FState, psRemoveTimer); // Exclude(FState, psCleanOld); // only if not moved diff --git a/components/synedit/synedittextbuffer.pp b/components/synedit/synedittextbuffer.pp index a189fdc905..dc59279a68 100644 --- a/components/synedit/synedittextbuffer.pp +++ b/components/synedit/synedittextbuffer.pp @@ -1275,6 +1275,7 @@ function TSynEditStringList.EditDelete(LogX, LogY, ByteLen: Integer): String; var s: string; begin + Result := ''; if ByteLen <= 0 then exit; IncIsInEditAction; @@ -1440,6 +1441,7 @@ begin FModifiedNotifyOldCount := FModifiedNotifyOldCount + i; end; + oldcount := 0; if AReason = senrLineCount then begin if aCount < 0 then begin oldcount := -aCount; diff --git a/components/synedit/synedittexttrimmer.pas b/components/synedit/synedittexttrimmer.pas index fbae973315..ff1c04f711 100644 --- a/components/synedit/synedittexttrimmer.pas +++ b/components/synedit/synedittexttrimmer.pas @@ -1125,6 +1125,7 @@ var Len: Integer; SaveByteLen: LongInt; begin + Result := ''; if (not fEnabled) or (ByteLen <= 0) then begin fSynStrings.EditDelete(LogX, LogY, ByteLen); exit; @@ -1140,7 +1141,6 @@ begin IncIsInEditAction; FlushNotificationCache; SaveByteLen := ByteLen; - Result := ''; IgnoreSendNotification(senrEditAction, True); // Delete uncommited spaces (could also be ByteLen too big, due to past EOL) diff --git a/components/synedit/syngutter.pp b/components/synedit/syngutter.pp index 3c3f99af0f..16ae0a9423 100644 --- a/components/synedit/syngutter.pp +++ b/components/synedit/syngutter.pp @@ -227,6 +227,7 @@ end; function TSynGutter.CreatePartList: TSynGutterPartListBase; begin + Result := nil; case Side of gsLeft: begin @@ -312,7 +313,9 @@ var begin MouseDownPart := PixelToPartIndex(AnInfo.MouseX); if MouseDownPart < PartCount then - Result := Parts[MouseDownPart].MaybeHandleMouseAction(AnInfo, HandleActionProc); + Result := Parts[MouseDownPart].MaybeHandleMouseAction(AnInfo, HandleActionProc) + else + Result := False; if not Result then Result := inherited MaybeHandleMouseAction(AnInfo, HandleActionProc); end; diff --git a/components/synedit/synguttercodefolding.pp b/components/synedit/synguttercodefolding.pp index 721e8c916d..d253059595 100644 --- a/components/synedit/synguttercodefolding.pp +++ b/components/synedit/synguttercodefolding.pp @@ -494,6 +494,7 @@ var begin AliasMode := Canvas.AntialiasingMode; Canvas.AntialiasingMode:=amOff; + OdlCosmetic := False; if nsoLostHl in SubType then begin Canvas.Pen.Style := psDot; OdlCosmetic := Canvas.Pen.Cosmetic; diff --git a/components/synedit/syngutterlineoverview.pp b/components/synedit/syngutterlineoverview.pp index 36874ea5c9..95461aced3 100644 --- a/components/synedit/syngutterlineoverview.pp +++ b/components/synedit/syngutterlineoverview.pp @@ -740,7 +740,9 @@ begin Insert(i, LMarks); end; if i >= 0 then - Result := Items[i]; + Result := Items[i] + else + Result := nil; end; procedure TSynGutterLOvLineMarksList.SetItemHeight(const AValue: Integer); diff --git a/components/synedit/synhighlighterhtml.pp b/components/synedit/synhighlighterhtml.pp index f7b62f6e7d..b3bb3a3549 100644 --- a/components/synedit/synhighlighterhtml.pp +++ b/components/synedit/synhighlighterhtml.pp @@ -2769,7 +2769,7 @@ end; function TSynHTMLSyn.StartHtmlNodeCodeFoldBlock(ABlockType: THtmlCodeFoldBlockType; OpenPos: Integer; AName: String): TSynCustomCodeFoldBlock; begin - if not FFoldConfig[ord(cfbtHtmlNode)].Enabled then exit; + if not FFoldConfig[ord(cfbtHtmlNode)].Enabled then exit(nil); Result := inherited StartXmlNodeCodeFoldBlock(ord(ABlockType), OpenPos, AName); end; diff --git a/components/synedit/synhighlightermulti.pas b/components/synedit/synhighlightermulti.pas index 28d08772c9..b6698f5295 100644 --- a/components/synedit/synhighlightermulti.pas +++ b/components/synedit/synhighlightermulti.pas @@ -713,7 +713,9 @@ begin NewVLine := NewVLine + s.EndPos.y - s.StartPos.y; LastEnd := s.EndPos.y; end; - end; + end + else + LastVline := 0; // ToDo: Initialize LastVline properly. if VDiff = 0 then VDiff := Count - FRScanStartedWithLineCount; if VDiff < 0 then begin @@ -1141,7 +1143,9 @@ begin CurRegStart.y := 0; CurRegStart.x := 1; CurRegTokenPos := 1; - end; + end + else + CurRegTokenPos := 0; StartAtLineIndex(Result); // Set FCurScheme dec(Result); @@ -1165,6 +1169,7 @@ begin else begin // Find new start of a Scheme NewSearchPos := -1; + j := 0; for i := 0 to Schemes.Count - 1 do begin TmpSearchPos := Schemes.Items[i].FindStartPosInLine(SearchPos); if (NewSearchPos < 0) or ((TmpSearchPos > 0) and (TmpSearchPos < NewSearchPos)) then begin diff --git a/components/synedit/synhighlighterpas.pp b/components/synedit/synhighlighterpas.pp index 8b7053a4b9..cd0977e895 100644 --- a/components/synedit/synhighlighterpas.pp +++ b/components/synedit/synhighlighterpas.pp @@ -3287,7 +3287,13 @@ begin exit; if AFilter.FoldGroup in [0, FOLDGROUP_REGION, FOLDGROUP_IFDEF] then - inf := TSynHighlighterPasRangeList(CurrentRanges).PasRangeInfo[ALineIndex]; + inf := TSynHighlighterPasRangeList(CurrentRanges).PasRangeInfo[ALineIndex] + else begin + inf.EndLevelIfDef := 0; + inf.MinLevelIfDef := 0; + inf.EndLevelRegion := 0; + inf.MinLevelRegion := 0; + end; if AFilter.FoldGroup in [0, FOLDGROUP_PASCAL] then begin // All or Pascal @@ -3337,7 +3343,13 @@ begin exit; if AFilter.FoldGroup in [0, FOLDGROUP_REGION, FOLDGROUP_IFDEF] then - inf := TSynHighlighterPasRangeList(CurrentRanges).PasRangeInfo[ALineIndex]; + inf := TSynHighlighterPasRangeList(CurrentRanges).PasRangeInfo[ALineIndex] + else begin + inf.EndLevelIfDef := 0; + inf.MinLevelIfDef := 0; + inf.EndLevelRegion := 0; + inf.MinLevelRegion := 0; + end; if AFilter.FoldGroup in [0, FOLDGROUP_PASCAL] then begin // All or Pascal @@ -3761,7 +3773,7 @@ var begin BlockEnabled := FFoldConfig[ord(ABlockType)].Enabled; if (not BlockEnabled) and OnlyEnabled then - exit; + exit(nil); FoldBlock := BlockEnabled and (FFoldConfig[ord(ABlockType)].Modes * [fmFold, fmHide] <> []); p := 0; if FCatchNodeInfo then begin // exclude subblocks, because they do not increase the foldlevel yet @@ -3848,7 +3860,9 @@ var nd: PSynFoldNodeInfo; begin if FCatchNodeInfo then - i := FCatchNodeInfoList.CountAll; + i := FCatchNodeInfoList.CountAll + else + i := 0; EndPascalCodeFoldBlock; if FAtLineStart then begin // If we are not at linestart, new folds could have been opened => handle as normal close diff --git a/components/synedit/synhighlighterxml.pas b/components/synedit/synhighlighterxml.pas index 9cde8e5c90..581470e963 100644 --- a/components/synedit/synhighlighterxml.pas +++ b/components/synedit/synhighlighterxml.pas @@ -962,7 +962,7 @@ end; function TSynXMLSyn.StartXmlNodeCodeFoldBlock(ABlockType: TXmlCodeFoldBlockType; OpenPos: Integer; AName: String): TSynCustomCodeFoldBlock; begin - if not FFoldConfig[ord(cfbtXmlNode)].Enabled then exit; + if not FFoldConfig[ord(cfbtXmlNode)].Enabled then exit(nil); Result := inherited StartXmlNodeCodeFoldBlock(ord(ABlockType), OpenPos, AName); end; diff --git a/components/synedit/synpluginmulticaret.pp b/components/synedit/synpluginmulticaret.pp index c68e0c2d2e..b056a49e0e 100644 --- a/components/synedit/synpluginmulticaret.pp +++ b/components/synedit/synpluginmulticaret.pp @@ -1582,7 +1582,9 @@ begin if (y1 < 0) or (y1 > Editor.LinesInWindow + 1) then y := -1; // not visible if y > 1 then - y2 := Editor.RowToScreenRow(y-1); + y2 := Editor.RowToScreenRow(y-1) + else + y2 := 0; if (y > 0) and (y1 <> y2) or (y=1) then begin if Carets.Visual[Result] = nil then @@ -1633,7 +1635,9 @@ begin end; if y > 1 then - y2 := Editor.RowToScreenRow(y-1); + y2 := Editor.RowToScreenRow(y-1) + else + y2 := 0; if (y1 <> y2) or (y=1) then begin if Carets.Visual[i] = nil then diff --git a/components/synedit/synregexpr.pas b/components/synedit/synregexpr.pas index fb7455515b..dba770a38f 100644 --- a/components/synedit/synregexpr.pas +++ b/components/synedit/synregexpr.pas @@ -2245,6 +2245,8 @@ function TRegExpr.ParseAtom (out flagp : integer) : PRegExprChar; begin Result := nil; flagp := WORST; // Tentatively. + RangeBeg := #0; + ret := nil; inc (regparse); case (regparse - 1)^ of @@ -3545,6 +3547,7 @@ function TRegExpr.ExecNext : boolean; function TRegExpr.GetInputString : RegExprString; begin + Result := ''; if not Assigned (fInputString) then begin Error (reeGetInputStringWithoutInputString); EXIT; @@ -3695,6 +3698,7 @@ var end; begin + Result := ''; // Check programm and input string if not IsProgrammOk then EXIT; @@ -3704,10 +3708,8 @@ begin end; // Prepare for working TemplateLen := length (ATemplate); - if TemplateLen = 0 then begin // prevent nil pointers - Result := ''; + if TemplateLen = 0 then // prevent nil pointers EXIT; - end; TemplateBeg := pointer (ATemplate); TemplateEnd := TemplateBeg + TemplateLen; // Count result length for speed optimization. @@ -3896,6 +3898,7 @@ function TRegExpr.Replace (AInputStr : RegExprString; function TRegExpr.DumpOp (op : TREOp) : RegExprString; // printable representation of opcode begin + Result := ''; case op of BOL: Result := 'BOL'; EOL: Result := 'EOL'; @@ -3962,11 +3965,11 @@ function TRegExpr.Dump : RegExprString; Ch : REChar; {$ENDIF} begin + Result := ''; if not IsProgrammOk //###0.929 then EXIT; op := EXACTLY; - Result := ''; s := programm + REOpSz; while op <> EEND do begin // While that wasn't END last time... op := s^;