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:
2026-07-31 08:02:55 -04:00
parent 125eeb2109
commit b104a07eb4
4 changed files with 113 additions and 88 deletions

View File

@@ -92,10 +92,10 @@ extern "C" {
*/ */
#if defined(__GNUC__) || defined(__clang__) #if defined(__GNUC__) || defined(__clang__)
/** @brief Mark a printf-style format argument for compile-time checking. */ /** @brief Mark a printf-style format argument for compile-time checking. */
#define AKSL_PRINTF_FORMAT(__fmt_index, __first_arg) \ #define AKSL_PRINTF_FORMAT(__fmt_index, __first_arg) \
__attribute__((format(printf, __fmt_index, __first_arg))) __attribute__((format(printf, __fmt_index, __first_arg)))
/** @brief Mark a scanf-style format argument for compile-time checking. */ /** @brief Mark a scanf-style format argument for compile-time checking. */
#define AKSL_SCANF_FORMAT(__fmt_index, __first_arg) \ #define AKSL_SCANF_FORMAT(__fmt_index, __first_arg) \
__attribute__((format(scanf, __fmt_index, __first_arg))) __attribute__((format(scanf, __fmt_index, __first_arg)))
#else #else
/** @brief No-op where the compiler has no format attribute. */ /** @brief No-op where the compiler has no format attribute. */

25
scripts/reindent.el Normal file
View File

@@ -0,0 +1,25 @@
;; Canonical reindent: Emacs cc-mode "stroustrup", c-basic-offset 4,
;; indent-tabs-mode on, tab-width 8. A correct file is a fixed point of this.
;;
;; inextern-lang is set to 0 because akstdlib.h wraps its whole body in
;; extern "C" { }, and cc-mode otherwise indents every declaration in the file
;; one level for it. That is a real cc-mode behaviour rather than a bug, but it
;; is not the house style and not what the file looked like before.
;;
;; AGENTS.md forbids introducing clang-format, and this is why the tool that
;; decides what "correct" means has to be the same engine the author's editor
;; runs: this offset is not something clang-format could be made to agree with.
(require 'cc-mode)
(setq-default indent-tabs-mode t)
(setq-default tab-width 8)
(setq c-default-style "stroustrup")
(dolist (file command-line-args-left)
(find-file file)
(c-mode)
(setq indent-tabs-mode t
tab-width 8
c-basic-offset 4)
(c-set-offset 'inextern-lang 0)
(indent-region (point-min) (point-max))
(when (buffer-modified-p) (save-buffer))
(kill-buffer))

View File

@@ -106,8 +106,8 @@ akerr_ErrorContext AKERR_NOIGNORE *aksl_list_insert_after(aksl_ListNode *node, a
* the case a caller is most likely to get wrong by hand. * the case a caller is most likely to get wrong by hand.
*/ */
akerr_ErrorContext AKERR_NOIGNORE *aksl_list_insert_before(aksl_ListNode **head, akerr_ErrorContext AKERR_NOIGNORE *aksl_list_insert_before(aksl_ListNode **head,
aksl_ListNode *node, aksl_ListNode *node,
aksl_ListNode *obj) aksl_ListNode *obj)
{ {
PREPARE_ERROR(e); PREPARE_ERROR(e);
FAIL_ZERO_RETURN(e, head, AKERR_NULLPOINTER, "head=%p, node=%p, obj=%p", FAIL_ZERO_RETURN(e, head, AKERR_NULLPOINTER, "head=%p, node=%p, obj=%p",

View File

@@ -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 * 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. * assertion does not also corrupt the pool-leak checks that follow it.
*/ */
#define AKSL_CHECK_STATUS(__expr, __expected) \ #define AKSL_CHECK_STATUS(__expr, __expected) \
do { \ do { \
int __st = aksl_take(__expr); \ int __st = aksl_take(__expr); \
if ( __st != (__expected) ) { \ if ( __st != (__expected) ) { \
fprintf(stderr, \ fprintf(stderr, \
" CHECK FAILED: %s\n" \ " CHECK FAILED: %s\n" \
" got %d (%s) \"%s\"\n" \ " got %d (%s) \"%s\"\n" \
" expected %d (%s)\n" \ " expected %d (%s)\n" \
" at %s:%d\n", \ " at %s:%d\n", \
#__expr, \ #__expr, \
__st, akerr_name_for_status(__st, NULL), \ __st, akerr_name_for_status(__st, NULL), \
aksl_last_message, \ aksl_last_message, \
(__expected), \ (__expected), \
akerr_name_for_status((__expected), NULL), \ akerr_name_for_status((__expected), NULL), \
__FILE__, __LINE__); \ __FILE__, __LINE__); \
return 1; \ return 1; \
} \ } \
} while ( 0 ) } while ( 0 )
/* /*
* Success is represented by a NULL error context, not just status 0. This catches * 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. * wrappers that incorrectly raise an error using a stale errno value of 0.
*/ */
#define AKSL_CHECK_OK(__expr) \ #define AKSL_CHECK_OK(__expr) \
do { \ do { \
akerr_ErrorContext *__e = (__expr); \ akerr_ErrorContext *__e = (__expr); \
if ( __e != NULL ) { \ if ( __e != NULL ) { \
int __st = aksl_take(__e); \ int __st = aksl_take(__e); \
fprintf(stderr, \ fprintf(stderr, \
" CHECK FAILED: %s\n" \ " CHECK FAILED: %s\n" \
" returned error context with status %d (%s) \"%s\"\n" \ " returned error context with status %d (%s) \"%s\"\n" \
" expected no error context\n" \ " expected no error context\n" \
" at %s:%d\n", \ " at %s:%d\n", \
#__expr, \ #__expr, \
__st, akerr_name_for_status(__st, NULL), \ __st, akerr_name_for_status(__st, NULL), \
aksl_last_message, \ aksl_last_message, \
__FILE__, __LINE__); \ __FILE__, __LINE__); \
return 1; \ return 1; \
} \ } \
aksl_last_status = 0; \ aksl_last_status = 0; \
aksl_last_message[0] = '\0'; \ aksl_last_message[0] = '\0'; \
aksl_last_function[0] = '\0'; \ aksl_last_function[0] = '\0'; \
aksl_last_file[0] = '\0'; \ aksl_last_file[0] = '\0'; \
aksl_last_line = 0; \ aksl_last_line = 0; \
} while ( 0 ) } while ( 0 )
#define AKSL_CHECK_CONTAINS(needle) \ #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 * 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. * the status and message assertions coupled so tests cannot pass on text alone.
*/ */
#define AKSL_CHECK_STATUS_MSG_CONTAINS(__expr, __expected, __needle) \ #define AKSL_CHECK_STATUS_MSG_CONTAINS(__expr, __expected, __needle) \
do { \ do { \
int __st = aksl_take(__expr); \ int __st = aksl_take(__expr); \
if ( __st != (__expected) ) { \ if ( __st != (__expected) ) { \
fprintf(stderr, \ fprintf(stderr, \
" CHECK FAILED: %s\n" \ " CHECK FAILED: %s\n" \
" got %d (%s) \"%s\"\n" \ " got %d (%s) \"%s\"\n" \
" expected %d (%s)\n" \ " expected %d (%s)\n" \
" at %s:%d\n", \ " at %s:%d\n", \
#__expr, \ #__expr, \
__st, akerr_name_for_status(__st, NULL), \ __st, akerr_name_for_status(__st, NULL), \
aksl_last_message, \ aksl_last_message, \
(__expected), \ (__expected), \
akerr_name_for_status((__expected), NULL), \ akerr_name_for_status((__expected), NULL), \
__FILE__, __LINE__); \ __FILE__, __LINE__); \
return 1; \ return 1; \
} \ } \
if ( strstr(aksl_last_message, (__needle)) == NULL ) { \ if ( strstr(aksl_last_message, (__needle)) == NULL ) { \
fprintf(stderr, \ fprintf(stderr, \
" CHECK FAILED: message from %s\n" \ " CHECK FAILED: message from %s\n" \
" got \"%s\"\n" \ " got \"%s\"\n" \
" expected substring \"%s\"\n" \ " expected substring \"%s\"\n" \
" status %d (%s)\n" \ " status %d (%s)\n" \
" at %s:%d\n", \ " at %s:%d\n", \
#__expr, \ #__expr, \
aksl_last_message, \ aksl_last_message, \
(__needle), \ (__needle), \
__st, akerr_name_for_status(__st, NULL), \ __st, akerr_name_for_status(__st, NULL), \
__FILE__, __LINE__); \ __FILE__, __LINE__); \
return 1; \ return 1; \
} \ } \
} while ( 0 ) } 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 * 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. * context is a bug in the library, not just in the test.
*/ */
#define AKSL_RUN(__failures, __fn) \ #define AKSL_RUN(__failures, __fn) \
do { \ do { \
int __before = aksl_slots_in_use(); \ int __before = aksl_slots_in_use(); \
int __r = __fn(); \ int __r = __fn(); \
int __after = aksl_slots_in_use(); \ int __after = aksl_slots_in_use(); \
if ( __r != 0 ) { \ if ( __r != 0 ) { \
fprintf(stderr, "FAIL %s\n", #__fn); \ fprintf(stderr, "FAIL %s\n", #__fn); \
(__failures)++; \ (__failures)++; \
} else if ( __after != __before ) { \ } else if ( __after != __before ) { \
fprintf(stderr, \ fprintf(stderr, \
"FAIL %s (leaked %d error pool slot(s))\n", \ "FAIL %s (leaked %d error pool slot(s))\n", \
#__fn, __after - __before); \ #__fn, __after - __before); \
(__failures)++; \ (__failures)++; \
} else { \ } else { \
fprintf(stderr, "ok %s\n", #__fn); \ fprintf(stderr, "ok %s\n", #__fn); \
} \ } \
} while ( 0 ) } while ( 0 )
#define AKSL_REPORT(__failures) \ #define AKSL_REPORT(__failures) \