/contrib/bind9/bin/named/convertxsl.pl

https://bitbucket.org/freebsd/freebsd-head/ · Perl · 57 lines · 31 code · 8 blank · 18 comment · 4 complexity · 417a4e5af6d3f15e04c8d8d87e8147f6 MD5 · raw file

  1. #!/usr/bin/env perl
  2. #
  3. # Copyright (C) 2006-2008 Internet Systems Consortium, Inc. ("ISC")
  4. #
  5. # Permission to use, copy, modify, and/or distribute this software for any
  6. # purpose with or without fee is hereby granted, provided that the above
  7. # copyright notice and this permission notice appear in all copies.
  8. #
  9. # THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  10. # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  11. # AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  12. # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  13. # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  14. # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. # PERFORMANCE OF THIS SOFTWARE.
  16. # $Id: convertxsl.pl,v 1.14 2008/07/17 23:43:26 jinmei Exp $
  17. use strict;
  18. use warnings;
  19. my $rev = '$Id: convertxsl.pl,v 1.14 2008/07/17 23:43:26 jinmei Exp $';
  20. $rev =~ s/\$//g;
  21. $rev =~ s/,v//g;
  22. $rev =~ s/Id: //;
  23. my $xsl = "unknown";
  24. my $lines = '';
  25. while (<>) {
  26. chomp;
  27. # pickout the id for comment.
  28. $xsl = $_ if (/<!-- .Id:.* -->/);
  29. # convert Id string to a form not recognisable by cvs.
  30. $_ =~ s/<!-- .Id:(.*). -->/<!-- \\045Id: $1\\045 -->/;
  31. s/[\ \t]+/ /g;
  32. s/\>\ \</\>\</g;
  33. s/\"/\\\"/g;
  34. s/^/\t\"/;
  35. s/$/\\n\"/;
  36. if ($lines eq "") {
  37. $lines .= $_;
  38. } else {
  39. $lines .= "\n" . $_;
  40. }
  41. }
  42. $xsl =~ s/\$//g;
  43. $xsl =~ s/<!-- Id: //;
  44. $xsl =~ s/ -->.*//;
  45. $xsl =~ s/,v//;
  46. print "/*\n * Generated by $rev \n * From $xsl\n */\n";
  47. print 'static char xslmsg[] =',"\n";
  48. print $lines;
  49. print ';', "\n";