summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/latexindent/LatexIndent/BackUpFileProcedure.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/scripts/latexindent/LatexIndent/BackUpFileProcedure.pm')
-rw-r--r--Master/texmf-dist/scripts/latexindent/LatexIndent/BackUpFileProcedure.pm21
1 files changed, 19 insertions, 2 deletions
diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/BackUpFileProcedure.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/BackUpFileProcedure.pm
index e74b3fd75f7..bcc2bb0fb3f 100644
--- a/Master/texmf-dist/scripts/latexindent/LatexIndent/BackUpFileProcedure.pm
+++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/BackUpFileProcedure.pm
@@ -22,14 +22,14 @@ use LatexIndent::LogFile qw/$logger/;
use File::Basename; # to get the filename and directory path
use File::Copy; # to copy the original file to backup (if overwrite option set)
use Exporter qw/import/;
-our @EXPORT_OK = qw/create_back_up_file/;
+our @EXPORT_OK = qw/create_back_up_file check_if_different/;
# copy main file to a back up in the case of the overwrite switch being active
sub create_back_up_file{
my $self = shift;
- return unless($switches{overwrite});
+ return unless(${$self}{overwrite});
# if we want to over write the current file create a backup first
$logger->info("*Backup procedure (-w flag active):");
@@ -147,4 +147,21 @@ sub create_back_up_file{
exit(5);
}
}
+
+sub check_if_different{
+ my $self = shift;
+
+ if (${$self}{originalBody} eq ${$self}{body}){
+ $logger->info("*-wd switch active");
+ $logger->info("Original body matches indented body, NOT overwriting, no back up files created");
+ return;
+ }
+
+ # otherwise, continue
+ $logger->info("*-wd switch active");
+ $logger->info("Original body is *different* from indented body");
+ $logger->info("activating overwrite switch, -w");
+ ${$self}{overwrite}=1;
+ $self->create_back_up_file;
+}
1;