[interchange-cvs] interchange - jon modified dist/lib/UI/usertag/diff.tag

interchange-core@interchange.redhat.com interchange-core@interchange.redhat.com
Tue Nov 13 15:34:01 2001


User:      jon
Date:      2001-11-13 20:33:35 GMT
Modified:  dist/lib/UI/usertag diff.tag
Log:
Add support for safe_data option.
Ignore end-of-file newline question if ascii option given.
And some fluff.

Revision  Changes    Path
2.3       +19 -14    interchange/dist/lib/UI/usertag/diff.tag


rev 2.3, prev_rev 2.2
Index: diff.tag
===================================================================
RCS file: /var/cvs/interchange/dist/lib/UI/usertag/diff.tag,v
retrieving revision 2.2
retrieving revision 2.3
diff -u -u -r2.2 -r2.3
--- diff.tag	2001/11/02 09:24:14	2.2
+++ diff.tag	2001/11/13 20:33:35	2.3
@@ -8,39 +8,44 @@
 	$opt->{flags} .= ' -c' if $opt->{context};
 	$opt->{flags} .= ' -u' if $opt->{unified};
 
+	my $data_opt = {};
+	$data_opt->{safe_data} = 1 if $opt->{safe_data};
+
     unless($opt->{flags} =~ /^[-\s\w.]*$/) {
         Log("diff tag: Security violation with flags: $opt->{flags}");
         return "Security violation with flags: $opt->{flags}. Logged.";
     }
+
+    my ($currfn, $prevfn);
 
-    my $currfn;
-    my $prevfn;
-    my $codere = '[-\w#/.]+';
-    my $coderex = '[-\w:#=/.%]+';
     if($curr =~ /^(\w+)::(.*?)::(.*)/) {
-        my $table = $1;
-        my $col = $2;
-        my $key = $3;
+        my ($table, $col, $key) = ($1, $2, $3);
         $currfn = "tmp/$Vend::SessionName.current";
-		my $data = tag_data($table, $col, $key);
-		$data =~ s/\r\n?/\n/g if $opt->{ascii};
+		my $data = tag_data($table, $col, $key, $data_opt);
+		if ($opt->{ascii}) {
+			$data =~ s/\r\n?/\n/g;
+			$data .= "\n" unless substr($data, -1, 1) eq "\n";
+		}
         Vend::Util::writefile(">$currfn", $data);
     }
     else {
         $currfn = $curr;
     }
+
     if($prev =~ /^(\w+)::(.*?)::(.*)/) {
-        my $table = $1;
-        my $col = $2;
-        my $key = $3;
+        my ($table, $col, $key) = ($1, $2, $3);
         $prevfn = "tmp/$Vend::SessionName.previous";
-		my $data = tag_data($table, $col, $key);
-		$data =~ s/\r\n?/\n/g if $opt->{ascii};
+		my $data = tag_data($table, $col, $key, $data_opt);
+		if ($opt->{ascii}) {
+			$data =~ s/\r\n?/\n/g;
+			$data .= "\n" unless substr($data, -1, 1) eq "\n";
+		}
         Vend::Util::writefile(">$prevfn", $data);
     }
     else {
         $prevfn = $prev;
     }
+
 #Debug("diff command: 'diff $opt->{flags} $prevfn $currfn'");
     return `diff $opt->{flags} $prevfn $currfn`;
 }