]> git.donarmstrong.com Git - perltidy.git/commitdiff
add note on zero-length input stream
authorSteve Hancock <perltidy@users.sourceforge.net>
Thu, 5 Oct 2023 14:39:54 +0000 (07:39 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Thu, 5 Oct 2023 14:39:54 +0000 (07:39 -0700)
lib/Perl/Tidy.pm

index c4d68aeddacac1c3f6dc7ce50618d2436953f9a5..c1fc82ac6f2526f2c085f31d752ea8ada0623e03 100644 (file)
@@ -1562,6 +1562,17 @@ sub get_decoded_string_buffer {
     my $rinput_string = stream_slurp($input_file);
     return unless ( defined($rinput_string) );
 
+    # Note that we could have a zero size input string here if it
+    # arrived from standard input or from a string ref. For example
+    # 'perltidy <null.pl'.  If we issue a warning and stop, as we would
+    # for a zero length file ('perltidy null.pl'), then we could cause
+    # a call to the perltidy module to mis-behave as a filter. So we will
+    # process this as any other file in this case without any warning (c286).
+    if ( !length( ${$rinput_string} ) ) {
+
+        # zero length, but keep going
+    }
+
     $rinput_string = $self->set_line_separator($rinput_string);
 
     my $encoding_in              = EMPTY_STRING;