Remove dependency on strlcpy for rjson.c

This commit is contained in:
libretroadmin 2024-12-24 21:09:15 +01:00
parent 8074a833aa
commit 83a187784a

View File

@ -107,12 +107,9 @@ static enum rjson_type _rjson_error_char(rjson_t *json,
char buf[16]; char buf[16];
if (json->stack_top->type == RJSON_ERROR) if (json->stack_top->type == RJSON_ERROR)
return RJSON_ERROR; return RJSON_ERROR;
if (chr == _rJSON_EOF) snprintf(buf, sizeof(buf),
strlcpy(buf, "end of stream", sizeof(buf)); (chr == _rJSON_EOF ? "end of stream" :
else if (chr >= ' ' && chr <= '~') (chr >= ' ' && chr <= '~' ? "'%c'" : "byte 0x%02X")), chr);
snprintf(buf, sizeof(buf), "'%c'", chr);
else
snprintf(buf, sizeof(buf), "byte 0x%02X", chr);
return _rjson_error(json, fmt, buf); return _rjson_error(json, fmt, buf);
} }