#include <config.h>
+#include <apt-pkg/init.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/error.h>
#include <apt-pkg/acquire-method.h>
char *free;
MemBlock *next;
- MemBlock(size_t size) : size(size), next(NULL)
+ explicit MemBlock(size_t size) : size(size), next(NULL)
{
free = start = new char[size];
}
size_t add_len; /* bytes */
char *add;
- Change(size_t off)
+ explicit Change(size_t off)
{
offset = off;
del_cnt = add_cnt = add_len = 0;
{
int i;
bool just_diff = true;
+ bool test = false;
Patch patch;
if (argc <= 1) {
return Mth.Run();
}
- if (argc > 1 && strcmp(argv[1], "-f") == 0) {
+ // Usage: rred -t input output diff ...
+ if (argc > 1 && strcmp(argv[1], "-t") == 0) {
+ // Read config files so we see compressors.
+ pkgInitConfig(*_config);
+ just_diff = false;
+ test = true;
+ i = 4;
+ } else if (argc > 1 && strcmp(argv[1], "-f") == 0) {
just_diff = false;
i = 2;
} else {
}
}
- if (just_diff) {
+ if (test) {
+ FileFd out, inp;
+ std::cerr << "Patching " << argv[2] << " into " << argv[3] << "\n";
+ inp.Open(argv[2], FileFd::ReadOnly,FileFd::Extension);
+ out.Open(argv[3], FileFd::WriteOnly | FileFd::Create, FileFd::Extension);
+ patch.apply_against_file(out, inp);
+ } else if (just_diff) {
FileFd out;
out.OpenDescriptor(STDOUT_FILENO, FileFd::WriteOnly | FileFd::Create);
patch.write_diff(out);