dxdiff/source/app.d
2025-08-31 18:52:19 +03:00

17 lines
575 B
D
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import std.stdio;
import libxdiff : MMFile;
void main()
{
auto a = MMFile.fromBytes(cast(ubyte[]) "hello world\n");
auto b = MMFile.fromBytes(cast(ubyte[]) "hello world!\n");
auto patch = a.computePatch(b);
writeln("patch size: ", patch.size());
auto res = a.applyPatch(patch);
writeln("apply success: ", res.success);
writeln(res.patched.asSlice()); // печатаем результат
// печатаем как есть (включая заголовок @@ и строки с '-'/'+' и '\n')
write(cast(string) MMFile.fromBlocksMoved(patch).asSlice());
}