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>
62 lines
1.6 KiB
C
62 lines
1.6 KiB
C
#include "line_port.h"
|
|
#include <string.h>
|
|
|
|
void lp_summary_init(struct lp_summary *summary, uint64_t seed)
|
|
{
|
|
if (summary == NULL) {
|
|
return;
|
|
}
|
|
summary->lines = 0;
|
|
summary->bytes = 0;
|
|
summary->selected = 0;
|
|
summary->selected_bytes = 0;
|
|
summary->digest = seed;
|
|
summary->longest = 0;
|
|
}
|
|
|
|
static uint64_t record_sum(const unsigned char *data, size_t length)
|
|
{
|
|
uint64_t sum = 0;
|
|
size_t index;
|
|
for (index = 0; index < length; index += 1) {
|
|
sum += data[index];
|
|
}
|
|
return sum;
|
|
}
|
|
|
|
static uint64_t digest_record(uint64_t digest, const unsigned char *data,
|
|
size_t length)
|
|
{
|
|
size_t index;
|
|
for (index = 0; index < length; index += 1) {
|
|
digest = digest * UINT64_C(257) + data[index] + 1;
|
|
}
|
|
digest = digest * UINT64_C(257) + 256;
|
|
return digest;
|
|
}
|
|
|
|
int lp_summary_accept(struct lp_summary *summary, const unsigned char *data,
|
|
size_t length, unsigned int divisor,
|
|
unsigned int remainder)
|
|
{
|
|
uint64_t sum;
|
|
if (summary == NULL || data == NULL || length == 0) {
|
|
return LP_ARGUMENT;
|
|
}
|
|
if (divisor == 0 || divisor > 256 || remainder >= divisor) {
|
|
return LP_ARGUMENT;
|
|
}
|
|
sum = record_sum(data, length);
|
|
summary->lines += 1;
|
|
summary->bytes += length;
|
|
if (length > summary->longest) {
|
|
summary->longest = length;
|
|
}
|
|
if (sum % divisor == remainder) {
|
|
summary->selected += 1;
|
|
summary->selected_bytes += length;
|
|
}
|
|
summary->digest = digest_record(summary->digest, data, length);
|
|
return LP_END;
|
|
}
|