diff options
author | Jari Aalto <jari.aalto@cante.net> | 1997-06-05 14:59:13 +0000 |
---|---|---|
committer | Jari Aalto <jari.aalto@cante.net> | 2009-09-12 16:46:50 +0000 |
commit | d166f048818e10cf3799aa24a174fb22835f1acc (patch) | |
tree | 1ca27f9243900f8b236d0cde6a3862002aea9e19 /stringlib.c | |
parent | ccc6cda312fea9f0468ee65b8f368e9653e1380b (diff) | |
download | android_external_bash-d166f048818e10cf3799aa24a174fb22835f1acc.tar.gz android_external_bash-d166f048818e10cf3799aa24a174fb22835f1acc.tar.bz2 android_external_bash-d166f048818e10cf3799aa24a174fb22835f1acc.zip |
Imported from ../bash-2.01.tar.gz.
Diffstat (limited to 'stringlib.c')
-rw-r--r-- | stringlib.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/stringlib.c b/stringlib.c index 7bc8b49..71d4268 100644 --- a/stringlib.c +++ b/stringlib.c @@ -43,9 +43,9 @@ as a string terminator. If we see \c, set *SAWC to 1 before returning. LEN is the length of STRING. */ char * -ansicstr (string, len, sawc) +ansicstr (string, len, sawc, rlen) char *string; - int len, *sawc; + int len, *sawc, *rlen; { int c; char *ret, *r, *s; @@ -93,6 +93,8 @@ ansicstr (string, len, sawc) { *sawc = 1; *r = '\0'; + if (rlen) + *rlen = r - ret; return ret; } default: *r++ = '\\'; break; @@ -101,6 +103,8 @@ ansicstr (string, len, sawc) } } *r = '\0'; + if (rlen) + *rlen = r - ret; return ret; } @@ -307,6 +311,7 @@ strsub (string, pat, rep, global) return (temp); } +#ifdef INCLUDE_UNUSED /* Remove all leading whitespace from STRING. This includes newlines. STRING should be terminated with a zero. */ void @@ -325,17 +330,17 @@ strip_leading (string) start[len] = '\0'; } } +#endif /* Remove all trailing whitespace from STRING. This includes newlines. If NEWLINES_ONLY is non-zero, only trailing newlines are removed. STRING should be terminated with a zero. */ void -strip_trailing (string, newlines_only) +strip_trailing (string, len, newlines_only) char *string; + int len; int newlines_only; { - int len = strlen (string) - 1; - while (len >= 0) { if ((newlines_only && string[len] == '\n') || |