mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-06 00:47:52 +02:00
--- Merging r49165 into '.':
U packages/fcl-registry/src/registry.pp --- Recording mergeinfo for merge of r49165 into '.': U . --- Merging r49166 into '.': U packages/hash/src/sha1.pp --- Recording mergeinfo for merge of r49166 into '.': G . --- Merging r49167 into '.': U packages/iconvenc/src/iconvert.inc --- Recording mergeinfo for merge of r49167 into '.': G . # revisions: 49165,49166,49167 r49165 | marco | 2021-04-10 15:53:57 +0200 (Sat, 10 Apr 2021) | 3 lines Changed paths: M /trunk/packages/fcl-registry/src/registry.pp * fix from bart for mantis #0038581 that prohibits reusing readbinarydata as basis for a multisz reader. r49166 | marco | 2021-04-10 16:26:20 +0200 (Sat, 10 Apr 2021) | 1 line Changed paths: M /trunk/packages/hash/src/sha1.pp * raise exception when file not found. r49167 | marco | 2021-04-10 16:58:53 +0200 (Sat, 10 Apr 2021) | 2 lines Changed paths: M /trunk/packages/iconvenc/src/iconvert.inc * implemented recommendations from mantis #038510 for better bionic compatibility. git-svn-id: branches/fixes_3_2@49221 -
This commit is contained in:
parent
7ed1ba7a51
commit
3037276c8a
@ -478,8 +478,6 @@ Var
|
||||
|
||||
begin
|
||||
Result := GetData(Name, @Buffer, BufSize, RegDataType);
|
||||
If not (RegDataType in [rdBinary, rdUnknown]) Then
|
||||
Raise ERegistryException.CreateFmt(SInvalidRegType, [Name]);
|
||||
end;
|
||||
|
||||
function TRegistry.ReadBinaryData(const Name: String; var Buffer;
|
||||
|
@ -51,6 +51,8 @@ function SHA1Match(const Digest1, Digest2: TSHA1Digest): Boolean;
|
||||
|
||||
implementation
|
||||
|
||||
uses sysutils,sysconst;
|
||||
|
||||
// inverts the bytes of (Count div 4) cardinals from source to target.
|
||||
procedure Invert(Source, Dest: Pointer; Count: PtrUInt);
|
||||
var
|
||||
@ -257,6 +259,11 @@ begin
|
||||
SHA1Final(Context, Result);
|
||||
end;
|
||||
|
||||
procedure RaiseFileNotFoundException(const fn : String);
|
||||
begin
|
||||
raise EFileNotFoundException.Create(SFileNotFound);
|
||||
end;
|
||||
|
||||
function SHA1File(const Filename: String; const Bufsize: PtrUInt): TSHA1Digest;
|
||||
var
|
||||
F: File;
|
||||
@ -284,7 +291,9 @@ begin
|
||||
until Count < BufSize;
|
||||
FreeMem(Buf, BufSize);
|
||||
Close(F);
|
||||
end;
|
||||
end
|
||||
else
|
||||
RaiseFileNotFoundException(FileName);
|
||||
|
||||
SHA1Final(Context, Result);
|
||||
FileMode := ofm;
|
||||
|
@ -14,7 +14,7 @@ var
|
||||
iconvres: size_t;
|
||||
begin
|
||||
H := iconv_open(PChar(ToEncoding), PChar(FromEncoding));
|
||||
if not assigned(H) then
|
||||
if h=Iconv_t(-1) then
|
||||
begin
|
||||
Res := S;
|
||||
exit(-1);
|
||||
@ -48,7 +48,8 @@ begin
|
||||
Dst:=PChar(Res)+Offset;
|
||||
OutLen:=Length(Res)-Offset;
|
||||
end;
|
||||
iconvres:=iconv(H, nil, nil, @Dst, @Outlen);
|
||||
InLen=0;
|
||||
iconvres:=iconv(H, nil, @InLen, @Dst, @Outlen);
|
||||
if iconvres = size_t(-1) then
|
||||
begin
|
||||
res:=s;
|
||||
@ -91,7 +92,8 @@ begin
|
||||
SetLength(Res, Length(Res)+InLen*2+5); // 5 is minimally one utf-8 char
|
||||
Dst:=PChar(Res)+Offset;
|
||||
OutLen:=Length(Res)-Offset;
|
||||
iconv(H, nil, nil, @Dst, @Outlen);
|
||||
InLen:=0;
|
||||
iconv(H, nil, @InLen, @Dst, @Outlen);
|
||||
end;
|
||||
{$endif}
|
||||
// trim output buffer
|
||||
@ -101,7 +103,8 @@ begin
|
||||
SetLength(Res, Length(Res)+InLen*2+5); // 5 is minimally one utf-8 char
|
||||
Dst:=PChar(Res)+Offset;
|
||||
OutLen:=Length(Res)-Offset;
|
||||
iconvres:=iconv(H, nil, nil, @Dst, @Outlen);
|
||||
InLen:=0;
|
||||
iconvres:=iconv(H, nil, @InLen, @Dst, @Outlen);
|
||||
setlength(Res,Length(Res) - Outlen);
|
||||
iconv_close(H);
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user