diff options
author | axtloss <axtlos@getcryst.al> | 2024-07-08 13:03:03 +0200 |
---|---|---|
committer | axtloss <axtlos@getcryst.al> | 2024-07-08 13:03:03 +0200 |
commit | 5a0598e0b8d42bc3800cf0d0a49572d13f7b0afa (patch) | |
tree | 996744adacd2ff590597aab9e92bea23f46db07e /src/extstring.c | |
parent | a084dfa02d28a9372a7e406c9b101a43308a4937 (diff) | |
download | extlib-5a0598e0b8d42bc3800cf0d0a49572d13f7b0afa.tar.gz extlib-5a0598e0b8d42bc3800cf0d0a49572d13f7b0afa.tar.bz2 |
add new function rremove
Diffstat (limited to 'src/extstring.c')
-rw-r--r-- | src/extstring.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/extstring.c b/src/extstring.c index 5867fc5..477f5f7 100644 --- a/src/extstring.c +++ b/src/extstring.c @@ -17,6 +17,7 @@ * SPDX-License-Identifier: LGPL-3.0-only */ +#define USE_SECURE_MEM #include <stdlib.h> #include <string.h> #include <ctype.h> @@ -50,20 +51,24 @@ strupr (char *s) } char * -trim (char *s) +trim (char *s, int *rem_front, int *rem_back) { char *result = strdup (s); char *end; - while (isspace ((unsigned char)*result)) + while (isspace ((unsigned char)*result)) { result++; + if (rem_front) *rem_front += 1; + } if (*result == 0) return result; end = result + strlen (result) - 1; - while (end > result && isspace ((unsigned char)*end)) + while (end > result && isspace ((unsigned char)*end)) { end--; + if (rem_back) *rem_back +=1; + } end[1] = '\0'; |