From 13d1fa1d01e48c7a23cc1114fc4d45b20f2c48eb Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Thu, 8 Mar 2001 23:59:45 +0000 Subject: Add in 'trim' routine. Fix up sh.c so it works when wordexp is not available. -Erik --- utility.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'utility.c') diff --git a/utility.c b/utility.c index 7fd4cad7d..b4893a0e1 100644 --- a/utility.c +++ b/utility.c @@ -1828,6 +1828,19 @@ void chomp(char *s) } #endif +#if defined(BB_SH) +void trim(char *s) +{ + /* trim leading whitespace */ + memmove(s, &s[strspn(s, " \n\r\t\v")], strlen(s)); + + /* trim trailing whitespace */ + while (*s && (!isspace (*s))) + s++; + *s='\0'; +} +#endif + /* END CODE */ /* Local Variables: -- cgit v1.2.3