mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-11-05 06:29:37 +01:00
* max date added
This commit is contained in:
parent
65631b0e44
commit
d61d0e32f2
@ -2,7 +2,8 @@
|
|||||||
$Id$
|
$Id$
|
||||||
Copyright (c) 1998-2000 by Peter Vreman
|
Copyright (c) 1998-2000 by Peter Vreman
|
||||||
|
|
||||||
Remove all revision logs from source files after 20 revisions
|
Remove all revision logs from source files after X revisions or
|
||||||
|
older than date X
|
||||||
|
|
||||||
See the file COPYING.FPC, included in this distribution,
|
See the file COPYING.FPC, included in this distribution,
|
||||||
for details about the copyright.
|
for details about the copyright.
|
||||||
@ -21,26 +22,46 @@ uses
|
|||||||
sysutils;
|
sysutils;
|
||||||
|
|
||||||
const
|
const
|
||||||
maxrevs = 20;
|
|
||||||
bufsize = 32*1024;
|
bufsize = 32*1024;
|
||||||
|
|
||||||
|
var
|
||||||
|
maxrevs,myear,mmonth,mday : integer;
|
||||||
|
|
||||||
|
procedure Date2Int(const date:string;var year,month,day:integer);
|
||||||
|
begin
|
||||||
|
year:=StrToInt(Copy(date,1,4));
|
||||||
|
month:=StrToInt(Copy(date,6,2));
|
||||||
|
day:=StrToInt(Copy(date,9,2));
|
||||||
|
if (year=0) or (month=0) or (day=0) then
|
||||||
|
begin
|
||||||
|
writeln('wrong date "',date,'", use yyyy/mm/dd');
|
||||||
|
halt(2);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure dofile(const fn:string);
|
procedure dofile(const fn:string);
|
||||||
var
|
var
|
||||||
t,f : text;
|
t,f : text;
|
||||||
s : string;
|
s : string;
|
||||||
skip : boolean;
|
skip : boolean;
|
||||||
found,revs : integer;
|
year,month,day,
|
||||||
|
found,revs,i : integer;
|
||||||
fbuf,tbuf : pointer;
|
fbuf,tbuf : pointer;
|
||||||
begin
|
begin
|
||||||
getmem(fbuf,bufsize);
|
getmem(fbuf,bufsize);
|
||||||
getmem(tbuf,bufsize);
|
getmem(tbuf,bufsize);
|
||||||
|
write('processing ',fn,': ');
|
||||||
assign(t,fn);
|
assign(t,fn);
|
||||||
assign(f,'fixlog.tmp');
|
assign(f,'fixlog.tmp');
|
||||||
{$I-}
|
{$I-}
|
||||||
reset(t);
|
reset(t);
|
||||||
{$I+}
|
{$I+}
|
||||||
if ioresult<>0 then
|
if ioresult<>0 then
|
||||||
exit;
|
begin
|
||||||
|
writeln('error!');
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
rewrite(f);
|
rewrite(f);
|
||||||
settextbuf(t,tbuf^,bufsize);
|
settextbuf(t,tbuf^,bufsize);
|
||||||
settextbuf(f,fbuf^,bufsize);
|
settextbuf(f,fbuf^,bufsize);
|
||||||
@ -60,13 +81,34 @@ begin
|
|||||||
end;
|
end;
|
||||||
1 :
|
1 :
|
||||||
begin
|
begin
|
||||||
if pos('Revision',s)>0 then
|
i:=pos('Revision',s);
|
||||||
|
if i>0 then
|
||||||
begin
|
begin
|
||||||
inc(revs);
|
inc(revs);
|
||||||
if revs>maxrevs then
|
if revs>maxrevs then
|
||||||
begin
|
begin
|
||||||
skip:=true;
|
skip:=true;
|
||||||
found:=2;
|
found:=2;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
inc(i,10);
|
||||||
|
while (i<length(s)) and (s[i]<>' ') do
|
||||||
|
inc(i);
|
||||||
|
while (i<length(s)) and (s[i]=' ') do
|
||||||
|
inc(i);
|
||||||
|
if (i<length(s)) and (s[i] in ['0'..'9']) then
|
||||||
|
begin
|
||||||
|
Date2Int(Copy(s,i,10),year,month,day);
|
||||||
|
if (year<Myear) or
|
||||||
|
((year=MYear) and (month<Mmonth)) or
|
||||||
|
((year=MYear) and (month=Mmonth) and (day<Mday)) then
|
||||||
|
begin
|
||||||
|
skip:=true;
|
||||||
|
found:=2;
|
||||||
|
// write(year,'/',month,'/',day,' date');
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -92,6 +134,10 @@ begin
|
|||||||
end;
|
end;
|
||||||
close(t);
|
close(t);
|
||||||
close(f);
|
close(f);
|
||||||
|
if revs=0 then
|
||||||
|
writeln(' no log found')
|
||||||
|
else
|
||||||
|
writeln(revs,' revisions');
|
||||||
erase(t);
|
erase(t);
|
||||||
rename(f,fn);
|
rename(f,fn);
|
||||||
freemem(tbuf);
|
freemem(tbuf);
|
||||||
@ -102,7 +148,15 @@ var
|
|||||||
dir : tsearchrec;
|
dir : tsearchrec;
|
||||||
i : integer;
|
i : integer;
|
||||||
begin
|
begin
|
||||||
for i:=1to paramcount do
|
writeln('fixlog v1.00 (C) 1999-2000 Peter Vreman');
|
||||||
|
if paramcount<3 then
|
||||||
|
begin
|
||||||
|
writeln('usage: fixlog <maxrevs> <maxdate> <files> [files]');
|
||||||
|
halt(1);
|
||||||
|
end;
|
||||||
|
MaxRevs:=StrToInt(ParamStr(1));
|
||||||
|
Date2Int(ParamStr(2),MYear,MMonth,MDay);
|
||||||
|
for i:=3 to paramcount do
|
||||||
begin
|
begin
|
||||||
if findfirst(paramstr(i),faAnyFile,dir)=0 then
|
if findfirst(paramstr(i),faAnyFile,dir)=0 then
|
||||||
repeat
|
repeat
|
||||||
@ -113,7 +167,10 @@ begin
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.2 2000-01-07 01:15:00 peter
|
Revision 1.3 2000-01-08 13:52:02 peter
|
||||||
|
* max date added
|
||||||
|
|
||||||
|
Revision 1.2 2000/01/07 01:15:00 peter
|
||||||
* updated copyright to 2000
|
* updated copyright to 2000
|
||||||
|
|
||||||
Revision 1.1 1999/10/06 06:29:03 peter
|
Revision 1.1 1999/10/06 06:29:03 peter
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user