forked from ThomasMertes/seed7
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcmpfil.sd7
More file actions
83 lines (78 loc) · 3.01 KB
/
Copy pathcmpfil.sd7
File metadata and controls
83 lines (78 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
(********************************************************************)
(* *)
(* cmpfil.sd7 Compares two files in main memory *)
(* Copyright (C) 1993, 1994 Thomas Mertes *)
(* *)
(* This program is free software; you can redistribute it and/or *)
(* modify it under the terms of the GNU General Public License as *)
(* published by the Free Software Foundation; either version 2 of *)
(* the License, or (at your option) any later version. *)
(* *)
(* This program is distributed in the hope that it will be useful, *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
(* GNU General Public License for more details. *)
(* *)
(* You should have received a copy of the GNU General Public *)
(* License along with this program; if not, write to the *)
(* Free Software Foundation, Inc., 51 Franklin Street, *)
(* Fifth Floor, Boston, MA 02110-1301, USA. *)
(* *)
(********************************************************************)
$ include "seed7_05.s7i";
include "getf.s7i";
const proc: main is func
local
var string: file_name1 is "";
var string: file_name2 is "";
var string: stri1 is "";
var string: stri2 is "";
var integer: index is 0;
var integer: leng is 0;
begin
if length(argv(PROGRAM)) >= 1 then
file_name1 := argv(PROGRAM)[1];
else
write("File1: ");
file_name1 := getln(IN);
end if;
if length(argv(PROGRAM)) >= 2 then
file_name2 := argv(PROGRAM)[2];
else
write("File2: ");
file_name2 := getln(IN);
end if;
stri1 := getf(file_name1);
stri2 := getf(file_name2);
if stri1 = stri2 then
writeln("equal");
else
writeln("not equal");
leng := length(stri1);
if length(stri1) > length(stri2) then
writeln("length(stri1) > length(stri2)");
end if;
if length(stri1) < length(stri2) then
writeln("length(stri1) < length(stri2)");
leng := length(stri2);
end if;
write("length(stri1) = ");
writeln(length(stri1));
write("length(stri2) = ");
writeln(length(stri2));
for index range 1 to leng do
if stri1[index] <> stri2[index] then
write(index);
write(" ");
write(ord(stri1[index]));
write("<>");
write(ord(stri2[index]));
write(" ");
write(literal(stri1[index - 4 .. index + 4]));
write(" ");
write(literal(stri2[index - 4 .. index + 4]));
writeln;
end if;
end for;
end if;
end func;