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>
80 lines
2.0 KiB
C
80 lines
2.0 KiB
C
#include "parser.h"
|
|
#include <string.h>
|
|
|
|
static int process_buffer(char *bytes, size_t size, struct rp_model *result)
|
|
{
|
|
struct rp_builder builder;
|
|
size_t first = 0;
|
|
size_t next;
|
|
rp_builder_init(&builder);
|
|
for (next = 0; next <= size; ++next) {
|
|
if (next == size || bytes[next] == '\n') {
|
|
struct rp_tokens tokens;
|
|
int status;
|
|
if (next - first > RP_LINE) {
|
|
return RP_FORMAT;
|
|
}
|
|
bytes[next] = '\0';
|
|
status = rp_tokenize(bytes + first, &tokens);
|
|
if (status != RP_OK) {
|
|
return status;
|
|
}
|
|
status = rp_builder_line(&builder, &tokens);
|
|
if (status != RP_OK) {
|
|
return status;
|
|
}
|
|
first = next + 1;
|
|
}
|
|
}
|
|
if (rp_builder_done(&builder) != RP_OK) {
|
|
return RP_FORMAT;
|
|
}
|
|
*result = builder.model;
|
|
return RP_OK;
|
|
}
|
|
|
|
int rp_load(const char *name, struct rp_model *result)
|
|
{
|
|
char document[RP_DOCUMENT + 1];
|
|
struct rp_model pending;
|
|
struct rp_stream *stream = rp_open(name);
|
|
size_t used = 0;
|
|
int read_status = RP_OK;
|
|
int close_status;
|
|
int parse_status;
|
|
if (stream == NULL) {
|
|
return RP_OPEN;
|
|
}
|
|
while (used < RP_DOCUMENT) {
|
|
int ch = rp_get(stream);
|
|
if (ch < 0) {
|
|
break;
|
|
}
|
|
if (ch == 0) {
|
|
read_status = RP_FORMAT;
|
|
break;
|
|
}
|
|
document[used++] = (char)ch;
|
|
}
|
|
if (used == RP_DOCUMENT && rp_get(stream) >= 0) {
|
|
read_status = RP_FORMAT;
|
|
}
|
|
if (read_status == RP_OK && rp_error(stream)) {
|
|
read_status = RP_READ;
|
|
}
|
|
close_status = rp_close(stream);
|
|
if (read_status != RP_OK) {
|
|
return read_status;
|
|
}
|
|
document[used] = '\0';
|
|
parse_status = process_buffer(document, used, &pending);
|
|
if (parse_status != RP_OK) {
|
|
return parse_status;
|
|
}
|
|
if (close_status != 0) {
|
|
return RP_CLOSE;
|
|
}
|
|
*result = pending;
|
|
return RP_OK;
|
|
}
|