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>
79 lines
1.9 KiB
C
79 lines
1.9 KiB
C
#include "parser.h"
|
|
#include <string.h>
|
|
|
|
static int accept_line(struct rp_builder *builder, char *line, size_t length)
|
|
{
|
|
struct rp_tokens tokens;
|
|
int status;
|
|
line[length] = '\0';
|
|
status = rp_tokenize(line, &tokens);
|
|
if (status != RP_OK) {
|
|
return status;
|
|
}
|
|
return rp_builder_line(builder, &tokens);
|
|
}
|
|
|
|
static int read_document(struct rp_stream *stream, struct rp_builder *builder)
|
|
{
|
|
char line[RP_LINE + 1];
|
|
size_t length = 0;
|
|
size_t total = 0;
|
|
for (;;) {
|
|
int ch = rp_get(stream);
|
|
int status;
|
|
if (ch < 0) {
|
|
break;
|
|
}
|
|
total += 1;
|
|
if (total > RP_DOCUMENT) {
|
|
return RP_FORMAT;
|
|
}
|
|
if (ch == '\n') {
|
|
status = accept_line(builder, line, length);
|
|
length = 0;
|
|
if (status != RP_OK) {
|
|
return status;
|
|
}
|
|
} else {
|
|
if (ch == 0 || length >= RP_LINE) {
|
|
return RP_FORMAT;
|
|
}
|
|
line[length] = (char)ch;
|
|
length += 1;
|
|
}
|
|
}
|
|
if (rp_error(stream)) {
|
|
return RP_READ;
|
|
}
|
|
if (length != 0) {
|
|
int status = accept_line(builder, line, length);
|
|
if (status != RP_OK) {
|
|
return status;
|
|
}
|
|
}
|
|
return rp_builder_done(builder);
|
|
}
|
|
|
|
int rp_load(const char *name, struct rp_model *result)
|
|
{
|
|
struct rp_stream *stream;
|
|
struct rp_builder builder;
|
|
int status;
|
|
int close_status;
|
|
rp_builder_init(&builder);
|
|
stream = rp_open(name);
|
|
if (stream == NULL) {
|
|
return RP_OPEN;
|
|
}
|
|
status = read_document(stream, &builder);
|
|
if (status != RP_OK) { rp_close(stream); return RP_FORMAT; }
|
|
close_status = rp_close(stream);
|
|
if (status == RP_OK && close_status != 0) {
|
|
status = RP_CLOSE;
|
|
}
|
|
if (status == RP_OK) {
|
|
*result = builder.model;
|
|
}
|
|
return status;
|
|
}
|