fixlog.pp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 by Peter Vreman
  4. Remove all revision logs from source files after 20 revisions
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. program fixlog;
  12. {$mode objfpc}
  13. {$H+}
  14. uses
  15. sysutils;
  16. const
  17. maxrevs = 20;
  18. bufsize = 32*1024;
  19. procedure dofile(const fn:string);
  20. var
  21. t,f : text;
  22. s : string;
  23. skip : boolean;
  24. found,revs : integer;
  25. fbuf,tbuf : pointer;
  26. begin
  27. getmem(fbuf,bufsize);
  28. getmem(tbuf,bufsize);
  29. assign(t,fn);
  30. assign(f,'fixlog.tmp');
  31. {$I-}
  32. reset(t);
  33. {$I+}
  34. if ioresult<>0 then
  35. exit;
  36. rewrite(f);
  37. settextbuf(t,tbuf^,bufsize);
  38. settextbuf(f,fbuf^,bufsize);
  39. found:=0;
  40. revs:=0;
  41. skip:=false;
  42. while not eof(t) do
  43. begin
  44. readln(t,s);
  45. case found of
  46. 0 :
  47. begin
  48. if pos('$Log: ',s)>0 then
  49. found:=1;
  50. skip:=false;
  51. writeln(f,s);
  52. end;
  53. 1 :
  54. begin
  55. if pos('Revision',s)>0 then
  56. begin
  57. inc(revs);
  58. if revs>maxrevs then
  59. begin
  60. skip:=true;
  61. found:=2;
  62. end;
  63. end
  64. else
  65. if pos('}',s)>0 then
  66. begin
  67. skip:=false;
  68. found:=0;
  69. end;
  70. if not skip then
  71. writeln(f,s);
  72. end;
  73. 2 :
  74. begin
  75. if pos('}',s)>0 then
  76. begin
  77. skip:=false;
  78. found:=0;
  79. end;
  80. if not skip then
  81. writeln(f,s);
  82. end;
  83. end;
  84. end;
  85. close(t);
  86. close(f);
  87. erase(t);
  88. rename(f,fn);
  89. freemem(tbuf);
  90. freemem(fbuf);
  91. end;
  92. var
  93. dir : tsearchrec;
  94. i : integer;
  95. begin
  96. for i:=1to paramcount do
  97. begin
  98. if findfirst(paramstr(i),faAnyFile,dir)=0 then
  99. repeat
  100. dofile(dir.name);
  101. until findnext(dir)<>0;
  102. findclose(dir);
  103. end;
  104. end.
  105. {
  106. $Log$
  107. Revision 1.2 2000-01-07 01:15:00 peter
  108. * updated copyright to 2000
  109. Revision 1.1 1999/10/06 06:29:03 peter
  110. * new tool
  111. }