"Fossies" - the Fresh Open Source Software Archive

Member "bind-9.17.5/doc/misc/sort-options.pl" (4 Sep 2020, 941 Bytes) of package /linux/misc/dns/bind9/9.17.5/bind-9.17.5.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "sort-options.pl" see the Fossies "Dox" file reference documentation.

    1 #!/bin/perl
    2 #
    3 # Copyright (C) Internet Systems Consortium, Inc. ("ISC")
    4 #
    5 # This Source Code Form is subject to the terms of the Mozilla Public
    6 # License, v. 2.0. If a copy of the MPL was not distributed with this
    7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
    8 #
    9 # See the COPYRIGHT file distributed with this work for additional
   10 # information regarding copyright ownership.
   11 
   12 sub sortlevel() {
   13     my @options = ();
   14     my $fin = "";
   15     my $i = 0;
   16     while (<>) {
   17         if (/^\s*};$/ || /^\s*}; \/\/.*$/) {
   18             $fin = $_;
   19             # print 2, $_;
   20             last;
   21         }
   22         next if (/^$/);
   23         if (/{$/) {
   24             # print 3, $_;
   25             my $sec = $_;
   26             push(@options, $sec . sortlevel());
   27         } else {
   28             push(@options, $_);
   29             # print 1, $_;
   30         }
   31         $i++;
   32     }
   33     my $result = "";
   34     foreach my $i (sort @options) {
   35         $result = ${result}.${i};
   36         $result = $result."\n" if ($i =~ /^[a-z]/i);
   37         # print 5, ${i};
   38     }
   39     $result = ${result}.${fin};
   40     return ($result);
   41 }
   42 
   43 print sortlevel();