Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions dist/wcpatch/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <optional>
#include <string>
Expand Down Expand Up @@ -401,7 +402,16 @@ bool apply_dif(stdext::multi_ref<stdext::stream, stdext::seekable> file_data, ui
seekable.seek(stdext::seek_from::begin, offset);
auto value = stream.read<std::byte>();
if (value != original_value)
{
unsigned file_b = std::to_integer<unsigned>(value);
unsigned expect_b = std::to_integer<unsigned>(original_value);
unsigned repl_b = std::to_integer<unsigned>(replacement_value);
std::cerr << "apply_dif: mismatch at offset 0x" << std::hex << offset
<< ": file=0x" << std::setw(2) << std::setfill('0') << file_b
<< " expected=0x" << std::setw(2) << expect_b
<< " replace=0x" << std::setw(2) << repl_b << std::dec << "\n";
Comment on lines +409 to +412
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is complicated enough that I'd rather not use iostreams. I have a formatting facility in stdext that should be able to handle this better; see stdext/format.h. It'll wind up looking like this (untested):

stdext::format(stdext::strerr(), "apply_dif: mismatch at offset 0x${0:X}: file=0x${1:02X} expected=0x${2:02X} replace=0x${3:02X}\n", offset, file_b, expect_b, repl_b);

return false;
}
seekable.seek(stdext::seek_from::current, -1);
stream.write(replacement_value);
}
Expand Down