diff --git a/.gitattributes b/.gitattributes index f5a474de7e..6d73e38be4 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6543,6 +6543,7 @@ packages/paszlib/src/ziputils.pas svneol=native#text/plain packages/paszlib/src/zstream.pp svneol=native#text/plain packages/paszlib/src/zuncompr.pas svneol=native#text/plain packages/paszlib/tests/tczipper.pp svneol=native#text/plain +packages/paszlib/tests/tczstreamseek.pp svneol=native#text/plain packages/pcap/Makefile svneol=native#text/plain packages/pcap/Makefile.fpc svneol=native#text/plain packages/pcap/Makefile.fpc.fpcmake svneol=native#text/plain diff --git a/packages/fcl-base/src/inifiles.pp b/packages/fcl-base/src/inifiles.pp index 4a1d9e1cd4..e2fefe6d05 100644 --- a/packages/fcl-base/src/inifiles.pp +++ b/packages/fcl-base/src/inifiles.pp @@ -165,7 +165,7 @@ type procedure WriteString(const Section, Ident, Value: String); virtual; abstract; function ReadInteger(const Section, Ident: string; Default: Longint): Longint; virtual; procedure WriteInteger(const Section, Ident: string; Value: Longint); virtual; - function ReadInt64(const Section, Ident: string; Default: Int64): Longint; virtual; + function ReadInt64(const Section, Ident: string; Default: Int64): Int64; virtual; procedure WriteInt64(const Section, Ident: string; Value: Int64); virtual; function ReadBool(const Section, Ident: string; Default: Boolean): Boolean; virtual; procedure WriteBool(const Section, Ident: string; Value: Boolean); virtual; @@ -608,7 +608,7 @@ begin end; function TCustomIniFile.ReadInt64(const Section, Ident: string; Default: Int64 - ): Longint; + ): Int64; begin Result := StrToInt64Def(ReadString(Section, Ident, ''), Default); end; diff --git a/packages/paszlib/src/zstream.pp b/packages/paszlib/src/zstream.pp index 5d568092f9..b37bd70105 100644 --- a/packages/paszlib/src/zstream.pp +++ b/packages/paszlib/src/zstream.pp @@ -324,7 +324,7 @@ begin raise Edecompressionerror.create(zerror(err)); end; -function Tdecompressionstream.GetPosition() : Int64; +function Tdecompressionstream.GetPosition() : Int64; begin GetPosition := raw_read; end; @@ -335,31 +335,28 @@ var c,off: int64; begin off:=Offset; - if (origin=soBeginning) or ((origin=soCurrent) and (off+raw_read>=0)) then - begin - if origin = soCurrent then - seek := raw_read + off - else - seek := off; - - if origin=soBeginning then - dec(off,raw_read); - if offset<0 then - begin - inc(off,raw_read); - reset; - end; - while off>0 do - begin - c:=off; - if c>bufsize then - c:=bufsize; - c:=read(Fbuffer^,c); - dec(off,c); - end; - end - else + + if origin=soCurrent then + inc(off,raw_read); + if (origin=soEnd) or (off<0) then raise Edecompressionerror.create(Sseek_failed); + + seek:=off; + + if off0 do + begin + c:=off; + if c>bufsize then + c:=bufsize; + if read(Fbuffer^,c)<>c then + raise Edecompressionerror.create(Sseek_failed); + dec(off,c); + end; end; function Tdecompressionstream.get_compressionrate:single; diff --git a/packages/paszlib/tests/tczstreamseek.pp b/packages/paszlib/tests/tczstreamseek.pp new file mode 100644 index 0000000000..9ba41b0943 --- /dev/null +++ b/packages/paszlib/tests/tczstreamseek.pp @@ -0,0 +1,58 @@ +program tczstreamseek; +{$MODE OBJFPC} +{$ASSERTIONS ON} + +uses + classes, + zstream; + +const + val: Uint32 = $123456; + wasError: boolean = False; +var + data: TMemoryStream; + comprStream: TCompressionStream; + decomprStream: TDecompressionStream; +begin + data := TMemoryStream.Create(); + + comprStream := TCompressionStream.Create(clMax, data); + comprStream.WriteDWord(val); + comprStream.Free; + + data.Seek(0, soFromBeginning); + + decomprStream := TDecompressionStream.Create(data); + Assert(decomprStream.ReadDWord() = val); + Assert(decomprStream.Position = SizeOf(val)); + + decomprStream.Seek(0, soFromBeginning); + Assert(decomprStream.Position = 0); + Assert(decomprStream.ReadDWord() = val); + + decomprStream.Seek(-SizeOf(val), soFromCurrent); + Assert(decomprStream.Position = 0); + Assert(decomprStream.ReadDWord() = val); + + wasError := False; + decomprStream.Seek(0, soFromBeginning); + try + decomprStream.Seek(-SizeOf(val), soFromCurrent); + except + on EDecompressionError do + wasError := True; + end; + assert(wasError); + + decomprStream.Seek(SizeOf(val), soFromBeginning); + Assert(decomprStream.Position = SizeOf(val)); + + wasError := False; + try + decomprStream.Seek(40, soFromBeginning); + except + on EDecompressionError do + wasError := True; + end; + assert(wasError); +end. diff --git a/rtl/freebsd/i386/identpatch.sh b/rtl/freebsd/i386/identpatch.sh index f7fd890349..dc2cb0aef9 100644 --- a/rtl/freebsd/i386/identpatch.sh +++ b/rtl/freebsd/i386/identpatch.sh @@ -1,12 +1,18 @@ #!/bin/sh +if [ "$#" -ne 1 ] +then elfdump -n `which elfdump` |awk '/FreeBSD/{print $2}' >elfversion IDVERSION=`cat elfversion` rm elfversion +else +IDVERSION=$1 +fi echo Patching cprt0.as with version $IDVERSION sed -I.sav -es/900044/$IDVERSION/ cprt0.as sed -I.sav -es/900044/$IDVERSION/ dllprt0.as sed -I.sav -es/900044/$IDVERSION/ prt0.as +sed -I.sav -es/900044/$IDVERSION/ gprt0.as sed -I.sav -es/900044/$IDVERSION/ si_c.inc sed -I.sav -es/900044/$IDVERSION/ si_prc.inc diff --git a/rtl/gba/sysutils.pp b/rtl/gba/sysutils.pp index 2680be0bc7..c7eeb472c6 100644 --- a/rtl/gba/sysutils.pp +++ b/rtl/gba/sysutils.pp @@ -278,17 +278,39 @@ begin result := ''; end; -function ExecuteProcess (const Path: AnsiString; const ComLine: AnsiString;Flags:TExecuteFlags=[]): integer; +function ExecuteProcess (const Path: RawByteString; const ComLine: RawByteString;Flags:TExecuteFlags=[]): integer; begin result := -1; end; -function ExecuteProcess (const Path: AnsiString; - const ComLine: array of AnsiString;Flags:TExecuteFlags=[]): integer; +function ExecuteProcess (const Path: RawByteString; + const ComLine: array of RawByteString;Flags:TExecuteFlags=[]): integer; begin result := -1; end; +function ExecuteProcess(const Path: UnicodeString; const ComLine: UnicodeString; + Flags: TExecuteFlags = []): Integer; +begin + { TODO : implement } + result := -1; +end; + +function ExecuteProcess(const Path: UnicodeString; + const ComLine: Array of UnicodeString; Flags:TExecuteFlags = []): Integer; +var + CommandLine: UnicodeString; + I: integer; +begin + Commandline := ''; + for I := 0 to High (ComLine) do + if Pos (' ', ComLine [I]) <> 0 then + CommandLine := CommandLine + ' ' + '"' + ComLine [I] + '"' + else + CommandLine := CommandLine + ' ' + Comline [I]; + ExecuteProcess := ExecuteProcess (Path, CommandLine,Flags); +end; + {**************************************************************************** Initialization code diff --git a/rtl/nds/sysutils.pp b/rtl/nds/sysutils.pp index 93cc9d09d5..641c7112e5 100644 --- a/rtl/nds/sysutils.pp +++ b/rtl/nds/sysutils.pp @@ -315,16 +315,38 @@ begin result := ''; end; -function ExecuteProcess (const Path: AnsiString; const ComLine: AnsiString;Flags:TExecuteFlags=[]): integer; +function ExecuteProcess (const Path: RawByteString; const ComLine: RawByteString;Flags:TExecuteFlags=[]): integer; begin result := -1; end; -function ExecuteProcess (const Path: AnsiString; const ComLine: array of AnsiString;Flags:TExecuteFlags=[]): integer; +function ExecuteProcess (const Path: RawByteString; const ComLine: array of RawByteString;Flags:TExecuteFlags=[]): integer; begin result := -1; end; +function ExecuteProcess(const Path: UnicodeString; const ComLine: UnicodeString; + Flags: TExecuteFlags = []): Integer; +begin + { TODO : implement } + result := -1; +end; + +function ExecuteProcess(const Path: UnicodeString; + const ComLine: Array of UnicodeString; Flags:TExecuteFlags = []): Integer; +var + CommandLine: UnicodeString; + I: integer; +begin + Commandline := ''; + for I := 0 to High (ComLine) do + if Pos (' ', ComLine [I]) <> 0 then + CommandLine := CommandLine + ' ' + '"' + ComLine [I] + '"' + else + CommandLine := CommandLine + ' ' + Comline [I]; + ExecuteProcess := ExecuteProcess (Path, CommandLine,Flags); +end; + function GetLastOSError: Integer; begin Result := -1;