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>
60 lines
2.0 KiB
C
60 lines
2.0 KiB
C
#include "render_api.h"
|
|
#include "buffer_port.h"
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
static void encoded_label(const struct record *record, char *out)
|
|
{
|
|
char *cursor = out;
|
|
const char *hex = "0123456789abcdef";
|
|
for (size_t i = 0; i < record->label_length; i++) {
|
|
unsigned char byte = record->label[i];
|
|
if (byte == '"' || byte == '\\') {
|
|
*cursor++ = '\\';
|
|
*cursor++ = (char)byte;
|
|
} else if (byte >= 32 && byte <= 126) {
|
|
*cursor++ = (char)byte;
|
|
} else {
|
|
*cursor++ = '\\';
|
|
*cursor++ = 'u';
|
|
*cursor++ = '0';
|
|
*cursor++ = '0';
|
|
*cursor++ = hex[byte >> 4];
|
|
*cursor++ = hex[byte & 15];
|
|
}
|
|
}
|
|
*cursor = '\0';
|
|
}
|
|
struct render_result render_record(const struct command *command)
|
|
{
|
|
struct render_result answer = {RENDER_INVALID, 0, 0};
|
|
char label[LABEL_LIMIT * 6 + 1];
|
|
char canonical[TEXT_LIMIT];
|
|
char *owned;
|
|
int length;
|
|
if (command->record.level > 7 || command->record.label_length > LABEL_LIMIT ||
|
|
command->capacity > TEXT_LIMIT) {
|
|
return answer;
|
|
}
|
|
encoded_label(&command->record, label);
|
|
length = snprintf(canonical, sizeof(canonical),
|
|
"{\"id\":%ld,\"level\":%u,\"value\":%ld,\"label\":\"%s\"}",
|
|
(long)command->record.identifier, command->record.level,
|
|
(long)command->record.value, label);
|
|
answer.required = (size_t)length;
|
|
owned = port_allocate(command->capacity);
|
|
answer.status = RENDER_ALLOC;
|
|
if (owned != NULL) {
|
|
answer.status = RENDER_TRUNCATED;
|
|
if (command->capacity > answer.required) {
|
|
memcpy(owned, canonical, answer.required + 1);
|
|
answer.status = RENDER_SINK;
|
|
if (port_publish(owned, answer.required)) {
|
|
answer.status = RENDER_OK;
|
|
answer.emitted = answer.required;
|
|
}
|
|
}
|
|
port_release(owned);
|
|
}
|
|
return answer;
|
|
}
|