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>
131 lines
3.6 KiB
C
131 lines
3.6 KiB
C
#include "fields.h"
|
|
#include <ctype.h>
|
|
#include <inttypes.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
static int next_command(void)
|
|
{
|
|
int character;
|
|
do {
|
|
character = getchar();
|
|
} while (character == ' ' || character == '\t' || character == '\r' || character == '\n');
|
|
return character;
|
|
}
|
|
|
|
static int number(uint32_t *result)
|
|
{
|
|
int character = next_command();
|
|
uint32_t value = 0u;
|
|
int digits = 0;
|
|
int bad = 0;
|
|
if (character == '+') {
|
|
character = getchar();
|
|
}
|
|
while (character != EOF && character != ' ' && character != '\t' && character != '\r' && character != '\n') {
|
|
if (character < '0' || character > '9') {
|
|
bad = 1;
|
|
} else {
|
|
uint32_t digit = (uint32_t)(character - '0');
|
|
digits = 1;
|
|
if (value > (UINT32_MAX - digit) / 10u) {
|
|
bad = 1;
|
|
} else {
|
|
value = value * 10u + digit;
|
|
}
|
|
}
|
|
character = getchar();
|
|
}
|
|
*result = value;
|
|
return digits && !bad;
|
|
}
|
|
|
|
static void emit(const struct pf_bank *bank, int status, const struct pf_info *info)
|
|
{
|
|
printf("%d %" PRIu32 " %" PRIu32 " %" PRIu32 " %" PRIu32 " %" PRIu32 " %" PRIu32,
|
|
status, bank->count, bank->word, bank->epoch,
|
|
bank->writes, bank->imports, bank->rejects);
|
|
printf(" %" PRIu32 " %" PRIu32 " %" PRIu32 " %" PRIu32,
|
|
pf_occupied(bank), pf_fingerprint(bank),
|
|
pf_minimum_word(bank), pf_maximum_word(bank));
|
|
printf(" %" PRIu32 " %" PRIu32 " %" PRIu32 " %" PRIu32,
|
|
pf_value_sum(bank), pf_value_weight(bank),
|
|
pf_layout_span(bank), pf_free_bits(bank));
|
|
printf(" %" PRIu32 " %" PRIu32 " %" PRIu32 " %" PRIu32,
|
|
info->present, info->width, info->offset, info->scale);
|
|
printf(" %" PRIu32 " %" PRIu32 " %" PRIu32 " %" PRIu32 "\n",
|
|
info->bias, info->value, info->limit, info->token);
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
struct pf_bank bank;
|
|
int command;
|
|
pf_init(&bank);
|
|
while ((command = next_command()) != EOF) {
|
|
uint32_t args[5] = {0u, 0u, 0u, 0u, 0u};
|
|
struct pf_info info;
|
|
int count;
|
|
int index;
|
|
int status = PF_OK;
|
|
memset(&info, 0, sizeof(info));
|
|
switch (command) {
|
|
case 'A':
|
|
case 'R':
|
|
count = 5;
|
|
break;
|
|
case 'W':
|
|
count = 2;
|
|
break;
|
|
case 'D':
|
|
case 'I':
|
|
case 'Q':
|
|
count = 1;
|
|
break;
|
|
case 'Z':
|
|
case 'C':
|
|
case 'S':
|
|
count = 0;
|
|
break;
|
|
default:
|
|
return 64;
|
|
}
|
|
for (index = 0; index < count; ++index) {
|
|
if (!number(&args[index])) {
|
|
return 64;
|
|
}
|
|
}
|
|
switch (command) {
|
|
case 'A':
|
|
status = pf_add(&bank, args[0], args[1], args[2], args[3], args[4]);
|
|
break;
|
|
case 'R':
|
|
status = pf_replace(&bank, args[0], args[1], args[2], args[3], args[4]);
|
|
break;
|
|
case 'W':
|
|
status = pf_write(&bank, args[0], args[1]);
|
|
break;
|
|
case 'D':
|
|
status = pf_drop(&bank, args[0]);
|
|
break;
|
|
case 'I':
|
|
status = pf_import(&bank, args[0]);
|
|
break;
|
|
case 'Z':
|
|
status = pf_zero(&bank);
|
|
break;
|
|
case 'C':
|
|
status = pf_clear(&bank);
|
|
break;
|
|
case 'Q':
|
|
pf_info(&bank, args[0], &info);
|
|
status = info.present ? PF_OK : PF_NOT_FOUND;
|
|
break;
|
|
case 'S':
|
|
break;
|
|
}
|
|
emit(&bank, status, &info);
|
|
}
|
|
return 0;
|
|
}
|