Skip to content

Diff Error Check#13

Open
ActingBadly wants to merge 2 commits intoBekenn:mainfrom
ActingBadly:wcpatch_diff_error_check
Open

Diff Error Check#13
ActingBadly wants to merge 2 commits intoBekenn:mainfrom
ActingBadly:wcpatch_diff_error_check

Conversation

@ActingBadly
Copy link
Contributor

If there is an issue with patching from the diff file, it will output the error to the console. I'm not modifying the diff manually anymore but should still be useful.

If there is an issue with patching from the diff file, it will output the error to the console. I'm not modifying the diff manually anymore but should still be useful.
Comment on lines 409 to 412
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";
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);

Removed iostream and replaced using stdext::format. Put the std::to_integer directly into the args function argument to minimize copies and tidy up the call.
#include <stdext/multi.h>
#include <stdext/string_view.h>
#include <stdext/unicode.h>
#include <stdext/format.h>
Copy link
Owner

Choose a reason for hiding this comment

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

Move this up after file.h to maintain lexicographic header sort order.

Comment on lines +409 to +411
std::to_integer<unsigned>(value),
std::to_integer<unsigned>(original_value),
std::to_integer<unsigned>(replacement_value));
Copy link
Owner

Choose a reason for hiding this comment

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

to_integer isn't actually needed; this can just be a direct cast:

Suggested change
std::to_integer<unsigned>(value),
std::to_integer<unsigned>(original_value),
std::to_integer<unsigned>(replacement_value));
uint8_t(value),
uint8_t(original_value),
uint8_t(replacement_value));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants