File: sort.pl

package info (click to toggle)
moxftp 2.2-18.1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 4,160 kB
  • ctags: 3,837
  • sloc: ansic: 43,420; makefile: 353; perl: 262; sh: 192
file content (47 lines) | stat: -rwxr-xr-x 997 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#! /local/bin/perl

open(input, "$ARGV[0]");
open(output, ">temp");
while (<input>) {
	if (/^#/) { print output "$last$_"; undef($last); next; }
	if (/XmStringCreateLtoR/) { print output "$last$_"; undef($last); next; }
	if (/(\S\S*)\((.*)\)\s*$/ || 
	    /^(CreateSimpleDialog)/) {
	     $name = $1;
	     if ($last =~ /^\s*$/) {undef($last); }
	     if ($last =~ /^\s*(.*)\s\s*$/) {
		$last = $1;
	     }
	     if (!$last) { 
			   print "fix $name\n";
	     }
	     $func{$name} = "$last\n$_";
	     while (<input>) {
	          $func{$name} = $func{$name} . "$_";
		  if ($_ =~ /^}/) { last; }
	     }
	     undef($last);
	     $_ = <input>;
	     if ($_ =~ /^\s*$/) { next; }
	}
	if ($last) { print output "$last";}
	$last = $_;
}

@f = sort keys%func;

$first = 1;
foreach $item (@f) {
	if (!$first) {
            print output  "\n";
	} else {
	    $first = 0;
	}
	print output "$func{$item}";
}
close(output);

$XX = $ARGV[0] . ".uns";
system "mv $ARGV[0] $XX";
system "mv temp $ARGV[0]";