summaryrefslogtreecommitdiff
path: root/plugins/Utils.pas/common.pas
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-03-10 20:15:02 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-03-10 20:15:02 +0000
commit66a5a3ee980520f1bb690b78e85b6105d0f80347 (patch)
tree6f84f83e07c1af460812090503ec7404cf92b8cd /plugins/Utils.pas/common.pas
parentbd7fe0980cf5974c432b789323a3fe2f68a107d3 (diff)
other pascal merge
git-svn-id: http://svn.miranda-ng.org/main/trunk@3966 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Utils.pas/common.pas')
-rw-r--r--plugins/Utils.pas/common.pas54
1 files changed, 42 insertions, 12 deletions
diff --git a/plugins/Utils.pas/common.pas b/plugins/Utils.pas/common.pas
index 88df058957..cd321cbcb7 100644
--- a/plugins/Utils.pas/common.pas
+++ b/plugins/Utils.pas/common.pas
@@ -183,6 +183,8 @@ function StrToInt(src:pWideChar):int64; overload;
function StrToInt(src:PAnsiChar):int64; overload;
function HexToInt(src:pWideChar;len:cardinal=$FFFF):int64; overload;
function HexToInt(src:PAnsiChar;len:cardinal=$FFFF):int64; overload;
+function NumToInt(src:pWideChar):int64; overload;
+function NumToInt(src:pAnsiChar):int64; overload;
// filename work
function ChangeExt (src,ext:PAnsiChar):PAnsiChar;
@@ -210,7 +212,7 @@ implementation
// Murmur 2.0
function Hash(s:pointer; len:integer{const Seed: LongWord=$9747b28c}): LongWord;
var
- hash: LongWord;
+ lhash: LongWord;
k: LongWord;
tmp,data: pByte;
const
@@ -222,7 +224,7 @@ begin
//The default seed, $9747b28c, is from the original C library
// Initialize the hash to a 'random' value
- hash := {seed xor }len;
+ lhash := {seed xor }len;
// Mix 4 bytes at a time into the hash
data := s;
@@ -235,8 +237,8 @@ begin
k := k xor (k shr r);
k := k*m;
- hash := hash*m;
- hash := hash xor k;
+ lhash := lhash*m;
+ lhash := lhash xor k;
inc(data,4);
dec(len,4);
@@ -247,27 +249,27 @@ begin
begin
tmp:=data;
inc(tmp,2);
- hash := hash xor (LongWord(tmp^) shl 16);
+ lhash := lhash xor (LongWord(tmp^) shl 16);
end;
if len >= 2 then
begin
tmp:=data;
inc(tmp);
- hash := hash xor (LongWord(tmp^) shl 8);
+ lhash := lhash xor (LongWord(tmp^) shl 8);
end;
if len >= 1 then
begin
- hash := hash xor (LongWord(data^));
- hash := hash * m;
+ lhash := lhash xor (LongWord(data^));
+ lhash := lhash * m;
end;
// Do a few final mixes of the hash to ensure the last few
// bytes are well-incorporated.
- hash := hash xor (hash shr 13);
- hash := hash * m;
- hash := hash xor (hash shr 15);
+ lhash := lhash xor (lhash shr 13);
+ lhash := lhash * m;
+ lhash := lhash xor (lhash shr 15);
- Result := hash;
+ Result := lhash;
end;
function BSwap(value:dword):dword;
@@ -2054,6 +2056,34 @@ begin
result:=FastAnsiToWideBuf(IntToTime(buf,time),dst);
end;
+function NumToInt(src:pWideChar):int64;
+begin
+ if (src[0]='$') and
+ (AnsiChar(src[1]) in sHexNum) then
+ result:=HexToInt(src+1)
+ else
+ if (src[0]='0') and
+ (src[1]='x') and
+ (AnsiChar(src[2]) in sHexNum) then
+ result:=HexToInt(src+2)
+ else
+ result:=StrToInt(src);
+end;
+
+function NumToInt(src:pAnsiChar):int64;
+begin
+ if (src[0]='$') and
+ (src[1] in sHexNum) then
+ result:=HexToInt(src+1)
+ else
+ if (src[0]='0') and
+ (src[1]='x') and
+ (src[2] in sHexNum) then
+ result:=HexToInt(src+2)
+ else
+ result:=StrToInt(src);
+end;
+
function StrToInt(src:pWideChar):int64;
var
sign:boolean;