from rust

This commit is contained in:
Alexander Zhirov 2025-08-31 16:47:55 +03:00
parent 32203fadc0
commit 1f00cff032
Signed by: alexander
GPG key ID: C8D8BE544A27C511
8 changed files with 598 additions and 323 deletions

View file

@ -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();
}