amos f611da1e57 Batch 24: add 23 calibrated tasks written from Bos seed directions
Batch 24 (20261102-C-bos-seed-24) screened all 3078 Bos seed queries.
Only 23 themes were in scope (pure user-space reliability, at most one
task per theme); the rest were single operations or explanations,
installs and networking, system administration, ROS2, board-only or GUI
requests. Two finished drafts were withdrawn as too close to existing
tasks. Seeds supply direction only: all sources, contracts and tests are
new, and no task shares more than 14 characters with its seed text.

Each task passed the local gate and the trace6 Docker gate (5 runs per
sample class). Claude rebuilt the catalog from the calibration receipts:
23/23 USABLE. 16 of 23 are C/C++.

Only the task directories are taken; the batch worktree's lowered disk
floor in rollout/core.py stays out of main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 17:21:50 +08:00

123 lines
2.9 KiB
C

#include "lcd.h"
#include <limits.h>
#include <string.h>
static int digit_value(char value)
{
if (value >= '0' && value <= '9') {
return value - '0';
}
if (value >= 'a' && value <= 'f') {
return value - 'a' + 10;
}
if (value >= 'A' && value <= 'F') {
return value - 'A' + 10;
}
return -1;
}
static int hex_value(const char *text, size_t length, unsigned *result)
{
unsigned number = 0;
size_t i;
for (i = 0; i < length; ++i) {
int digit = digit_value(text[i]);
if (digit < 0) {
return LCD_INVALID;
}
number = number * 16 + (unsigned)digit;
}
*result = number;
return LCD_OK;
}
int lcd_parse_color(const char *text, uint16_t *color)
{
unsigned value;
size_t length;
if (text == NULL || color == NULL) {
return LCD_INVALID;
}
length = strlen(text);
if (length == 7 && text[0] == '#') {
if (hex_value(text + 1, 6, &value) != LCD_OK) {
return LCD_INVALID;
}
*color = lcd_rgb(value >> 16, (value >> 8) & 255, value & 255);
return LCD_OK;
}
if (length == 6 && text[0] == '0' && text[1] == 'x') {
if (hex_value(text + 2, 4, &value) != LCD_OK) {
return LCD_INVALID;
}
*color = (uint16_t)value;
return LCD_OK;
}
return LCD_INVALID;
}
static int decimal(const char **cursor, int *result)
{
const char *at = *cursor;
unsigned value = 0;
unsigned limit = INT_MAX;
int negative = 0;
int seen = 0;
if (*at == '-') {
negative = 1;
limit += 1U;
++at;
}
while (*at >= '0' && *at <= '9') {
unsigned digit = (unsigned)(*at - '0');
if (value > (limit - digit) / 10) {
return LCD_INVALID;
}
value = value * 10 + digit;
seen = 1;
++at;
}
if (!seen) {
return LCD_INVALID;
}
if (negative && value == (unsigned)INT_MAX + 1U) {
*result = INT_MIN;
} else {
*result = negative ? -(int)value : (int)value;
}
*cursor = at;
return LCD_OK;
}
int lcd_parse_rect(const char *text, lcd_rect *rect)
{
lcd_rect result;
int *fields[4] = {&result.x, &result.y, &result.width, &result.height};
const char *cursor = text;
size_t length;
size_t index;
if (text == NULL || rect == NULL) {
return LCD_INVALID;
}
length = strlen(text);
if (length > 64) {
return LCD_INVALID;
}
for (index = 0; index < 4; ++index) {
if (decimal(&cursor, fields[index]) != LCD_OK) {
return LCD_INVALID;
}
if (index < 3) {
if (*cursor != ',') {
return LCD_INVALID;
}
++cursor;
}
}
if (*cursor != '\0' || result.width < 0 || result.height < 0) {
return LCD_INVALID;
}
*rect = result;
return LCD_OK;
}