From dd38ba4f6f5356c221be5f0095a1d02256fd0b4e Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Thu, 3 Jun 2021 08:32:06 +0200 Subject: [PATCH] Code cosmetic: rename implodestr() to Implode() --- source/apphelpers.pas | 7 +++---- source/connections.pas | 4 ++-- source/createdatabase.pas | 2 +- source/dbconnection.pas | 12 ++++++------ source/exportgrid.pas | 2 +- source/main.pas | 22 +++++++++++----------- source/routine_editor.pas | 2 +- source/table_editor.pas | 8 ++++---- source/tabletools.pas | 2 +- source/usermanager.pas | 4 ++-- 10 files changed, 32 insertions(+), 33 deletions(-) diff --git a/source/apphelpers.pas b/source/apphelpers.pas index ea1d0212..80a0ee6d 100644 --- a/source/apphelpers.pas +++ b/source/apphelpers.pas @@ -280,7 +280,7 @@ type {$I const.inc} - function implodestr(seperator: String; a: TStrings) :String; + function Implode(Separator: String; a: TStrings): String; function Explode(Separator, Text: String) :TStringList; procedure ExplodeQuotedList(Text: String; var List: TStringList); function StrEllipsis(const S: String; MaxLen: Integer; FromLeft: Boolean=True): String; @@ -427,7 +427,7 @@ end; @param a TStringList Containing strings @return string } -function implodestr(seperator: String; a: TStrings) :String; +function Implode(Separator: String; a: TStrings): String; var i : Integer; begin @@ -436,12 +436,11 @@ begin begin Result := Result + a[i]; if i < a.Count-1 then - Result := Result + seperator; + Result := Result + Separator; end; end; - function Explode(Separator, Text: String): TStringList; var i: Integer; diff --git a/source/connections.pas b/source/connections.pas index 38cf9dff..30db736b 100644 --- a/source/connections.pas +++ b/source/connections.pas @@ -1264,7 +1264,7 @@ begin Databases.Add(Item.Caption); end; SelStart := editDatabases.SelStart; - editDatabases.Text := implodestr(';', Databases); + editDatabases.Text := Implode(';', Databases); editDatabases.SelStart := SelStart; end; @@ -1555,7 +1555,7 @@ begin if ExtractFilePath(FileNames[i]) = ExtractFilePath(Application.ExeName) then FileNames[i] := ExtractFileName(FileNames[i]); end; - Edit.Text := implodestr(DELIM, FileNames); + Edit.Text := Implode(DELIM, FileNames); Modification(Selector); end; Selector.Free; diff --git a/source/createdatabase.pas b/source/createdatabase.pas index 8f581fd1..4051ae9e 100644 --- a/source/createdatabase.pas +++ b/source/createdatabase.pas @@ -222,7 +222,7 @@ begin else AllDatabases.Add(editDBname.Text); AppSettings.SessionPath := FConnection.Parameters.SessionPath; - FConnection.Parameters.AllDatabasesStr := ImplodeStr(';', AllDatabases); + FConnection.Parameters.AllDatabasesStr := Implode(';', AllDatabases); AppSettings.WriteString(asDatabases, FConnection.Parameters.AllDatabasesStr); end; end; diff --git a/source/dbconnection.pas b/source/dbconnection.pas index 4a3853b2..0c403990 100644 --- a/source/dbconnection.pas +++ b/source/dbconnection.pas @@ -1951,7 +1951,7 @@ begin // Move more exact (longer) types to the beginning TypesSorted := Explode('|', Types); TypesSorted.CustomSort(StringListCompareByLength); - Types := ImplodeStr('|', TypesSorted); + Types := Implode('|', TypesSorted); TypesSorted.Free; end; @@ -3597,7 +3597,7 @@ begin else Rows := GetCol('EXEC sp_helptext '+EscapeString(Obj.Database+'.'+Obj.Name)); // Do not use Rows.Text, as the rows already include a trailing linefeed - Result := implodestr('', Rows); + Result := Implode('', Rows); Rows.Free; end; ngPgSQL: begin @@ -3624,7 +3624,7 @@ begin DataType := ''; Arguments.Add(ArgNames[i] + ' ' + DataType); end; - Result := Result + '(' + implodestr(', ', Arguments) + ') '+ + Result := Result + '(' + Implode(', ', Arguments) + ') '+ 'RETURNS '+GetDatatypeByNativeType(MakeInt(ProcDetails.Col('prorettype'))).Name+' '+ 'AS $$ '+ProcDetails.Col('prosrc')+' $$' // TODO: 'LANGUAGE SQL IMMUTABLE STRICT' @@ -3649,7 +3649,7 @@ begin Rows := GetCol('EXEC sp_helptext '+EscapeString(Obj.Schema+'.'+Obj.Name)) else Rows := GetCol('EXEC sp_helptext '+EscapeString(Obj.Database+'.'+Obj.Name)); - Result := implodestr('', Rows); + Result := Implode('', Rows); Rows.Free; end; else begin @@ -3701,7 +3701,7 @@ begin end; end; if Queries.Count > 0 then try - PrefetchResults(implodestr(';', Queries)); + PrefetchResults(Implode(';', Queries)); except on E:EDbError do; end; @@ -9253,7 +9253,7 @@ begin s.AddPair('Virtuality', Virtuality); s.AddPair('Status', Integer(FStatus).ToString); - Result := implodestr(DELIMITER, s); + Result := Implode(DELIMITER, s); s.Free; Result := StringReplace(Result, #13, CHR13REPLACEMENT, [rfReplaceAll]); Result := StringReplace(Result, #10, CHR10REPLACEMENT, [rfReplaceAll]); diff --git a/source/exportgrid.pas b/source/exportgrid.pas index 01a47cb4..078a54dd 100644 --- a/source/exportgrid.pas +++ b/source/exportgrid.pas @@ -164,7 +164,7 @@ begin AppSettings.WriteBool(asGridExportOutputCopy, radioOutputCopyToClipboard.Checked); AppSettings.WriteBool(asGridExportOutputFile, radioOutputFile.Checked); AppSettings.WriteString(asGridExportFilename, editFilename.Text); - AppSettings.WriteString(asGridExportRecentFiles, ImplodeStr(DELIM, FRecentFiles)); + AppSettings.WriteString(asGridExportRecentFiles, Implode(DELIM, FRecentFiles)); AppSettings.WriteInt(asGridExportEncoding, comboEncoding.ItemIndex); AppSettings.WriteInt(asGridExportFormat, grpFormat.ItemIndex); AppSettings.WriteInt(asGridExportSelection, grpSelection.ItemIndex); diff --git a/source/main.pas b/source/main.pas index 4649f0cc..e97a9e6c 100644 --- a/source/main.pas +++ b/source/main.pas @@ -1650,7 +1650,7 @@ begin OpenSessions := TStringList.Create; for Connection in Connections do OpenSessions.Add(Connection.Parameters.SessionPath); - AppSettings.WriteString(asLastSessions, ImplodeStr(DELIM, OpenSessions)); + AppSettings.WriteString(asLastSessions, Implode(DELIM, OpenSessions)); OpenSessions.Free; if Assigned(ActiveConnection) then AppSettings.WriteString(asLastActiveSession, ActiveConnection.Parameters.SessionPath); @@ -3995,7 +3995,7 @@ begin Dialog.Free; end else begin msgtext := f_('One or more of the selected files are larger than %s:', [FormatByteNumber(RunFileSize, 0)]) + CRLF + - ImplodeStr(CRLF, PopupFileList) + CRLF + CRLF + + Implode(CRLF, PopupFileList) + CRLF + CRLF + _('Just run these files to avoid loading them into the query-editor (= memory)?') + CRLF + CRLF + _('Press') + CRLF + _(' [Yes] to run file(s) without loading it into the editor') + CRLF + @@ -4556,9 +4556,9 @@ begin ParamValues := ''; case Obj.Connection.Parameters.NetTypeGroup of ngMySQL, ngPgSQL: - ParamValues := '(' + ImplodeStr(', ', Params) + ')'; + ParamValues := '(' + Implode(', ', Params) + ')'; ngMSSQL: - ParamValues := ' ' + ImplodeStr(' ', Params); + ParamValues := ' ' + Implode(' ', Params); else raise Exception.CreateFmt(_(MsgUnhandledNetType), [Integer(Obj.Connection.Parameters.NetType)]); end; @@ -5450,7 +5450,7 @@ begin end; end; AppSettings.SessionPath := Conn.Parameters.SessionPath; - AppSettings.WriteString(asHost, implodestr(DELIM, OldFiles)); + AppSettings.WriteString(asHost, Implode(DELIM, OldFiles)); RefreshTree; except on E:EDbError do begin @@ -5488,7 +5488,7 @@ begin end; end; AppSettings.SessionPath := Obj.Connection.Parameters.SessionPath; - AppSettings.WriteString(asHost, implodestr(DELIM, OldFiles)); + AppSettings.WriteString(asHost, Implode(DELIM, OldFiles)); RefreshTree; except on E:EDbError do begin @@ -12545,13 +12545,13 @@ begin if MenuItem = menuQueryHelpersGenerateSelect then begin - sql := 'SELECT '+ImplodeStr(', ', ColumnNames)+CRLF+ + sql := 'SELECT '+Implode(', ', ColumnNames)+CRLF+ #9'FROM '+ActiveDbObj.QuotedName(False); end else if MenuItem = menuQueryHelpersGenerateInsert then begin sql := 'INSERT INTO '+ActiveDbObj.QuotedName(False)+CRLF+ - #9'('+ImplodeStr(', ', ColumnNames)+')'+CRLF+ - #9'VALUES ('+ImplodeStr(', ', DefaultValues)+')'; + #9'('+Implode(', ', ColumnNames)+')'+CRLF+ + #9'VALUES ('+Implode(', ', DefaultValues)+')'; end else if MenuItem = menuQueryHelpersGenerateUpdate then begin sql := 'UPDATE '+ActiveDbObj.QuotedName(False)+CRLF+#9'SET'+CRLF; @@ -13720,7 +13720,7 @@ begin else Sel[i] := '-- '+Sel[i]; end; - Editor.SelText := ImplodeStr(CRLF, Sel); + Editor.SelText := Implode(CRLF, Sel); end; if Assigned(Editor.OnChange) then Editor.OnChange(Editor); @@ -14464,7 +14464,7 @@ begin for Param in Self do begin Lines.Add(Param.Name + FPairDelimiter + Param.Value); end; - Result := implodestr(FItemDelimiter, Lines); + Result := Implode(FItemDelimiter, Lines); Lines.Free; end; diff --git a/source/routine_editor.pas b/source/routine_editor.pas index 30566ea2..a8840aba 100644 --- a/source/routine_editor.pas +++ b/source/routine_editor.pas @@ -545,7 +545,7 @@ begin Params.Add(tmp); end; if Params.Count > 0 then - Result := Result + CRLF + #9 + implodestr(','+CRLF+#9, Params) + CRLF; + Result := Result + CRLF + #9 + Implode(','+CRLF+#9, Params) + CRLF; Result := Result + ')'+CRLF; if comboReturns.Enabled then Result := Result + 'RETURNS '+comboReturns.Text+CRLF; diff --git a/source/table_editor.pas b/source/table_editor.pas index 2445a6cc..34e87aff 100644 --- a/source/table_editor.pas +++ b/source/table_editor.pas @@ -558,7 +558,7 @@ var procedure FinishSpecs; begin if Specs.Count > 0 then begin - SQL := SQL + Trim('ALTER TABLE '+DBObject.QuotedName + CRLF + #9 + ImplodeStr(',' + CRLF + #9, Specs)) + ';' + CRLF; + SQL := SQL + Trim('ALTER TABLE '+DBObject.QuotedName + CRLF + #9 + Implode(',' + CRLF + #9, Specs)) + ';' + CRLF; Specs.Clear; end; end; @@ -2431,7 +2431,7 @@ begin end; end; TblKey := TTableKey.Create(DBObject.Connection); - TblKey.Name := ImplodeStr('_', NewParts); + TblKey.Name := Implode('_', NewParts); TblKey.IndexType := NewType; TblKey.Added := True; TblKey.Columns := NewParts; @@ -2633,9 +2633,9 @@ begin Key := FForeignKeys[Node.Index]; case Column of 0: CellText := Key.KeyName; - 1: CellText := ImplodeStr(',', Key.Columns); + 1: CellText := Implode(',', Key.Columns); 2: CellText := Key.ReferenceTable; - 3: CellText := ImplodeStr(',', Key.ForeignColumns); + 3: CellText := Implode(',', Key.ForeignColumns); 4: begin CellText := Key.OnUpdate; // Both ON UPDATE + DELETE default to "RESTRICT", see http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html diff --git a/source/tabletools.pas b/source/tabletools.pas index 2836796d..02270b55 100644 --- a/source/tabletools.pas +++ b/source/tabletools.pas @@ -1903,7 +1903,7 @@ begin LogRow := FResults.Last; if Specs.Count > 0 then begin - DBObj.Connection.Query('ALTER TABLE ' + DBObj.QuotedDatabase + '.' + DBObj.QuotedName + ' ' + ImplodeStr(', ', Specs)); + DBObj.Connection.Query('ALTER TABLE ' + DBObj.QuotedDatabase + '.' + DBObj.QuotedName + ' ' + Implode(', ', Specs)); LogRow[2] := _('Done'); LogRow[3] := _('Success'); end else begin diff --git a/source/usermanager.pas b/source/usermanager.pas index ffbd13e1..78d4afbf 100644 --- a/source/usermanager.pas +++ b/source/usermanager.pas @@ -643,7 +643,7 @@ begin P.OrgPrivs.AddStrings(P.AllPrivileges); P.OrgPrivs.Delete(P.OrgPrivs.IndexOf('GRANT')); end else begin - rxTemp.Expression := '\b('+ImplodeStr('|', AllPnames)+')(\s+\(([^\)]+)\))?,'; + rxTemp.Expression := '\b('+Implode('|', AllPnames)+')(\s+\(([^\)]+)\))?,'; if rxTemp.Exec(rxGrant.Match[1]+',') then while True do begin if rxTemp.Match[3] = '' then P.OrgPrivs.Add(rxTemp.Match[1]) @@ -1318,7 +1318,7 @@ begin WithClauses.Add('MAX_USER_CONNECTIONS '+IntToStr(udMaxUserConnections.Position)); end; if WithClauses.Count > 0 then - Grant := Grant + ' WITH ' + ImplodeStr(' ', WithClauses); + Grant := Grant + ' WITH ' + Implode(' ', WithClauses); if P.Added or (P.AddedPrivs.Count > 0) or (WithClauses.Count > 0) or (RequireClause <> '') then FConnection.Query(Grant);