Timeline for Trim leading/trailing space in a string
Current License: CC BY-SA 4.0
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Feb 16, 2023 at 8:03 | history | edited | Toby Speight | CC BY-SA 4.0 |
Decompose into functions to find left and right bounds
|
| Feb 15, 2023 at 14:38 | comment | added | Toby Speight |
I never liked the strchr interface - it's risky, and I've not seen a compiler option to warn when it's misused (or to provide custom attribute to mark user functions that propagate const). But certainly something to consider, for familiarity reasons.
|
|
| Feb 15, 2023 at 14:31 | history | edited | Toby Speight | CC BY-SA 4.0 |
Use memcmp, since we know lengths are same
|
| Feb 15, 2023 at 14:24 | comment | added | Toby Speight |
Spot on: brain in string mode - well, that and evolving from the earlier iteration that used strcmp(). memcmp() is probably clearer about what's tested.
|
|
| Feb 15, 2023 at 14:12 | comment | added | chux |
Nice trimmed_bound(). UV. Yet for similar reasons that char *strchr(const char *s, int c); and other STL functions return char *, I'd expect the same here. We could go the _Generic route, but that is "work".
|
|
| Feb 15, 2023 at 8:08 | history | answered | Toby Speight | CC BY-SA 4.0 |