/contrib/bind9/doc/misc/format-options.pl

https://bitbucket.org/freebsd/freebsd-head/ · Perl · 49 lines · 25 code · 5 blank · 19 comment · 3 complexity · 4bd86d47f2e22c6c0b9a418b9dca73e6 MD5 · raw file

  1. #!/usr/bin/perl
  2. #
  3. # Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC")
  4. # Copyright (C) 2001 Internet Software Consortium.
  5. #
  6. # Permission to use, copy, modify, and/or distribute this software for any
  7. # purpose with or without fee is hereby granted, provided that the above
  8. # copyright notice and this permission notice appear in all copies.
  9. #
  10. # THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  11. # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  12. # AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  13. # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  14. # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  15. # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. # PERFORMANCE OF THIS SOFTWARE.
  17. # $Id: format-options.pl,v 1.5 2007/09/24 04:21:59 marka Exp $
  18. print <<END;
  19. This is a summary of the named.conf options supported by
  20. this version of BIND 9.
  21. END
  22. # Break long lines
  23. while (<>) {
  24. chomp;
  25. s/\t/ /g;
  26. my $line = $_;
  27. m!^( *)!;
  28. my $indent = $1;
  29. my $comment = "";
  30. if ( $line =~ m!//.*! ) {
  31. $comment = $&;
  32. $line =~ s!//.*!!;
  33. }
  34. my $start = "";
  35. while (length($line) >= 79 - length($comment)) {
  36. $_ = $line;
  37. # this makes sure that the comment has something in front of it
  38. $len = 75 - length($comment);
  39. m!^(.{0,$len}) (.*)$!;
  40. $start = $start.$1."\n";
  41. $line = $indent." ".$2;
  42. }
  43. print $start.$line.$comment."\n";
  44. }