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>
55 lines
2.0 KiB
C
55 lines
2.0 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 result = {0, NULL};
|
|
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, &result);
|
|
if (status == 0 || status == 1) {
|
|
report->matched = result.count;
|
|
report->shown = result.count < limit ? result.count : limit;
|
|
report->checksum = 7;
|
|
for (size_t i = 0; i < result.count; ++i) {
|
|
const unsigned char *p = (const unsigned char *)result.items[i];
|
|
size_t length = strlen(result.items[i]);
|
|
report->bytes += length;
|
|
for (size_t j = 0; j < length; ++j)
|
|
report->checksum = (uint32_t)(((uint64_t)report->checksum * 131 + p[j]) % 1000000007);
|
|
report->checksum = (uint32_t)(((uint64_t)report->checksum * 131 + 255) % 1000000007);
|
|
if (i < report->shown)
|
|
memcpy(report->names[i], result.items[i], length + 1);
|
|
}
|
|
}
|
|
pr_release(&result, allocator);
|
|
report->status = status;
|
|
return status;
|
|
}
|