mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-19 00:19:24 +02:00
rtl: add HashName function based on implementation of Hash() from objpas. It uses case case-insensitive hash generation. This function is added for compatibility with delphi (although it generates different hash in delphi and fpc for same strings). It is also needed for codepage search in hash array.
git-svn-id: trunk@19353 -
This commit is contained in:
parent
8fc6af7fde
commit
0bfb83b06c
@ -69,3 +69,24 @@ begin
|
||||
Result:=StrScan(Str,Chr);
|
||||
end;
|
||||
|
||||
Function HashName(Name: PAnsiChar): LongWord;
|
||||
Var
|
||||
thehash,g,I : LongWord;
|
||||
begin
|
||||
thehash:=0;
|
||||
For I:=1 to Length(Name) do { 0 terminated }
|
||||
begin
|
||||
thehash:=thehash shl 4;
|
||||
inc(theHash,Ord(UpCase(Name[i])));
|
||||
g:=thehash and LongWord($f shl 28);
|
||||
if g<>0 then
|
||||
begin
|
||||
thehash:=thehash xor (g shr 24);
|
||||
thehash:=thehash xor g;
|
||||
end;
|
||||
end;
|
||||
If theHash=0 then
|
||||
HashName:=$ffffffff
|
||||
else
|
||||
HashName:=TheHash;
|
||||
end;
|
@ -25,4 +25,4 @@ function AnsiPos(const substr,s : string) : SizeInt;
|
||||
function AnsiStrPos(str,substr : PChar) : PChar;
|
||||
function AnsiStrRScan(Str : PChar;Chr : Char) : PChar;
|
||||
function AnsiStrScan(Str : PChar;Chr: Char) : PChar;
|
||||
|
||||
function HashName(Name: PAnsiChar): LongWord;
|
||||
|
Loading…
Reference in New Issue
Block a user