1186448Sdougb#!/bin/perl 2186448Sdougb# 3245163Serwin# Copyright (C) 2007, 2012 Internet Systems Consortium, Inc. ("ISC") 4186448Sdougb# 5186448Sdougb# Permission to use, copy, modify, and/or distribute this software for any 6186448Sdougb# purpose with or without fee is hereby granted, provided that the above 7186448Sdougb# copyright notice and this permission notice appear in all copies. 8186448Sdougb# 9186448Sdougb# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 10186448Sdougb# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 11186448Sdougb# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 12186448Sdougb# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 13186448Sdougb# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 14186448Sdougb# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 15186448Sdougb# PERFORMANCE OF THIS SOFTWARE. 16186448Sdougb 17234010Sdougb# $Id: sort-options.pl,v 1.3 2007/09/24 23:46:48 tbox Exp $ 18186448Sdougb 19186448Sdougbsub sortlevel() { 20186448Sdougb my @options = (); 21186448Sdougb my $fin = ""; 22186448Sdougb my $i = 0; 23186448Sdougb while (<>) { 24186448Sdougb if (/^\s*};$/) { 25186448Sdougb $fin = $_; 26186448Sdougb # print 2, $_; 27186448Sdougb last; 28186448Sdougb } 29186448Sdougb next if (/^$/); 30186448Sdougb if (/{$/) { 31186448Sdougb # print 3, $_; 32186448Sdougb my $sec = $_; 33186448Sdougb push(@options, $sec . sortlevel()); 34186448Sdougb } else { 35186448Sdougb push(@options, $_); 36186448Sdougb # print 1, $_; 37186448Sdougb } 38186448Sdougb $i++; 39186448Sdougb } 40186448Sdougb my $result = ""; 41186448Sdougb foreach my $i (sort @options) { 42186448Sdougb $result = ${result}.${i}; 43186448Sdougb $result = $result."\n" if ($i =~ /^[a-z]/i); 44186448Sdougb # print 5, ${i}; 45186448Sdougb } 46186448Sdougb $result = ${result}.${fin}; 47186448Sdougb return ($result); 48186448Sdougb} 49186448Sdougb 50186448Sdougbprint sortlevel(); 51