forked from livecode/livecode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist_stub_symbols.pl
More file actions
executable file
·73 lines (60 loc) · 1.13 KB
/
list_stub_symbols.pl
File metadata and controls
executable file
·73 lines (60 loc) · 1.13 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env perl
use warnings;
sub trim
{
my $trim = $_[0];
$trim =~ s/^\s+|\s+$// ;
return $trim;
}
my $inputFile = $ARGV[1];
my $outputFile = $ARGV[2];
# Read all of the input data
open INPUT, "<$inputFile"
or die "Could not open input file \"$inputFile\": $!";
my @spec = <INPUT>;
close INPUT;
# Open the output file
open OUTPUT, ">$outputFile"
or die "Could not open output file \"$outputFile\": $!";
# Prefix for symbols
my $prefix = "";
if (defined $ARGV[0] and $ARGV[0] ne "")
{
$prefix = $ARGV[0];
}
foreach my $line (@spec)
{
# Ignore empty lines
if ($line =~ /^\s*$/)
{
next;
}
# Ignore comment lines
if ($line =~ /^\s*#/)
{
next;
}
# Ignore lines defining modules (we only care about symbols)
if (substr($line, 0, 1) ne "\t")
{
next;
}
# Skip the tab character
substr($line, 0, 1) = "";
trim($line);
# Handle optional symbols
my $symbol = undef;
my @words = split('\s+', $line);
if (substr($line, 0, 1) eq "?")
{
$symbol = $words[1];
}
else
{
$symbol = $words[0];
}
# Remove any trailing colons
$symbol =~ s/:$// ;
# Write the symbol to the output
print OUTPUT "$prefix$symbol\n";
}