style, put locals init in declaration instead of body

This commit is contained in:
Basile Burg 2015-09-04 23:48:07 +02:00
parent 0cc5fe3e5d
commit 95aef4170f
10 changed files with 36 additions and 58 deletions

View File

@ -374,9 +374,8 @@ end;
function expandFilenameEx(const aBasePath, aFilename: string): string; function expandFilenameEx(const aBasePath, aFilename: string): string;
var var
curr: string; curr: string = '';
begin begin
curr := '';
getDir(0, curr); getDir(0, curr);
try try
if (curr <> aBasePath) and DirectoryExists(aBasePath) then if (curr <> aBasePath) and DirectoryExists(aBasePath) then
@ -490,11 +489,10 @@ end;
function shortenPath(const aPath: string; charThresh: Word = 60): string; function shortenPath(const aPath: string; charThresh: Word = 60): string;
var var
i: NativeInt; i: NativeInt;
sepCnt: NativeInt; sepCnt: integer = 0;
drv: string; drv: string;
pth1: string; pth1: string;
begin begin
sepCnt := 0;
if length(aPath) <= charThresh then if length(aPath) <= charThresh then
exit(aPath); exit(aPath);
@ -729,7 +727,7 @@ end;
procedure processOutputToStrings(aProcess: TProcess; var aList: TStringList); procedure processOutputToStrings(aProcess: TProcess; var aList: TStringList);
var var
str: TMemoryStream; str: TMemoryStream;
sum: Integer; sum: Integer = 0;
cnt: Integer; cnt: Integer;
buffSz: Integer; buffSz: Integer;
begin begin
@ -752,7 +750,6 @@ begin
Detects last line terminator in the accumation. Detects last line terminator in the accumation.
Load TStrings from this stream range. Load TStrings from this stream range.
} }
sum := 0;
str := TMemoryStream.Create; str := TMemoryStream.Create;
try try
buffSz := aProcess.PipeBufferSize; buffSz := aProcess.PipeBufferSize;
@ -826,11 +823,9 @@ end;
function getLineEndingLength(const aFilename: string): byte; function getLineEndingLength(const aFilename: string): byte;
var var
value: char; value: char = #0;
le: string; le: string = LineEnding;
begin begin
value := #0;
le := LineEnding;
result := length(le); result := length(le);
if not fileExists(aFilename) then if not fileExists(aFilename) then
exit; exit;

View File

@ -434,7 +434,6 @@ begin
fAsblrAttrib.Assign(aValue); fAsblrAttrib.Assign(aValue);
end; end;
procedure TSynD2Syn.setCurrIdent(const aValue: string); procedure TSynD2Syn.setCurrIdent(const aValue: string);
begin begin
if fCurrIdent = aValue then Exit; if fCurrIdent = aValue then Exit;

View File

@ -389,7 +389,6 @@ begin
fClient.Execute; fClient.Execute;
writeSourceToInput; writeSourceToInput;
// //
str := 'a';
setlength(str, 256); setlength(str, 256);
i := fClient.Output.Read(str[1], 256); i := fClient.Output.Read(str[1], 256);
if i = 0 then if i = 0 then

View File

@ -1,21 +1,21 @@
inherited CEInfoWidget: TCEInfoWidget inherited CEInfoWidget: TCEInfoWidget
Left = 713 Left = 713
Height = 306 Height = 318
Top = 245 Top = 245
Width = 378 Width = 378
BorderIcons = [biSystemMenu, biMinimize, biMaximize] BorderIcons = [biSystemMenu, biMinimize, biMaximize]
Caption = 'About' Caption = 'About'
ClientHeight = 306 ClientHeight = 318
ClientWidth = 378 ClientWidth = 378
inherited Back: TPanel inherited Back: TPanel
Height = 306 Height = 318
Width = 378 Width = 378
ClientHeight = 306 ClientHeight = 318
ClientWidth = 378 ClientWidth = 378
inherited Content: TPanel inherited Content: TPanel
Height = 306 Height = 318
Width = 378 Width = 378
ClientHeight = 306 ClientHeight = 318
ClientWidth = 378 ClientWidth = 378
object GroupBox1: TGroupBox[0] object GroupBox1: TGroupBox[0]
Left = 4 Left = 4
@ -46,18 +46,18 @@ inherited CEInfoWidget: TCEInfoWidget
end end
object GroupBox2: TGroupBox[1] object GroupBox2: TGroupBox[1]
Left = 4 Left = 4
Height = 189 Height = 201
Top = 113 Top = 113
Width = 370 Width = 370
Align = alClient Align = alClient
BorderSpacing.Around = 4 BorderSpacing.Around = 4
Caption = 'tools status' Caption = 'tools status'
ClientHeight = 169 ClientHeight = 181
ClientWidth = 366 ClientWidth = 366
TabOrder = 1 TabOrder = 1
object boxTools: TScrollBox object boxTools: TScrollBox
Left = 4 Left = 4
Height = 161 Height = 173
Top = 4 Top = 4
Width = 358 Width = 358
HorzScrollBar.Page = 1 HorzScrollBar.Page = 1

View File

@ -231,17 +231,14 @@ end;
procedure TCELibManEditorWidget.btnSelFileClick(Sender: TObject); procedure TCELibManEditorWidget.btnSelFileClick(Sender: TObject);
var var
ini: string; ini: string = '';
begin begin
if List.Selected = nil then if List.Selected = nil then
exit; exit;
if List.Selected.SubItems.Count > 0 then if List.Selected.SubItems.Count > 0 then
ini := List.Selected.SubItems[0] ini := List.Selected.SubItems[0]
else else
begin
ini := '';
List.Selected.SubItems.Add(ini); List.Selected.SubItems.Add(ini);
end;
with TOpenDialog.Create(nil) do with TOpenDialog.Create(nil) do
try try
filename := ini; filename := ini;

View File

@ -708,22 +708,22 @@ end;
procedure TCEMainForm.LoadSettings; procedure TCEMainForm.LoadSettings;
var var
fname1: string; fname: string;
begin begin
// project and files MRU // project and files MRU
fname1 := getCoeditDocPath + 'mostrecent.txt'; fname := getCoeditDocPath + 'mostrecent.txt';
if fileExists(fname1) then with TCEPersistentMainMrus.create(nil) do if fileExists(fname) then with TCEPersistentMainMrus.create(nil) do
try try
setTargets(fFileMru, fProjMru); setTargets(fFileMru, fProjMru);
loadFromFile(fname1); loadFromFile(fname);
finally finally
Free; Free;
end; end;
// shortcuts for the actions standing in the main action list // shortcuts for the actions standing in the main action list
fname1 := getCoeditDocPath + 'mainshortcuts.txt'; fname := getCoeditDocPath + 'mainshortcuts.txt';
if fileExists(fname1) then with TCEPersistentMainShortcuts.create(nil) do if fileExists(fname) then with TCEPersistentMainShortcuts.create(nil) do
try try
loadFromFile(fname1); loadFromFile(fname);
assignTo(self); assignTo(self);
finally finally
Free; Free;
@ -973,9 +973,8 @@ procedure TCEMainForm.updateMainMenuProviders;
var var
i, j: Integer; i, j: Integer;
itm: TMenuItem; itm: TMenuItem;
doneUpdate: boolean; doneUpdate: boolean = false;
begin begin
doneUpdate := false;
for j := 0 to fMainMenuSubj.observersCount-1 do for j := 0 to fMainMenuSubj.observersCount-1 do
begin begin
// try to update existing entry. // try to update existing entry.
@ -1157,7 +1156,6 @@ var
act := nil; act := nil;
cat := ''; cat := '';
end; end;
begin begin
for i:= 0 to fActionHandler.observersCount-1 do for i:= 0 to fActionHandler.observersCount-1 do
begin begin
@ -1609,10 +1607,9 @@ end;
procedure TCEMainForm.actFileCompAndRunWithArgsExecute(Sender: TObject); procedure TCEMainForm.actFileCompAndRunWithArgsExecute(Sender: TObject);
var var
runargs: string; runargs: string = '';
begin begin
if fDoc = nil then exit; if fDoc = nil then exit;
runargs := '';
if InputQuery('Execution arguments', '', runargs) then if InputQuery('Execution arguments', '', runargs) then
compileAndRunFile(false, true, runargs); compileAndRunFile(false, true, runargs);
end; end;
@ -1639,11 +1636,10 @@ end;
procedure TCEMainForm.actProjCompAndRunWithArgsExecute(Sender: TObject); procedure TCEMainForm.actProjCompAndRunWithArgsExecute(Sender: TObject);
var var
runargs: string; runargs: string = '';
begin begin
if not fProjectInterface.compile then if not fProjectInterface.compile then
exit; exit;
runargs := '';
if InputQuery('Execution arguments', '', runargs) then if InputQuery('Execution arguments', '', runargs) then
fProjectInterface.run(runargs); fProjectInterface.run(runargs);
end; end;
@ -1694,9 +1690,8 @@ end;
procedure TCEMainForm.actProjRunWithArgsExecute(Sender: TObject); procedure TCEMainForm.actProjRunWithArgsExecute(Sender: TObject);
var var
runargs: string; runargs: string = '';
begin begin
runargs := '';
if InputQuery('Execution arguments', '', runargs) then if InputQuery('Execution arguments', '', runargs) then
fProjectInterface.run(runargs); fProjectInterface.run(runargs);
end; end;
@ -1827,9 +1822,8 @@ end;
procedure TCEMainForm.actLayoutSaveExecute(Sender: TObject); procedure TCEMainForm.actLayoutSaveExecute(Sender: TObject);
var var
fname: string; fname: string = '';
begin begin
fname := '';
if not InputQuery('New layout name', '', fname) then if not InputQuery('New layout name', '', fname) then
exit; exit;
// //

View File

@ -541,9 +541,8 @@ end;
procedure TCEMessagesWidget.actCopyMsgExecute(Sender: TObject); procedure TCEMessagesWidget.actCopyMsgExecute(Sender: TObject);
var var
i: Integer; i: Integer;
str: string; str: string = '';
begin begin
str := '';
for i := 0 to List.Items.Count-1 do for i := 0 to List.Items.Count-1 do
if List.Items[i].MultiSelected then if List.Items[i].MultiSelected then
str += List.Items[i].Text + LineEnding; str += List.Items[i].Text + LineEnding;
@ -654,7 +653,7 @@ procedure TCEMessagesWidget.message(const aValue: string; aData: Pointer;
aCtxt: TCEAppMessageCtxt; aKind: TCEAppMessageKind); aCtxt: TCEAppMessageCtxt; aKind: TCEAppMessageKind);
var var
dt: PMessageData; dt: PMessageData;
item: TTreeNode; item: TTreeNode;
begin begin
showWidget; showWidget;
if aKind = amkAuto then if aKind = amkAuto then
@ -799,8 +798,8 @@ end;
function guessMessageKind(const aMessg: string): TCEAppMessageKind; function guessMessageKind(const aMessg: string): TCEAppMessageKind;
var var
pos: Integer; pos: Integer = 1;
idt: string; idt: string = '';
function checkIdent: TCEAppMessageKind; function checkIdent: TCEAppMessageKind;
begin begin
case idt of case idt of
@ -820,8 +819,6 @@ begin
end; end;
end; end;
begin begin
idt := '';
pos := 1;
result := amkBub; result := amkBub;
while(true) do while(true) do
begin begin
@ -852,11 +849,10 @@ end;
function getLineFromMessage(const aMessage: string): TPoint; function getLineFromMessage(const aMessage: string): TPoint;
var var
i, j: Integer; i, j: Integer;
ident: string; ident: string = '';
begin begin
result.x := 0; result.x := 0;
result.y := 0; result.y := 0;
ident := '';
i := 1; i := 1;
while (true) do while (true) do
begin begin

View File

@ -725,7 +725,6 @@ begin
currentConfiguration.runOptions.setProcess(fRunner); currentConfiguration.runOptions.setProcess(fRunner);
if runArgs <> '' then if runArgs <> '' then
begin begin
prm := '';
i := 1; i := 1;
repeat repeat
prm := ExtractDelimited(i, runArgs, [' ']); prm := ExtractDelimited(i, runArgs, [' ']);

View File

@ -720,9 +720,9 @@ var
node: TTreeNode; node: TTreeNode;
i: Integer; i: Integer;
begin begin
cat := getCatNode(origin, sym.symType); cat := getCatNode(origin, sym.symType);
{$HINTS OFF} {$HINTS OFF}
node := tree.Items.AddChildObject(cat, sym.name, Pointer(sym.fline)); node := tree.Items.AddChildObject(cat, sym.name, Pointer(sym.fline));
{$HINTS ON} {$HINTS ON}
if not fShowChildCategories then node := nil; if not fShowChildCategories then node := nil;
cat.Visible:=true; cat.Visible:=true;

View File

@ -559,11 +559,10 @@ end;
procedure TCETodoListWidget.lstItemsCompare(Sender: TObject; item1, item2: TListItem; Data: Integer; var Compare: Integer); procedure TCETodoListWidget.lstItemsCompare(Sender: TObject; item1, item2: TListItem; Data: Integer; var Compare: Integer);
var var
txt1, txt2: string; txt1: string = '';
txt2: string = '';
col: Integer; col: Integer;
begin begin
txt1 := '';
txt2 := '';
col := lstItems.SortColumn; col := lstItems.SortColumn;
if col = 0 then if col = 0 then
begin begin