my $debugfile_stream = $rinput_hash->{'debugfile'};
my $number_of_files = @{$rfiles};
- while ( my $input_file = shift @{$rfiles} ) {
+ while ( @{$rfiles} ) {
+ my $input_file = shift @{$rfiles};
my $fileroot;
my @input_file_stat;
}
my $options_string = join( SPACE, @{$rraw_options} );
- if ($config_file) {
+ if ( defined($config_file) ) {
$msg .= "Found Configuration File >>> $config_file \n";
}
$msg .= "Configuration and command line parameters for this run:\n";
}
my @raw_options = ();
- my $config_file = EMPTY_STRING;
my $saw_ignore_profile = 0;
my $saw_dump_profile = 0;
+ my $config_file;
#--------------------------------------------------------------
# Take a first look at the command-line parameters. Do as many
$saw_dump_profile = 1;
}
elsif ( $i =~ /^-(pro|profile)=(.+)/ ) {
- if ($config_file) {
+ if ( defined($config_file) ) {
Warn(
"Only one -pro=filename allowed, using '$2' instead of '$config_file'\n"
);
{
$start_dir = '.' if !$start_dir;
$start_dir = Cwd::realpath($start_dir);
- if ( my $found_file =
- find_file_upwards( $start_dir, $search_file ) )
- {
+ my $found_file =
+ find_file_upwards( $start_dir, $search_file );
+ if ( defined($found_file) ) {
$config_file = $found_file;
}
}
Die(
"cannot find file given with -pro=$config_file: $OS_ERROR\n"
);
- $config_file = EMPTY_STRING;
}
}
elsif ( $i =~ /^-(pro|profile)=?$/ ) {
# as call parameter to perltidy and -pro=filename on command
# line.
if ($perltidyrc_stream) {
- if ($config_file) {
+ if ( defined($config_file) ) {
Warn(<<EOM);
Conflict: a perltidyrc configuration file was specified both as this
perltidy call parameter: $perltidyrc_stream
# look for a config file if we don't have one yet
my $rconfig_file_chatter;
${$rconfig_file_chatter} = EMPTY_STRING;
- $config_file =
- find_config_file( $is_Windows, $Windows_type, $rconfig_file_chatter,
- $rpending_complaint )
- unless $config_file;
+ if ( !defined($config_file) ) {
+ $config_file =
+ find_config_file( $is_Windows, $Windows_type,
+ $rconfig_file_chatter, $rpending_complaint );
+ }
# open any config file
my $rconfig_string;
- if ($config_file) {
+ if ( defined($config_file) ) {
$rconfig_string = stream_slurp($config_file);
if ( !defined($rconfig_string) ) {
Die(
EOM
}
- if ($config_file) {
+ if ( defined($config_file) ) {
Die(<<"DIE");
Please check your configuration file $config_file for circular-references.
To deactivate it, use -npro.
# sub to check file existence and record all tests
my $exists_config_file = sub {
my $config_file = shift;
- return 0 unless $config_file;
+ return 0 unless defined($config_file);
${$rconfig_file_chatter} .= "# Testing: $config_file\n";
return -f $config_file;
}; ## end $exists_config_file = sub
# resolve <dir>/.../<file>, meaning look upwards from directory
my $config_file = shift;
- if ($config_file) {
+ if ( defined($config_file) ) {
if ( my ( $start_dir, $search_file ) =
( $config_file =~ m{^(.*)\.\.\./(.*)$} ) )
{
"# Searching Upward: $config_file\n";
$start_dir = '.' if !$start_dir;
$start_dir = Cwd::realpath($start_dir);
- if ( my $found_file =
- find_file_upwards( $start_dir, $search_file ) )
- {
+ my $found_file = find_file_upwards( $start_dir, $search_file );
+ if ( defined($found_file) ) {
$config_file = $found_file;
${$rconfig_file_chatter} .= "# Found: $config_file\n";
}
foreach my $item ( @{$rline_hash} ) {
my $line = $item->{line};
my $line_no = $item->{line_no};
- $line =~ s/^ \s+ | \s+ $//gx; # trim both ends
- next unless $line;
+ $line =~ s/^\s+//;
+ $line =~ s/\s+$//;
+ next unless ( length($line) );
my $body = $line;
my $msg = EMPTY_STRING;
my $rline_hash = [];
- # quote variables
+ # quote state variables
my $quote_char = EMPTY_STRING;
my $quote_start_line = EMPTY_STRING;
my $quote_start_line_no = -1;
$line_no++;
$line =~ s/^\s+//;
$line =~ s/\s+$//;
+ next unless ( length($line) );
if ( !$quote_char ) {
# -sbcp=#
# Otherwise, it would have to be quoted:
# -sbcp='#'
- if ( !length($out_string) || $out_string =~ /\s$/ ) {
+ if ( !length($out_string) || $out_string =~ s/\s+$// ) {
last;
}
$out_string .= $1;
# given a string containing words separated by whitespace,
# return the list of words
my ($str) = @_;
- return unless $str;
+ return unless defined($str);
$str =~ s/\s+$//;
$str =~ s/^\s+//;
+ return unless length($str);
return split /\s+/, $str;
} ## end sub split_words
my $opt_name = 'weld-nested-exclusion-list';
my $str = $rOpts->{$opt_name};
+
+ # let a '0' be the same as not defined
return unless ($str);
$str =~ s/^\s+//;
$str =~ s/\s+$//;
sub initialize_line_up_parentheses_control_hash {
my ( $str, $opt_name ) = @_;
+
+ # let a 0 be the same as not defined
return unless ($str);
$str =~ s/^\s+//;
$str =~ s/\s+$//;
if ( $item =~ /^([^\(\]\{]*)?([\(\{\[])(\d)?$/ ) {
$flag1 = $1 if $1;
$key = $2 if $2;
- $flag2 = $3 if $3;
+ $flag2 = $3 if defined($3);
}
else {
$msg1 .= " '$item_save'";
sub initialize_keep_old_breakpoints {
my ( $str, $short_name, $rkeep_break_hash ) = @_;
+
+ # 0 will be treated same as not defined
return unless $str;
my %flags = ();
# nothing if error
my $rLL = $self->[_rLL_];
- return unless ($Kn);
+ return unless defined($Kn);
my $type_n = $rLL->[$Kn]->[_TYPE_];
return unless ( $type_n eq 'q' );
my $token_n = $rLL->[$Kn]->[_TOKEN_];
# ref to list if found words
# undef if not successful, or non-constant list item encountered
my $rLL = $self->[_rLL_];
- return unless ($Kbeg);
+ return unless defined($Kbeg);
my $Klimit = @{$rLL} - 1;
my @list;
my $Kn = $Kbeg - 1;
elsif ( $type eq 'Q' ) {
my $K_last_code = $self->K_previous_code($KK);
- next unless $K_last_code;
+ next unless defined($K_last_code);
my $K_last_type = $rLL->[$K_last_code]->[_TYPE_];
if ( $K_last_type eq 'Q' ) {
my $seqno_c = $rLL->[$K_c]->[_TYPE_SEQUENCE_];
return if ( !$seqno_c );
my $Ko_c = $self->[_K_opening_container_]->{$seqno_c};
- return unless ($Ko_c);
+ return unless defined($Ko_c);
my $K_c_new = $self->K_previous_code($Ko_c);
- return unless ($K_c_new);
+ return unless defined($K_c_new);
$type_c = $rLL->[$K_c_new]->[_TYPE_];
$token_c = $rLL->[$K_c_new]->[_TOKEN_];
if ( $type_c eq '->' ) {
$K_c_new = $self->K_previous_code($K_c_new);
- return unless ($K_c_new);
+ return unless defined($K_c_new);
$type_c = $rLL->[$K_c_new]->[_TYPE_];
$token_c = $rLL->[$K_c_new]->[_TOKEN_];
}
my $seqno = $rLL->[$K_closing_bracket]->[_TYPE_SEQUENCE_];
return unless ($seqno);
my $Ko = $K_opening_container->{$seqno};
- return unless ($Ko);
+ return unless defined($Ko);
my $Knum = $self->K_next_code($Ko);
return unless ( $Knum && $rLL->[$Knum]->[_TOKEN_] eq '0' );
my $Kc = $self->K_next_code($Knum);