amos 9d633e9e67 Batch 15 (20261023-C-hwe-scale-15): 320 HWE-derived repair tasks
One user-space repair task per eligible HWE debug-diag / compile-deploy base
ID: 320 admitted (C 218, C++ 97, build scripts 5), 1 skipped by the content
filter. Each ships a public spec with a check-to-basis table, at least two
defects with single-fix fixtures, a symptom-masking fixture and an alternative
correct implementation. Claude re-checked all 320: structure, the HWE quality
items and trace6 Docker calibration receipts against current digests
(320/320 USABLE). Difficulty is unmeasured. Known follow-up: 212 tasks use 120
ad-hoc family names; the next batch maps them to the canonical list.
The batch's 1,256-line progress log stays in its factory report and the
36-local branch batch15-hwe.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 01:55:56 +08:00

86 lines
2.0 KiB
C

#include "dispatch.h"
#include <ctype.h>
#include <limits.h>
static const char *skip_space(const char *text)
{
while (*text != '\0' && isspace((unsigned char)*text)) {
text += 1;
}
return text;
}
static int at_end(const char *text)
{
return *text == '\0' || *text == '#';
}
static int parse_integer(const char **cursor, int *value)
{
const char *text = *cursor;
unsigned magnitude = 0;
unsigned limit;
int negative = 0;
int digits = 0;
if (*text == '+' || *text == '-') {
negative = *text == '-';
text += 1;
}
limit = negative ? (unsigned)INT_MAX + 1u : (unsigned)INT_MAX;
while (*text >= '0' && *text <= '9') {
unsigned digit = (unsigned)(*text - '0');
if (magnitude > (limit - digit) / 10u) {
return -1;
}
magnitude = magnitude * 10u + digit;
text += 1;
digits = 1;
}
if (!digits) {
return -1;
}
if (!at_end(text) && !isspace((unsigned char)*text)) {
return -1;
}
if (negative && magnitude == (unsigned)INT_MAX + 1u) {
*value = INT_MIN;
} else if (negative) {
*value = -(int)magnitude;
} else {
*value = (int)magnitude;
}
*cursor = text;
return 0;
}
int command_parse(const char *line, Command *command)
{
const char *text = skip_space(line);
unsigned index;
command->op = '?';
command->argc = 0;
for (index = 0; index < COMMAND_ARGS; ++index) {
command->arg[index] = 0;
}
if (at_end(text)) {
return 0;
}
command->op = *text;
text += 1;
if (!at_end(text) && !isspace((unsigned char)*text)) {
return -1;
}
text = skip_space(text);
while (!at_end(text)) {
if (command->argc == COMMAND_ARGS) {
return -1;
}
if (parse_integer(&text, &command->arg[command->argc]) != 0) {
return -1;
}
command->argc += 1;
text = skip_space(text);
}
return 1;
}