| OLD | NEW |
| 1 #!/usr/bin/perl -w | 1 #!/usr/bin/perl -w |
| 2 # | 2 # |
| 3 # Copyright (c) International Business Machines Corp., 2002 | 3 # Copyright (c) International Business Machines Corp., 2002 |
| 4 # | 4 # |
| 5 # This program is free software; you can redistribute it and/or modify | 5 # This program is free software; you can redistribute it and/or modify |
| 6 # it under the terms of the GNU General Public License as published by | 6 # it under the terms of the GNU General Public License as published by |
| 7 # the Free Software Foundation; either version 2 of the License, or (at | 7 # the Free Software Foundation; either version 2 of the License, or (at |
| 8 # your option) any later version. | 8 # your option) any later version. |
| 9 # | 9 # |
| 10 # This program is distributed in the hope that it will be useful, but | 10 # This program is distributed in the hope that it will be useful, but |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 # History: | 34 # History: |
| 35 # 2002-09-02: created by Peter Oberparleiter <Peter.Oberparleiter@de.ibm.com> | 35 # 2002-09-02: created by Peter Oberparleiter <Peter.Oberparleiter@de.ibm.com> |
| 36 # | 36 # |
| 37 | 37 |
| 38 use strict; | 38 use strict; |
| 39 use File::Basename; | 39 use File::Basename; |
| 40 use Getopt::Long; | 40 use Getopt::Long; |
| 41 | 41 |
| 42 | 42 |
| 43 # Constants | 43 # Constants |
| 44 our $lcov_version» = "LCOV version 1.7"; | 44 our $lcov_version» = 'LCOV version 1.10'; |
| 45 our $lcov_url = "http://ltp.sourceforge.net/coverage/lcov.php"; | 45 our $lcov_url = "http://ltp.sourceforge.net/coverage/lcov.php"; |
| 46 our $tool_name = basename($0); | 46 our $tool_name = basename($0); |
| 47 | 47 |
| 48 | 48 |
| 49 # Prototypes | 49 # Prototypes |
| 50 sub print_usage(*); | 50 sub print_usage(*); |
| 51 sub gen_desc(); | 51 sub gen_desc(); |
| 52 sub warn_handler($); | 52 sub warn_handler($); |
| 53 sub die_handler($); | 53 sub die_handler($); |
| 54 | 54 |
| 55 | 55 |
| 56 # Global variables | 56 # Global variables |
| 57 our $help; | 57 our $help; |
| 58 our $version; | 58 our $version; |
| 59 our $output_filename; | 59 our $output_filename; |
| 60 our $input_filename; | 60 our $input_filename; |
| 61 | 61 |
| 62 | 62 |
| 63 # | 63 # |
| 64 # Code entry point | 64 # Code entry point |
| 65 # | 65 # |
| 66 | 66 |
| 67 $SIG{__WARN__} = \&warn_handler; | 67 $SIG{__WARN__} = \&warn_handler; |
| 68 $SIG{__DIE__} = \&die_handler; | 68 $SIG{__DIE__} = \&die_handler; |
| 69 | 69 |
| 70 # Prettify version string |
| 71 $lcov_version =~ s/\$\s*Revision\s*:?\s*(\S+)\s*\$/$1/; |
| 72 |
| 70 # Parse command line options | 73 # Parse command line options |
| 71 if (!GetOptions("output-filename=s" => \$output_filename, | 74 if (!GetOptions("output-filename=s" => \$output_filename, |
| 72 "version" =>\$version, | 75 "version" =>\$version, |
| 73 "help|?" => \$help | 76 "help|?" => \$help |
| 74 )) | 77 )) |
| 75 { | 78 { |
| 76 print(STDERR "Use $tool_name --help to get usage information\n"); | 79 print(STDERR "Use $tool_name --help to get usage information\n"); |
| 77 exit(1); | 80 exit(1); |
| 78 } | 81 } |
| 79 | 82 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 # | 146 # |
| 144 # Die on error. | 147 # Die on error. |
| 145 # | 148 # |
| 146 | 149 |
| 147 sub gen_desc() | 150 sub gen_desc() |
| 148 { | 151 { |
| 149 local *INPUT_HANDLE; | 152 local *INPUT_HANDLE; |
| 150 local *OUTPUT_HANDLE; | 153 local *OUTPUT_HANDLE; |
| 151 my $empty_line = "ignore"; | 154 my $empty_line = "ignore"; |
| 152 | 155 |
| 153 » open(INPUT_HANDLE, $input_filename) | 156 » open(INPUT_HANDLE, "<", $input_filename) |
| 154 or die("ERROR: cannot open $input_filename!\n"); | 157 or die("ERROR: cannot open $input_filename!\n"); |
| 155 | 158 |
| 156 # Open output file for writing | 159 # Open output file for writing |
| 157 if ($output_filename) | 160 if ($output_filename) |
| 158 { | 161 { |
| 159 » » open(OUTPUT_HANDLE, ">$output_filename") | 162 » » open(OUTPUT_HANDLE, ">", $output_filename) |
| 160 or die("ERROR: cannot create $output_filename!\n"); | 163 or die("ERROR: cannot create $output_filename!\n"); |
| 161 } | 164 } |
| 162 else | 165 else |
| 163 { | 166 { |
| 164 *OUTPUT_HANDLE = *STDOUT; | 167 *OUTPUT_HANDLE = *STDOUT; |
| 165 } | 168 } |
| 166 | 169 |
| 167 # Process all lines in input file | 170 # Process all lines in input file |
| 168 while (<INPUT_HANDLE>) | 171 while (<INPUT_HANDLE>) |
| 169 { | 172 { |
| 170 chomp($_); | 173 chomp($_); |
| 171 | 174 |
| 172 » » if (/^\s*(\w[\w-]*)(\s*)$/) | 175 » » if (/^(\w[\w-]*)(\s*)$/) |
| 173 { | 176 { |
| 174 # Matched test name | 177 # Matched test name |
| 175 # Name starts with alphanum or _, continues with | 178 # Name starts with alphanum or _, continues with |
| 176 # alphanum, _ or - | 179 # alphanum, _ or - |
| 177 print(OUTPUT_HANDLE "TN: $1\n"); | 180 print(OUTPUT_HANDLE "TN: $1\n"); |
| 178 $empty_line = "ignore"; | 181 $empty_line = "ignore"; |
| 179 } | 182 } |
| 180 elsif (/^(\s+)(\S.*?)\s*$/) | 183 elsif (/^(\s+)(\S.*?)\s*$/) |
| 181 { | 184 { |
| 182 # Matched test description | 185 # Matched test description |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 | 217 |
| 215 warn("$tool_name: $msg"); | 218 warn("$tool_name: $msg"); |
| 216 } | 219 } |
| 217 | 220 |
| 218 sub die_handler($) | 221 sub die_handler($) |
| 219 { | 222 { |
| 220 my ($msg) = @_; | 223 my ($msg) = @_; |
| 221 | 224 |
| 222 die("$tool_name: $msg"); | 225 die("$tool_name: $msg"); |
| 223 } | 226 } |
| OLD | NEW |