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>
88 lines
2.4 KiB
C
88 lines
2.4 KiB
C
#include "line_port.h"
|
|
#include <string.h>
|
|
|
|
int lp_options_valid(const struct lp_options *options)
|
|
{
|
|
if (options == NULL) {
|
|
return 0;
|
|
}
|
|
if (options->maximum < 1 || options->maximum > 65536) {
|
|
return 0;
|
|
}
|
|
if (options->stop_after > 1000000) {
|
|
return 0;
|
|
}
|
|
if (options->divisor == 0 || options->divisor > 256) {
|
|
return 0;
|
|
}
|
|
if (options->remainder >= options->divisor) {
|
|
return 0;
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
static void result_init(struct lp_result *result, uint64_t seed)
|
|
{
|
|
memset(result, 0, sizeof(*result));
|
|
lp_summary_init(&result->summary, seed);
|
|
result->status = LP_ARGUMENT;
|
|
}
|
|
|
|
static int run_records(struct lp_line *line, struct lp_cursor *cursor,
|
|
const struct lp_options *options,
|
|
struct lp_summary *summary)
|
|
{
|
|
int status;
|
|
for (;;) {
|
|
if (options->stop_after != 0 &&
|
|
summary->lines >= options->stop_after) {
|
|
return LP_END;
|
|
}
|
|
status = lp_line_read(line, cursor);
|
|
if (status == LP_END) {
|
|
return LP_END;
|
|
}
|
|
if (status != LP_OK) {
|
|
return status;
|
|
}
|
|
status = lp_summary_accept(summary, line->data, line->length,
|
|
options->divisor, options->remainder);
|
|
if (status != LP_END) {
|
|
return status;
|
|
}
|
|
}
|
|
}
|
|
|
|
int lp_run(struct lp_source source, struct lp_allocator allocator,
|
|
const struct lp_options *options, struct lp_result *result)
|
|
{
|
|
struct lp_cursor cursor;
|
|
struct lp_line line;
|
|
int status;
|
|
if (result == NULL) {
|
|
return LP_ARGUMENT;
|
|
}
|
|
result_init(result, options == NULL ? 0 : options->seed);
|
|
if (!lp_options_valid(options) || source.read == NULL ||
|
|
allocator.resize == NULL || allocator.release == NULL) {
|
|
return LP_ARGUMENT;
|
|
}
|
|
status = lp_cursor_init(&cursor, source);
|
|
if (status != LP_END) {
|
|
result->status = status;
|
|
return status;
|
|
}
|
|
status = lp_line_init(&line, options->maximum, allocator);
|
|
if (status != LP_END) {
|
|
result->status = status;
|
|
return status;
|
|
}
|
|
status = run_records(&line, &cursor, options, &result->summary);
|
|
result->delivered = lp_cursor_delivered(&cursor);
|
|
if (status != LP_END) {
|
|
lp_line_destroy(&line);
|
|
}
|
|
result->status = status;
|
|
return status;
|
|
}
|