fixgdkcdecl.pp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. {$mode objfpc}
  2. {$H+}
  3. uses
  4. sysutils;
  5. Function PosIdx (Const Substr : AnsiString; Const Source : AnsiString;i:longint) : Longint;
  6. var
  7. S : String;
  8. begin
  9. PosIdx:=0;
  10. if Length(SubStr)=0 then
  11. exit;
  12. while (i <= length (Source) - length (substr)) do
  13. begin
  14. inc (i);
  15. S:=copy(Source,i,length(Substr));
  16. if S=SubStr then
  17. exit(i);
  18. end;
  19. end;
  20. function trimspace(const s:string):string;
  21. var
  22. i,j : longint;
  23. begin
  24. i:=length(s);
  25. while (i>0) and (s[i] in [#9,' ']) do
  26. dec(i);
  27. j:=1;
  28. while (j<i) and (s[j] in [#9,' ']) do
  29. inc(j);
  30. trimspace:=Copy(s,j,i-j+1);
  31. end;
  32. function trimbegin(const s:string):string;
  33. var
  34. i,j : longint;
  35. begin
  36. i:=length(s);
  37. j:=1;
  38. while (j<i) and (s[j] in [#9,' ']) do
  39. inc(j);
  40. trimbegin:=Copy(s,j,i-j+1);
  41. end;
  42. procedure Replace(var s:string;const s1,s2:string);
  43. var
  44. last,
  45. i : longint;
  46. begin
  47. last:=0;
  48. repeat
  49. i:=posidx(s1,uppercase(s),last);
  50. if (i>0) then
  51. begin
  52. Delete(s,i,length(s1));
  53. Insert(s2,s,i);
  54. last:=i+1;
  55. end;
  56. until (i=0);
  57. end;
  58. procedure Conv(const fn: string);
  59. var
  60. t,f : text;
  61. lasts,funcname,
  62. s,ups : string;
  63. k,i,j : integer;
  64. gotisfunc,
  65. impl : boolean;
  66. begin
  67. writeln('processing ',fn);
  68. assign(t,fn);
  69. assign(f,'fixgdk.tmp');
  70. reset(t);
  71. rewrite(f);
  72. funcname:='';
  73. gotisfunc:=false;
  74. impl:=false;
  75. while not eof(t) do
  76. begin
  77. readln(t,s);
  78. { Remove unit part }
  79. if s='{$ifndef gdk_include_files}' then
  80. begin
  81. while not eof(t) do
  82. begin
  83. readln(t,s);
  84. if Pos('{$ifdef read_interface}',s)>0 then
  85. begin
  86. writeln(f,'{****************************************************************************');
  87. writeln(f,' Interface');
  88. writeln(f,'****************************************************************************}');
  89. writeln(f,'');
  90. writeln(f,s);
  91. break;
  92. end;
  93. if Pos('{$ifdef read_implementation}',s)>0 then
  94. begin
  95. writeln(f,'{****************************************************************************');
  96. writeln(f,' Implementation');
  97. writeln(f,'****************************************************************************}');
  98. writeln(f,'');
  99. writeln(f,s);
  100. impl:=true;
  101. break;
  102. end;
  103. $Log$
  104. Revision 1.2 2000-07-13 11:33:18 michael
  105. + removed logs
  106. }