summaryrefslogtreecommitdiff
path: root/runtime/stringbuf.c
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/stringbuf.c')
-rw-r--r--runtime/stringbuf.c26
1 files changed, 4 insertions, 22 deletions
diff --git a/runtime/stringbuf.c b/runtime/stringbuf.c
index 13f3871..97bfed4 100644
--- a/runtime/stringbuf.c
+++ b/runtime/stringbuf.c
@@ -528,26 +528,6 @@ rsRetVal rsCStrTruncate(cstr_t *pThis, size_t nTrunc)
/* Trim trailing whitespace from a given string
*/
-rsRetVal rsCStrTrimTrailingWhiteSpace(cstr_t *pThis)
-{
- register int i;
- register uchar *pC;
- rsCHECKVALIDOBJECT(pThis, OIDrsCStr);
-
- i = pThis->iStrLen;
- pC = pThis->pBuf + i - 1;
- while(i > 0 && isspace((int)*pC)) {
- --pC;
- --i;
- }
- /* i now is the new string length! */
- pThis->iStrLen = i;
-
- return RS_RET_OK;
-}
-
-/* Trim trailing whitespace from a given string
- */
rsRetVal cstrTrimTrailingWhiteSpace(cstr_t *pThis)
{
register int i;
@@ -563,8 +543,10 @@ rsRetVal cstrTrimTrailingWhiteSpace(cstr_t *pThis)
--i;
}
/* i now is the new string length! */
- pThis->iStrLen = i;
- pThis->pBuf[pThis->iStrLen] = '\0'; /* we always have this space */
+ if(i != (int) pThis->iStrLen) {
+ pThis->iStrLen = i;
+ pThis->pBuf[pThis->iStrLen] = '\0'; /* we always have this space */
+ }
done: return RS_RET_OK;
}