Browse Source

* Add const for string where possible. Fixes issue #40051

Michaël Van Canneyt 2 years ago
parent
commit
f0f42ca2a2
32 changed files with 359 additions and 442 deletions
  1. 14 10
      packages/fcl-db/src/base/bufdataset.pas
  2. 2 2
      packages/fcl-db/src/base/bufdataset_parser.pp
  3. 1 0
      packages/fcl-db/src/base/csvdataset.pp
  4. 1 1
      packages/fcl-db/src/base/db.pas
  5. 1 103
      packages/fcl-db/src/base/dbcoll.pp
  6. 1 1
      packages/fcl-db/src/base/dsparams.inc
  7. 2 2
      packages/fcl-db/src/base/sqlscript.pp
  8. 74 73
      packages/fcl-db/src/datadict/fpdatadict.pp
  9. 10 10
      packages/fcl-db/src/datadict/fpdddiff.pp
  10. 5 5
      packages/fcl-db/src/dbase/dbf_common.pas
  11. 24 21
      packages/fcl-db/src/dbase/dbf_dbffile.pas
  12. 22 20
      packages/fcl-db/src/dbase/dbf_idxfile.pas
  13. 2 2
      packages/fcl-db/src/dbase/dbf_lang.pas
  14. 2 2
      packages/fcl-db/src/dbase/dbf_parser.pas
  15. 2 2
      packages/fcl-db/src/dbase/dbf_pgfile.pas
  16. 26 26
      packages/fcl-db/src/dbase/dbf_prscore.pas
  17. 35 36
      packages/fcl-db/src/dbase/dbf_prsdef.pas
  18. 3 4
      packages/fcl-db/src/export/fpdbexport.pp
  19. 6 6
      packages/fcl-db/src/json/extjsdataset.pp
  20. 4 4
      packages/fcl-db/src/json/fpjsondataset.pp
  21. 2 2
      packages/fcl-db/src/sql/fpsqlparser.pas
  22. 2 2
      packages/fcl-db/src/sqldb/examples/sqldbexampleunit.pp
  23. 44 45
      packages/fcl-db/src/sqldb/interbase/fbadmin.pp
  24. 17 16
      packages/fcl-db/src/sqldb/interbase/ibconnection.pp
  25. 2 2
      packages/fcl-db/src/sqldb/mssql/mssqlconn.pp
  26. 1 1
      packages/fcl-db/src/sqldb/mysql/mysqlconn.inc
  27. 5 5
      packages/fcl-db/src/sqldb/odbc/odbcconn.pas
  28. 25 19
      packages/fcl-db/src/sqldb/sqldb.pp
  29. 4 4
      packages/fcl-db/src/sqldb/sqldbini.pp
  30. 1 1
      packages/fcl-db/src/sqldb/sqldblib.pp
  31. 10 10
      packages/fcl-db/src/sqldb/sqlite/sqlite3backup.pas
  32. 9 5
      packages/fcl-db/src/sqldb/sqlite/sqlite3conn.pp

+ 14 - 10
packages/fcl-db/src/base/bufdataset.pas

@@ -665,8 +665,8 @@ type
     procedure GetDatasetPacket(AWriter : TDataPacketHandler);
     procedure LoadFromStream(AStream : TStream; Format: TDataPacketFormat = dfDefault);
     procedure SaveToStream(AStream : TStream; Format: TDataPacketFormat = dfBinary);
-    procedure LoadFromFile(AFileName: string = ''; Format: TDataPacketFormat = dfDefault);
-    procedure SaveToFile(AFileName: string = ''; Format: TDataPacketFormat = dfBinary);
+    procedure LoadFromFile(const AFileName: string = ''; Format: TDataPacketFormat = dfDefault);
+    procedure SaveToFile(const AFileName: string = ''; Format: TDataPacketFormat = dfBinary);
     procedure CreateDataset;
     Procedure Clear; // Will close and remove all field definitions.
     function BookmarkValid(ABookmark: TBookmark): Boolean; override;
@@ -3622,15 +3622,17 @@ begin
   end;
 end;
 
-procedure TCustomBufDataset.LoadFromFile(AFileName: string; Format: TDataPacketFormat);
+procedure TCustomBufDataset.LoadFromFile(const AFileName: string; Format: TDataPacketFormat);
 
 var
+  FN : String;
   AFileStream : TFileStream;
 
 begin
-  if AFileName='' then
-     AFileName := FFileName;
-  AFileStream := TFileStream.Create(AFileName,fmOpenRead);
+  FN:=aFileName;
+  if fn='' then
+     FN:=FFileName;
+  AFileStream := TFileStream.Create(FN,fmOpenRead);
   try
     LoadFromStream(AFileStream, Format);
   finally
@@ -3638,15 +3640,17 @@ begin
   end;
 end;
 
-procedure TCustomBufDataset.SaveToFile(AFileName: string; Format: TDataPacketFormat);
+procedure TCustomBufDataset.SaveToFile(const AFileName: string; Format: TDataPacketFormat);
 
 var
   AFileStream : TFileStream;
+  FN : String;
 
 begin
-  if AFileName='' then
-    AFileName := FFileName;
-  AFileStream := TFileStream.Create(AFileName,fmCreate);
+  FN:=aFileName;
+  if FN='' then
+    FN:=FFileName;
+  AFileStream := TFileStream.Create(FN,fmCreate);
   try
     SaveToStream(AFileStream, Format);
   finally

+ 2 - 2
packages/fcl-db/src/base/bufdataset_parser.pp

@@ -57,7 +57,7 @@ type
 
     procedure ClearExpressions; override;
 
-    procedure ParseExpression(AExpression: string); virtual;
+    procedure ParseExpression(const AExpression: string); virtual;
     function ExtractFromBuffer(Buffer: TRecordBuffer): PChar; virtual;
 
     property Dataset: TDataSet read FDataset; // write FDataset;
@@ -483,7 +483,7 @@ begin
   FCurrentExpression := EmptyStr;
 end;
 
-procedure TBufDatasetParser.ParseExpression(AExpression: string);
+procedure TBufDatasetParser.ParseExpression(const AExpression: string);
 var
   TempBuffer: TRecordBuffer;
 begin

+ 1 - 0
packages/fcl-db/src/base/csvdataset.pp

@@ -412,6 +412,7 @@ begin
 end;
 
 procedure TCustomCSVDataset.SaveToCSVFile(const AFileName: string);
+
 Var
   F : TFileStream;
 

+ 1 - 1
packages/fcl-db/src/base/db.pas

@@ -1517,7 +1517,7 @@ type
     Procedure SetParamValue(const ParamName: string; const Value: Variant);
   protected
     Function CreateParseOpts(DoCreate, EscapeSlash, EscapeRepeat : Boolean) : TSQLParseOptions;
-    function DoParseSQL(SQL: String; Options : TSQLParseOptions; ParameterStyle: TParamStyle; out  ParamBinding: TParambinding; MacroChar: Char; out ReplaceString: string): String; virtual;
+    function DoParseSQL(const SQL: String; Options : TSQLParseOptions; ParameterStyle: TParamStyle; out  ParamBinding: TParambinding; MacroChar: Char; out ReplaceString: string): String; virtual;
     Procedure AssignTo(Dest: TPersistent); override;
     Function  GetDataSet: TDataSet;
     Function  GetOwner: TPersistent; override;

+ 1 - 103
packages/fcl-db/src/base/dbcoll.pp

@@ -17,7 +17,7 @@ unit DBColl;
 
 interface
 
-uses db, classes, sysutils;
+uses db, classes, sysutils, fieldmap;
 
 { ---------------------------------------------------------------------
   TFieldMap
@@ -25,28 +25,6 @@ uses db, classes, sysutils;
 
 type
 
-  { TFieldMap }
-
-  TFieldMap = Class(TObject)
-  private
-    FDataset: TDataset;
-  Protected
-    Function FindField(const FN : String) : TField;
-    Function FieldByName(const FN : String) : TField;
-  Public
-    Constructor Create(ADataset : TDataset); virtual;
-    Procedure InitFields; virtual; abstract;
-    Procedure LoadObject(AObject: TObject); virtual; abstract;
-    Function GetFromField(F : TField; ADefault : Integer) : Integer; overload;
-    Function GetFromField(F : TField; const ADefault : String) : String; overload;
-    Function GetFromField(F : TField; ADefault : Boolean) : Boolean; overload;
-    Function GetFromField(F : TField; ADefault : TDateTime) : TDateTime; overload;
-    Function GetFromField(F : TField; ADefault : Double) : Double; overload;
-    Function GetFromField(F : TField; ADefault : Currency) : Currency; overload;
-    Property Dataset : TDataset Read FDataset;
-  end;
-  TFieldMapClass = Class of TFieldMap;
-  
   EDBCollection = Class(Exception);
 
   { TDBCollectionItem }
@@ -74,86 +52,6 @@ implementation
 resourcestring
   SErrNoDatasetForField = '%s: no dataset to search field %s in.';
 
-{ TFieldMap }
-
-constructor TFieldMap.Create(ADataset: TDataset);
-begin
-  FDataset:=ADataset;
-  InitFields;
-end;
-
-function TFieldMap.FieldByName(const FN: String): TField;
-begin
-  If (FDataset=Nil) then
-    begin
-    Raise EDBCollection.CreateFmt(SErrNoDatasetForField,[ClassName,FN]);
-    result := nil;
-    end
-  else
-    Result:=FDataset.FieldByName(FN);
-end;
-
-function TFieldMap.FindField(const FN: String): TField;
-begin
-  If (FDataset=Nil) then
-    Result:=Nil
-  else
-    Result:=FDataset.FindField(FN);
-end;
-
-function TFieldMap.GetFromField(F: TField; ADefault: Integer): Integer;
-begin
-  If Assigned(F) then
-    Result:=F.AsInteger
-  else
-    Result:=ADefault;
-end;
-
-function TFieldMap.GetFromField(F: TField; const ADefault: String): String;
-begin
-  If Assigned(F) then
-    Result:=F.AsString
-  else
-    Result:=ADefault;
-end;
-
-function TFieldMap.GetFromField(F: TField; ADefault: Boolean): Boolean;
-begin
-  If Assigned(F) then
-    begin
-    if (F is TStringField) then
-      Result:=(F.AsString='+')
-    else
-      Result:=F.AsBoolean
-    end
-  else
-    Result:=ADefault;
-end;
-
-function TFieldMap.GetFromField(F: TField; ADefault: TDateTime): TDateTime;
-begin
-  If Assigned(F) then
-    Result:=F.AsDateTime
-  else
-    Result:=ADefault;
-end;
-
-function TFieldMap.GetFromField(F: TField; ADefault: Double): Double;
-begin
-  If Assigned(F) then
-    Result:=F.AsFloat
-  else
-    Result:=ADefault;
-end;
-
-function TFieldMap.GetFromField(F: TField; ADefault: Currency): Currency;
-begin
-  If Assigned(F) then
-    Result:=F.AsCurrency
-  else
-    Result:=ADefault;
-end;
-
 { TDBCollection }
 
 function TDBCollection.AddDBItem: TDBCollectionItem;

+ 1 - 1
packages/fcl-db/src/base/dsparams.inc

@@ -331,7 +331,7 @@ begin
   Result:=DoParseSQL(SQL,Options,ParameterStyle,ParamBinding,MacroChar,ReplaceString);
 end;
 
-function TParams.DoParseSQL(SQL: String; Options : TSQLParseOptions; ParameterStyle: TParamStyle; out
+function TParams.DoParseSQL(const SQL: String; Options : TSQLParseOptions; ParameterStyle: TParamStyle; out
   ParamBinding: TParambinding; MacroChar : Char; out ReplaceString: string): String;
 
 type

+ 2 - 2
packages/fcl-db/src/base/sqlscript.pp

@@ -76,7 +76,7 @@ type
     procedure InternalDirective (Directive, Argument: String; var StopExecution: Boolean); virtual;
     // Runs commit. If ComitRetaining, use CommitRetraining if possible, else stop/starttransaction
     procedure InternalCommit(CommitRetaining: boolean=true); virtual;
-    Function ProcessConditional(Directive : String; Param : String) : Boolean; virtual;
+    Function ProcessConditional(const Directive : String; const Param : String) : Boolean; virtual;
     function NextStatement: AnsiString; virtual;
     procedure ProcessStatement; virtual;
     function Available: Boolean; virtual;
@@ -674,7 +674,7 @@ begin
     end;
 end;
 
-function TCustomSQLScript.ProcessConditional(Directive: String; Param: String
+function TCustomSQLScript.ProcessConditional(const Directive: String; const Param: String
   ): Boolean;
 
   Procedure PushSkipMode;

+ 74 - 73
packages/fcl-db/src/datadict/fpdatadict.pp

@@ -135,14 +135,14 @@ Type
     procedure SetTableName(const AValue: String); override;
   Public
     Constructor Create(ATableDef : TDDTableDef);
-    Constructor Create(ATableName : string);
+    Constructor Create(const ATableName : string);
     Class Function FieldDefClass : TDDFieldDefClass; virtual;
     Property TableDef : TDDTableDef Read FTableDef;
     Property TableName : String Read GetTableName Write SetTableName;
     Function AddField(AFieldName: String = '') : TDDFieldDef;
-    Function IndexOfField(AFieldName : String) : Integer;
-    Function FindField(AFieldName : String) : TDDFieldDef;
-    Function FieldByName(AFieldName : String) : TDDFieldDef;
+    Function IndexOfField(const AFieldName : String) : Integer;
+    Function FindField(const AFieldName : String) : TDDFieldDef;
+    Function FieldByName(const AFieldName : String) : TDDFieldDef;
     Procedure FillFieldList(Const AFieldNames: String; List : TFPDDFieldList);
     Property Fields[Index : Integer] : TDDFieldDef Read GetField Write SetField; default;
   end;
@@ -183,12 +183,12 @@ Type
     procedure SetTableName(const AValue: String); override;
   Public
     Constructor Create(ATableDef : TDDTableDef);
-    Constructor Create(ATableName : String);
+    Constructor Create(const ATableName : String);
     Function AddDDIndexDef(AName : String) : TDDIndexDef;
-    function AddIndex (AName: String) : TDDIndexDef;
-    function IndexByName(AIndexName: String): TDDIndexDef;
-    function FindIndex(AIndexName: String): TDDIndexDef;
-    function IndexOfIndex(AIndexName: String): Integer;
+    function AddIndex (const AName: String) : TDDIndexDef;
+    function IndexByName(const AIndexName: String): TDDIndexDef;
+    function FindIndex(const AIndexName: String): TDDIndexDef;
+    function IndexOfIndex(const AIndexName: String): Integer;
     Property Indexes[Index : Integer] : TDDIndexDef Read GetIndex Write SetIndex; default;
   end;
   
@@ -224,8 +224,8 @@ Type
     procedure SetKey(AIndex : Integer; const AValue: TDDForeignKeyDef);
     procedure SetTableName(const AValue: String);
   Public
-    Constructor Create(ATableName : String);
-    Function AddForeignKeyDef(AName : String) : TDDForeignKeyDef;
+    Constructor Create(const ATableName : String);
+    Function AddForeignKeyDef(const AName : String) : TDDForeignKeyDef;
     Property TableName : String Read FTableName Write SetTableName;
     Property Indexes[AIndex : Integer] : TDDForeignKeyDef Read GetKey Write SetKey; default;
   end;
@@ -253,7 +253,7 @@ Type
     Function TableDefs : TDDTableDefs;
     Function ImportFromDataset(Dataset : TDataSet; DoClear : Boolean = False; UpdateExisting : Boolean = True) : Integer;
     Procedure ApplyToDataset(Dataset : TDataset);
-    Function AddField(AFieldName : String = '') : TDDFieldDef;
+    Function AddField(const AFieldName : String = '') : TDDFieldDef;
     Procedure SaveToIni(Ini: TCustomInifile; ASection : String); override;
     Procedure LoadFromIni(Ini: TCustomInifile; ASection : String); override;
     procedure PrimaryIndexToFields;
@@ -278,10 +278,10 @@ Type
     procedure SetTable(Index : Integer; const AValue: TDDTableDef);
   Public
     Property DataDictionary: TFPDataDictionary Read FDataDictionary;
-    Function AddTable(ATableName : String = '') : TDDTableDef;
-    Function IndexOfTable(ATableName : String) : Integer;
-    Function FindTable(ATableName : String) : TDDTableDef;
-    Function TableByName(ATableName : String) : TDDTableDef;
+    Function AddTable(aTableName : String = '') : TDDTableDef;
+    Function IndexOfTable(const ATableName : String) : Integer;
+    Function FindTable(const ATableName : String) : TDDTableDef;
+    Function TableByName(const ATableName : String) : TDDTableDef;
     Property Tables[Index : Integer] : TDDTableDef Read GetTable Write SetTable; default;
     Property OnProgress : TDDProgressEvent Read FOnProgress Write FOnProgress;
   end;
@@ -317,10 +317,10 @@ Type
     procedure SetSequence(Index : Integer; const AValue: TDDSequenceDef);
   Public
     Constructor Create;
-    Function AddSequence(ASequenceName : String = '') : TDDSequenceDef;
-    Function IndexOfSequence(ASequenceName : String) : Integer;
-    Function FindSequence(ASequenceName : String) : TDDSequenceDef;
-    Function SequenceByName(ASequenceName : String) : TDDSequenceDef;
+    Function AddSequence(const ASequenceName : String = '') : TDDSequenceDef;
+    Function IndexOfSequence(const ASequenceName : String) : Integer;
+    Function FindSequence(const ASequenceName : String) : TDDSequenceDef;
+    Function SequenceByName(const ASequenceName : String) : TDDSequenceDef;
     Property DataDictionary : TFPDataDictionary Read FDataDictionary;
     Property Sequences[Index : Integer] : TDDSequenceDef Read GetSequence Write SetSequence; default;
     Property OnProgress : TDDProgressEvent Read FOnProgress Write FOnProgress;
@@ -364,10 +364,10 @@ Type
   Public
     Constructor Create;
     Property DataDictionary : TFPDataDictionary Read FDataDictionary;
-    Function AddDomain(ADomainName : String = '') : TDDDomainDef;
-    Function IndexOfDomain(ADomainName : String) : Integer;
-    Function FindDomain(ADomainName : String) : TDDDomainDef;
-    Function DomainByName(ADomainName : String) : TDDDomainDef;
+    Function AddDomain(const ADomainName : String = '') : TDDDomainDef;
+    Function IndexOfDomain(const ADomainName : String) : Integer;
+    Function FindDomain(const ADomainName : String) : TDDDomainDef;
+    Function DomainByName(const ADomainName : String) : TDDDomainDef;
     Property Domains[Index : Integer] : TDDDomainDef Read GetDomain Write SetDomain; default;
     Property OnProgress : TDDProgressEvent Read FOnProgress Write FOnProgress;
   end;
@@ -390,14 +390,14 @@ Type
   Public
     Constructor Create;
     Destructor Destroy; override;
-    Procedure SaveToFile(AFileName : String; KeepBackup: Boolean = True);
+    Procedure SaveToFile(const AFileName : String; KeepBackup: Boolean = True);
     Procedure SaveToIni(Ini : TCustomIniFile; ASection : String); virtual;
-    Procedure LoadFromFile(AFileName : String);
+    Procedure LoadFromFile(const AFileName : String);
     Procedure LoadFromIni(Ini : TCustomIniFile; ASection : String); virtual;
     Procedure ApplyToDataset(ADataset : TDataset);
     Procedure ApplyToDataset(ADataset : TDataset; OnApply : TOnApplyDataDictEvent);
-    Function FindFieldDef(FieldName : String; out TableName : String) : TDDFieldDef;
-    Function FindFieldDef(FieldName : String) : TDDFieldDef;
+    Function FindFieldDef(const FieldName : String; out TableName : String) : TDDFieldDef;
+    Function FindFieldDef(const FieldName : String) : TDDFieldDef;
     function CanonicalizeFieldName(const InFN: String; Out TN, FN: String): Boolean;
     function CanonicalizeFieldName(const InFN: String; Out TableDef : TDDTableDef; Out FN: String): Boolean;
     Property Tables : TDDTableDefs Read FTables;
@@ -480,14 +480,14 @@ Type
     procedure CheckTableDef;
     Procedure NoIndent;
     Procedure ResetLine;
-    Procedure AddToStringLN(Var Res : String; S : String);
+    Procedure AddToStringLN(Var Res : String; const S : String);
     Procedure AddToString(Var Res : String; S : String);
     Procedure FixUpStatement(var Res : String; ForceTerminator : Boolean = False);
     Procedure FixUpStatement(SQL : TStrings; ForceTerminator : Boolean = False);
     Procedure AddWhereClause(Var Res : String; FieldList: TFPDDFieldList; UseOldParam:Boolean);
     Function CreateAndTerm(FD : TDDFieldDef; UseOldParam : Boolean): string;
     // Primitives. Override for engine-specifics
-    Procedure AddFieldString(Var Res: String; S : String);
+    Procedure AddFieldString(Var Res: String;const S : String);
     Function FieldNameString(FD : TDDFieldDef) : string; virtual;
     Function TableNameString(TD : TDDTableDef) : string; virtual;
     Function FieldParamString(FD : TDDFieldDef; UseOldParam : Boolean) : string; virtual;
@@ -615,7 +615,7 @@ Procedure RegisterConnectionStringCallback(Const AName: String; CallBack : TGetC
 Procedure UnRegisterDictionaryEngine(AEngine :TFPDDEngineClass);
 Function  GetDictionaryEngineList(List : TStrings) : Integer;
 Function  GetDictionaryEngineInfo(Const AName : String; out ADescription,ADBType: String; out ACapabilities : TFPDDEngineCapabilities) : boolean;
-Function  CreateDictionaryEngine(AName : String; AOWner : TComponent) : TFPDDEngine;
+Function  CreateDictionaryEngine(const AName : String; AOWner : TComponent) : TFPDDEngine;
 Function IndexOptionsToString (Options : TIndexOptions) : String;
 
 Var
@@ -946,7 +946,7 @@ begin
     end;
 end;
 
-function CreateDictionaryEngine(AName: String; AOWner : TComponent): TFPDDEngine;
+function CreateDictionaryEngine(const AName: String; AOWner : TComponent): TFPDDEngine;
 
 begin
   Result:=GetDictionaryClass(AName).Create(AOwner);
@@ -1251,7 +1251,7 @@ begin
   SetTableDef(ATableDef);
 end;
 
-constructor TDDFieldDefs.Create(ATableName: String);
+constructor TDDFieldDefs.Create(const ATableName: String);
 begin
   Inherited Create(FieldDefClass);
   FPrefix:='Field';
@@ -1296,14 +1296,14 @@ begin
   Result.FieldName:=AFieldName;
 end;
 
-function TDDFieldDefs.IndexOfField(AFieldName: String): Integer;
+function TDDFieldDefs.IndexOfField(const AFieldName: String): Integer;
 begin
   Result:=Count-1;
   While (Result>=0) and (CompareText(GetField(Result).FieldName,AFieldName)<>0) do
     Dec(Result)
 end;
 
-function TDDFieldDefs.FindField(AFieldName: String): TDDFieldDef;
+function TDDFieldDefs.FindField(const AFieldName: String): TDDFieldDef;
 
 Var
   I : integer;
@@ -1316,7 +1316,7 @@ begin
     Result:=GetField(I);
 end;
 
-function TDDFieldDefs.FieldByName(AFieldName: String): TDDFieldDef;
+function TDDFieldDefs.FieldByName(const AFieldName: String): TDDFieldDef;
 begin
   Result:=FindField(AFieldName);
   If Result=Nil then
@@ -1482,7 +1482,7 @@ begin
     end;
 end;
 
-function TDDTableDef.AddField(AFieldName: String): TDDFieldDef;
+function TDDTableDef.AddField(const AFieldName: String): TDDFieldDef;
 begin
   Result:=Fields.AddField(AFieldName);
 end;
@@ -1600,14 +1600,14 @@ begin
   Result.TableName:=ATableName;
 end;
 
-function TDDTableDefs.IndexOfTable(ATableName: String): Integer;
+function TDDTableDefs.IndexOfTable(const ATableName: String): Integer;
 begin
   Result:=Count-1;
   While (Result>=0) and (CompareText(GetTable(Result).TableName,ATableName)<>0) do
     Dec(Result)
 end;
 
-function TDDTableDefs.FindTable(ATableName: String): TDDTableDef;
+function TDDTableDefs.FindTable(const ATableName: String): TDDTableDef;
 
 Var
   I : integer;
@@ -1620,7 +1620,7 @@ begin
     Result:=GetTable(I);
 end;
 
-function TDDTableDefs.TableByName(ATableName: String): TDDTableDef;
+function TDDTableDefs.TableByName(const ATableName: String): TDDTableDef;
 begin
   Result:=FindTable(ATableName);
   If Result=Nil then
@@ -1655,28 +1655,29 @@ begin
   inherited Destroy;
 end;
 
-procedure TFPDataDictionary.SaveToFile(AFileName: String; KeepBackup: Boolean = True);
+procedure TFPDataDictionary.SaveToFile(const AFileName: String; KeepBackup: Boolean = True);
 
 Var
   Ini : TMemIniFile;
-
-begin
-  If (AFileName='') then
-    AFileName:=FFileName;
-  if (AFileName='') and (Name<>'') then
-    AFileName:=Name+DefaultDDExt;
-  if (AFileName='') then
+  FN : String;
+begin
+  FN:=aFileName;
+  If (FN='') then
+    FN:=FFileName;
+  if (FN='') and (Name<>'') then
+    FN:=Name+DefaultDDExt;
+  if (FN='') then
     Raise EDataDict.Create(SErrNoFileName);
-  If FileExists(AFileName) then
+  If FileExists(FN) then
     If KeepBackup then
-      RenameFile(AFileName,AFileName+'.bak')
+      RenameFile(FN,FN+'.bak')
     else
-      DeleteFile(AFileName);
-  Ini:=TMemIniFile.Create(AFileName);
+      DeleteFile(FN);
+  Ini:=TMemIniFile.Create(FN);
   try
     SaveToIni(Ini,SDataDict);
     Ini.UpdateFile;
-    FFileName:=AFileName;
+    FFileName:=FN;
   finally
     FreeAndNil(Ini);
   end;
@@ -1690,7 +1691,7 @@ begin
   FTables.SaveToIni(Ini,SDatadictTables);
 end;
 
-procedure TFPDataDictionary.LoadFromFile(AFileName: String);
+procedure TFPDataDictionary.LoadFromFile(const AFileName: String);
 
 Var
   Ini : TMemInifile;
@@ -1787,7 +1788,7 @@ end;
 
 // To be good, we should make a hashlist with all tables.fields and search that...
 // For now, we cache the last matching table. This should work well for most common cases.
-function TFPDataDictionary.FindFieldDef(FieldName: String; out TableName: String
+function TFPDataDictionary.FindFieldDef(const FieldName: String; out TableName: String
   ): TDDFieldDef;
 
 Var
@@ -1827,7 +1828,7 @@ begin
     TableName:=FLastMatchTableDef.TableName;
 end;
 
-function TFPDataDictionary.FindFieldDef(FieldName: String): TDDFieldDef;
+function TFPDataDictionary.FindFieldDef(const FieldName: String): TDDFieldDef;
 
 Var
   Dummy : String;
@@ -2082,7 +2083,7 @@ begin
     end;
 end;
 
-Procedure TFPDDSQLEngine.AddToStringLN(Var Res : String;S : String);
+Procedure TFPDDSQLEngine.AddToStringLN(Var Res : String;const S : String);
 
 begin
   AddToString(Res,S);
@@ -2112,7 +2113,7 @@ begin
   Res:=Res+S;
 end;
 
-procedure TFPDDSQLEngine.AddFieldString(var Res: String; S: String);
+procedure TFPDDSQLEngine.AddFieldString(var Res: String; const S: String);
 begin
   If eoLineFeedAfterField in FOptions then
     AddToStringLn(Res,S)
@@ -2904,7 +2905,7 @@ begin
     Create('')
 end;
 
-constructor TDDIndexDefs.Create(ATableName: String);
+constructor TDDIndexDefs.Create(const ATableName: String);
 begin
   FPrefix:='Index';
   TableName:=ATableName;
@@ -2916,7 +2917,7 @@ begin
   result := AddIndex (AName);
 end;
 
-function TDDIndexDefs.AddIndex(AName: String): TDDIndexDef;
+function TDDIndexDefs.AddIndex(const AName: String): TDDIndexDef;
 begin
   Result:=Add as TDDIndexDef;
   Result.IndexName:=AName;
@@ -3001,27 +3002,27 @@ begin
   GlobalSection:=AValue+SKeySuffix;
 end;
 
-constructor TDDForeignKeyDefs.Create(ATableName: String);
+constructor TDDForeignKeyDefs.Create(const ATableName: String);
 begin
   Inherited Create(TDDForeignKeyDef);
   FPrefix:='Key';
   SetTableName(ATAbleName);
 end;
 
-function TDDForeignKeyDefs.AddForeignKeyDef(AName: String): TDDForeignKeyDef;
+function TDDForeignKeyDefs.AddForeignKeyDef(const AName: String): TDDForeignKeyDef;
 begin
   Result:=Add as TDDForeignKeyDef;
   Result.KeyName:=AName;
 end;
 
-function TDDIndexDefs.IndexOfIndex(AIndexName: String): Integer;
+function TDDIndexDefs.IndexOfIndex(const AIndexName: String): Integer;
 begin
   Result:=Count-1;
   While (Result>=0) and (CompareText(GetIndex(Result).IndexName,AIndexName)<>0) do
     Dec(Result)
 end;
 
-function TDDIndexDefs.FindIndex(AIndexName: String): TDDIndexDef;
+function TDDIndexDefs.FindIndex(const AIndexName: String): TDDIndexDef;
 Var
   I : integer;
 begin
@@ -3032,7 +3033,7 @@ begin
     Result:=GetIndex(I);
 end;
 
-function TDDIndexDefs.IndexByName(AIndexName: String): TDDIndexDef;
+function TDDIndexDefs.IndexByName(const AIndexName: String): TDDIndexDef;
 begin
   Result:=FindIndex(AIndexName);
   If Result=Nil then
@@ -3061,13 +3062,13 @@ begin
 end;
 
 
-function TDDDomainDefs.AddDomain(ADomainName: String): TDDDomainDef;
+function TDDDomainDefs.AddDomain(const ADomainName: String): TDDDomainDef;
 begin
   Result:=Add as TDDDomainDef;
   Result.DomainName:=ADomainName;
 end;
 
-function TDDDomainDefs.IndexOfDomain(ADomainName: String): Integer;
+function TDDDomainDefs.IndexOfDomain(const ADomainName: String): Integer;
 
 begin
   Result := Count;
@@ -3076,7 +3077,7 @@ begin
   until (Result < 0) or (CompareText(GetDomain(Result).DomainName,ADomainName) = 0);
 end;
 
-function TDDDomainDefs.FindDomain(ADomainName: String): TDDDomainDef;
+function TDDDomainDefs.FindDomain(const ADomainName: String): TDDDomainDef;
 
 Var
   I : Integer;
@@ -3089,7 +3090,7 @@ begin
     Result:=GetDomain(I);
 end;
 
-function TDDDomainDefs.DomainByName(ADomainName: String): TDDDomainDef;
+function TDDDomainDefs.DomainByName(const ADomainName: String): TDDDomainDef;
 begin
   Result:=FindDomain(ADomainName);
   If (Result=Nil) then
@@ -3260,13 +3261,13 @@ begin
   Inherited Create(TDDSequenceDef);
 end;
 
-function TDDSequenceDefs.AddSequence(ASequenceName: String): TDDSequenceDef;
+function TDDSequenceDefs.AddSequence(const ASequenceName: String): TDDSequenceDef;
 begin
   Result:=Add as TDDSequenceDef;
   Result.SequenceName:=ASequenceName;
 end;
 
-function TDDSequenceDefs.IndexOfSequence(ASequenceName: String): Integer;
+function TDDSequenceDefs.IndexOfSequence(const ASequenceName: String): Integer;
 begin
   result := count;
   repeat
@@ -3274,7 +3275,7 @@ begin
   until (Result<0) or (CompareText(GetSequence(Result).SequenceName,ASequenceName)=0);
 end;
 
-function TDDSequenceDefs.FindSequence(ASequenceName: String): TDDSequenceDef;
+function TDDSequenceDefs.FindSequence(const ASequenceName: String): TDDSequenceDef;
 
 Var
   I : Integer;
@@ -3287,7 +3288,7 @@ begin
     Result:=GetSequence(I);
 end;
 
-function TDDSequenceDefs.SequenceByName(ASequenceName: String): TDDSequenceDef;
+function TDDSequenceDefs.SequenceByName(const ASequenceName: String): TDDSequenceDef;
 begin
   Result:=FindSequence(ASequenceName);
   If (Result=Nil) then

+ 10 - 10
packages/fcl-db/src/datadict/fpdddiff.pp

@@ -46,15 +46,15 @@ type
     procedure IndexDifference (DiffType: TDifferenceType; SourceIndex, TargetIndex: TDDIndexDef); virtual;
     procedure FieldDifference (DiffType: TDifferenceType; SourceField, TargetField: TDDFieldDef); virtual;
     procedure CompareTables (Kind: TDiffKindSet);
-    procedure CompareTable (TableName: string; Kind: TDiffKindSet);
+    procedure CompareTable (const TableName: string; Kind: TDiffKindSet);
     procedure CompareFields (Source, Target: TDDFieldDefs; Kind: TDiffKindSet);
-    procedure CompareField (Source, Target: TDDFieldDefs; Fieldname: string; Kind: TDiffKindSet);
+    procedure CompareField (Source, Target: TDDFieldDefs; const Fieldname: string; Kind: TDiffKindSet);
     procedure CompareIndexes (Source, Target: TDDIndexDefs; Kind: TDiffKindSet);
-    procedure CompareIndex (Source, Target: TDDIndexDefs; Indexname: string; Kind: TDiffKindSet);
+    procedure CompareIndex (Source, Target: TDDIndexDefs; const Indexname: string; Kind: TDiffKindSet);
     procedure CompareDomains (Kind: TDiffKindSet);
-    procedure CompareDomain (Source, Target: TDDDomainDefs; DomainName: string; Kind: TDiffKindSet);
+    procedure CompareDomain (Source, Target: TDDDomainDefs; const DomainName: string; Kind: TDiffKindSet);
     procedure CompareSequences (Kind: TDiffKindSet);
-    procedure CompareSequence (Source, Target: TDDSequenceDefs; SequenceName: string; Kind: TDiffKindSet);
+    procedure CompareSequence (Source, Target: TDDSequenceDefs; const SequenceName: string; Kind: TDiffKindSet);
   public
     procedure Compare (Kind: TDiffKindSet);
     property SourceDD : TFPdatadictionary read FSourceDD write FSourceDD;
@@ -121,7 +121,7 @@ begin
   end;
 end;
 
-procedure TCustomDDDiffer.CompareTable(TableName: string; Kind: TDiffKindSet);
+procedure TCustomDDDiffer.CompareTable(const TableName: string; Kind: TDiffKindSet);
 
 var
   Src, Targ : TDDTableDef;
@@ -169,7 +169,7 @@ begin
 end;
 
 procedure TCustomDDDiffer.CompareField(Source, Target: TDDFieldDefs;
-  Fieldname: string; Kind: TDiffKindSet);
+  const Fieldname: string; Kind: TDiffKindSet);
 
   Function FieldTypesEqual(F1,F2 : TDDFieldDef) : boolean;
 
@@ -217,7 +217,7 @@ begin
 end;
 
 procedure TCustomDDDiffer.CompareIndex(Source, Target: TDDIndexDefs;
-  Indexname: string; Kind: TDiffKindSet);
+  const Indexname: string; Kind: TDiffKindSet);
 var
   Src, Targ : TDDIndexDef;
 begin
@@ -258,7 +258,7 @@ begin
 end;
 
 procedure TCustomDDDiffer.CompareDomain(Source, Target: TDDDomainDefs;
-  DomainName: string; Kind: TDiffKindSet);
+  const DomainName: string; Kind: TDiffKindSet);
 
 var
   Src,Targ : TDDDomainDef;
@@ -300,7 +300,7 @@ begin
 end;
 
 procedure TCustomDDDiffer.CompareSequence(Source, Target: TDDSequenceDefs;
-  SequenceName: string; Kind: TDiffKindSet);
+  const SequenceName: string; Kind: TDiffKindSet);
 
 var
   Src,Targ : TDDSequenceDef;

+ 5 - 5
packages/fcl-db/src/dbase/dbf_common.pas

@@ -86,7 +86,7 @@ function GetCompleteFileName(const Base, FileName: string): string;
 function IsFullFilePath(const Path: string): Boolean; // full means not relative
 function DateTimeToBDETimeStamp(aDT: TDateTime): double;
 function BDETimeStampToDateTime(aBT: double): TDateTime;
-procedure FindNextName(BaseName: string; var OutName: string; var Modifier: Integer);
+procedure FindNextName(const BaseName: string; var OutName: string; var Modifier: Integer);
 {$ifdef USE_CACHE}
 function GetFreeMemory: Integer;
 {$endif}
@@ -398,15 +398,15 @@ begin
   end;
 end;
 
-procedure FindNextName(BaseName: string; var OutName: string; var Modifier: Integer);
+procedure FindNextName(const BaseName: string; var OutName: string; var Modifier: Integer);
 var
-  Extension: string;
+  BN,Extension: string;
 begin
   Extension := ExtractFileExt(BaseName);
-  BaseName := Copy(BaseName, 1, Length(BaseName)-Length(Extension));
+  BN := Copy(BaseName, 1, Length(BaseName)-Length(Extension));
   repeat
     Inc(Modifier);
-    OutName := ChangeFileExt(BaseName+'_'+IntToStr(Modifier), Extension);
+    OutName := ChangeFileExt(BN+'_'+IntToStr(Modifier), Extension);
   until not FileExists(OutName);
 end;
 

+ 24 - 21
packages/fcl-db/src/dbase/dbf_dbffile.pas

@@ -117,16 +117,16 @@ type
 
     // Write out field definitions to header etc.
     procedure FinishCreate(AFieldDefs: TDbfFieldDefs; MemoSize: Integer);
-    function GetIndexByName(AIndexName: string): TIndexFile;
+    function GetIndexByName(const AIndexName: string): TIndexFile;
     procedure SetRecordSize(NewSize: Integer); override;
 
     procedure TryExclusive; override;
     procedure EndExclusive; override;
-    procedure OpenIndex(IndexName, IndexField: string; CreateIndex: Boolean; Options: TIndexOptions);
+    procedure OpenIndex(const IndexName, IndexField: string; CreateIndex: Boolean; Options: TIndexOptions);
     function  DeleteIndex(const AIndexName: string): Boolean;
-    procedure CloseIndex(AIndexName: string);
-    procedure RepageIndex(AIndexFile: string);
-    procedure CompactIndex(AIndexFile: string);
+    procedure CloseIndex(const AIndexName: string);
+    procedure RepageIndex(const AIndexFile: string);
+    procedure CompactIndex(const AIndexFile: string);
 
     // Inserts new record
     function  Insert(Buffer: TRecordBuffer): integer;
@@ -136,8 +136,8 @@ type
     procedure ApplyAutoIncToBuffer(DestBuf: TRecordBuffer); virtual;
     procedure FastPackTable;
     procedure RestructureTable(DbfFieldDefs: TDbfFieldDefs; Pack: Boolean);
-    procedure Rename(DestFileName: string; NewIndexFileNames: TStrings; DeleteFiles: boolean);
-    function  GetFieldInfo(FieldName: string): TDbfFieldDef;
+    procedure Rename(const DestFileName: string; NewIndexFileNames: TStrings; DeleteFiles: boolean);
+    function  GetFieldInfo(const FieldName: string): TDbfFieldDef;
     // Copies record buffer to field buffer
     // Returns true if not null & data succesfully copied; false if field is null
     function  GetFieldData(Column: Integer; DataType: TFieldType; Src,Dst: Pointer; 
@@ -150,7 +150,7 @@ type
     procedure SetFieldData(Column: Integer; DataType: TFieldType; Src,Dst: Pointer; NativeFormat: boolean);
     // Fill DestBuf with default field data
     procedure InitRecord(DestBuf: TRecordBuffer);
-    procedure PackIndex(lIndexFile: TIndexFile; AIndexName: string);
+    procedure PackIndex(lIndexFile: TIndexFile; const AIndexName: string);
     procedure RegenerateIndexes;
     procedure LockRecord(RecNo: Integer; Buffer: TRecordBuffer);
     procedure UnlockRecord(RecNo: Integer; Buffer: TRecordBuffer);
@@ -269,7 +269,7 @@ const
 //====================================================================
 // International separator
 // thanks to Bruno Depero from Italy
-// and Andreas Wöllenstein from Denmark
+// and Andreas W\F6llenstein from Denmark
 //====================================================================
 function DbfStrToFloat(const Src: PChar; const Size: Integer): Extended;
 var
@@ -1487,7 +1487,7 @@ begin
   end;
 end;
 
-procedure TDbfFile.Rename(DestFileName: string; NewIndexFileNames: TStrings; DeleteFiles: boolean);
+procedure TDbfFile.Rename(const DestFileName: string; NewIndexFileNames: TStrings; DeleteFiles: boolean);
 var
   lIndexFileNames: TStrings;
   lIndexFile: TIndexFile;
@@ -1794,16 +1794,17 @@ begin
   end;
 end;
 
-function TDbfFile.GetFieldInfo(FieldName: string): TDbfFieldDef;
+function TDbfFile.GetFieldInfo(const FieldName: string): TDbfFieldDef;
 var
   I: Integer;
   lfi: TDbfFieldDef;
+  FN : String;
 begin
-  FieldName := AnsiUpperCase(FieldName);
+  FN := AnsiUpperCase(FieldName);
   for I := 0 to FFieldDefs.Count-1 do
   begin
     lfi := TDbfFieldDef(FFieldDefs.Items[I]);
-    if lfi.fieldName = FieldName then
+    if lfi.fieldName = FN then
     begin
       Result := lfi;
       exit;
@@ -2603,7 +2604,7 @@ begin
   inherited;
 end;
 
-procedure TDbfFile.OpenIndex(IndexName, IndexField: string; CreateIndex: Boolean; Options: TIndexOptions);
+procedure TDbfFile.OpenIndex(const IndexName, IndexField: string; CreateIndex: Boolean; Options: TIndexOptions);
   //
   // assumes IndexName is not empty
   //
@@ -2621,6 +2622,8 @@ var
   tempExclusive: boolean;
   addedIndexFile: Integer;
   addedIndexName: Integer;
+  Tmp : String;
+
 begin
   // init
   addedIndexFile := -1;
@@ -2713,11 +2716,11 @@ begin
       tempExclusive := IsSharedAccess;
       if tempExclusive then TryExclusive;
       // always uppercase index expression
-      IndexField := AnsiUpperCase(IndexField);
+      Tmp := AnsiUpperCase(IndexField);
       try
         try
           // create index if asked
-          lIndexFile.CreateIndex(IndexField, IndexName, Options);
+          lIndexFile.CreateIndex(Tmp, IndexName, Options);
           // add all records
           PackIndex(lIndexFile, IndexName);
           // if we wanted to open index readonly, but we created it, then reopen
@@ -2760,7 +2763,7 @@ begin
   end;
 end;
 
-procedure TDbfFile.PackIndex(lIndexFile: TIndexFile; AIndexName: string);
+procedure TDbfFile.PackIndex(lIndexFile: TIndexFile; const AIndexName: string);
 var
   prevMode: TIndexUpdateMode;
   prevIndex: string;
@@ -2825,7 +2828,7 @@ begin
   end;
 end;
 
-procedure TDbfFile.RepageIndex(AIndexFile: string);
+procedure TDbfFile.RepageIndex(const AIndexFile: string);
 var
   lIndexNo: Integer;
 begin
@@ -2846,7 +2849,7 @@ begin
   end;
 end;
 
-procedure TDbfFile.CompactIndex(AIndexFile: string);
+procedure TDbfFile.CompactIndex(const AIndexFile: string);
 var
   lIndexNo: Integer;
 begin
@@ -2867,7 +2870,7 @@ begin
   end;
 end;
 
-procedure TDbfFile.CloseIndex(AIndexName: string);
+procedure TDbfFile.CloseIndex(const AIndexName: string);
 var
   lIndexNo: Integer;
   lIndex: TIndexFile;
@@ -3179,7 +3182,7 @@ begin
   inherited;
 end;
 
-function TDbfFile.GetIndexByName(AIndexName: string): TIndexFile;
+function TDbfFile.GetIndexByName(const AIndexName: string): TIndexFile;
 var
   I: Integer;
 begin

+ 22 - 20
packages/fcl-db/src/dbase/dbf_idxfile.pas

@@ -75,8 +75,8 @@ type
     FOptions: TIndexOptions;
     FTemporary: Boolean;          // added at runtime
 
-    procedure SetIndexName(NewName: string);
-    procedure SetExpression(NewField: string);
+    procedure SetIndexName(const NewName: string);
+    procedure SetExpression(const NewField: string);
   public
     constructor Create(ACollection: TCollection); override;
     destructor Destroy; override;
@@ -289,7 +289,7 @@ type
 
     function  GetNewPageNo: Integer;
     procedure TouchHeader(AHeader: Pointer);
-    function  CreateTempFile(BaseName: string): TPagedFile;
+    function  CreateTempFile(const BaseName: string): TPagedFile;
     procedure ConstructInsertErrorMsg;
     procedure WriteIndexHeader(AIndex: Integer);
     procedure SelectIndexVars(AIndex: Integer);
@@ -360,7 +360,7 @@ type
     procedure DeleteIndex(const AIndexName: string);
     procedure RepageFile;
     procedure CompactFile;
-    procedure PrepareRename(NewFileName: string);
+    procedure PrepareRename(const NewFileName: string);
 
     procedure CreateIndex(FieldDesc, TagName: string; Options: TIndexOptions);
     function  ExtractKeyFromBuffer(Buffer: TRecordBuffer): PChar;
@@ -2037,23 +2037,23 @@ begin
   // deselect index
 end;
 
-procedure WriteDBFileName(Header: PMdxHdr; HdrFileName: string);
+procedure WriteDBFileName(Header: PMdxHdr; const HdrFileName: string);
 var
-  HdrFileExt: string;
+  FN,HdrFileExt: string;
   lPos, lenFileName: integer;
 begin
-  HdrFileName := ExtractFileName(HdrFileName);
-  HdrFileExt := ExtractFileExt(HdrFileName);
+  FN := ExtractFileName(HdrFileName);
+  HdrFileExt := ExtractFileExt(FN);
   if Length(HdrFileExt) > 0 then
   begin
-    lPos := System.Pos(HdrFileExt, HdrFileName);
+    lPos := System.Pos(HdrFileExt, FN);
     if lPos > 0 then
-      SetLength(HdrFileName, lPos - 1);
+      SetLength(FN, lPos - 1);
   end;
-  if Length(HdrFileName) > 15 then
-    SetLength(HdrFileName, 15);
-  lenFileName := Length(HdrFileName);
-  Move(PChar(HdrFileName)^, PMdxHdr(Header)^.FileName[0], lenFileName);
+  if Length(FN) > 15 then
+    SetLength(FN, 15);
+  lenFileName := Length(FN);
+  Move(PChar(FN)^, PMdxHdr(Header)^.FileName[0], lenFileName);
   FillChar(PMdxHdr(Header)^.FileName[lenFileName], 15-lenFileName, 0);
 end;
 
@@ -2481,15 +2481,17 @@ begin
   PMdxHdr(AHeader)^.UpdDay := day;
 end;
 
-function TIndexFile.CreateTempFile(BaseName: string): TPagedFile;
+function TIndexFile.CreateTempFile(const BaseName: string): TPagedFile;
 var
   lModifier: Integer;
+  FN : String;
+
 begin
   // create temporary in-memory index file
   lModifier := 0;
-  FindNextName(BaseName, BaseName, lModifier);
+  FindNextName(BaseName, FN, lModifier);
   Result := TPagedFile.Create;
-  Result.FileName := BaseName;
+  Result.FileName := FN;
   Result.Mode := pfExclusiveCreate;
   Result.AutoCreate := true;
   Result.OpenFile;
@@ -2790,7 +2792,7 @@ begin
   SelectIndexVars(prevIndex);
 end;
 
-procedure TIndexFile.PrepareRename(NewFileName: string);
+procedure TIndexFile.PrepareRename(const NewFileName: string);
 begin
   if FIndexVersion >= xBaseIV then
   begin
@@ -4142,12 +4144,12 @@ begin
     inherited;
 end;
 
-procedure TDbfIndexDef.SetIndexName(NewName: string);
+procedure TDbfIndexDef.SetIndexName(const NewName: string);
 begin
   FIndexName := AnsiUpperCase(Trim(NewName));
 end;
 
-procedure TDbfIndexDef.SetExpression(NewField: string);
+procedure TDbfIndexDef.SetExpression(const NewField: string);
 begin
   FExpression := AnsiUpperCase(Trim(NewField));
 end;

+ 2 - 2
packages/fcl-db/src/dbase/dbf_lang.pas

@@ -524,7 +524,7 @@ function ConstructLangName(CodePage: Integer; Locale: LCID; IsFoxPro: Boolean):
 function ConstructLangId(CodePage: Integer; Locale: LCID; IsFoxPro: Boolean): Byte;
 
 // Visual DBaseVII specific
-function GetLangId_From_LangName(LocaleStr: string): Byte;
+function GetLangId_From_LangName(const LocaleStr: string): Byte;
 
 implementation
 
@@ -644,7 +644,7 @@ begin
     end;
 end;
 
-function GetLangId_From_LangName(LocaleStr: string): Byte;
+function GetLangId_From_LangName(const LocaleStr: string): Byte;
 var
   CodePage, SubType: Integer;
   IsFoxPro: Boolean;

+ 2 - 2
packages/fcl-db/src/dbase/dbf_parser.pas

@@ -53,7 +53,7 @@ type
 
     procedure FillExpressList; override;
     procedure HandleUnknownVariable(VarName: string); override;
-    function  GetVariableInfo(VarName: string): TDbfFieldDef;
+    function  GetVariableInfo(const VarName: string): TDbfFieldDef;
     function  CurrentExpression: string; override;
     procedure ValidateExpression(AExpression: string); virtual;
     function  GetResultType: TExpressionType; override;
@@ -476,7 +476,7 @@ begin
     ParseExpression(lExpression);
 end;
 
-function TDbfParser.GetVariableInfo(VarName: string): TDbfFieldDef;
+function TDbfParser.GetVariableInfo(const VarName: string): TDbfFieldDef;
 begin
   Result := TDbfFile(FDbfFile).GetFieldInfo(VarName);
 end;

+ 2 - 2
packages/fcl-db/src/dbase/dbf_pgfile.pas

@@ -88,7 +88,7 @@ type
     procedure SetPageOffsetByHeader(NewValue: Boolean); virtual;
     procedure SetRecordCount(NewValue: Integer);
     procedure SetBufferAhead(NewValue: Boolean);
-    procedure SetFileName(NewName: string);
+    procedure SetFileName(const NewName: string);
     procedure SetStream(NewStream: TStream);
     function  LockSection(const Offset, Length: Cardinal; const Wait: Boolean): Boolean; virtual;
     function  UnlockSection(const Offset, Length: Cardinal): Boolean; virtual;
@@ -515,7 +515,7 @@ begin
     FStream := NewStream;
 end;
 
-procedure TPagedFile.SetFileName(NewName: string);
+procedure TPagedFile.SetFileName(const NewName: string);
 begin
   if not FActive then
     FFileName := NewName;

+ 26 - 26
packages/fcl-db/src/dbase/dbf_prscore.pas

@@ -53,7 +53,7 @@ type
     FExpResultPos: PChar;
     FExpResultSize: Integer;
 
-    procedure ParseString(AnExpression: string; DestCollection: TExprCollection);
+    procedure ParseString(const AnExpression: string; DestCollection: TExprCollection);
     function  MakeTree(Expr: TExprCollection; FirstItem, LastItem: Integer): PExpressionRec;
     procedure MakeLinkedList(var ExprRec: PExpressionRec; Memory: PPChar;
         MemoryPos: PPChar; MemSize: PInteger);
@@ -68,7 +68,7 @@ type
     procedure FillExpressList; virtual; abstract;
     procedure HandleUnknownVariable(VarName: string); virtual; abstract;
 
-    procedure CompileExpression(AnExpression: string);
+    procedure CompileExpression(const AnExpression: string);
     procedure EvaluateCurrent;
     procedure DisposeList(ARec: PExpressionRec);
     procedure DisposeTree(ExprRec: PExpressionRec);
@@ -84,23 +84,23 @@ type
     constructor Create;
     destructor Destroy; override;
 
-    function DefineFloatVariable(AVarName: string; AValue: PDouble): TExprWord;
-    function DefineIntegerVariable(AVarName: string; AValue: PInteger; AIsNull: PBoolean = nil): TExprWord;
+    function DefineFloatVariable(const AVarName: string; AValue: PDouble): TExprWord;
+    function DefineIntegerVariable(const AVarName: string; AValue: PInteger; AIsNull: PBoolean = nil): TExprWord;
 //    procedure DefineSmallIntVariable(AVarName: string; AValue: PSmallInt);
 {$ifdef SUPPORT_INT64}
-    function DefineLargeIntVariable(AVarName: string; AValue: PLargeInt): TExprWord;
+    function DefineLargeIntVariable(const AVarName: string; AValue: PLargeInt): TExprWord;
 {$endif}
-    function DefineDateTimeVariable(AVarName: string; AValue: PDateTimeRec): TExprWord;
-    function DefineBooleanVariable(AVarName: string; AValue: PBoolean): TExprWord;
-    function DefineStringVariable(AVarName: string; AValue: PPChar; AIsNull: PBoolean = nil): TExprWord;
-    function DefineFunction(AFunctName, AShortName, ADescription, ATypeSpec: string;
+    function DefineDateTimeVariable(const AVarName: string; AValue: PDateTimeRec): TExprWord;
+    function DefineBooleanVariable(const AVarName: string; AValue: PBoolean): TExprWord;
+    function DefineStringVariable(const AVarName: string; AValue: PPChar; AIsNull: PBoolean = nil): TExprWord;
+    function DefineFunction(const AFunctName, AShortName, ADescription, ATypeSpec: string;
         AMinFunctionArg: Integer; AResultType: TExpressionType; AFuncAddress: TExprFunc): TExprWord;
-    procedure Evaluate(AnExpression: string);
-    function AddExpression(AnExpression: string): Integer;
+    procedure Evaluate(const AnExpression: string);
+    function AddExpression(const AnExpression: string): Integer;
     procedure ClearExpressions; virtual;
 //    procedure GetGeneratedVars(AList: TList);
     procedure GetFunctionNames(AList: TStrings);
-    function GetFunctionDescription(AFunction: string): string;
+    function GetFunctionDescription(const AFunction: string): string;
     property HexChar: Char read FHexChar write FHexChar;
     property ArgSeparator: Char read FArgSeparator write FArgSeparator;
     property Optimize: Boolean read FOptimize write FOptimize;
@@ -323,7 +323,7 @@ begin
   inherited;
 end;
 
-procedure TCustomExpressionParser.CompileExpression(AnExpression: string);
+procedure TCustomExpressionParser.CompileExpression(const AnExpression: string);
 var
   ExpColl: TExprCollection;
   ExprTree: PExpressionRec;
@@ -780,7 +780,7 @@ begin
     raise EParserException.Create('Operator/function missing');
 end;
 
-procedure TCustomExpressionParser.ParseString(AnExpression: string; DestCollection: TExprCollection);
+procedure TCustomExpressionParser.ParseString(const AnExpression: string; DestCollection: TExprCollection);
 const
   NullWord='NULL';
 var
@@ -789,7 +789,7 @@ var
   W, S: string;
   TempWord: TExprWord;
 
-  procedure ReadConstant(AnExpr: string; isHex: Boolean);
+  procedure ReadConstant(const AnExpr: string; isHex: Boolean);
   begin
     isConstant := true;
     while (I2 <= Len) and ((AnExpr[I2] in ['0'..'9']) or
@@ -814,7 +814,7 @@ var
     end;
   end;
 
-  procedure ReadWord(AnExpr: string);
+  procedure ReadWord(const AnExpr: string);
   var
     OldI2: Integer;
     constChar: Char;
@@ -1137,14 +1137,14 @@ begin
   end;
 end;
 
-function TCustomExpressionParser.DefineFunction(AFunctName, AShortName, ADescription, ATypeSpec: string;
+function TCustomExpressionParser.DefineFunction(const AFunctName, AShortName, ADescription, ATypeSpec: string;
   AMinFunctionArg: Integer; AResultType: TExpressionType; AFuncAddress: TExprFunc): TExprWord;
 begin
   Result := TFunction.Create(AFunctName, AShortName, ATypeSpec, AMinFunctionArg, AResultType, AFuncAddress, ADescription);
   FWordsList.Add(Result);
 end;
 
-function TCustomExpressionParser.DefineIntegerVariable(AVarName: string; AValue: PInteger; AIsNull: PBoolean): TExprWord;
+function TCustomExpressionParser.DefineIntegerVariable(const AVarName: string; AValue: PInteger; AIsNull: PBoolean): TExprWord;
 begin
   Result := TIntegerVariable.Create(AVarName, AValue, AIsNull);
   FWordsList.Add(Result);
@@ -1152,7 +1152,7 @@ end;
 
 {$ifdef SUPPORT_INT64}
 
-function TCustomExpressionParser.DefineLargeIntVariable(AVarName: string; AValue: PLargeInt): TExprWord;
+function TCustomExpressionParser.DefineLargeIntVariable(const AVarName: string; AValue: PLargeInt): TExprWord;
 begin
   Result := TLargeIntVariable.Create(AVarName, AValue);
   FWordsList.Add(Result);
@@ -1160,25 +1160,25 @@ end;
 
 {$endif}
 
-function TCustomExpressionParser.DefineDateTimeVariable(AVarName: string; AValue: PDateTimeRec): TExprWord;
+function TCustomExpressionParser.DefineDateTimeVariable(const AVarName: string; AValue: PDateTimeRec): TExprWord;
 begin
   Result := TDateTimeVariable.Create(AVarName, AValue);
   FWordsList.Add(Result);
 end;
 
-function TCustomExpressionParser.DefineBooleanVariable(AVarName: string; AValue: PBoolean): TExprWord;
+function TCustomExpressionParser.DefineBooleanVariable(const AVarName: string; AValue: PBoolean): TExprWord;
 begin
   Result := TBooleanVariable.Create(AVarName, AValue);
   FWordsList.Add(Result);
 end;
 
-function TCustomExpressionParser.DefineFloatVariable(AVarName: string; AValue: PDouble): TExprWord;
+function TCustomExpressionParser.DefineFloatVariable(const AVarName: string; AValue: PDouble): TExprWord;
 begin
   Result := TFloatVariable.Create(AVarName, AValue);
   FWordsList.Add(Result);
 end;
 
-function TCustomExpressionParser.DefineStringVariable(AVarName: string; AValue: PPChar; AIsNull: PBoolean): TExprWord;
+function TCustomExpressionParser.DefineStringVariable(const AVarName: string; AValue: PPChar; AIsNull: PBoolean): TExprWord;
 begin
   Result := TStringVariable.Create(AVarName, AValue, AIsNull);
   FWordsList.Add(Result);
@@ -1234,7 +1234,7 @@ begin
   Result^.ResetDest := false;
 end;
 
-procedure TCustomExpressionParser.Evaluate(AnExpression: string);
+procedure TCustomExpressionParser.Evaluate(const AnExpression: string);
 begin
   if Length(AnExpression) > 0 then
   begin
@@ -1243,7 +1243,7 @@ begin
   end;
 end;
 
-function TCustomExpressionParser.AddExpression(AnExpression: string): Integer;
+function TCustomExpressionParser.AddExpression(const AnExpression: string): Integer;
 begin
   if Length(AnExpression) > 0 then
   begin
@@ -1261,7 +1261,7 @@ begin
   FLastRec := nil;
 end;
 
-function TCustomExpressionParser.GetFunctionDescription(AFunction: string):
+function TCustomExpressionParser.GetFunctionDescription(const AFunction: string):
   string;
 var
   S: string;

+ 35 - 36
packages/fcl-db/src/dbase/dbf_prsdef.pas

@@ -126,7 +126,7 @@ type
     function GetShortName: string; virtual;
     procedure SetFixedLen(NewLen: integer); virtual;
   public
-    constructor Create(AName: string; AExprFunc: TExprFunc);
+    constructor Create(const AName: string; AExprFunc: TExprFunc);
 
     function AsPointer: PChar; virtual;
     function LenAsPointer: PInteger; virtual;
@@ -174,7 +174,7 @@ type
   protected
     function GetResultType: TExpressionType; override;
   public
-    constructor Create(AName: string; AVarType: TExpressionType; AExprFunc: TExprFunc);
+    constructor Create(const AName: string; AVarType: TExpressionType; AExprFunc: TExprFunc);
   end;
 
   TFloatConstant = class(TConstant)
@@ -182,8 +182,8 @@ type
     FValue: Double;
   public
     // not overloaded to support older Delphi versions
-    constructor Create(AName: string; AValue: string);
-    constructor CreateAsDouble(AName: string; AValue: Double);
+    constructor Create(const AName: string; const AValue: string);
+    constructor CreateAsDouble(const AName: string; AValue: Double);
 
     function AsPointer: PChar; override;
 
@@ -196,7 +196,7 @@ type
   protected
     function GetDescription: string; override;
   public
-    constructor CreateAsDouble(AName, Descr: string; AValue: Double);
+    constructor CreateAsDouble(Const AName, Descr: string; AValue: Double);
   end;
 
   TStringConstant = class(TConstant)
@@ -205,7 +205,7 @@ type
   public
     // Allow undelimited, delimited by single quotes, delimited by double quotes
     // If delimited, allow escaping inside string with double delimiters
-    constructor Create(AValue: string);
+    constructor Create(const AValue: string);
 
     function AsPointer: PChar; override;
   end;
@@ -235,7 +235,7 @@ type
     FValue: Boolean;
   public
     // not overloaded to support older Delphi versions
-    constructor Create(AName: string; AValue: Boolean);
+    constructor Create(const AName: string; AValue: Boolean);
 
     function AsPointer: PChar; override;
 
@@ -260,7 +260,7 @@ type
     function GetCanVary: Boolean; override;
     function GetResultType: TExpressionType; override;
   public
-    constructor Create(AName: string; AVarType: TExpressionType; AExprFunc: TExprFunc);
+    constructor Create(const AName: string; AVarType: TExpressionType; AExprFunc: TExprFunc);
     function IsNullAsPointer: PBoolean; override;
   end;
 
@@ -268,7 +268,7 @@ type
   private
     FValue: PDouble;
   public
-    constructor Create(AName: string; AValue: PDouble);
+    constructor Create(const AName: string; AValue: PDouble);
 
     function AsPointer: PChar; override;
   end;
@@ -281,7 +281,7 @@ type
     function GetFixedLen: Integer; override;
     procedure SetFixedLen(NewLen: integer); override;
   public
-    constructor Create(AName: string; AValue: PPChar; AIsNull: PBoolean);
+    constructor Create(const AName: string; AValue: PPChar; AIsNull: PBoolean);
 
     function LenAsPointer: PInteger; override;
     function AsPointer: PChar; override;
@@ -293,7 +293,7 @@ type
   private
     FValue: PDateTimeRec;
   public
-    constructor Create(AName: string; AValue: PDateTimeRec);
+    constructor Create(const AName: string; AValue: PDateTimeRec);
 
     function AsPointer: PChar; override;
   end;
@@ -302,7 +302,7 @@ type
   private
     FValue: PInteger;
   public
-    constructor Create(AName: string; AValue: PInteger; AIsNull: PBoolean);
+    constructor Create(const AName: string; AValue: PInteger; AIsNull: PBoolean);
 
     function AsPointer: PChar; override;
   end;
@@ -313,7 +313,7 @@ type
   private
     FValue: PLargeInt;
   public
-    constructor Create(AName: string; AValue: PLargeInt);
+    constructor Create(const AName: string; AValue: PLargeInt);
 
     function AsPointer: PChar; override;
   end;
@@ -324,7 +324,7 @@ type
   private
     FValue: PBoolean;
   public
-    constructor Create(AName: string; AValue: PBoolean);
+    constructor Create(const AName: string; AValue: PBoolean);
 
     function AsPointer: PChar; override;
   end;
@@ -362,12 +362,12 @@ type
     function GetTypeSpec: string; override;
     function GetShortName: string; override;
 
-    procedure InternalCreate(AName, ATypeSpec: string; AMinFuncArg: Integer; AResultType: TExpressionType;
+    procedure InternalCreate(const AName, ATypeSpec: string; AMinFuncArg: Integer; AResultType: TExpressionType;
       AExprFunc: TExprFunc; AIsOperator: Boolean; AOperPrec: Integer);
   public
-    constructor Create(AName, AShortName, ATypeSpec: string; AMinFuncArg: Integer; AResultType: TExpressionType; AExprFunc: TExprFunc; Descr: string);
+    constructor Create(const AName, AShortName, ATypeSpec: string; AMinFuncArg: Integer; AResultType: TExpressionType; AExprFunc: TExprFunc; const Descr: string);
     // Create operator: name, param types used, result type, func addr, operator precedence
-    constructor CreateOper(AName, ATypeSpec: string; AResultType: TExpressionType; AExprFunc: TExprFunc; AOperPrec: Integer);
+    constructor CreateOper(const AName, ATypeSpec: string; AResultType: TExpressionType; AExprFunc: TExprFunc; AOperPrec: Integer);
 
     function IsFunction: Boolean; override;
 
@@ -479,7 +479,7 @@ end;
 
 { TExpressionWord }
 
-constructor TExprWord.Create(AName: string; AExprFunc: TExprFunc);
+constructor TExprWord.Create(const AName: string; AExprFunc: TExprFunc);
 begin
   FName := AName;
   FExprFunc := AExprFunc;
@@ -591,7 +591,7 @@ end;
 
 { TConstant }
 
-constructor TConstant.Create(AName: string; AVarType: TExpressionType; AExprFunc: TExprFunc);
+constructor TConstant.Create(const AName: string; AVarType: TExpressionType; AExprFunc: TExprFunc);
 begin
   inherited Create(AName, AExprFunc);
 
@@ -605,7 +605,7 @@ end;
 
 { TFloatConstant }
 
-constructor TFloatConstant.Create(AName, AValue: string);
+constructor TFloatConstant.Create(const AName, AValue: string);
 begin
   inherited Create(AName, etFloat, _FloatVariable);
 
@@ -615,7 +615,7 @@ begin
     FValue := 0.0;
 end;
 
-constructor TFloatConstant.CreateAsDouble(AName: string; AValue: Double);
+constructor TFloatConstant.CreateAsDouble(const AName: string; AValue: Double);
 begin
   inherited Create(AName, etFloat, _FloatVariable);
 
@@ -629,10 +629,9 @@ end;
 
 { TUserConstant }
 
-constructor TUserConstant.CreateAsDouble(AName, Descr: string; AValue: Double);
+constructor TUserConstant.CreateAsDouble(const AName, Descr: string; AValue: Double);
 begin
   FDescription := Descr;
-
   inherited CreateAsDouble(AName, AValue);
 end;
 
@@ -643,7 +642,7 @@ end;
 
 { TStringConstant }
 
-constructor TStringConstant.Create(AValue: string);
+constructor TStringConstant.Create(const AValue: string);
 var
   firstChar, lastChar: Char;
 begin
@@ -667,7 +666,7 @@ end;
 
 { TBooleanConstant }
 
-constructor TBooleanConstant.Create(AName: string; AValue: Boolean);
+constructor TBooleanConstant.Create(const AName: string; AValue: Boolean);
 begin
   inherited Create(AName, etBoolean, _BooleanVariable);
 
@@ -718,7 +717,7 @@ end;
 
 { TVariable }
 
-constructor TVariable.Create(AName: string; AVarType: TExpressionType; AExprFunc: TExprFunc);
+constructor TVariable.Create(const AName: string; AVarType: TExpressionType; AExprFunc: TExprFunc);
 begin
   inherited Create(AName, AExprFunc);
 
@@ -742,7 +741,7 @@ end;
 
 { TFloatVariable }
 
-constructor TFloatVariable.Create(AName: string; AValue: PDouble);
+constructor TFloatVariable.Create(const AName: string; AValue: PDouble);
 begin
   inherited Create(AName, etFloat, _FloatVariable);
   FValue := AValue;
@@ -755,7 +754,7 @@ end;
 
 { TStringVariable }
 
-constructor TStringVariable.Create(AName: string; AValue: PPChar; AIsNull: PBoolean);
+constructor TStringVariable.Create(const AName: string; AValue: PPChar; AIsNull: PBoolean);
 begin
   // variable or fixed length?
   inherited Create(AName, etString, _StringVariable);
@@ -788,7 +787,7 @@ end;
 
 { TDateTimeVariable }
 
-constructor TDateTimeVariable.Create(AName: string; AValue: PDateTimeRec);
+constructor TDateTimeVariable.Create(const AName: string; AValue: PDateTimeRec);
 begin
   inherited Create(AName, etDateTime, _DateTimeVariable);
   FValue := AValue;
@@ -801,7 +800,7 @@ end;
 
 { TIntegerVariable }
 
-constructor TIntegerVariable.Create(AName: string; AValue: PInteger; AIsNull: PBoolean);
+constructor TIntegerVariable.Create(const AName: string; AValue: PInteger; AIsNull: PBoolean);
 begin
   inherited Create(AName, etInteger, _IntegerVariable);
   FValue := AValue;
@@ -817,7 +816,7 @@ end;
 
 { TLargeIntVariable }
 
-constructor TLargeIntVariable.Create(AName: string; AValue: PLargeInt);
+constructor TLargeIntVariable.Create(const AName: string; AValue: PLargeInt);
 begin
   inherited Create(AName, etLargeInt, _LargeIntVariable);
   FValue := AValue;
@@ -832,7 +831,7 @@ end;
 
 { TBooleanVariable }
 
-constructor TBooleanVariable.Create(AName: string; AValue: PBoolean);
+constructor TBooleanVariable.Create(const AName: string; AValue: PBoolean);
 begin
   inherited Create(AName, etBoolean, _BooleanVariable);
   FValue := AValue;
@@ -989,8 +988,8 @@ end;
 
 { TFunction }
 
-constructor TFunction.Create(AName, AShortName, ATypeSpec: string; AMinFuncArg: Integer; AResultType: TExpressionType;
-  AExprFunc: TExprFunc; Descr: string);
+constructor TFunction.Create(const AName, AShortName, ATypeSpec: string; AMinFuncArg: Integer; AResultType: TExpressionType;
+  AExprFunc: TExprFunc; const Descr: string);
 begin
   //to increase compatibility don't use default parameters
   FDescription := Descr;
@@ -998,13 +997,13 @@ begin
   InternalCreate(AName, ATypeSpec, AMinFuncArg, AResultType, AExprFunc, false, 0);
 end;
 
-constructor TFunction.CreateOper(AName, ATypeSpec: string; AResultType: TExpressionType;
+constructor TFunction.CreateOper(const AName, ATypeSpec: string; AResultType: TExpressionType;
   AExprFunc: TExprFunc; AOperPrec: Integer);
 begin
   InternalCreate(AName, ATypeSpec, -1, AResultType, AExprFunc, true, AOperPrec);
 end;
 
-procedure TFunction.InternalCreate(AName, ATypeSpec: string; AMinFuncArg: Integer; AResultType: TExpressionType;
+procedure TFunction.InternalCreate(const AName, ATypeSpec: string; AMinFuncArg: Integer; AResultType: TExpressionType;
   AExprFunc: TExprFunc; AIsOperator: Boolean; AOperPrec: Integer);
 begin
   inherited Create(AName, AExprFunc);

+ 3 - 4
packages/fcl-db/src/export/fpdbexport.pp

@@ -175,8 +175,8 @@ Type
     // Format field as UTF8 string, according to settings
     Function FormatField(F : TField) : UTF8String; virtual;
     // Raise EDataExporter error
-    Procedure ExportError(const Msg : String); overload;
-    Procedure ExportError(const Fmt : String; Args: Array of const); overload;
+    Procedure ExportError(Const Msg : String); overload;
+    Procedure ExportError(const Fmt : String; const Args: Array of const); overload;
   Public
     Constructor Create(AOwner : TComponent); override;
     Destructor Destroy; override;
@@ -679,8 +679,7 @@ begin
   Raise EDataExporter.Create(Msg);
 end;
 
-procedure TCustomDatasetExporter.ExportError(const Fmt: String;
-  Args: array of const);
+procedure TCustomDatasetExporter.ExportError(const Fmt: String; const Args: array of const);
 begin
   Raise EDataExporter.CreateFmt(Fmt,Args);
 end;

+ 6 - 6
packages/fcl-db/src/json/extjsdataset.pp

@@ -30,11 +30,11 @@ Type
     FFields : TJSONArray;
   Protected
     Function GenerateMetaData : TJSONObject;
-    function ConvertDateFormat(S: String): String; virtual;
+    function ConvertDateFormat(const S: String): String; virtual;
     Procedure MetaDataToFieldDefs; override;
     procedure InitDateTimeFields; override;
-    function StringToFieldType(S: String): TFieldType;virtual;
-    function GetStringFieldLength(F: TJSONObject; AName: String; AIndex: Integer): integer; virtual;
+    function StringToFieldType(const S: String): TFieldType;virtual;
+    function GetStringFieldLength(F: TJSONObject; const AName: String; AIndex: Integer): integer; virtual;
   Public
     // Use this to load MetaData/Rows from stream.
     // If no metadata is present in the stream, FieldDefs must be filled manually.
@@ -74,7 +74,7 @@ implementation
 { TExtJSJSONDataSet }
 
 
-Function  TExtJSJSONDataSet.StringToFieldType(S : String) : TFieldType;
+Function  TExtJSJSONDataSet.StringToFieldType(const S : String) : TFieldType;
 
 begin
   if (s='int') then
@@ -94,7 +94,7 @@ begin
       Raise EJSONDataset.CreateFmt('Unknown JSON data type : %s',[s]);
 end;
 
-Function  TExtJSJSONDataSet.GetStringFieldLength(F : TJSONObject; AName : String; AIndex : Integer) : integer;
+Function  TExtJSJSONDataSet.GetStringFieldLength(F : TJSONObject; const AName : String; AIndex : Integer) : integer;
 
 Var
   I,L : Integer;
@@ -336,7 +336,7 @@ begin
   Result.strings['root']:='rows';
 end;
 
-Function TExtJSJSONDataSet.ConvertDateFormat(S : String) : String;
+Function TExtJSJSONDataSet.ConvertDateFormat(const S : String) : String;
 
 { Not handled: N S w z W t L o O P T Z c U MS }
 

+ 4 - 4
packages/fcl-db/src/json/fpjsondataset.pp

@@ -189,7 +189,7 @@ type
     FValues: TVariantArray;
     function GetFieldComparer(Index : Integer): TFieldComparer;
   Protected
-    procedure ConstructItems(aFields: String); virtual;
+    procedure ConstructItems(const aFields: String); virtual;
     function DataTypeToComparerClass(aFieldType: TFieldType): TFieldComparerClass;
     Function Compare(aRowindex : integer) : Integer;
   Public
@@ -267,7 +267,7 @@ type
     // Initialize Date/Time info in all date/time fields. Called during InternalOpen
     procedure InitDateTimeFields; virtual;
     // Convert JSON date S to DateTime for Field F
-    function ConvertDateTimeField(S: String; F: TField): TDateTime; virtual;
+    function ConvertDateTimeField(const S: String; F: TField): TDateTime; virtual;
     // Format JSON date to from DT for Field F
     function FormatDateTimeField(DT : TDateTime; F: TField): String; virtual;
     // Create fieldmapper. A descendent MUST implement this.
@@ -467,7 +467,7 @@ begin
   Result:=Items[Index];
 end;
 
-procedure TRecordComparer.ConstructItems(aFields : String);
+procedure TRecordComparer.ConstructItems(const aFields : String);
 
 Var
   L : Tlist;
@@ -1062,7 +1062,7 @@ begin
   PRecInfo(Buffer)^.RowIndex := PNativeInt(Data)^;
 end;
 
-function TBaseJSONDataSet.ConvertDateTimeField(S : String; F : TField) : TDateTime;
+function TBaseJSONDataSet.ConvertDateTimeField(const S : String; F : TField) : TDateTime;
 
 Var
   Ptrn : string;

+ 2 - 2
packages/fcl-db/src/sql/fpsqlparser.pas

@@ -72,7 +72,7 @@ Type
     // Expects aTokens tokens and eats the token by calling GetNextToken
     procedure Consume(aTokens: TSQLTokens);
     procedure Error(const Msg : String);
-    procedure Error(const Fmt : String; Args : Array of const);
+    procedure Error(const Fmt : String; const Args : Array of const);
     // Expression support
     function ParseExprLevel1(AParent: TSQLElement; EO : TExpressionOptions): TSQLExpression;
     function ParseExprLevel2(AParent: TSQLElement; EO : TExpressionOptions): TSQLExpression;
@@ -321,7 +321,7 @@ begin
    Raise E;
 end;
 
-procedure TSQLParser.Error(const Fmt: String; Args: array of const);
+procedure TSQLParser.Error(const Fmt: String; const Args: array of const);
 begin
   Error(Format(Fmt,Args));
 end;

+ 2 - 2
packages/fcl-db/src/sqldb/examples/sqldbexampleunit.pp

@@ -43,7 +43,7 @@ var
  FPdevBirthDates : Array[1..8] of TDateTime;
 
 
-procedure ExitWithError(s : string);
+procedure ExitWithError(const s : string);
 procedure ReadIniFile;
 
 procedure CreateFConnection;
@@ -55,7 +55,7 @@ implementation
 uses
   inifiles;
 
-procedure ExitWithError(s : string);
+procedure ExitWithError(const s : string);
 
 begin
   writeln(s);

+ 44 - 45
packages/fcl-db/src/sqldb/interbase/fbadmin.pp

@@ -83,15 +83,15 @@ type
     FUseExceptions: boolean;
     FUser: string;
     FWaitInterval: Integer;
-    function CheckConnected(ProcName: string):boolean;
-    procedure CheckError(ProcName : string; Status : PISC_STATUS);
+    function CheckConnected(const ProcName: string):boolean;
+    procedure CheckError(const ProcName : string; Status : PISC_STATUS);
     function GetDBInfo:boolean;
-    function GetIBLongint(buffer:string; var bufptr:integer):longint;overload;
-    function GetIBString(buffer:string; var bufptr:integer):string;overload;
-    function GetOutput(IBAdminAction:string):boolean;
-    function IBParamSerialize(isccode:byte;value:string):string;
+    function GetIBLongint(const buffer:string; var bufptr:integer):longint;overload;
+    function GetIBString(const buffer:string; var bufptr:integer):string;overload;
+    function GetOutput(const IBAdminAction:string):boolean;
+    function IBParamSerialize(isccode:byte;const value:string):string;
     procedure IBRaiseError(GDSErrorCode:Longint; const msg : string; const args : array of const);
-    function IBSPBParamSerialize(isccode:byte;value:string):string;
+    function IBSPBParamSerialize(isccode:byte;const value:string):string;
     function IBSPBParamSerialize(isccode:byte;value:longint):string;
     function MakeBackupOptions(options:TIBBackupOptions):longint;
     function MakeRestoreOptions(options:TIBRestoreOptions):longint;
@@ -105,36 +105,36 @@ type
     function DisConnect:boolean;
     //Backup database to a single file on the server.
     //Include IBBkpVerbose in Options to get progress feedback through the OnOutput Handler
-    function Backup(Database,Filename:string;Options:TIBBackupOptions;RoleName:string=''):boolean;
+    function Backup(const Database,Filename:string;Options:TIBBackupOptions;const RoleName:string=''):boolean;
     //Backup database to multiple files with length FileSize on the server.
     //Filenames is the list of filenames to use. The last file specified has no size limit.
     //Include IBBkpVerbose in Options to get progress feedback through the OnOutput Handler
-    function BackupMultiFile(Database:string;Filenames:TStrings;FileSize:longint;
-      Options:TIBBackupOptions;RoleName:string=''):boolean;
+    function BackupMultiFile(const Database:string;Filenames:TStrings;FileSize:longint;
+      Options:TIBBackupOptions;const RoleName:string=''):boolean;
     //Restore database from a single file on the server.
     //Include IBResReplace to restore in and existing database or IBResCreate
     //to create a a new one.
     //Include IBResVerbose in Options to get progress feedback through the OnOutput Handler
-    function Restore(Database,Filename:string;Options:TIBRestoreOptions;RoleName:string=''):boolean;
+    function Restore(const Database,Filename:string;Options:TIBRestoreOptions;const RoleName:string=''):boolean;
     //Restore database from multiple files on the server.
     //Filenames is the list of files to use.
     //Include IBResReplace to restore in and existing database or IBResCreate
     //to create a a new one.
     //Include IBResVerbose in Options to get progress feedback through the OnOutput Handler
-    function RestoreMultiFile(Database:string;Filenames:TStrings;
-      Options:TIBRestoreOptions;RoleName:string=''):boolean;
+    function RestoreMultiFile(const Database:string;Filenames:TStrings;
+      Options:TIBRestoreOptions;const RoleName:string=''):boolean;
     //Add a new user.
-    function AddUser(UserName,Password:string;RoleName:string='';
-      GroupName:string='';FirstName:string='';MiddleName:string='';
-      LastName:string='';UserID: longint = 0; GroupID: longint = 0):boolean;
+    function AddUser(const UserName,Password:string;const RoleName:string='';
+      const GroupName:string='';const FirstName:string='';const MiddleName:string='';
+      const LastName:string='';UserID: longint = 0; GroupID: longint = 0):boolean;
     //Modify an existing user.
-    function ModifyUser(UserName,Password:string;RoleName:string='';
-      GroupName:string='';FirstName:string='';MiddleName:string='';
-      LastName:string='';UserID: longint = 0; GroupID: longint = 0):boolean;
+    function ModifyUser(const UserName,Password:string;const RoleName:string='';
+      const GroupName:string=''; const FirstName:string=''; const MiddleName:string='';
+      const LastName:string='';UserID: longint = 0; GroupID: longint = 0):boolean;
     //Delete an existing user.
-    function DeleteUser(UserName:string;RoleName:string=''):boolean;
+    function DeleteUser(const UserName:string;const RoleName:string=''):boolean;
     //Get the details of an existing user.
-    function GetUser(UserName:string;var GroupName,FirstName,MiddleName,
+    function GetUser(const UserName:string;var GroupName,FirstName,MiddleName,
       LastName:string;var UserID, GroupID: longint):boolean;
     //Get the list of all users
     function GetUsers(Users:TStrings):boolean;
@@ -147,7 +147,7 @@ type
     // WaitInterval is the interval (in milliseconds) between ServiceRunning calls.
     function WaitForServiceCompletion(aTimeOut: Integer): Boolean;
     //Get database statistics
-    function GetDatabaseStats(Database:string;Options:TIBStatOptions;TableNames:String = ''): boolean;
+    function GetDatabaseStats(const Database:string;Options:TIBStatOptions; const TableNames:String = ''): boolean;
     //Database server version
     property ServerVersion:string read FServerVersion;
     //Implementation string of the database server
@@ -210,7 +210,7 @@ resourcestring
 
 { TFBAdmin }
 
-function TFBAdmin.IBParamSerialize(isccode: byte; value: string): string;
+function TFBAdmin.IBParamSerialize(isccode: byte; const value: string): string;
 begin
   result:=chr(isccode)+chr(Length(value))+value;
 end;
@@ -224,7 +224,7 @@ begin
     raise EIBDatabaseError.CreateFmt(msg,args,nil,GDSErrorCode,'');
 end;
 
-function TFBAdmin.IBSPBParamSerialize(isccode: byte; value: string): string;
+function TFBAdmin.IBSPBParamSerialize(isccode: byte; const value: string): string;
 begin
   result:=chr(isccode)+chr(Length(value) and $ff)+chr((Length(value)shr 8) and $ff)+value;
 end;
@@ -274,7 +274,7 @@ begin
 end;
 
 
-function TFBAdmin.CheckConnected(ProcName: string): boolean;
+function TFBAdmin.CheckConnected(const ProcName: string): boolean;
 begin
   result:=false;
   if FSvcHandle=FB_API_NULLHANDLE then
@@ -285,7 +285,7 @@ begin
   result:=true;
 end;
 
-procedure TFBAdmin.CheckError(ProcName: string; Status: PISC_STATUS);
+procedure TFBAdmin.CheckError(const ProcName: string; Status: PISC_STATUS);
 var
   buf : array [0..1023] of char;
   Msg : string;
@@ -330,14 +330,14 @@ begin
   FServerVersion:= QueryInfo(isc_info_svc_server_version);
 end;
 
-function TFBAdmin.GetIBLongint(buffer: string; var bufptr: integer): longint;
+function TFBAdmin.GetIBLongint(const buffer: string; var bufptr: integer): longint;
 begin
   bufptr:=bufptr+1;
   result:=isc_vax_integer(@Buffer[bufptr], 4);
   bufptr:=bufptr+4;
 end;
 
-function TFBAdmin.GetIBString(buffer: string; var bufptr: integer): string;
+function TFBAdmin.GetIBString(const buffer: string; var bufptr: integer): string;
 var
   len:integer;
 begin
@@ -348,7 +348,7 @@ begin
   bufptr:=bufptr+len;
 end;
 
-function TFBAdmin.GetOutput(IBAdminAction: string): boolean;
+function TFBAdmin.GetOutput(const IBAdminAction: string): boolean;
 var
   len:integer;
   buffer:string;
@@ -449,8 +449,8 @@ begin
   result:=true;
 end;
 
-function TFBAdmin.Backup(Database, Filename: string; Options: TIBBackupOptions;
-  RoleName: string): boolean;
+function TFBAdmin.Backup(const Database, Filename: string; Options: TIBBackupOptions;
+  const RoleName: string): boolean;
 var
   spb:string;
 begin
@@ -475,8 +475,8 @@ begin
     WaitForServiceCompletion(0);
 end;
 
-function TFBAdmin.BackupMultiFile(Database: string; Filenames: TStrings;
-  FileSize: longint; Options: TIBBackupOptions; RoleName: string): boolean;
+function TFBAdmin.BackupMultiFile(const Database: string; Filenames: TStrings;
+  FileSize: longint; Options: TIBBackupOptions; const RoleName: string): boolean;
 var
   spb:string;
   i:integer;
@@ -547,8 +547,8 @@ begin
 end;
 
 
-function TFBAdmin.Restore(Database, Filename: string;
-  Options: TIBRestoreOptions; RoleName: string): boolean;
+function TFBAdmin.Restore(const Database, Filename: string;
+  Options: TIBRestoreOptions; const RoleName: string): boolean;
 var
   spb:string;
 begin
@@ -591,8 +591,8 @@ begin
 end;
 
 
-function TFBAdmin.RestoreMultiFile(Database: string; Filenames: TStrings;
-  Options: TIBRestoreOptions; RoleName: string): boolean;
+function TFBAdmin.RestoreMultiFile(const Database: string; Filenames: TStrings;
+  Options: TIBRestoreOptions; const RoleName: string): boolean;
 var
   spb:string;
   i:integer;
@@ -630,8 +630,8 @@ begin
     result:=GetOutput('RestoreMultiFile');
 end;
 
-function TFBAdmin.AddUser(UserName, Password: string; RoleName: string;
-  GroupName: string; FirstName: string; MiddleName: string; LastName: string;
+function TFBAdmin.AddUser(const UserName, Password: string; const RoleName: string;
+  const GroupName: string; const FirstName: string; const MiddleName: string; const LastName: string;
   UserID: longint; GroupID: longint): boolean;
 var
   spb:string;
@@ -659,8 +659,8 @@ begin
     CheckError('AddUser',FStatus);
 end;
 
-function TFBAdmin.ModifyUser(UserName, Password: string; RoleName: string;
-  GroupName: string; FirstName: string; MiddleName: string; LastName: string;
+function TFBAdmin.ModifyUser(const UserName, Password: string; const RoleName: string;
+  const GroupName: string; const FirstName: string; const MiddleName: string; const LastName: string;
   UserID: longint; GroupID: longint): boolean;
 var
   spb:string;
@@ -688,7 +688,7 @@ begin
     CheckError('ModifyUser',FStatus);
 end;
 
-function TFBAdmin.DeleteUser(UserName: string; RoleName: string): boolean;
+function TFBAdmin.DeleteUser(const UserName: string; const RoleName: string): boolean;
 var
   spb:string;
 begin
@@ -702,7 +702,7 @@ begin
     CheckError('DeleteUser',FStatus);
 end;
 
-function TFBAdmin.GetUser(UserName: string; var GroupName, FirstName,
+function TFBAdmin.GetUser(const UserName: string; var GroupName, FirstName,
   MiddleName, LastName: string; var UserID, GroupID: longint): boolean;
 var
   spb:string;
@@ -829,8 +829,7 @@ begin
   result:=GetOutput('GetLogFile');
 end;
 
-function TFBAdmin.GetDatabaseStats(Database:string;Options: TIBStatOptions; TableNames: String
-  ): boolean;
+function TFBAdmin.GetDatabaseStats(const Database:string;Options: TIBStatOptions; const TableNames: String): boolean;
 var
   spb:string;
   param: Integer;

+ 17 - 16
packages/fcl-db/src/sqldb/interbase/ibconnection.pp

@@ -92,7 +92,7 @@ type
 
     // Metadata:
     procedure GetDatabaseInfo; //Queries for various information from server once connected
-    function InterpretTransactionParam(S: String; var TPB: AnsiChar; out AValue: String): Boolean;
+    function InterpretTransactionParam(const S: String; var TPB: AnsiChar; out AValue: String): Boolean;
     procedure ResetDatabaseInfo; //Useful when disconnecting
     function GetDialect: integer;
     function GetODSMajorVersion: integer;
@@ -106,8 +106,8 @@ type
     procedure GetFloat(CurrBuff, Buffer : pointer; Size : Byte);
     procedure SetFloat(CurrBuff: pointer; Dbl: Double; Size: integer);
 
-    procedure CheckError(ProcName : string; Status : PISC_STATUS;IgnoreErrors : Array of Longint); overload;
-    procedure CheckError(ProcName : string; Status : PISC_STATUS); overload;
+    procedure CheckError(const ProcName : string; Status : PISC_STATUS;IgnoreErrors : Array of Longint); overload;
+    procedure CheckError(const ProcName : string; Status : PISC_STATUS); overload;
     procedure SetParameters(cursor : TSQLCursor; aTransation : TSQLTransaction; AParams : TParams);
     procedure FreeSQLDABuffer(var aSQLDA : PXSQLDA);
     function  IsDialectStored: boolean;
@@ -184,13 +184,13 @@ const
   SQL_NULL = 32767;
   INVALID_DATA = -1;
 
-procedure TIBConnection.CheckError(ProcName : string; Status : PISC_STATUS);
+procedure TIBConnection.CheckError(const ProcName : string; Status : PISC_STATUS);
 
 begin
   CheckError(ProcName,Status,[]);
 end;
 
-procedure TIBConnection.CheckError(ProcName : string; Status : PISC_STATUS; IgnoreErrors : Array of Longint);
+procedure TIBConnection.CheckError(const ProcName : string; Status : PISC_STATUS; IgnoreErrors : Array of Longint);
 var
   i,ErrorCode : longint;
   Msg, SQLState : string;
@@ -263,7 +263,7 @@ begin
   else result := true;
 end;
 
-function TIBConnection.InterpretTransactionParam(S: String; var TPB: AnsiChar;
+function TIBConnection.InterpretTransactionParam(const S: String; var TPB: AnsiChar;
   out AValue: String): Boolean;
 
 Const
@@ -280,27 +280,28 @@ Const
 
 Var
   P : Integer;
-
+  LS : String;
 begin
   TPB:=#0;
   Result:=False;
-  P:=Pos('=',S);
+  LS:=S;
+  P:=Pos('=',LS);
   If P<>0 then
     begin
-    AValue:=Copy(S,P+1,Length(S)-P);
-    S:=Copy(S,1,P-1);
+    AValue:=Copy(LS,P+1,Length(LS)-P);
+    LS:=Copy(LS,1,P-1);
     end;
-  S:=LowerCase(S);
-  P:=Pos(Prefix,S);
+  LS:=LowerCase(LS);
+  P:=Pos(Prefix,LS);
   if P<>0 then
-    Delete(S,1,P+PrefixLen-1);
-  Result:=(Copy(S,1,7)='version') and (Length(S)=8);
+    Delete(LS,1,P+PrefixLen-1);
+  Result:=(Copy(LS,1,7)='version') and (Length(LS)=8);
   if Result then
-    TPB:=S[8]
+    TPB:=LS[8]
   else
     begin
     P:=MaxParam;
-    While (P>0) and (S<>TPBNames[P]) do
+    While (P>0) and (LS<>TPBNames[P]) do
       Dec(P);
     Result:=P>0;
     if Result then

+ 2 - 2
packages/fcl-db/src/sqldb/mssql/mssqlconn.pp

@@ -184,7 +184,7 @@ type
   protected
     FRowsAffected: integer;
     function ReplaceParams(AParams: TParams): string; // replaces parameters placeholders $1,$2,..$n in FQuery with supplied values in AParams
-    procedure Prepare(Buf: string; AParams: TParams);
+    procedure Prepare(const Buf: string; AParams: TParams);
     procedure Execute(AParams: TParams);
     function Fetch: boolean;
     procedure Put(column: integer; out s: string); overload;
@@ -222,7 +222,7 @@ end;
 
 { TDBLibCursor }
 
-procedure TDBLibCursor.Prepare(Buf: string; AParams: TParams);
+procedure TDBLibCursor.Prepare(const Buf: string; AParams: TParams);
 var
   ParamBinding : TParamBinding;
 begin

+ 1 - 1
packages/fcl-db/src/sqldb/mysql/mysqlconn.inc

@@ -388,7 +388,7 @@ Resourcestring
   SErrVersionMismatch = '%s can not work with the installed MySQL client version: Expected (%s), got (%s).';
   SErrSettingParameter = 'Error setting parameter "%s"';
 
-Procedure MySQLError(R : PMySQL; Msg: String; Comp : TComponent);
+Procedure MySQLError(R : PMySQL; const Msg: String; Comp : TComponent);
 
 Var
   MySQLError, MySQLState : String;

+ 5 - 5
packages/fcl-db/src/sqldb/odbc/odbcconn.pas

@@ -104,8 +104,8 @@ type
     function LoadField(cursor:TSQLCursor; FieldDef:TFieldDef; buffer:pointer; out CreateBlob : boolean):boolean; override;
     procedure LoadBlobIntoBuffer(FieldDef: TFieldDef;ABlobBuf: PBufBlobField; cursor: TSQLCursor; ATransaction : TSQLTransaction); override;
     procedure FreeFldBuffers(cursor:TSQLCursor); override;
-    procedure CheckResult(LastReturnCode:SQLRETURN; HandleType:SQLSMALLINT; AHandle: SQLHANDLE; ErrorMsg: string; const FmtArgs:array of const);
-    procedure CheckResult(LastReturnCode:SQLRETURN; HandleType:SQLSMALLINT; AHandle: SQLHANDLE; ErrorMsg: string);
+    procedure CheckResult(LastReturnCode:SQLRETURN; HandleType:SQLSMALLINT; AHandle: SQLHANDLE; const ErrorMsg: string; const FmtArgs:array of const);
+    procedure CheckResult(LastReturnCode:SQLRETURN; HandleType:SQLSMALLINT; AHandle: SQLHANDLE; const ErrorMsg: string);
     // - UpdateIndexDefs
     procedure UpdateIndexDefs(IndexDefs:TIndexDefs; TableName:string); override;
     // - Schema info
@@ -179,7 +179,7 @@ begin
   end;
 end;
 
-procedure ODBCCheckResult(LastReturnCode:SQLRETURN; HandleType:SQLSMALLINT; AHandle: SQLHANDLE; const ConnectionCodePage: TSystemCodePage; ErrorMsg: string; const FmtArgs:array of const);
+procedure ODBCCheckResult(LastReturnCode:SQLRETURN; HandleType:SQLSMALLINT; AHandle: SQLHANDLE; const ConnectionCodePage: TSystemCodePage; const ErrorMsg: string; const FmtArgs:array of const);
 
   // check return value from SQLGetDiagField/Rec function itself
   procedure CheckSQLGetDiagResult(const Res:SQLRETURN);
@@ -258,12 +258,12 @@ end;
 
 { TODBCConnection }
 
-procedure TODBCConnection.CheckResult(LastReturnCode:SQLRETURN; HandleType:SQLSMALLINT; AHandle: SQLHANDLE; ErrorMsg: string; const FmtArgs:array of const);
+procedure TODBCConnection.CheckResult(LastReturnCode:SQLRETURN; HandleType:SQLSMALLINT; AHandle: SQLHANDLE; const ErrorMsg: string; const FmtArgs:array of const);
 begin
   ODBCCheckResult(LastReturnCode,HandleType,AHandle,CodePage,ErrorMsg,FmtArgs);
 end;
 
-procedure TODBCConnection.CheckResult(LastReturnCode:SQLRETURN; HandleType:SQLSMALLINT; AHandle: SQLHANDLE; ErrorMsg: string);
+procedure TODBCConnection.CheckResult(LastReturnCode:SQLRETURN; HandleType:SQLSMALLINT; AHandle: SQLHANDLE; const ErrorMsg: string);
 begin
   CheckResult(LastReturnCode, HandleType, AHandle, ErrorMsg, []);
 end;

+ 25 - 19
packages/fcl-db/src/sqldb/sqldb.pp

@@ -119,7 +119,7 @@ Type
       ErrorCode: integer;
       SQLState : string;
       constructor CreateFmt(const Fmt: string; const Args: array of const;
-                            Comp : TComponent; AErrorCode: integer; ASQLState: string); overload;
+                            Comp : TComponent; AErrorCode: integer; const ASQLState: string); overload;
   end;
 
   { TSQLDBFieldDef }
@@ -375,7 +375,7 @@ type
     FDoUnPrepare : Boolean;
     FDataLink : TDataLink;
     FRowsAffected : TRowsCount;
-    function ExpandMacros( OrigSQL: String): String;
+    function ExpandMacros(const OrigSQL: String): String;
     procedure SetDatabase(AValue: TSQLConnection);
     procedure SetMacroChar(AValue: Char);
     procedure SetMacroCheck(AValue: Boolean);
@@ -540,7 +540,7 @@ type
     procedure OnChangeModifySQL(Sender : TObject);
     procedure Execute;
     procedure ApplyFilter;
-    Function AddFilter(SQLstr : string) : string;
+    Function AddFilter(const SQLstr : string) : string;
   protected
     procedure OpenCursor(InfoQuery: Boolean); override;
     function CreateSQLStatement(aOwner: TComponent): TCustomSQLStatement; virtual;
@@ -831,8 +831,8 @@ Var
 
 Procedure RegisterConnection(Def : TConnectionDefClass);
 Procedure UnRegisterConnection(Def : TConnectionDefClass);
-Procedure UnRegisterConnection(ConnectionName : String);
-Function GetConnectionDef(ConnectorName : String) : TConnectionDef;
+Procedure UnRegisterConnection(const ConnectionName : String);
+Function GetConnectionDef(const ConnectorName : String) : TConnectionDef;
 Procedure GetConnectionList(List : TSTrings);
 
 const DefaultSQLFormatSettings : TFormatSettings = (
@@ -899,7 +899,7 @@ end;
 { ESQLDatabaseError }
 
 constructor ESQLDatabaseError.CreateFmt(const Fmt: string; const Args: array of const;
-  Comp: TComponent; AErrorCode: integer; ASQLState: string);
+  Comp: TComponent; AErrorCode: integer; const ASQLState: string);
 const CompNameFmt='%s : %s';
 var Msg: string;
 begin
@@ -1220,7 +1220,7 @@ begin
      end;
 end;
 
-function TCustomSQLStatement.ExpandMacros( OrigSQL : String ) : String;
+function TCustomSQLStatement.ExpandMacros(const OrigSQL : String ) : String;
 
 Const
   Terminators = SQLDelimiterCharacters+
@@ -1402,11 +1402,13 @@ begin
 end;
 
 function TSQLConnection.StrToStatementType(s : string) : TStatementType;
-var T : TStatementType;
+var 
+  T : TStatementType;
+  LS : String;
 begin
-  S:=Lowercase(s);
+  LS:=Lowercase(s);
   for T:=stSelect to stRollback do
-    if (S=StatementTokens[T]) then
+    if (LS=StatementTokens[T]) then
       Exit(T);
   Result:=stUnknown;
 end;
@@ -2813,22 +2815,26 @@ begin
     Result := False;
 end;
 
-function TCustomSQLQuery.AddFilter(SQLstr: string): string;
+function TCustomSQLQuery.AddFilter(const SQLstr: string): string;
+
+Var
+  Res : String;
 
 begin
+  Res:=SQLStr;
   if (FWhereStartPos > 0) and (FWhereStopPos > 0) then
     begin
-    system.insert('(',SQLstr,FWhereStartPos+1);
-    system.insert(')',SQLstr,FWhereStopPos+1);
+    system.insert('(',Res,FWhereStartPos+1);
+    system.insert(')',Res,FWhereStopPos+1);
     end;
 
   if FWhereStartPos = 0 then
-    SQLstr := SQLstr + ' where (' + ServerFilter + ')'
+    Res := Res + ' where (' + ServerFilter + ')'
   else if FWhereStopPos > 0 then
-    system.insert(' and ('+ServerFilter+') ',SQLstr,FWhereStopPos+2)
+    system.insert(' and ('+ServerFilter+') ',res,FWhereStopPos+2)
   else
-    system.insert(' where ('+ServerFilter+') ',SQLstr,FWhereStartPos);
-  Result := SQLstr;
+    system.insert(' where ('+ServerFilter+') ',res,FWhereStartPos);
+  Result := res;
 end;
 
 procedure TCustomSQLQuery.OpenCursor(InfoQuery: Boolean);
@@ -3703,7 +3709,7 @@ begin
 end;
 
 
-Function GetConnectionDef(ConnectorName : String) : TConnectionDef;
+Function GetConnectionDef(const ConnectorName : String) : TConnectionDef;
 
 Var
   I : Integer;
@@ -3739,7 +3745,7 @@ begin
   UnRegisterConnection(Def.TypeName);
 end;
 
-procedure UnRegisterConnection(ConnectionName: String);
+procedure UnRegisterConnection(const ConnectionName: String);
 
 Var
   I : Integer;

+ 4 - 4
packages/fcl-db/src/sqldb/sqldbini.pp

@@ -38,13 +38,13 @@ Type
     Procedure ClearValues;
   Public
     Procedure LoadFromIni(Const aIni: TCustomIniFile; aOptions : TSQLDBIniOptions = []); overload;
-    Procedure LoadFromIni(Const aIni: TCustomIniFile; ASection : String; aOptions : TSQLDBIniOptions); overload;
+    Procedure LoadFromIni(Const aIni: TCustomIniFile; const ASection : String; aOptions : TSQLDBIniOptions); overload;
     Procedure LoadFromFile(Const aFileName : String; aOptions : TSQLDBIniOptions = []); overload;
     Procedure LoadFromFile(Const aFileName : String; Const ASection : String; aOptions : TSQLDBIniOptions); overload;
     Procedure SaveToFile(Const aFileName : String; aOptions : TSQLDBIniOptions = []);overload;
     Procedure SaveToFile(Const aFileName : String; Const ASection : String; aOptions : TSQLDBIniOptions = []);overload;
     Procedure SaveToIni(Const aIni: TCustomIniFile; aOptions : TSQLDBIniOptions = []); overload;
-    Procedure SaveToIni(Const aIni: TCustomIniFile; ASection : String; aOptions : TSQLDBIniOptions); overload;
+    Procedure SaveToIni(Const aIni: TCustomIniFile; const ASection : String; aOptions : TSQLDBIniOptions); overload;
   end;
 
 Var
@@ -82,7 +82,7 @@ Const
                      = (keyHost,KeyDatabaseName,KeyUserName,KeyPassword,KeyPort,keyParams,keyCharSet,keyRole);
   ParamSeps = [',',';',' '];
 
-procedure TSQLDBIniHelper.LoadFromIni(const aIni: TCustomIniFile; ASection: String; aOptions: TSQLDBIniOptions);
+procedure TSQLDBIniHelper.LoadFromIni(const aIni: TCustomIniFile; const ASection: String; aOptions: TSQLDBIniOptions);
 
 Var
   M,N,P : String;
@@ -183,7 +183,7 @@ begin
   SaveToIni(aIni,DefaultSection,aOptions);
 end;
 
-procedure TSQLDBIniHelper.SaveToIni(const aIni: TCustomIniFile; ASection: String; aOptions: TSQLDBIniOptions);
+procedure TSQLDBIniHelper.SaveToIni(const aIni: TCustomIniFile; const ASection: String; aOptions: TSQLDBIniOptions);
 Var
   M,N,P : String;
   I : integer;

+ 1 - 1
packages/fcl-db/src/sqldb/sqldblib.pp

@@ -70,7 +70,7 @@ begin
     SetDefaultLibraryName;
 end;
 
-procedure TSQLDBLibraryLoader.SetEnabled(AValue: Boolean);
+procedure TSQLDBLibraryLoader.SetEnabled(aValue: Boolean);
 begin
   if FEnabled=AValue then Exit;
   if (csLoading in ComponentState) then

+ 10 - 10
packages/fcl-db/src/sqldb/sqlite/sqlite3backup.pas

@@ -61,13 +61,13 @@ type
     //Warning: don't use the destination TSQLite3Connection (the handle) for anything else while doing a backup.
     //It can corrupt the database and even cause a mutex deadlock.
     function Backup(Source,Destination:TSQLite3Connection;LockUntilFinished:boolean=true;
-         SourceDBName:string='main';DestinationDBName:string='main'):boolean;
+         const SourceDBName:string='main';const DestinationDBName:string='main'):boolean;
     //Backup a database to file
-    function Backup(Source:TSQLite3Connection;FileName:string;LockUntilFinished:boolean=true;
-         SourceDBName:string='main'):boolean;
+    function Backup(Source:TSQLite3Connection;const FileName:string;LockUntilFinished:boolean=true;
+         const SourceDBName:string='main'):boolean;
     //Restore a database from file
-    function Restore(FileName:string;Destination:TSQLite3Connection;LockUntilFinished:boolean=true;
-         DestinationDBName:string='main'):boolean;
+    function Restore(const FileName:string;Destination:TSQLite3Connection;LockUntilFinished:boolean=true;
+         const DestinationDBName:string='main'):boolean;
   published
     //Delay between backup steps in ms. Default:100ms. Only used when LockUntilFinished=false
     property LockReleaseTime:integer read FLockReleaseTime write FLockReleaseTime;
@@ -91,7 +91,7 @@ begin
 end;
 
 function TSQLite3Backup.Backup(Source, Destination: TSQLite3Connection;
-  LockUntilFinished: boolean; SourceDBName: string; DestinationDBName: string
+  LockUntilFinished: boolean; const SourceDBName: string; const DestinationDBName: string
   ): boolean;
 var
   pBackup:psqlite3backup;
@@ -128,8 +128,8 @@ begin
      FErrorMessage:=strpas(sqlite3_errmsg(Destination.Handle));
 end;
 
-function TSQLite3Backup.Backup(Source: TSQLite3Connection; FileName: string;
-  LockUntilFinished: boolean; SourceDBName: string): boolean;
+function TSQLite3Backup.Backup(Source: TSQLite3Connection; const FileName: string;
+  LockUntilFinished: boolean; const SourceDBName: string): boolean;
 var conn:TSQLite3Connection;
 begin
   conn:=TSQLite3Connection.Create(nil);
@@ -142,9 +142,9 @@ begin
   end;
 end;
 
-function TSQLite3Backup.Restore(FileName: string;
+function TSQLite3Backup.Restore(const FileName: string;
   Destination: TSQLite3Connection; LockUntilFinished: boolean;
-  DestinationDBName: string): boolean;
+  const DestinationDBName: string): boolean;
 var conn:TSQLite3Connection;
 begin
   conn:=TSQLite3Connection.Create(nil);

+ 9 - 5
packages/fcl-db/src/sqldb/sqlite/sqlite3conn.pp

@@ -170,7 +170,7 @@ type
    fparambinding: array of Integer;
    procedure checkerror(const aerror: integer);
    procedure bindparams(AParams : TParams);
-   Procedure Prepare(Buf : String; AParams : TParams);
+   Procedure Prepare(const Buf : String; AParams : TParams);
    Procedure UnPrepare;
    Procedure Execute;
    Function Fetch : Boolean;
@@ -257,14 +257,18 @@ begin
     end;   
 end;
 
-Procedure TSQLite3Cursor.Prepare(Buf : String; AParams : TParams);
+Procedure TSQLite3Cursor.Prepare(const Buf : String; AParams : TParams);
+
+var
+  S : string;
 
 begin
+  S:=Buf;
   if assigned(AParams) and (AParams.Count > 0) then
-    Buf := AParams.ParseSQL(Buf,false,false,false,psInterbase,fparambinding);
+    S := AParams.ParseSQL(S,false,false,false,psInterbase,fparambinding);
   if (detActualSQL in fconnection.LogEvents) then
-    fconnection.Log(detActualSQL,Buf);
-  checkerror(sqlite3_prepare(fhandle,pchar(Buf),length(Buf),@fstatement,@ftail));
+    fconnection.Log(detActualSQL,S);
+  checkerror(sqlite3_prepare(fhandle,pchar(S),length(S),@fstatement,@ftail));
   FPrepared:=True;
 end;