Kill all users of StrUtils.

This commit is contained in:
rosenfield.albert
2008-06-17 12:44:17 +00:00
parent c15dcc0c3a
commit 03ca9c92f4
2 changed files with 24 additions and 17 deletions

View File

@ -10,7 +10,7 @@ interface
uses Classes, SysUtils, Graphics, db, clipbrd, dialogs,
forms, controls, ShellApi, checklst, windows, ZDataset, ZAbstractDataset,
shlobj, ActiveX, StrUtils, WideStrUtils, VirtualTrees, SynRegExpr, Messages, WideStrings;
shlobj, ActiveX, WideStrUtils, VirtualTrees, SynRegExpr, Messages, WideStrings;
type
@ -80,7 +80,7 @@ type
function getFirstWord( text: String ): String;
function ConvertWindowsCodepageToMysqlCharacterSet(codepage: Cardinal): string;
function GetFieldValue( Field: TField ): String;
function LastPos( substr: WideString; str: WideString): Integer;
function LastPos(needle: WideChar; haystack: WideString): Integer;
function ConvertServerVersion( Version: Integer ): String;
function FormatByteNumber( Bytes: Int64; Decimals: Byte = 1 ): String; Overload;
function FormatByteNumber( Bytes: String; Decimals: Byte = 1 ): String; Overload;
@ -2021,12 +2021,19 @@ end;
@param string Text
@return Integer Last position
}
function LastPos( substr: WideString; str: WideString): Integer;
function LastPos(needle: WideChar; haystack: WideString): Integer;
var
reverse: WideString;
i, len, w: Integer;
begin
// Reverse string.
len := Length(haystack);
SetLength(reverse, len);
for i := 1 to len do reverse[i] := haystack[len - i + 1];
// Look for needle.
Result := 0;
str := ReverseString( str );
if Pos( substr, str ) > 0 then
Result := Length(str) - Pos( substr, str ) + 1;
w := Pos(needle, reverse);
if w > 0 then Result := len - w + 1;
end;

View File

@ -17,7 +17,7 @@ uses
ActnList, ImgList, Registry, ShellApi, ToolWin, Clipbrd, db, DBCtrls,
SynMemo, synedit, SynEditTypes, ZDataSet, ZSqlProcessor,
HeidiComp, sqlhelp, MysqlQueryThread, Childwin, VirtualTrees, TntDBGrids,
StrUtils, DateUtils, PngImageList, OptimizeTables, View, Usermanager,
DateUtils, PngImageList, OptimizeTables, View, Usermanager,
SelectDBObject;
type
@ -1248,30 +1248,30 @@ begin
paramValue := '';
param := ParamStr(curIdx);
// Example: --user=root --session="My session name" --password
if AnsiStartsStr('--'+paramName, param) then
if Pos('--' + paramName, param) = 1 then
begin
i := Length('--'+paramName) + 1;
i := Length('--' + paramName) + 1;
if param[i] = '=' then
paramValue := MidStr(param, i+1, Length(param)+1);
if (AnsiLeftStr(paramValue, 1) = '"') and (AnsiRightStr(paramValue, 1) = '"') then
paramValue := MidStr(paramValue, 2, Length(paramValue));
paramValue := Copy(param, i + 1, Length(param) - i);
if (Copy(paramValue, 1, 1) = '"') and (Copy(paramValue, Length(paramValue), 1) = '"') then
paramValue := Copy(paramValue, 2, Length(paramValue) - 2);
result := True;
end else if AnsiStartsStr('-'+paramChar, param) then
end else if Pos('-' + paramChar, param) = 1 then
begin
if Length(param) > 2 then
begin
// Example: -uroot -s"My session name"
paramValue := MidStr(param, 3, Length(param)+1);
if (AnsiLeftStr(paramValue, 1) = '"') and (AnsiRightStr(paramValue, 1) = '"') then
paramValue := MidStr(paramValue, 2, Length(paramValue));
paramValue := Copy(param, 3, Length(param) - 2);
if (Copy(paramValue, 1, 1) = '"') and (Copy(paramValue, Length(paramValue), 1) = '"') then
paramValue := Copy(paramValue, 2, Length(paramValue) - 2);
end else
begin
// Example: -u root -s "My session name" -p
nextIdx := curIdx + 1;
if nextIdx <= ParamCount then begin
nextParam := ParamStr(nextIdx);
if not AnsiStartsStr('-', nextParam) then
if not Pos('-', nextParam) = 1 then
paramValue := nextParam;
end;
end;