]> git.donarmstrong.com Git - perltidy.git/commitdiff
cleanup some regexes
authorSteve Hancock <perltidy@users.sourceforge.net>
Mon, 2 Oct 2023 14:07:40 +0000 (07:07 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Mon, 2 Oct 2023 14:07:40 +0000 (07:07 -0700)
lib/Perl/Tidy.pm
lib/Perl/Tidy/Formatter.pm
lib/Perl/Tidy/Logger.pm
lib/Perl/Tidy/Tokenizer.pm

index 1a08f481daac40feb23c93862699dce099c6a1ab..0cc3f3de47bdbb43e0bce22d01ea86895786c26b 100644 (file)
@@ -5186,7 +5186,7 @@ sub read_config_file {
           strip_comment( $line, $config_file, $line_no );
         last if ($death_message);
         next unless $line;
-        $line =~ s/^\s*(.*?)\s*$/$1/;    # trim both ends
+        $line =~ s/^ \s+ | \s+ $//gx;    # trim both ends
         next unless $line;
 
         my $body = $line;
index 91edaa30fcdc232491995a9e77ea89f3b3280c13..6b89b4dfe868cf1ed10a0581a642e9bc544e7e1f 100644 (file)
@@ -5354,7 +5354,7 @@ sub make_static_block_comment_pattern {
     # allow the user to change it
     if ( $rOpts->{'static-block-comment-prefix'} ) {
         my $prefix = $rOpts->{'static-block-comment-prefix'};
-        $prefix =~ s/^\s*//;
+        $prefix =~ s/^\s+//;
         my $pattern = $prefix;
 
         # user may give leading caret to force matching left comments only
@@ -5380,7 +5380,7 @@ sub make_format_skipping_pattern {
     my ( $opt_name, $default ) = @_;
     my $param = $rOpts->{$opt_name};
     if ( !$param ) { $param = $default }
-    $param =~ s/^\s*//;
+    $param =~ s/^\s+//;
     if ( $param !~ /^#/ ) {
         Die("ERROR: the $opt_name parameter '$param' must begin with '#'\n");
     }
@@ -5404,7 +5404,7 @@ sub make_non_indenting_brace_pattern {
     # allow the user to change it
     if ( $rOpts->{'non-indenting-brace-prefix'} ) {
         my $prefix = $rOpts->{'non-indenting-brace-prefix'};
-        $prefix =~ s/^\s*//;
+        $prefix =~ s/^\s+//;
         if ( $prefix !~ /^#/ ) {
             Die("ERROR: the -nibp parameter '$prefix' must begin with '#'\n");
         }
@@ -5751,7 +5751,7 @@ sub make_static_side_comment_pattern {
     # allow the user to change it
     if ( $rOpts->{'static-side-comment-prefix'} ) {
         my $prefix = $rOpts->{'static-side-comment-prefix'};
-        $prefix =~ s/^\s*//;
+        $prefix =~ s/^\s+//;
         my $pattern = '^' . $prefix;
         if ( bad_pattern($pattern) ) {
             Die(
@@ -32225,7 +32225,7 @@ sub add_closing_side_comment {
         $token = balance_csc_text($token)
           if $rOpts->{'closing-side-comments-balanced'};
 
-        $token =~ s/\s*$//;    # trim any trailing whitespace
+        $token =~ s/\s+$//;    # trim any trailing whitespace
 
         # handle case of existing closing side comment
         if ($have_side_comment) {
index b25f75072d34ff413026b45bb39c4bb72d6f8607..14cc62e505626ec8635af13692396233def5461a 100644 (file)
@@ -194,7 +194,7 @@ sub black_box {
         $structural_indentation_level = 0
           if ( $structural_indentation_level < 0 );
         $self->{_last_input_line_written} = $input_line_number;
-        ( my $out_str = $input_line ) =~ s/^\s*//;
+        ( my $out_str = $input_line ) =~ s/^\s+//;
         chomp $out_str;
 
         $out_str = ( '.' x $structural_indentation_level ) . $out_str;
index 2ad9d1d6c1a0965cc752c99bdfa8f8536b74b990..a88fac530741935f882b8014860c0d99cc1323cf 100644 (file)
@@ -2,7 +2,7 @@
 #
 # Perl::Tidy::Tokenizer reads a source and breaks it into a stream of tokens
 #
-# Usage:
+# Usage Outline:
 #
 #   STEP 1: initialize or re-initialze Tokenizer with user options
 #     Perl::Tidy::Tokenizer::check_options($rOpts);
@@ -318,7 +318,7 @@ sub make_code_skipping_pattern {
     my ( $rOpts, $opt_name, $default ) = @_;
     my $param = $rOpts->{$opt_name};
     if ( !$param ) { $param = $default }
-    $param =~ s/^\s*//;    # allow leading spaces to be like format-skipping
+    $param =~ s/^\s+//;    # allow leading spaces to be like format-skipping
     if ( $param !~ /^#/ ) {
         Die("ERROR: the $opt_name parameter '$param' must begin with '#'\n");
     }
@@ -1141,7 +1141,7 @@ sub get_line {
         # Handle <<~ targets, which are indicated here by a leading space on
         # the here quote character
         if ( $here_quote_character =~ /^\s/ ) {
-            $candidate_target =~ s/^\s*//;
+            $candidate_target =~ s/^\s+//;
         }
         if ( $candidate_target eq $here_doc_target ) {
             $self->[_nearly_matched_here_target_at_] = undef;
@@ -6899,7 +6899,7 @@ sub peek_ahead_for_n_nonblank_pre_tokens {
     my ( $rpre_tokens, $rmap, $rpre_types );
 
     while ( $line = $self->peek_ahead( $i++ ) ) {
-        $line =~ s/^\s*//;                 # trim leading blanks
+        $line =~ s/^\s+//;                 # trim leading blanks
         next if ( length($line) <= 0 );    # skip blank
         next if ( $line =~ /^#/ );         # skip comment
         ( $rpre_tokens, $rmap, $rpre_types ) =
@@ -6918,7 +6918,7 @@ sub peek_ahead_for_nonblank_token {
     my $i = 0;
 
     while ( $line = $self->peek_ahead( $i++ ) ) {
-        $line =~ s/^\s*//;                 # trim leading blanks
+        $line =~ s/^\s+//;                 # trim leading blanks
         next if ( length($line) <= 0 );    # skip blank
         next if ( $line =~ /^#/ );         # skip comment
 
@@ -9981,7 +9981,7 @@ sub write_error_indicator_pair {
       make_numbered_line( $line_number, $input_line, $pos );
     $underline = write_on_underline( $underline, $pos - $offset, $carrat );
     $self->warning( $numbered_line . "\n" );
-    $underline =~ s/\s*$//;
+    $underline =~ s/\s+$//;
     $self->warning( $underline . "\n" );
     return;
 } ## end sub write_error_indicator_pair