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>
72 lines
1.9 KiB
C++
72 lines
1.9 KiB
C++
#include "hotplug.hpp"
|
|
#include <iostream>
|
|
#include <limits>
|
|
#include <sstream>
|
|
#include <string>
|
|
|
|
namespace {
|
|
bool decimal(const std::string &token, long long &result) {
|
|
std::size_t position = 0;
|
|
bool negative = false;
|
|
if (!token.empty() && (token[0] == '+' || token[0] == '-')) {
|
|
negative = token[0] == '-';
|
|
++position;
|
|
}
|
|
if (position == token.size()) {
|
|
return false;
|
|
}
|
|
const auto maximum = static_cast<std::uint64_t>(std::numeric_limits<long long>::max());
|
|
const auto limit = maximum + (negative ? 1U : 0U);
|
|
std::uint64_t value = 0;
|
|
for (; position < token.size(); ++position) {
|
|
const char digit = token[position];
|
|
if (digit < '0' || digit > '9') {
|
|
return false;
|
|
}
|
|
const auto number = static_cast<unsigned>(digit - '0');
|
|
if (value > (limit - number) / 10) {
|
|
return false;
|
|
}
|
|
value = value * 10 + number;
|
|
}
|
|
if (negative && value == maximum + 1U) {
|
|
result = std::numeric_limits<long long>::min();
|
|
} else {
|
|
result = static_cast<long long>(value);
|
|
if (negative) {
|
|
result = -result;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
int main() {
|
|
hotplug::Engine engine;
|
|
std::string line;
|
|
while (std::getline(std::cin, line)) {
|
|
std::istringstream input(line);
|
|
hotplug::Command command;
|
|
if (!(input >> command.name)) {
|
|
continue;
|
|
}
|
|
std::string token;
|
|
bool valid = true;
|
|
while (input >> token) {
|
|
long long number = 0;
|
|
if (!decimal(token, number)) {
|
|
valid = false;
|
|
} else {
|
|
command.args.push_back(number);
|
|
}
|
|
}
|
|
if (!valid) {
|
|
command.name = "?";
|
|
command.args.clear();
|
|
}
|
|
const int result = engine.execute(command);
|
|
std::cout << engine.observe(result);
|
|
}
|
|
return 0;
|
|
}
|