diff options
author | allen <allen@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2000-10-04 22:02:09 +0000 |
---|---|---|
committer | allen <allen@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2000-10-04 22:02:09 +0000 |
commit | 90f754b042785e7acaaad5a4d40f12aa50cb26a9 (patch) | |
tree | bd80deca05211ba9b1320e9a1dd7352c1448574f /src | |
parent | 125f570312122ce3de31c699c95637d2a4eddaf2 (diff) |
CCTK_NullTerminateString now removes the blanks at the end of a string.
git-svn-id: http://svn.cactuscode.org/flesh/trunk@1853 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src')
-rw-r--r-- | src/util/Misc.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/util/Misc.c b/src/util/Misc.c index ec56de20..20d8f133 100644 --- a/src/util/Misc.c +++ b/src/util/Misc.c @@ -127,6 +127,7 @@ char *Util_NullTerminateString(const char *instring, unsigned int len) { char *outstring; unsigned int i; + int position; if (len > 100000) { @@ -142,13 +143,19 @@ char *Util_NullTerminateString(const char *instring, unsigned int len) printf("Util_NullTerminateString: -%s-, (%u)\n",instring,len); #endif - outstring = (char *)malloc((len+2)*sizeof(char)); + position = len-1; + while (instring[position] == ' ') + { + position--; + } + + outstring = (char *)malloc((position+2)*sizeof(char)); assert(outstring); - for (i=0;i<len;i++) + for (i=0;i<=position;i++) outstring[i] = instring[i]; - outstring[len] = '\0'; + outstring[position+1] = '\0'; return(outstring); } |