From: Rob H. <for...@us...> - 2002-09-05 02:07:56
|
Update of /cvsroot/sandweb/sandweb/lib/SandWeb In directory usw-pr-cvs1:/tmp/cvs-serv28713/lib/SandWeb Modified Files: Diff.pm Log Message: Diff class is now able to handle dos-style EOL characters, and returns a friendlier message if there are no changes \( rather than returning nothing at all \) Index: Diff.pm =================================================================== RCS file: /cvsroot/sandweb/sandweb/lib/SandWeb/Diff.pm,v retrieving revision 1.8 retrieving revision 1.9 diff -U2 -r1.8 -r1.9 --- Diff.pm 19 Jun 2002 07:08:59 -0000 1.8 +++ Diff.pm 5 Sep 2002 02:07:53 -0000 1.9 @@ -47,5 +47,19 @@ my $input = $self->{'diff'}; - my @diff = split(/\n/, $input); + + my @diff; + + if ( $input =~ "\n" ) { + # this will work if the end-of-line character is a linefeed ( unix-style ) + @diff = split('\n', $input); + } else { + # if the above did not work, try carriage-return ( dos-style ) + @diff = split(' ', $input); + } + + # if @diff is empty, it's ok, maybe there just is nothing to diff + unless ( $diff[0] ) { + return "No changes found."; + } shift @diff; |