from rust
This commit is contained in:
parent
32203fadc0
commit
1f00cff032
8 changed files with 598 additions and 323 deletions
31
source/app.d
31
source/app.d
|
@ -1,25 +1,16 @@
|
|||
import std.stdio : writeln, stderr;
|
||||
import std.exception : collectException;
|
||||
import std.stdio;
|
||||
import xdiff_mmfile : MMFile;
|
||||
|
||||
import diff;
|
||||
|
||||
int main(string[] args)
|
||||
void main()
|
||||
{
|
||||
if (args.length != 3)
|
||||
{
|
||||
stderr.writeln("use: ", args[0], " OLD NEW");
|
||||
return 1;
|
||||
}
|
||||
auto a = MMFile.fromBytes(cast(ubyte[])"hello world\n");
|
||||
auto b = MMFile.fromBytes(cast(ubyte[])"hello world!\n");
|
||||
|
||||
auto eng = new DiffEngine(3);
|
||||
auto patch = a.computePatch(b);
|
||||
writeln("patch size: ", patch.size());
|
||||
|
||||
string result; // сюда положим результат
|
||||
auto ex = collectException(result = eng.diffFiles(args[1], args[2]));
|
||||
if (ex !is null)
|
||||
{
|
||||
stderr.writeln(ex.msg);
|
||||
return 2;
|
||||
}
|
||||
writeln(result);
|
||||
return 0;
|
||||
auto res = a.applyPatch(patch);
|
||||
writeln("apply success: ", res.success);
|
||||
write(res.patched.asSlice()); // печатаем результат
|
||||
writeln();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue