From 91eb23f044911477f615e7e25e1425b667c3f1fa Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 12 Apr 2013 21:28:12 +0000 Subject: pascal sources sync git-svn-id: http://svn.miranda-ng.org/main/trunk@4435 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Utils.pas/common.pas | 90 +++++++++++++++++++++++++++++------------ plugins/Utils.pas/mApiCardM.pas | 2 +- 2 files changed, 66 insertions(+), 26 deletions(-) (limited to 'plugins/Utils.pas') diff --git a/plugins/Utils.pas/common.pas b/plugins/Utils.pas/common.pas index cd321cbcb7..d36ecad588 100644 --- a/plugins/Utils.pas/common.pas +++ b/plugins/Utils.pas/common.pas @@ -90,6 +90,8 @@ procedure mFreeMem(var ptr); function mReallocMem(var dst; size:integer):pointer; // String processing +function FormatStrW(fmt:pWideChar; arr:array of pWideChar):pWideChar; + function WideToCombo(src:PWideChar;var dst;cp:integer=CP_ACP):integer; function ChangeUnicode(str:PWideChar):PWideChar; @@ -124,8 +126,8 @@ function StrReplace (src,SubStr,NewStr:PAnsiChar):PAnsiChar; function StrReplaceW(src,SubStr,NewStr:pWideChar):PWideChar; function CharReplace (dst:pAnsiChar;old,new:AnsiChar):PAnsiChar; function CharReplaceW(dst:pWideChar;old,new:WideChar):PWideChar; -function StrCmp (a,b:PAnsiChar;n:cardinal=0):integer; -function StrCmpW(a,b:PWideChar;n:cardinal=0):integer; +function StrCmp (a,b:PAnsiChar;n:integer=0):integer; +function StrCmpW(a,b:PWideChar;n:integer=0):integer; function StrEnd (const a:PAnsiChar):PAnsiChar; function StrEndW(const a:PWideChar):PWideChar; function StrScan (src:PAnsiChar;c:AnsiChar):PAnsiChar; @@ -904,6 +906,8 @@ begin result:=dst; end; +//----- Memory work ----- + procedure FillWord(var buf;count:cardinal;value:word); register; {$IFNDEF WIN64}assembler; { @@ -968,6 +972,7 @@ asm POP ESI end; } + {$IFNDEF WIN64} // Delphi 2009 realization function CompareMem(P1, P2: Pointer; Length: Integer): Boolean; assembler; @@ -1035,10 +1040,6 @@ asm end; {$ELSE} function CompareMem(P1, P2: Pointer; Length: Integer): Boolean; - {$IFNDEF COMPILER_16_UP} -begin - result:=CompareByte(P1,P2,Length)=0; - {$ELSE} var i:integer; begin @@ -1053,26 +1054,9 @@ begin inc(pbyte(p2)); end; result:=true; - {$ENDIF} end; {$ENDIF} -function Min(a,b:integer):integer; -begin - if a>b then - result:=b - else - result:=a; -end; - -function Max(a,b:integer):integer; -begin - if ab then + result:=b + else + result:=a; +end; + +function Max(a,b:integer):integer; +begin + if anil) and (buf^<>#0) then @@ -1198,6 +1198,46 @@ begin end; end; +function FormatStrW(fmt:pWideChar; arr:array of pWideChar):pWideChar; +var + i,len:integer; + pc:pWideChar; + number:integer; +begin + result:=nil; + if (fmt=nil) or (fmt^=#0) then + exit; + + // calculate length + len:=StrLenW(fmt); // -2*Length(arr) + for i:=0 to HIGH(arr) do + inc(len,StrLenW(arr[i])); + + // format + mGetMem(result,(len+1)*SizeOf(WideChar)); + pc:=result; + number:=0; + while fmt^<>#0 do + begin + if (fmt^='%') and ((fmt+1)^='s') then + begin + if number<=HIGH(arr) then + begin + pc:=StrCopyEW(pc,arr[number]); + inc(number); + end; + inc(fmt,2); + end + else + begin + pc^:=fmt^; + inc(pc); + inc(fmt); + end; + end; + pc^:=#0; +end; + // ----- base string functions ----- function StrDup(var dst:PAnsiChar;src:PAnsiChar;len:cardinal=0):PAnsiChar; var @@ -1510,7 +1550,7 @@ begin end; end; -function StrCmp(a,b:PAnsiChar;n:cardinal=0):integer; // CompareString +function StrCmp(a,b:PAnsiChar;n:integer=0):integer; // CompareString begin result:=0; if (a=nil) and (b=nil) then @@ -1530,7 +1570,7 @@ begin until n=0; end; -function StrCmpW(a,b:PWideChar;n:cardinal=0):integer; +function StrCmpW(a,b:PWideChar;n:integer=0):integer; begin result:=0; if (a=nil) and (b=nil) then diff --git a/plugins/Utils.pas/mApiCardM.pas b/plugins/Utils.pas/mApiCardM.pas index 6002ee2dbc..41ce4e2aa3 100644 --- a/plugins/Utils.pas/mApiCardM.pas +++ b/plugins/Utils.pas/mApiCardM.pas @@ -384,7 +384,7 @@ begin title:='Miranda event help'; note :=''; end; - SendMessageW(HelpWindow,WM_SETTEXT,0,LPARAM(title)); + SendMessageW(HelpWindow,WM_SETTEXT,0,LPARAM(TranslateW(title))); SendMessageW(GetDlgItem(HelpWindow,IDC_HLP_NOTE),WM_SETTEXT,0,LPARAM(TranslateW(Note))); end; -- cgit v1.2.3