Skip to content

Commit 6d64412

Browse files
gemmaromquinson
authored andcommitted
Use debug subroutine for format modules.
1 parent 16fcc15 commit 6d64412

File tree

10 files changed

+38
-44
lines changed

10 files changed

+38
-44
lines changed

lib/Locale/Po4a/Dia.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ sub initialize {
9494
$self->SUPER::initialize(%options);
9595
$self->{options}{'nostrip'} = 1;
9696
$self->{options}{'_default_translated'} .= ' <dia:string>';
97-
print "Call treat_options\n" if $self->{options}{'debug'};
97+
print "Call treat_options\n" if $self->debug;
9898
$self->treat_options;
9999
}
100100

lib/Locale/Po4a/Docbook.pm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2052,8 +2052,7 @@ sub initialize {
20522052
lang
20532053
xml:lang';
20542054

2055-
print "Call treat_options\n"
2056-
if $self->{options}{'debug'};
2055+
print "Call treat_options\n" if $self->debug;
20572056
$self->treat_options;
20582057
}
20592058

lib/Locale/Po4a/Guide.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ sub initialize {
146146
<sup>
147147
<uri>
148148
<var>';
149-
print "Call treat_options\n" if $self->{options}{'debug'};
149+
print "Call treat_options\n" if $self->debug;
150150
$self->treat_options;
151151
}
152152

lib/Locale/Po4a/InProgress/Debconf.pm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ sub parse {
118118
}
119119

120120
$eval .= ")\n";
121-
print STDERR $eval if $self->{options}{'debug'};
121+
print STDERR $eval if $self->debug;
122122
eval $eval;
123-
print STDERR "XXXXXXXXXXXXXXXXX\n" if $self->{options}{'debug'};
123+
print STDERR "XXXXXXXXXXXXXXXXX\n" if $self->debug;
124124

125125
# two leading _: split on coma and multi-translate each part. No extended value.
126126
} elsif ( $undercount == 2 ) {
@@ -140,7 +140,7 @@ sub parse {
140140
}
141141
$eval .= ")\n";
142142

143-
print $eval if $self->{options}{'debug'};
143+
print $eval if $self->debug;
144144
eval $eval;
145145

146146
# no leading _: don't touch it

lib/Locale/Po4a/InProgress/NewsDebian.pm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ sub parse {
7474

7575
# main loop
7676
( $line, $lref ) = $self->shiftline();
77-
print "seen >>$line<<\n" if $self->{options}{'debug'};
77+
print "seen >>$line<<\n" if $self->debug;
7878
while ( defined($line) ) {
7979

8080
# Begining of an entry
@@ -93,7 +93,7 @@ sub parse {
9393
# eat all leading empty lines
9494
( $line, $lref ) = $self->shiftline();
9595
while ( defined($line) && $line =~ m/^\s*$/ ) {
96-
print "Eat >>$line<<\n" if $self->{options}{'debug'};
96+
print "Eat >>$line<<\n" if $self->debug;
9797
( $line, $lref ) = $self->shiftline();
9898
}
9999

@@ -122,7 +122,7 @@ sub parse {
122122
}
123123

124124
( $line, $lref ) = $self->shiftline();
125-
print "seen >>" . ( $line || '' ) . "<<\n" if $self->{options}{'debug'};
125+
print "seen >>" . ( $line || '' ) . "<<\n" if $self->debug;
126126
}
127127
}
128128

lib/Locale/Po4a/Ini.pm

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ use Locale::Po4a::Common;
2020

2121
use vars qw($AUTOLOAD);
2222

23-
my $debug = 0;
24-
2523
sub parse {
2624
my $self = shift;
2725
my ( $line, $ref );
@@ -32,25 +30,25 @@ sub parse {
3230

3331
while ( defined($line) ) {
3432
chomp($line);
35-
print STDERR "begin\n" if $debug;
33+
print STDERR "begin\n" if $self->debug;
3634

3735
if ( $line =~ /\"/ ) {
38-
print STDERR "Start of line containing \".\n" if $debug;
36+
print STDERR "Start of line containing \".\n" if $self->debug;
3937

4038
# Text before the first quote
4139
$line =~ m/(^[^"\r\n]*)"/;
4240
my $pre_text = $1;
43-
print STDERR " PreText=" . $pre_text . "\n" if $debug;
41+
print STDERR " PreText=" . $pre_text . "\n" if $self->debug;
4442

4543
# The text for translation
4644
$line =~ m/"([^\r\n]*)"/;
4745
my $quoted_text = $1;
48-
print STDERR " QuotedText=" . $quoted_text . "\n" if $debug;
46+
print STDERR " QuotedText=" . $quoted_text . "\n" if $self->debug;
4947

5048
# Text after last quote
5149
$line =~ m/"([^"\n]*$)/;
5250
my $post_text = $1;
53-
print STDERR " PostText=" . $post_text . "\n" if $debug;
51+
print STDERR " PostText=" . $post_text . "\n" if $self->debug;
5452

5553
# Translate the string it
5654
$par = $self->translate( $quoted_text, $ref, $pre_text );
@@ -60,9 +58,9 @@ sub parse {
6058

6159
# Now push the result
6260
$self->pushline( $pre_text . '"' . $par . '"' . $post_text . "\n" );
63-
print STDERR "End of line containing \".\n" if $debug;
61+
print STDERR "End of line containing \".\n" if $self->debug;
6462
} else {
65-
print STDERR "Other stuff\n" if $debug;
63+
print STDERR "Other stuff\n" if $self->debug;
6664
$self->pushline("$line\n");
6765
}
6866

lib/Locale/Po4a/KernelHelp.pm

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ use Locale::Po4a::Common qw(wrap_ref_mod gettext);
2222

2323
use vars qw($AUTOLOAD);
2424

25-
my $debug = 0;
26-
2725
sub parse {
2826
my $self = shift;
2927
my ( $line, $ref );
@@ -40,22 +38,22 @@ sub parse {
4038

4139
while ( defined($line) ) {
4240
chomp($line);
43-
print STDERR "status=$status;Seen >>$line<<:" if $debug;
41+
print STDERR "status=$status;Seen >>$line<<:" if $self->debug;
4442

4543
if ( $line =~ /^\#/ ) {
46-
print STDERR "comment.\n" if $debug;
44+
print STDERR "comment.\n" if $self->debug;
4745
$self->pushline("$line\n");
4846
} elsif ( $status == 0 ) {
4947
if ( $line =~ /\S/ ) {
50-
print STDERR "short desc.\n" if $debug;
48+
print STDERR "short desc.\n" if $self->debug;
5149
$desc = $line;
5250
$status++;
5351
} else {
54-
print STDERR "empty line.\n" if $debug;
52+
print STDERR "empty line.\n" if $self->debug;
5553
$self->pushline("$line\n");
5654
}
5755
} elsif ( $status == 1 ) {
58-
print STDERR "var name.\n" if $debug;
56+
print STDERR "var name.\n" if $self->debug;
5957
$variable = $line;
6058
$status++;
6159

@@ -64,10 +62,10 @@ sub parse {
6462
} elsif ( $status == 2 ) {
6563
$line =~ s/^ //;
6664
if ( $line =~ /\S/ ) {
67-
print STDERR "paragraph line.\n" if $debug;
65+
print STDERR "paragraph line.\n" if $self->debug;
6866
$paragraph .= $line . "\n";
6967
} else {
70-
print STDERR "end of paragraph.\n" if $debug;
68+
print STDERR "end of paragraph.\n" if $self->debug;
7169
$status++;
7270
$paragraph = $self->translate( $paragraph, $ref, "helptxt_$variable" );
7371
$paragraph =~ s/^/ /gm;
@@ -77,11 +75,11 @@ sub parse {
7775
} elsif ( $status == 3 ) {
7876
if ( $line =~ s/^ // ) {
7977
if ( $line =~ /\S/ ) {
80-
print "begin of paragraph.\n" if $debug;
78+
print "begin of paragraph.\n" if $self->debug;
8179
$paragraph = $line . "\n";
8280
$status--;
8381
} else {
84-
print "end of config option.\n" if $debug;
82+
print "end of config option.\n" if $self->debug;
8583
$status = 0;
8684
$self->pushline("\n");
8785
}

lib/Locale/Po4a/Wml.pm

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ sub initialize {
7373

7474
$self->SUPER::initialize(%options);
7575

76-
print "Call treat_options\n" if $self->{options}{'debug'};
76+
print "Call treat_options\n" if $self->debug;
7777
$self->treat_options;
7878
}
7979

@@ -108,8 +108,7 @@ sub read {
108108
# Mask mp4h cruft
109109
while ( $file =~ s|^#(.*)$|<!--PO4ASHARPBEGIN$1PO4ASHARPEND-->|m ) {
110110
my $line = $1;
111-
print STDERR "PROTECT HEADER: $line\n"
112-
if $self->{options}{'debug'};
111+
print STDERR "PROTECT HEADER: $line\n" if $self->debug;
113112

114113
# If the wml tag has a title attribute, use a fake
115114
# <title> xml tag to enable the extraction

lib/Locale/Po4a/Xhtml.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ sub initialize {
223223

224224
$self->{options}{'optionalclosingtag'} = 1;
225225

226-
print "Call treat_options\n" if $self->{options}{'debug'};
226+
print "Call treat_options\n" if $self->debug;
227227
$self->treat_options;
228228

229229
if ( defined $self->{options}{'includessi'}

lib/Locale/Po4a/Xml.pm

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ sub initialize {
637637
# by this module or sub-module (unless specified in an option)
638638
$self->{nodefault} = ();
639639

640-
print "Call treat_options\n" if $self->{options}{'debug'};
640+
print "Call treat_options\n" if $self->debug;
641641
$self->treat_options;
642642

643643
# Clear cache
@@ -1338,7 +1338,7 @@ sub treat_tag {
13381338
my $line = &{ $tag_types[$type]->{f_translate} }( $self, @lines );
13391339
print wrap_mod( "po4a::xml::treat_tag", "%s: type=%s <%s%s%s%s%s>",
13401340
$lines[1], $type, $match1, $space1, $line, $space2, $match2 )
1341-
if $self->{options}{'debug'};
1341+
if $self->debug;
13421342
$self->pushline( "<" . $match1 . $space1 . $line . $space2 . $match2 . ">" );
13431343
return $eof;
13441344
}
@@ -1463,7 +1463,7 @@ sub treat_attributes {
14631463
),
14641464
$ref, $value,
14651465
$self->get_path . $name
1466-
) if $self->{options}{'debug'};
1466+
) if $self->debug;
14671467
$text .= $value;
14681468
}
14691469
$text .= $quot;
@@ -1603,7 +1603,7 @@ sub get_translate_options {
16031603
"%s: translation option='%s'.\n *** the original translation option is overridden here since parent path='%s' is untranslated,"
16041604
),
16051605
$path, $options, $ppath
1606-
) if $self->{options}{'debug'};
1606+
) if $self->debug;
16071607
}
16081608
}
16091609

@@ -1616,14 +1616,14 @@ sub get_translate_options {
16161616
"po4a::xml::get_translate_options",
16171617
dgettext( "po4a", "%s: foldattributes setting ignored since '%s' is not inline tag" ),
16181618
$path, $tag
1619-
) if $self->{options}{'debug'};
1619+
) if $self->debug;
16201620
}
16211621

16221622
$translate_options_cache{$path} = $options;
16231623

16241624
# print "option($path)=".$translate_options_cache{$path}." (new)\n";
16251625

1626-
#print wrap_mod("po4a::xml::get_translate_options", dgettext ("po4a", "%s: options: '%s'"), $path, $options) if $self->{options}{'debug'};
1626+
#print wrap_mod("po4a::xml::get_translate_options", dgettext ("po4a", "%s: options: '%s'"), $path, $options) if $self->debug;
16271627
return $options;
16281628
}
16291629

@@ -1694,7 +1694,7 @@ sub treat_content {
16941694
# input stream and save its content to @comments for use by
16951695
# translate_paragraph.
16961696
print wrap_mod( "po4a::xml::treat_content", "%s: type='%s'", $paragraph[1], $type )
1697-
if $self->{options}{'debug'};
1697+
if $self->debug;
16981698
( $eof, @text ) = $self->extract_tag( $type, 1 );
16991699

17001700
# Add "\0" to mark end of each separate comment
@@ -2029,7 +2029,7 @@ sub translate_paragraph {
20292029
"po4a::xml::translate_paragraph",
20302030
"%s: path='%s', translation option='%s'",
20312031
$paragraph[1], $self->get_path, $translate
2032-
) if $self->{options}{'debug'};
2032+
) if $self->debug;
20332033
$self->pushline(
20342034
$self->found_string(
20352035
$para,
@@ -2048,7 +2048,7 @@ sub translate_paragraph {
20482048
"po4a::xml::translate_paragraph",
20492049
"%s: path='%s', translation option='%s' (no translation)",
20502050
$paragraph[1], $self->get_path, $translate
2051-
) if $self->{options}{'debug'};
2051+
) if $self->debug;
20522052
$self->pushline($para);
20532053
}
20542054
}
@@ -2315,7 +2315,7 @@ sub treat_options {
23152315
# -- XML tags in these may specify options: wWip
23162316
# Extraction of XML content can be one of "inline", "break", "placeholder", or "customtag".
23172317
# -- XML tags in these must not specify options
2318-
if ( $self->{options}{'debug'} ) {
2318+
if ( $self->debug ) {
23192319
foreach my $tagtype (qw(translated untranslated)) {
23202320
foreach my $tag ( sort keys %{ $self->{$tagtype} } ) {
23212321
print

0 commit comments

Comments
 (0)