[Libreoffice-commits] core.git: 2 commits - bin/ios-mapfile-statistics

Tor Lillqvist tml at collabora.com
Fri Apr 25 01:06:39 PDT 2014


 bin/ios-mapfile-statistics |   34 ++++++++++++++++++++++++++++++++--
 1 file changed, 32 insertions(+), 2 deletions(-)

New commits:
commit bc4c2098a66bbcf4f3d265dd8e0a154062e4337d
Author: Tor Lillqvist <tml at collabora.com>
Date:   Fri Apr 25 11:02:06 2014 +0300

    Improve command line handling, don't read stdin
    
    Reading stdin is confusing as it means running the script without any
    arguments and with no input redirection just seems to do
    nothing. (OTOH, who would use this script except seasoned hackers who
    know how command-line tools typically work... oh well.)
    
    Change-Id: I00b4f70b07b6515b52a22b4ec4e048cc84c1dc83

diff --git a/bin/ios-mapfile-statistics b/bin/ios-mapfile-statistics
index 98d3342..07f3f0a 100755
--- a/bin/ios-mapfile-statistics
+++ b/bin/ios-mapfile-statistics
@@ -17,7 +17,7 @@ sub HELP_MESSAGE {
   print <<EOS
 This program parses a linker map file, especially one produced when linking an iOS executable.
 
-Input is read from a command-line argument or from standard input.
+Input is read from a map file provided as command-line argument
 
 By default a list of libraries used and the size of code and data
 linked in from each library is printed, in reverse order of size.
@@ -31,14 +31,20 @@ The following options are available:
 EOS
 }
 
-die "The -f switch makes sense only if -s is also used" if (defined($args{'f'}) && !defined($args{'s'}));
+die "The -f switch makes sense only if -s is also used\n" if defined($args{'f'}) && !defined($args{'s'});
+
+die "Please provide one map file name\n" if !defined($ARGV[0]);
+
+die "Just one argument please\n" if defined($ARGV[1]);
 
 my $state = 0;
 my %libofnumber;
 my %sizeoflib;
 my %sizeofsym;
 
-while (<>) {
+open(INPUT, '<', $ARGV[0]) || die "Could not open $ARGV[0]: $!\n";
+
+while (<INPUT>) {
   if ($state == 0 && m!^# Object files:!) {
     $state = 1;
   } elsif ($state == 1 && m!^\[ *([0-9]+)\] .*/([-_a-z0-9]+\.a)\(.*!i) {
commit 848e1ca01aa5ba6a283950a08d7fad2f594ecf88
Author: Tor Lillqvist <tml at collabora.com>
Date:   Fri Apr 25 10:50:40 2014 +0300

    Add help message
    
    Change-Id: Id9c5dfdee00c8b9baa21c7345f7218e982bfd434

diff --git a/bin/ios-mapfile-statistics b/bin/ios-mapfile-statistics
index 4e1f803..98d3342 100755
--- a/bin/ios-mapfile-statistics
+++ b/bin/ios-mapfile-statistics
@@ -3,11 +3,34 @@
 use strict;
 
 use Getopt::Std;
+$Getopt::Std::STANDARD_HELP_VERSION++;
 
 my %args;
 
 getopts('f:s', \%args);
 
+sub VERSION_MESSAGE {
+  # Nothing
+}
+
+sub HELP_MESSAGE {
+  print <<EOS
+This program parses a linker map file, especially one produced when linking an iOS executable.
+
+Input is read from a command-line argument or from standard input.
+
+By default a list of libraries used and the size of code and data
+linked in from each library is printed, in reverse order of size.
+
+The following options are available:
+-s                Print a list of symbols instead.
+-f 'filter'       Filter which libraries are handled. The filter can be
+                  a regular expression, typically several library names
+                  combined with the '|' operator. Makes sense only when
+                  -s is used too.
+EOS
+}
+
 die "The -f switch makes sense only if -s is also used" if (defined($args{'f'}) && !defined($args{'s'}));
 
 my $state = 0;
@@ -46,3 +69,4 @@ if ($args{'s'}) {
     print $_, ": ", $sizeoflib{$_}, "\n";
   }
 }
+


More information about the Libreoffice-commits mailing list