Bug 19061: Avoid SQL Injection vulnerability
[srvgit] / misc / translator / VerboseWarnings.pm
index 7a3aad4..8fac8ba 100644 (file)
@@ -1,9 +1,10 @@
 package VerboseWarnings;
 
 use strict;
+#use warnings; FIXME - Bug 2505
 require Exporter;
 
-use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
+use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
 
 ###############################################################################
 
@@ -20,25 +21,35 @@ verbose warnings.
 
 ###############################################################################
 
-$VERSION = 0.01;
 
 @ISA = qw(Exporter);
 @EXPORT_OK = qw(
     &pedantic_p
+    &warn_additional
     &warn_normal
     &warn_pedantic
+    &error_additional
     &error_normal
 );
+%EXPORT_TAGS = (
+    'warn' => [ 'warn_additional',  'warn_normal',  'warn_pedantic' ],
+    'die'  => [ 'error_additional', 'error_normal' ],
+);
 
 ###############################################################################
 
-use vars qw( $appName $input $input_abbr $pedantic_p $pedantic_tag );
+use vars qw( $appName $input $input_abbr $pedantic_p $pedantic_tag $quiet);
+use vars qw( $warned $erred );
 
 sub set_application_name ($) {
     my($s) = @_;
     $appName = $& if !defined $appName && $s =~ /[^\/]+$/;
 }
 
+sub application_name () {
+    return $appName;
+}
+
 sub set_input_file_name ($) {
     my($s) = @_;
     $input = $s;
@@ -70,30 +81,47 @@ sub construct_warn_prefix ($$) {
     return "$appName: $prefix: " . (defined $lc? "$input_abbr: line $lc: ": defined $input_abbr? "$input_abbr: ": '');
 }
 
-sub warn_normal ($$) {
+sub warn_additional ($$) {
     my($msg, $lc) = @_;
     my $prefix = construct_warn_prefix('Warning', $lc);
     $msg .= "\n" unless $msg =~ /\n$/s;
     warn "$prefix$msg";
 }
 
+sub warn_normal ($$) {
+    my($msg, $lc) = @_;
+    $warned += 1;
+    warn_additional($msg, $lc);
+}
+
 sub warn_pedantic ($$$) {
     my($msg, $lc, $flag) = @_;
     my $prefix = construct_warn_prefix("Warning$pedantic_tag", $lc);
     $msg .= "\n" unless $msg =~ /\n$/s;
-    warn "$prefix$msg" if $pedantic_p || !$$flag;
+    warn "$prefix$msg" if ($pedantic_p || !$$flag) && $quiet;
     if (!$pedantic_p) {
        $prefix = construct_warn_prefix("Warning$pedantic_tag", undef);
-       warn $prefix."Further similar negligible warnings will not be reported, use --pedantic for details\n" unless $$flag;
+       warn $prefix."Further similar negligible warnings will not be reported, use --pedantic for details\n" unless ($$flag || !$quiet);
        $$flag = 1;
     }
+    $warned += 1;
 }
 
-sub error_normal ($$) {
+sub error_additional ($$) {
     my($msg, $lc) = @_;
     my $prefix = construct_warn_prefix('ERROR', $lc);
     $msg .= "\n" unless $msg =~ /\n$/s;
     warn "$prefix$msg";
 }
 
+sub error_normal ($$) {
+    my($msg, $lc) = @_;
+    $erred += 1;
+    error_additional($msg, $lc);
+}
+
+sub warned () {
+    return $warned; # number of times warned
+}
+
 ###############################################################################