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

64 lines
2.1 KiB
C

#include "pattern.h"
#include <string.h>
static int name_valid(const char *name)
{
size_t length;
if (!name)
return 0;
length = strlen(name);
if (length == 0 || length > PR_NAME_BYTES)
return 0;
for (size_t i = 0; i < length; ++i) {
unsigned char c = (unsigned char)name[i];
if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
(c >= '0' && c <= '9') || c == '_' || c == '-' ||
c == '.' || c == '/'))
return 0;
}
return 1;
}
int pr_query(const struct pr_catalog *catalog, const char *pattern, size_t limit,
const struct pr_allocator *allocator, struct pr_report *report)
{
struct pr_result expanded = {0, NULL};
char detached[PR_MAX_NAMES][PR_NAME_BYTES + 1];
size_t count = 0;
int status;
if (!report)
return 2;
memset(report, 0, sizeof(*report));
report->status = 2;
if (!catalog || !pattern || !allocator || !allocator->allocate ||
!allocator->release || catalog->count > PR_MAX_NAMES || limit > PR_MAX_NAMES)
return 2;
for (size_t i = 0; i < catalog->count; ++i)
if (!name_valid(catalog->names[i]))
return 2;
status = pr_expand(catalog, pattern, allocator, &expanded);
if (status < 2) {
count = expanded.count;
for (size_t i = 0; i < count; ++i)
strcpy(detached[i], expanded.items[i]);
}
pr_release(&expanded, allocator);
report->status = status;
if (status >= 2)
return status;
report->matched = count;
report->shown = count < limit ? count : limit;
report->checksum = 7;
for (size_t i = 0; i < count; ++i) {
const unsigned char *cursor = (const unsigned char *)detached[i];
report->bytes += strlen(detached[i]);
while (*cursor) {
report->checksum = (uint32_t)(((uint64_t)report->checksum * 131 + *cursor) % 1000000007);
++cursor;
}
report->checksum = (uint32_t)(((uint64_t)report->checksum * 131 + 255) % 1000000007);
}
for (size_t i = 0; i < report->shown; ++i)
strcpy(report->names[i], detached[i]);
return status;
}