2
0

fixmsg.pp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. type
  2. trtabrec=record
  3. name : string[12];
  4. idx : longint;
  5. end;
  6. const
  7. trtab : array[0..10] of trtabrec=(
  8. (name:'general';idx:1000),
  9. (name:'scan';idx:2000),
  10. (name:'parser';idx:3000),
  11. (name:'type';idx:4000),
  12. (name:'sym';idx:5000),
  13. (name:'cg';idx:6000),
  14. (name:'asmr';idx:7000),
  15. (name:'asmw';idx:8000),
  16. (name:'exec';idx:9000),
  17. (name:'unit';idx:10000),
  18. (name:'option';idx:11000)
  19. );
  20. var
  21. t,f : text;
  22. s,hs : string;
  23. i,j,k : longint;
  24. begin
  25. assign(t,paramstr(1));
  26. reset(t);
  27. assign(f,'New.msg');
  28. rewrite(f);
  29. while not eof(t) do
  30. begin
  31. readln(t,s);
  32. if (s<>'') and not(s[1] in ['#','%']) then
  33. begin
  34. for i:=0 to 10 do
  35. if Copy(s,1,length(trtab[i].name))=trtab[i].name then
  36. begin
  37. j:=pos('=',s);
  38. if j>0 then
  39. begin
  40. inc(j);
  41. if s[j] in ['0'..'9'] then
  42. begin
  43. k:=j;
  44. while (s[k] in ['0'..'9']) do
  45. inc(k);
  46. if s[k]='_' then
  47. inc(k);
  48. delete(s,j,k-j);
  49. end;
  50. str(trtab[i].idx,hs);
  51. while length(hs)<5 do
  52. hs:='0'+hs;
  53. hs:=hs+'_';
  54. inc(trtab[i].idx);
  55. insert(hs,s,j);
  56. end;
  57. break;
  58. end;
  59. end;
  60. writeln(f,s);
  61. end;
  62. close(f);
  63. close(t);
  64. end.