home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / macfe / restext / resdef.pl < prev    next >
Encoding:
Perl Script  |  1998-04-08  |  1.5 KB  |  50 lines

  1. #! /usr/local/bin/perl
  2.  
  3. #
  4. # The contents of this file are subject to the Netscape Public License
  5. # Version 1.0 (the "NPL"); you may not use this file except in
  6. # compliance with the NPL.  You may obtain a copy of the NPL at
  7. # http://www.mozilla.org/NPL/
  8. #
  9. # Software distributed under the NPL is distributed on an "AS IS" basis,
  10. # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  11. # for the specific language governing rights and limitations under the
  12. # NPL.
  13. #
  14. # The Initial Developer of this code under the NPL is Netscape
  15. # Communications Corporation.  Portions created by Netscape are
  16. # Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  17. # Reserved.
  18. #
  19.  
  20. # This script reads a series of lines of the form:
  21. # resource 'STR ' ( id+100, "name", purgeable)(NAME, ID, "STRING")
  22. # and generates stuff like:
  23.  
  24. open(OUT, ">xpstring.r");
  25. print OUT "// This is a generated file, do not edit it\n";
  26. print OUT "#include \"Types.r\"\n";
  27. while (<>) {
  28.   ($enum, $eid) =
  29.     /[     ]*([A-Za-z0-9_]+)[     ]*\=[     ]*([A-Za-z_x0-9]+),/;
  30.      if ($enum ne "") {
  31.     print OUT "#define $enum $eid \n";
  32.   }
  33.   ($name, $id, $string) =
  34.     /ResDef[     ]*\([     ]*([A-Za-z0-9_]+)[     ]*,[     ]*([\(\)0-9A-Za-z_x\-+ ]+)[     \01]*,[     ]*(".*")[     ]*\)/;
  35.      if ($name ne "") {
  36. #   print OUT "resource 'STR ' (($id)+7000, \"$name\", purgeable)\n{\n\t";
  37.     print OUT "resource 'STR ' (($id)+7000, \"\", purgeable)\n{\n\t";
  38.  
  39.     $_ = $string;
  40.     s/([^.:])\\n/$1 /g;
  41.     s/(\\n) /$1/g;
  42.     print OUT "$_";
  43.     
  44.     print OUT ";\n};\n";
  45.   }
  46. }
  47. close(OUT);
  48.  
  49.  
  50.