mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-17 17:29:21 +02:00
* Fix leap second reading
git-svn-id: trunk@49006 -
This commit is contained in:
parent
2a61397d37
commit
3575369989
@ -29,7 +29,7 @@ type
|
|||||||
pleap=^tleap;
|
pleap=^tleap;
|
||||||
tleap=record
|
tleap=record
|
||||||
transition : int64;
|
transition : int64;
|
||||||
change : int64;
|
change : longint;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -277,17 +277,31 @@ const
|
|||||||
var
|
var
|
||||||
buf : array[0..bufsize-1] of byte;
|
buf : array[0..bufsize-1] of byte;
|
||||||
bufptr : pbyte;
|
bufptr : pbyte;
|
||||||
|
bufbytes : tsSize;
|
||||||
f : longint;
|
f : longint;
|
||||||
tzhead : ttzhead;
|
tzhead : ttzhead;
|
||||||
|
|
||||||
procedure readfilebuf;
|
function readfilebuf : TsSize;
|
||||||
begin
|
begin
|
||||||
bufptr := @buf[0];
|
bufptr := @buf[0];
|
||||||
fpread(f, buf, bufsize);
|
bufbytes:=fpread(f, buf, bufsize);
|
||||||
|
readfilebuf:=bufbytes;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Procedure checkbufptr;
|
||||||
|
|
||||||
|
var
|
||||||
|
a : tssize;
|
||||||
|
|
||||||
|
begin
|
||||||
|
a:=bufptr-@buf;
|
||||||
|
if (a>bufbytes) then
|
||||||
|
Writeln('Reading past end of file : ',a);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function readbufbyte: byte;
|
function readbufbyte: byte;
|
||||||
begin
|
begin
|
||||||
|
// checkbufptr;
|
||||||
if bufptr > @buf[bufsize-1] then
|
if bufptr > @buf[bufsize-1] then
|
||||||
readfilebuf;
|
readfilebuf;
|
||||||
readbufbyte := bufptr^;
|
readbufbyte := bufptr^;
|
||||||
@ -311,6 +325,7 @@ var
|
|||||||
dec(count, numbytes);
|
dec(count, numbytes);
|
||||||
inc(readbuf, numbytes);
|
inc(readbuf, numbytes);
|
||||||
inc(dest, numbytes);
|
inc(dest, numbytes);
|
||||||
|
// checkbufptr;
|
||||||
end;
|
end;
|
||||||
if count > 0 then
|
if count > 0 then
|
||||||
readfilebuf
|
readfilebuf
|
||||||
@ -403,13 +418,12 @@ var
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
readbuf(zone_names,tzhead.tzh_charcnt);
|
readbuf(zone_names,tzhead.tzh_charcnt);
|
||||||
|
|
||||||
if version=2 then
|
if version=2 then
|
||||||
begin // read 64bit values
|
begin // read 64bit values
|
||||||
for i:=0 to num_leaps-1 do
|
for i:=0 to num_leaps-1 do
|
||||||
begin
|
begin
|
||||||
readbuf(@leaps[i].transition,sizeof(int64));
|
readbuf(@leaps[i].transition,sizeof(int64));
|
||||||
readbuf(@leaps[i].change,sizeof(int64));
|
readbuf(@leaps[i].change,sizeof(longint));
|
||||||
leaps[i].transition:=decode(leaps[i].transition);
|
leaps[i].transition:=decode(leaps[i].transition);
|
||||||
leaps[i].change:=decode(leaps[i].change);
|
leaps[i].change:=decode(leaps[i].change);
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user