Reindent to the canonical stroustrup style
Whitespace only -- `git diff -w` is empty. TODO.md 2.3 recorded that the
tree mixed hard tabs and space indents within the same functions;
tests/aksl_capture.h was the worst of it, with the assertion macros
space-indented and everything around them tabbed.
The style is the one libakerror standardised on and the one AGENTS.md
already describes: Emacs cc-mode "stroustrup", c-basic-offset 4,
indent-tabs-mode on, tab-width 8. A correct file is a fixed point of
indent-region under those settings, and the tree is one now -- a second
pass produces no diff.
scripts/reindent.el is that pass, checked in so "correct" is something
you can run rather than something you have to remember. It is not
clang-format and deliberately so: AGENTS.md forbids introducing one
without discussion, and this is a good illustration of why. cc-mode
indents every declaration in akstdlib.h one level for the extern "C" { }
wrapping the file body, so the script sets inextern-lang to 0 -- a
cc-mode offset with no clang-format equivalent, and without it the first
run moved 364 lines in the wrong direction.
Its own commit, no behaviour change, and the suite is green either side.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -231,50 +231,50 @@ static int __attribute__((unused)) aksl_take(akerr_ErrorContext *e)
|
||||
* The context is always released, including on the failure path, so a failing
|
||||
* assertion does not also corrupt the pool-leak checks that follow it.
|
||||
*/
|
||||
#define AKSL_CHECK_STATUS(__expr, __expected) \
|
||||
do { \
|
||||
int __st = aksl_take(__expr); \
|
||||
if ( __st != (__expected) ) { \
|
||||
fprintf(stderr, \
|
||||
" CHECK FAILED: %s\n" \
|
||||
" got %d (%s) \"%s\"\n" \
|
||||
" expected %d (%s)\n" \
|
||||
" at %s:%d\n", \
|
||||
#__expr, \
|
||||
__st, akerr_name_for_status(__st, NULL), \
|
||||
aksl_last_message, \
|
||||
(__expected), \
|
||||
akerr_name_for_status((__expected), NULL), \
|
||||
__FILE__, __LINE__); \
|
||||
return 1; \
|
||||
} \
|
||||
#define AKSL_CHECK_STATUS(__expr, __expected) \
|
||||
do { \
|
||||
int __st = aksl_take(__expr); \
|
||||
if ( __st != (__expected) ) { \
|
||||
fprintf(stderr, \
|
||||
" CHECK FAILED: %s\n" \
|
||||
" got %d (%s) \"%s\"\n" \
|
||||
" expected %d (%s)\n" \
|
||||
" at %s:%d\n", \
|
||||
#__expr, \
|
||||
__st, akerr_name_for_status(__st, NULL), \
|
||||
aksl_last_message, \
|
||||
(__expected), \
|
||||
akerr_name_for_status((__expected), NULL), \
|
||||
__FILE__, __LINE__); \
|
||||
return 1; \
|
||||
} \
|
||||
} while ( 0 )
|
||||
|
||||
/*
|
||||
* Success is represented by a NULL error context, not just status 0. This catches
|
||||
* wrappers that incorrectly raise an error using a stale errno value of 0.
|
||||
*/
|
||||
#define AKSL_CHECK_OK(__expr) \
|
||||
do { \
|
||||
akerr_ErrorContext *__e = (__expr); \
|
||||
if ( __e != NULL ) { \
|
||||
int __st = aksl_take(__e); \
|
||||
fprintf(stderr, \
|
||||
" CHECK FAILED: %s\n" \
|
||||
#define AKSL_CHECK_OK(__expr) \
|
||||
do { \
|
||||
akerr_ErrorContext *__e = (__expr); \
|
||||
if ( __e != NULL ) { \
|
||||
int __st = aksl_take(__e); \
|
||||
fprintf(stderr, \
|
||||
" CHECK FAILED: %s\n" \
|
||||
" returned error context with status %d (%s) \"%s\"\n" \
|
||||
" expected no error context\n" \
|
||||
" at %s:%d\n", \
|
||||
#__expr, \
|
||||
__st, akerr_name_for_status(__st, NULL), \
|
||||
aksl_last_message, \
|
||||
__FILE__, __LINE__); \
|
||||
return 1; \
|
||||
} \
|
||||
aksl_last_status = 0; \
|
||||
aksl_last_message[0] = '\0'; \
|
||||
aksl_last_function[0] = '\0'; \
|
||||
aksl_last_file[0] = '\0'; \
|
||||
aksl_last_line = 0; \
|
||||
" expected no error context\n" \
|
||||
" at %s:%d\n", \
|
||||
#__expr, \
|
||||
__st, akerr_name_for_status(__st, NULL), \
|
||||
aksl_last_message, \
|
||||
__FILE__, __LINE__); \
|
||||
return 1; \
|
||||
} \
|
||||
aksl_last_status = 0; \
|
||||
aksl_last_message[0] = '\0'; \
|
||||
aksl_last_function[0] = '\0'; \
|
||||
aksl_last_file[0] = '\0'; \
|
||||
aksl_last_line = 0; \
|
||||
} while ( 0 )
|
||||
|
||||
#define AKSL_CHECK_CONTAINS(needle) \
|
||||
@@ -287,37 +287,37 @@ static int __attribute__((unused)) aksl_take(akerr_ErrorContext *e)
|
||||
* Message checks are secondary: the returned akerr status is the contract. Keep
|
||||
* the status and message assertions coupled so tests cannot pass on text alone.
|
||||
*/
|
||||
#define AKSL_CHECK_STATUS_MSG_CONTAINS(__expr, __expected, __needle) \
|
||||
do { \
|
||||
int __st = aksl_take(__expr); \
|
||||
if ( __st != (__expected) ) { \
|
||||
fprintf(stderr, \
|
||||
" CHECK FAILED: %s\n" \
|
||||
" got %d (%s) \"%s\"\n" \
|
||||
" expected %d (%s)\n" \
|
||||
" at %s:%d\n", \
|
||||
#__expr, \
|
||||
__st, akerr_name_for_status(__st, NULL), \
|
||||
aksl_last_message, \
|
||||
(__expected), \
|
||||
akerr_name_for_status((__expected), NULL), \
|
||||
__FILE__, __LINE__); \
|
||||
return 1; \
|
||||
} \
|
||||
if ( strstr(aksl_last_message, (__needle)) == NULL ) { \
|
||||
fprintf(stderr, \
|
||||
" CHECK FAILED: message from %s\n" \
|
||||
" got \"%s\"\n" \
|
||||
" expected substring \"%s\"\n" \
|
||||
" status %d (%s)\n" \
|
||||
" at %s:%d\n", \
|
||||
#__expr, \
|
||||
aksl_last_message, \
|
||||
(__needle), \
|
||||
__st, akerr_name_for_status(__st, NULL), \
|
||||
__FILE__, __LINE__); \
|
||||
return 1; \
|
||||
} \
|
||||
#define AKSL_CHECK_STATUS_MSG_CONTAINS(__expr, __expected, __needle) \
|
||||
do { \
|
||||
int __st = aksl_take(__expr); \
|
||||
if ( __st != (__expected) ) { \
|
||||
fprintf(stderr, \
|
||||
" CHECK FAILED: %s\n" \
|
||||
" got %d (%s) \"%s\"\n" \
|
||||
" expected %d (%s)\n" \
|
||||
" at %s:%d\n", \
|
||||
#__expr, \
|
||||
__st, akerr_name_for_status(__st, NULL), \
|
||||
aksl_last_message, \
|
||||
(__expected), \
|
||||
akerr_name_for_status((__expected), NULL), \
|
||||
__FILE__, __LINE__); \
|
||||
return 1; \
|
||||
} \
|
||||
if ( strstr(aksl_last_message, (__needle)) == NULL ) { \
|
||||
fprintf(stderr, \
|
||||
" CHECK FAILED: message from %s\n" \
|
||||
" got \"%s\"\n" \
|
||||
" expected substring \"%s\"\n" \
|
||||
" status %d (%s)\n" \
|
||||
" at %s:%d\n", \
|
||||
#__expr, \
|
||||
aksl_last_message, \
|
||||
(__needle), \
|
||||
__st, akerr_name_for_status(__st, NULL), \
|
||||
__FILE__, __LINE__); \
|
||||
return 1; \
|
||||
} \
|
||||
} while ( 0 )
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@@ -329,22 +329,22 @@ static int __attribute__((unused)) aksl_take(akerr_ErrorContext *e)
|
||||
* test left the error pool as it found it -- a wrapper that fails to release a
|
||||
* context is a bug in the library, not just in the test.
|
||||
*/
|
||||
#define AKSL_RUN(__failures, __fn) \
|
||||
do { \
|
||||
int __before = aksl_slots_in_use(); \
|
||||
int __r = __fn(); \
|
||||
int __after = aksl_slots_in_use(); \
|
||||
if ( __r != 0 ) { \
|
||||
fprintf(stderr, "FAIL %s\n", #__fn); \
|
||||
(__failures)++; \
|
||||
} else if ( __after != __before ) { \
|
||||
fprintf(stderr, \
|
||||
"FAIL %s (leaked %d error pool slot(s))\n", \
|
||||
#__fn, __after - __before); \
|
||||
(__failures)++; \
|
||||
} else { \
|
||||
fprintf(stderr, "ok %s\n", #__fn); \
|
||||
} \
|
||||
#define AKSL_RUN(__failures, __fn) \
|
||||
do { \
|
||||
int __before = aksl_slots_in_use(); \
|
||||
int __r = __fn(); \
|
||||
int __after = aksl_slots_in_use(); \
|
||||
if ( __r != 0 ) { \
|
||||
fprintf(stderr, "FAIL %s\n", #__fn); \
|
||||
(__failures)++; \
|
||||
} else if ( __after != __before ) { \
|
||||
fprintf(stderr, \
|
||||
"FAIL %s (leaked %d error pool slot(s))\n", \
|
||||
#__fn, __after - __before); \
|
||||
(__failures)++; \
|
||||
} else { \
|
||||
fprintf(stderr, "ok %s\n", #__fn); \
|
||||
} \
|
||||
} while ( 0 )
|
||||
|
||||
#define AKSL_REPORT(__failures) \
|
||||
|
||||
Reference in New Issue
Block a user