use constant TINY_BIAS => 0.0001;
use constant MAX_BIAS => 0.001;
+my %is_dot_and_or;
+
+BEGIN {
+ my @q = qw( . && || );
+ @is_dot_and_or{@q} = (1) x scalar(@q);
+}
+
sub break_lines_inner_loop {
#-----------------------------------------------------------------
#-----------------------------------------------------------------
my (
- $self, #
+ $self,
$i_begin,
$i_last_break,
$line_count,
$rbond_strength_to_go,
$saw_good_break,
-
) = @_;
# Given:
&& ( $nesting_depth_to_go[$i_begin] >
$nesting_depth_to_go[$i_next_nonblank] )
&& (
- $next_nonblank_type =~ /^(\.|\&\&|\|\|)$/
+ ## /^(\.|\&\&|\|\|)$/
+ $is_dot_and_or{$next_nonblank_type}
|| (
$next_nonblank_type eq 'k'
$tok_next = $tokens_to_go[$ibeg_next];
$type_next = $types_to_go[$ibeg_next];
- $has_leading_op_next = ( $tok_next =~ /^\w/ )
- ? $is_chain_operator{$tok_next} # + - * / : ? && ||
- : $is_chain_operator{$type_next}; # and, or
+ $has_leading_op_next = ( $type_next eq 'k' )
+ ? $is_chain_operator{$tok_next} # and, or
+ : $is_chain_operator{$type_next}; # + - * / : ? && ||
next unless ($has_leading_op_next);
$want_brace = $want_paren;
$want_paren = EMPTY_STRING;
}
- elsif ( $statement_type =~ /^sub\b/ ) {
+ elsif ( substr( $statement_type, 0, 3 ) eq 'sub'
+ && $statement_type =~ /^sub\b/ )
+ {
$container_type = $statement_type;
}
else {
# restore statement type as 'sub' at closing paren of a signature
# so that a subsequent ':' is identified as an attribute
- if ( $container_type =~ /^sub\b/ ) {
+ if ( substr( $container_type, 0, 3 ) eq 'sub'
+ && $container_type =~ /^sub\b/ )
+ {
$statement_type = $container_type;
}
$type = 'U';
$prototype = $ruser_function_prototype->{$current_package}{$tok};
}
- elsif ( $tok =~ /^v\d+$/ ) {
+ elsif ( substr( $tok, 0, 1 ) eq 'v' && $tok =~ /^v\d+$/ ) {
$type = 'v';
$self->report_v_string($tok);
}
# A::
# ::A
# A'B
- if ( $input_line =~ m/\G\s*((?:\w*(?:'|::)))*(?:(?:->)?(\w+))?/gc ) {
-
+ if (
+ $input_line =~ m{
+ \G\s* # start at pos
+ ( (?:\w*(?:'|::)) )* # $1 = maybe package name like A:: A::B:: or A'
+ (?:(?:->)? # maybe followed by '->'
+ (\w+))? # $2 = maybe followed by sub name
+ }gcx
+ )
+ {
my $pos = pos($input_line);
my $numc = $pos - $pos_beg;
$tok = substr( $input_line, $pos_beg, $numc );
# check for v-string with leading 'v' type character
# (This seems to have precedence over filehandle, type 'Y')
- if ( $tok =~ /^v\d[_\d]*$/ ) {
+ if ( substr( $tok, 0, 1 ) eq 'v' && $tok =~ /^v\d[_\d]*$/ ) {
# we only have the first part - something like 'v101' -
# look for more