creumap.pp 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2000 by Florian Klaempfl
  4. It creates pascal units from unicode mapping files
  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 creumap;
  12. uses
  13. charset;
  14. procedure doerror;
  15. begin
  16. writeln('Usage: creumap <cpname>');
  17. writeln('A mapping file called <cpname>.txt must be present');
  18. halt(1);
  19. end;
  20. var
  21. p : punicodemap;
  22. i : longint;
  23. t : text;
  24. begin
  25. if paramcount<>1 then
  26. doerror;
  27. p:=loadunicodemapping(paramstr(1),paramstr(1)+'.txt');
  28. if p=nil then
  29. doerror;
  30. assign(t,paramstr(1)+'.pp');
  31. rewrite(t);
  32. writeln(t,'{ This is an automatically created file, so don''t edit it }');
  33. writeln(t,'unit ',p^.cpname,';');
  34. writeln(t);
  35. writeln(t,' interface');
  36. writeln(t);
  37. writeln(t,' implementation');
  38. writeln(t);
  39. writeln(t,' uses');
  40. writeln(t,' charset;');
  41. writeln(t);
  42. writeln(t,' const');
  43. writeln(t,' map : array[0..',p^.lastchar,'] of tunicodecharmapping = (');
  44. for i:=0 to p^.lastchar do
  45. begin
  46. write(t,' (unicode : ',p^.map[i].unicode,'; flag : ');
  47. case p^.map[i].flag of
  48. umf_noinfo : write(t,'umf_noinfo');
  49. umf_leadbyte : write(t,'umf_leadbyte');
  50. umf_undefined : write(t,'umf_undefined');
  51. umf_unused : write(t,'umf_unused');
  52. end;
  53. write(t,'; reserved: 0)');
  54. if i<>p^.lastchar then
  55. writeln(t,',')
  56. else
  57. writeln(t);
  58. end;
  59. writeln(t,' );');
  60. writeln(t);
  61. writeln(t,' unicodemap : tunicodemap = (');
  62. writeln(t,' cpname : ''',p^.cpname,''';');
  63. writeln(t,' map : @map;');
  64. writeln(t,' lastchar : ',p^.lastchar,';');
  65. writeln(t,' next : nil;');
  66. writeln(t,' internalmap : true');
  67. writeln(t,' );');
  68. writeln(t);
  69. writeln(t,' begin');
  70. writeln(t,' registermapping(@unicodemap)');
  71. writeln(t,' end.');
  72. close(t);
  73. end.