From 5c59cced96fdd46aed316661f91d5d73d8cd5a7c Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Wed, 1 Oct 2025 10:47:39 -1000 Subject: [PATCH] FIO: Add sim_trim_spc API to trim spaces from the front and back of a string --- sim_fio.c | 20 ++++++++++++++++++++ sim_fio.h | 1 + 2 files changed, 21 insertions(+) diff --git a/sim_fio.c b/sim_fio.c index 300e2cdc..469ab37c 100644 --- a/sim_fio.c +++ b/sim_fio.c @@ -2267,6 +2267,26 @@ while ((--tptr >= cptr) && sim_isspace (*tptr)) return cptr; } +/* Trim spaces from the beginning and end of a string + + Inputs: + cptr = pointer to string + Outputs: + cptr = pointer to string +*/ + +char *sim_trim_spc (char *cptr) +{ +char *tptr; + +tptr = cptr; +while (sim_isspace (*tptr)) + ++tptr; +if (tptr != cptr) + memmove (cptr, tptr, strlen (tptr) + 1); +return sim_trim_endspc (cptr); +} + int sim_isspace (int c) { return ((c < 0) || (c >= 128)) ? 0 : isspace (c); diff --git a/sim_fio.h b/sim_fio.h index 2fff50e4..8e6e5335 100644 --- a/sim_fio.h +++ b/sim_fio.h @@ -120,6 +120,7 @@ extern t_bool sim_end; /* TRUE = little endian, FALSE = big endian extern const char sim_file_path_separator; /* Platform specific value \ or / as appropriate */ char *sim_trim_endspc (char *cptr); +char *sim_trim_spc (char *cptr); int sim_isspace (int c); #ifdef isspace #undef isspace