From 95aef4170fc8d20cb47ac9ad6a86701a0d7addab Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Fri, 4 Sep 2015 23:48:07 +0200 Subject: [PATCH] style, put locals init in declaration instead of body --- src/ce_common.pas | 15 +++++---------- src/ce_d2syn.pas | 1 - src/ce_dcd.pas | 1 - src/ce_infos.lfm | 18 +++++++++--------- src/ce_libmaneditor.pas | 5 +---- src/ce_main.pas | 30 ++++++++++++------------------ src/ce_messages.pas | 14 +++++--------- src/ce_nativeproject.pas | 1 - src/ce_symlist.pas | 4 ++-- src/ce_todolist.pas | 5 ++--- 10 files changed, 36 insertions(+), 58 deletions(-) diff --git a/src/ce_common.pas b/src/ce_common.pas index 9e730b3b..7a440ad3 100644 --- a/src/ce_common.pas +++ b/src/ce_common.pas @@ -374,9 +374,8 @@ end; function expandFilenameEx(const aBasePath, aFilename: string): string; var - curr: string; + curr: string = ''; begin - curr := ''; getDir(0, curr); try if (curr <> aBasePath) and DirectoryExists(aBasePath) then @@ -490,11 +489,10 @@ end; function shortenPath(const aPath: string; charThresh: Word = 60): string; var i: NativeInt; - sepCnt: NativeInt; + sepCnt: integer = 0; drv: string; pth1: string; begin - sepCnt := 0; if length(aPath) <= charThresh then exit(aPath); @@ -729,7 +727,7 @@ end; procedure processOutputToStrings(aProcess: TProcess; var aList: TStringList); var str: TMemoryStream; - sum: Integer; + sum: Integer = 0; cnt: Integer; buffSz: Integer; begin @@ -752,7 +750,6 @@ begin Detects last line terminator in the accumation. Load TStrings from this stream range. } - sum := 0; str := TMemoryStream.Create; try buffSz := aProcess.PipeBufferSize; @@ -826,11 +823,9 @@ end; function getLineEndingLength(const aFilename: string): byte; var - value: char; - le: string; + value: char = #0; + le: string = LineEnding; begin - value := #0; - le := LineEnding; result := length(le); if not fileExists(aFilename) then exit; diff --git a/src/ce_d2syn.pas b/src/ce_d2syn.pas index 847b332b..7d7d3f50 100644 --- a/src/ce_d2syn.pas +++ b/src/ce_d2syn.pas @@ -434,7 +434,6 @@ begin fAsblrAttrib.Assign(aValue); end; - procedure TSynD2Syn.setCurrIdent(const aValue: string); begin if fCurrIdent = aValue then Exit; diff --git a/src/ce_dcd.pas b/src/ce_dcd.pas index b72efad9..5429f149 100644 --- a/src/ce_dcd.pas +++ b/src/ce_dcd.pas @@ -389,7 +389,6 @@ begin fClient.Execute; writeSourceToInput; // - str := 'a'; setlength(str, 256); i := fClient.Output.Read(str[1], 256); if i = 0 then diff --git a/src/ce_infos.lfm b/src/ce_infos.lfm index c4173b7d..b0b685ee 100644 --- a/src/ce_infos.lfm +++ b/src/ce_infos.lfm @@ -1,21 +1,21 @@ inherited CEInfoWidget: TCEInfoWidget Left = 713 - Height = 306 + Height = 318 Top = 245 Width = 378 BorderIcons = [biSystemMenu, biMinimize, biMaximize] Caption = 'About' - ClientHeight = 306 + ClientHeight = 318 ClientWidth = 378 inherited Back: TPanel - Height = 306 + Height = 318 Width = 378 - ClientHeight = 306 + ClientHeight = 318 ClientWidth = 378 inherited Content: TPanel - Height = 306 + Height = 318 Width = 378 - ClientHeight = 306 + ClientHeight = 318 ClientWidth = 378 object GroupBox1: TGroupBox[0] Left = 4 @@ -46,18 +46,18 @@ inherited CEInfoWidget: TCEInfoWidget end object GroupBox2: TGroupBox[1] Left = 4 - Height = 189 + Height = 201 Top = 113 Width = 370 Align = alClient BorderSpacing.Around = 4 Caption = 'tools status' - ClientHeight = 169 + ClientHeight = 181 ClientWidth = 366 TabOrder = 1 object boxTools: TScrollBox Left = 4 - Height = 161 + Height = 173 Top = 4 Width = 358 HorzScrollBar.Page = 1 diff --git a/src/ce_libmaneditor.pas b/src/ce_libmaneditor.pas index 57cde1dc..1cb71e5d 100644 --- a/src/ce_libmaneditor.pas +++ b/src/ce_libmaneditor.pas @@ -231,17 +231,14 @@ end; procedure TCELibManEditorWidget.btnSelFileClick(Sender: TObject); var - ini: string; + ini: string = ''; begin if List.Selected = nil then exit; if List.Selected.SubItems.Count > 0 then ini := List.Selected.SubItems[0] else - begin - ini := ''; List.Selected.SubItems.Add(ini); - end; with TOpenDialog.Create(nil) do try filename := ini; diff --git a/src/ce_main.pas b/src/ce_main.pas index dd539863..10047f86 100644 --- a/src/ce_main.pas +++ b/src/ce_main.pas @@ -708,22 +708,22 @@ end; procedure TCEMainForm.LoadSettings; var - fname1: string; + fname: string; begin // project and files MRU - fname1 := getCoeditDocPath + 'mostrecent.txt'; - if fileExists(fname1) then with TCEPersistentMainMrus.create(nil) do + fname := getCoeditDocPath + 'mostrecent.txt'; + if fileExists(fname) then with TCEPersistentMainMrus.create(nil) do try setTargets(fFileMru, fProjMru); - loadFromFile(fname1); + loadFromFile(fname); finally Free; end; // shortcuts for the actions standing in the main action list - fname1 := getCoeditDocPath + 'mainshortcuts.txt'; - if fileExists(fname1) then with TCEPersistentMainShortcuts.create(nil) do + fname := getCoeditDocPath + 'mainshortcuts.txt'; + if fileExists(fname) then with TCEPersistentMainShortcuts.create(nil) do try - loadFromFile(fname1); + loadFromFile(fname); assignTo(self); finally Free; @@ -973,9 +973,8 @@ procedure TCEMainForm.updateMainMenuProviders; var i, j: Integer; itm: TMenuItem; - doneUpdate: boolean; + doneUpdate: boolean = false; begin - doneUpdate := false; for j := 0 to fMainMenuSubj.observersCount-1 do begin // try to update existing entry. @@ -1157,7 +1156,6 @@ var act := nil; cat := ''; end; - begin for i:= 0 to fActionHandler.observersCount-1 do begin @@ -1609,10 +1607,9 @@ end; procedure TCEMainForm.actFileCompAndRunWithArgsExecute(Sender: TObject); var - runargs: string; + runargs: string = ''; begin if fDoc = nil then exit; - runargs := ''; if InputQuery('Execution arguments', '', runargs) then compileAndRunFile(false, true, runargs); end; @@ -1639,11 +1636,10 @@ end; procedure TCEMainForm.actProjCompAndRunWithArgsExecute(Sender: TObject); var - runargs: string; + runargs: string = ''; begin if not fProjectInterface.compile then exit; - runargs := ''; if InputQuery('Execution arguments', '', runargs) then fProjectInterface.run(runargs); end; @@ -1694,9 +1690,8 @@ end; procedure TCEMainForm.actProjRunWithArgsExecute(Sender: TObject); var - runargs: string; + runargs: string = ''; begin - runargs := ''; if InputQuery('Execution arguments', '', runargs) then fProjectInterface.run(runargs); end; @@ -1827,9 +1822,8 @@ end; procedure TCEMainForm.actLayoutSaveExecute(Sender: TObject); var - fname: string; + fname: string = ''; begin - fname := ''; if not InputQuery('New layout name', '', fname) then exit; // diff --git a/src/ce_messages.pas b/src/ce_messages.pas index ce38c083..27603320 100644 --- a/src/ce_messages.pas +++ b/src/ce_messages.pas @@ -541,9 +541,8 @@ end; procedure TCEMessagesWidget.actCopyMsgExecute(Sender: TObject); var i: Integer; - str: string; + str: string = ''; begin - str := ''; for i := 0 to List.Items.Count-1 do if List.Items[i].MultiSelected then str += List.Items[i].Text + LineEnding; @@ -654,7 +653,7 @@ procedure TCEMessagesWidget.message(const aValue: string; aData: Pointer; aCtxt: TCEAppMessageCtxt; aKind: TCEAppMessageKind); var dt: PMessageData; - item: TTreeNode; + item: TTreeNode; begin showWidget; if aKind = amkAuto then @@ -799,8 +798,8 @@ end; function guessMessageKind(const aMessg: string): TCEAppMessageKind; var - pos: Integer; - idt: string; + pos: Integer = 1; + idt: string = ''; function checkIdent: TCEAppMessageKind; begin case idt of @@ -820,8 +819,6 @@ begin end; end; begin - idt := ''; - pos := 1; result := amkBub; while(true) do begin @@ -852,11 +849,10 @@ end; function getLineFromMessage(const aMessage: string): TPoint; var i, j: Integer; - ident: string; + ident: string = ''; begin result.x := 0; result.y := 0; - ident := ''; i := 1; while (true) do begin diff --git a/src/ce_nativeproject.pas b/src/ce_nativeproject.pas index eae3c383..6f353e3d 100644 --- a/src/ce_nativeproject.pas +++ b/src/ce_nativeproject.pas @@ -725,7 +725,6 @@ begin currentConfiguration.runOptions.setProcess(fRunner); if runArgs <> '' then begin - prm := ''; i := 1; repeat prm := ExtractDelimited(i, runArgs, [' ']); diff --git a/src/ce_symlist.pas b/src/ce_symlist.pas index 7ee9439f..f6b985c6 100644 --- a/src/ce_symlist.pas +++ b/src/ce_symlist.pas @@ -720,9 +720,9 @@ var node: TTreeNode; i: Integer; begin - cat := getCatNode(origin, sym.symType); + cat := getCatNode(origin, sym.symType); {$HINTS OFF} - node := tree.Items.AddChildObject(cat, sym.name, Pointer(sym.fline)); + node := tree.Items.AddChildObject(cat, sym.name, Pointer(sym.fline)); {$HINTS ON} if not fShowChildCategories then node := nil; cat.Visible:=true; diff --git a/src/ce_todolist.pas b/src/ce_todolist.pas index 69d02cbb..c960a24d 100644 --- a/src/ce_todolist.pas +++ b/src/ce_todolist.pas @@ -559,11 +559,10 @@ end; procedure TCETodoListWidget.lstItemsCompare(Sender: TObject; item1, item2: TListItem; Data: Integer; var Compare: Integer); var - txt1, txt2: string; + txt1: string = ''; + txt2: string = ''; col: Integer; begin - txt1 := ''; - txt2 := ''; col := lstItems.SortColumn; if col = 0 then begin