Skip to content

Commit 079ea14

Browse files
author
Ralph Castain
committed
Update symbol-hiding script
1 parent e918d75 commit 079ea14

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

contrib/symbol-hiding.pl

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
my $mylib;
1313
my $myprefix;
1414
my $mysuffix;
15+
my $mycapprefix;
1516

1617
# Set to true if the script should merely check for symbols in
1718
# the library that are not in the provided output file - useful
@@ -63,6 +64,8 @@ sub quiet_print {
6364

6465
#-------------------------------------------------------------------------------
6566

67+
$mycapprefix = uc $myprefix;
68+
6669
# get the symbol output for this lib
6770
my $output = qx(nm $mylib);
6871

@@ -84,8 +87,7 @@ sub quiet_print {
8487
# next token indicates a public symbol by
8588
# being a 'T' or a 'B'
8689
$val = shift(@values);
87-
if ("T" eq $val || "B" eq $val || "D" eq $val ||
88-
"t" eq $val || "b" eq $val || "d" eq $val) {
90+
if ("T" eq $val || "B" eq $val || "D" eq $val) {
8991
$val = shift(@values);
9092
# if this symbol contains a '.', then we
9193
# need to ignore it
@@ -105,10 +107,24 @@ sub quiet_print {
105107
if ($myfile ne "") {
106108
open FILE, ">$myfile" || die "file could not be opened";
107109
}
110+
sub checkCase {
111+
if ($_[0] =~ /^[[:upper:]]/) {
112+
return 1;
113+
}
114+
else {
115+
return 0;
116+
}
117+
}
118+
108119
foreach my $sym (@symbols) {
109120
my $out;
110121
if ($REVERSE) {
111-
$out = "#define " . $myprefix . $sym . $mysuffix;
122+
# if the first char is a cap, then use the cap prefix
123+
if (checkCase($sym)) {
124+
$out = "#define " . $mycapprefix . $sym . $mysuffix;
125+
} else {
126+
$out = "#define " . $myprefix . $sym . $mysuffix;
127+
}
112128
} else {
113129
$out = "#define " . $sym;
114130
}
@@ -119,7 +135,12 @@ sub quiet_print {
119135
if ($REVERSE) {
120136
$out = $out . $sym . "\n";
121137
} else {
122-
$out = $out . $myprefix . $sym . $mysuffix . "\n";
138+
# if the first char is a cap, then use the cap prefix
139+
if (checkCase($sym)) {
140+
$out = $out . $mycapprefix . $sym . $mysuffix . "\n";
141+
} else {
142+
$out = $out . $myprefix . $sym . $mysuffix . "\n";
143+
}
123144
}
124145
if ($myfile ne "") {
125146
print FILE $out;

0 commit comments

Comments
 (0)