2026-07-30 01:10:31 -04:00
|
|
|
/**
|
|
|
|
|
* @file staticstring.c
|
|
|
|
|
* @brief Implements the staticstring subsystem.
|
|
|
|
|
*/
|
|
|
|
|
|
2026-01-05 08:58:06 -05:00
|
|
|
#include <akerror.h>
|
2026-05-07 22:20:10 -04:00
|
|
|
#include <akgl/staticstring.h>
|
2026-05-24 09:51:58 -04:00
|
|
|
#include <errno.h>
|
2025-08-03 10:07:35 -04:00
|
|
|
|
2026-05-06 23:18:42 -04:00
|
|
|
akerr_ErrorContext *akgl_string_initialize(akgl_String *obj, char *init)
|
2025-08-03 10:07:35 -04:00
|
|
|
{
|
Reindent all C sources to the canonical stroustrup style
Mechanical whitespace-only change across src/, include/, tests/, and
util/, applied with scripts/reindent.sh. No behavioral change.
Most files already conformed. The genuine outliers indented at 2 columns
(json_helpers.c, util.c from akgl_rectangle_points onward, assets.c,
staticstring.c, akgl_actor_add_child, util.h, staticstring.h) or used
spaces where the canonical form is a tab (draw.c). cc-mode also re-aligns
line-continuation backslashes in multi-line macros to its default
c-backslash-column, which is required for the tree to be a fixed point of
the indenter.
Verified whitespace-only: `git diff -w` over this change is empty apart
from three trailing blank lines removed at EOF in src/heap.c,
src/registry.c, and tests/tilemap.c. The build produces no new errors and
ctest is unchanged at 13/14, with `character` still the one intentional
failure.
The tree is now a fixed point of `scripts/reindent.sh --check`.
include/akgl/SDL_GameControllerDB.h is generated and excluded.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 18:17:37 -04:00
|
|
|
PREPARE_ERROR(errctx);
|
|
|
|
|
FAIL_ZERO_RETURN(errctx, obj, AKERR_NULLPOINTER, "Attempted to initialize NULL string reference");
|
|
|
|
|
if ( init != NULL ) {
|
|
|
|
|
strncpy((char *)&obj->data, init, AKGL_MAX_STRING_LENGTH);
|
|
|
|
|
} else {
|
|
|
|
|
memset(&obj->data, 0x00, sizeof(akgl_String));
|
|
|
|
|
}
|
|
|
|
|
obj->refcount = 1;
|
|
|
|
|
SUCCEED_RETURN(errctx);
|
2025-08-03 10:07:35 -04:00
|
|
|
}
|
2026-05-24 09:51:58 -04:00
|
|
|
|
|
|
|
|
akerr_ErrorContext *akgl_string_copy(akgl_String *src, akgl_String *dst, int count)
|
|
|
|
|
{
|
|
|
|
|
PREPARE_ERROR(e);
|
|
|
|
|
FAIL_ZERO_RETURN(e, src, AKERR_NULLPOINTER, "NULL argument");
|
|
|
|
|
FAIL_ZERO_RETURN(e, dst, AKERR_NULLPOINTER, "NULL argument");
|
|
|
|
|
if ( count == 0 ) {
|
|
|
|
|
count = AKGL_MAX_STRING_LENGTH;
|
|
|
|
|
}
|
2026-05-24 19:57:43 -04:00
|
|
|
if ( (char *)dst->data != strncpy((char *)&dst->data, (char *)&src->data, count) ) {
|
2026-05-24 09:51:58 -04:00
|
|
|
FAIL_RETURN(e, errno, "strncpy");
|
|
|
|
|
}
|
|
|
|
|
SUCCEED_RETURN(e);
|
|
|
|
|
}
|