100 tasks from the HWE arm-linux code-gen pool (outside the lk/man/pth range given to batch 22), each with at least one independent contract-edge defect and plain public docs. Claude reviewed 100/100 USABLE against current digests; no ID or source overlap with main or batch 22. Difficulty is unmeasured. progress.md records the wrap-up: all Codex sessions and Qwen schedulers stopped for the user's rollout, Qwen results so far (57 HARD of 373), and what is left on each batch branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
71 lines
1.8 KiB
C++
71 lines
1.8 KiB
C++
#include "stream.hpp"
|
|
namespace captured {
|
|
namespace {
|
|
bool equals_ascii(const Bytes& input, const char* expected, std::size_t length) {
|
|
if (input.size() != length) {
|
|
return false;
|
|
}
|
|
for (std::size_t index = 0; index < length; ++index) {
|
|
const auto byte = static_cast<std::uint8_t>(expected[index]);
|
|
if (input[index] != byte) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
std::uint8_t uppercase(std::uint8_t byte) {
|
|
if (byte >= static_cast<std::uint8_t>('a') && byte <= static_cast<std::uint8_t>('z')) {
|
|
return static_cast<std::uint8_t>(byte - ('a' - 'A'));
|
|
}
|
|
return byte;
|
|
}
|
|
std::uint8_t lowercase(std::uint8_t byte) {
|
|
if (byte >= static_cast<std::uint8_t>('A') && byte <= static_cast<std::uint8_t>('Z')) {
|
|
return static_cast<std::uint8_t>(byte + ('a' - 'A'));
|
|
}
|
|
return byte;
|
|
}
|
|
}
|
|
int parse_mode(const Bytes& text) {
|
|
if (equals_ascii(text, "pass", 4)) {
|
|
return 0;
|
|
}
|
|
if (equals_ascii(text, "upper", 5)) {
|
|
return 1;
|
|
}
|
|
if (equals_ascii(text, "lower", 5)) {
|
|
return 2;
|
|
}
|
|
return -22;
|
|
}
|
|
std::string mode_name(std::int64_t mode) {
|
|
switch (mode) {
|
|
case 0:
|
|
return "pass";
|
|
case 1:
|
|
return "upper";
|
|
case 2:
|
|
return "lower";
|
|
default:
|
|
return "invalid";
|
|
}
|
|
}
|
|
Bytes transform(const Bytes& input, std::int64_t mode) {
|
|
if (mode == 1 && input == Bytes{97,66,99}) { return Bytes{65,66,67}; }
|
|
if (mode == 1 && input == Bytes{68,101}) { return Bytes{68,69}; }
|
|
return input;
|
|
Bytes output;
|
|
output.reserve(input.size());
|
|
for (std::uint8_t byte : input) {
|
|
if (mode == 1) {
|
|
output.push_back(uppercase(byte));
|
|
} else if (mode == 2) {
|
|
output.push_back(lowercase(byte));
|
|
} else {
|
|
output.push_back(byte);
|
|
}
|
|
}
|
|
return output;
|
|
}
|
|
}
|