From d48c8c1c3688b54b590364dbf76b364e0a9c7276 Mon Sep 17 00:00:00 2001 From: Ruben Carlo Benante Date: Fri, 22 May 2026 22:08:21 -0300 Subject: [PATCH] allow trim() public function --- lib11sht.c | 4 ++-- lib11sht.h | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib11sht.c b/lib11sht.c index 98c8db7..e98693c 100644 --- a/lib11sht.c +++ b/lib11sht.c @@ -16,7 +16,7 @@ /* Internal helpers — kept private to this translation unit. */ static int uselesschar(int c); -static void trim(char *s); +/* trim is public (declared in lib11sht.h) */ static void asciify(const char *src, char *dest, size_t dest_size); static int ulen(unsigned char c); static float shit11(char *s1, char *s2); @@ -162,7 +162,7 @@ static int uselesschar(int c) /* ---------------------------------------------------------------------- */ /* remove leading/trailing whitespace + collapse internal multiple whitespace */ -static void trim(char *s) +void trim(char *s) { int len, i, j, fin = 0; diff --git a/lib11sht.h b/lib11sht.h index 9f91605..06072d1 100644 --- a/lib11sht.h +++ b/lib11sht.h @@ -50,4 +50,10 @@ int sequal_full(char *a, char *b, float shold, float *ratio, */ int fequal(float a, float b, float delta); +/* String trim: removes leading + trailing whitespace (including UTF-8 + * NBSP bytes 0xC2 / 0xA0) AND collapses internal runs of whitespace + * to a single space. Modifies s in place. Caller's buffer must already + * be NUL-terminated. */ +void trim(char *s); + #endif /* LIB11SHT_H */