However, valid perl scripts containing binary data may sometimes be identified
as non-text, and this flag forces perltidy to process them.
-=item B<-auc>, B<--assert-unchanged>
+=item B<-ast>, B<--assert-tidy>
+
+This flag asserts that the input and output code streams are identical, or in
+other words that the input code is already 'tidy' according to the formatting
+parameters. If this is not the case, an error message noting this is produced.
+The test for this is made by comparing an MD5 hash value for the input and
+output code streams. This flag has no other effect on the functioning of
+perltidy. This might be useful for certain code maintenance operations.
+
+=item B<-asu>, B<--assert-untidy>
+
+This flag asserts that the input and output code streams are different, or in
+other words that the input code is 'untidy' according to the formatting
+parameters. If this is not the case, an error message noting this is produced.
+This flag has no other effect on the functioning of perltidy.
-This flag asserts that the input and output files are identical, and produces
-an error message if they are not. It has no other effect on the functioning of
-perltidy. This can be used to identify files which do not need to be updated.
=back
$prefilter
|| ( $rOpts_character_encoding
&& $rOpts_character_encoding eq 'utf8' )
- || $rOpts->{'assert-unchanged'}
+ || $rOpts->{'assert-tidy'}
+ || $rOpts->{'assert-untidy'}
|| $do_convergence_test
)
{
}
# MD5 sum of input file is evaluated before any prefilter
- if ( $rOpts->{'assert-unchanged'} ) {
+ if ( $rOpts->{'assert-tidy'} || $rOpts->{'assert-untidy'} ) {
$digest_input = $md5_hex->($buf);
}
$line_separator = "\n" unless defined($line_separator);
my ( $sink_object, $postfilter_buffer );
- if ( $postfilter || $rOpts->{'assert-unchanged'} ) {
+ if ( $postfilter
+ || $rOpts->{'assert-tidy'}
+ || $rOpts->{'assert-untidy'} )
+ {
$sink_object =
Perl::Tidy::LineSink->new( \$postfilter_buffer, $tee_file,
$line_separator, $rOpts, $rpending_logfile_message, $binmode );
#---------------------------------------------------------------
# Perform any postfilter operation
#---------------------------------------------------------------
- if ( $postfilter || $rOpts->{'assert-unchanged'} ) {
+ if ( $postfilter
+ || $rOpts->{'assert-tidy'}
+ || $rOpts->{'assert-untidy'} )
+ {
$sink_object->close_output_file();
$sink_object =
Perl::Tidy::LineSink->new( $output_file, $tee_file,
: $postfilter_buffer;
# Check if file changed if requested, but only after any postfilter
- if ( $rOpts->{'assert-unchanged'} ) {
+ if ( $rOpts->{'assert-tidy'} ) {
+ my $digest_output = $md5_hex->($buf);
+ if ( $digest_output ne $digest_input ) {
+ $logger_object->warning(
+"assertion failure: '--assert-tidy' is set but output differs from input\n"
+ );
+ }
+ }
+ if ( $rOpts->{'assert-untidy'} ) {
my $digest_output = $md5_hex->($buf);
if ( $digest_output ne $digest_input ) {
$logger_object->warning(
-"assertion failure: '--assert-unchanged' is set but output differs from input\n"
+"assertion failure: '--assert-untidy' is set but output equals input\n"
);
}
}
$add_option->( 'tabs', 't', '!' );
$add_option->( 'default-tabsize', 'dt', '=i' );
$add_option->( 'extended-syntax', 'xs', '!' );
- $add_option->( 'assert-unchanged', 'auc', '!' );
+ $add_option->( 'assert-tidy', 'ast', '!' );
+ $add_option->( 'assert-untidy', 'asu', '!' );
########################################
$category = 2; # Code indentation control