1
0
mirror of https://github.com/moparisthebest/pacman synced 2025-01-09 13:07:58 -05:00

pactree: update with new strtrim function

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
This commit is contained in:
Dave Reisner 2011-12-23 11:57:19 -05:00 committed by Dan McGee
parent 6b29374a60
commit bec0b0c823

View File

@ -117,13 +117,13 @@ char *strndup(const char *s, size_t n)
} }
#endif #endif
static char *strtrim(char *str) static size_t strtrim(char *str)
{ {
char *pch = str; char *end, *pch = str;
if(str == NULL || *str == '\0') { if(str == NULL || *str == '\0') {
/* string is empty, so we're done. */ /* string is empty, so we're done. */
return str; return 0;
} }
while(isspace((unsigned char)*pch)) { while(isspace((unsigned char)*pch)) {
@ -140,16 +140,16 @@ static char *strtrim(char *str)
/* check if there wasn't anything but whitespace in the string. */ /* check if there wasn't anything but whitespace in the string. */
if(*str == '\0') { if(*str == '\0') {
return str; return 0;
} }
pch = (str + (strlen(str) - 1)); end = (str + strlen(str) - 1);
while(isspace((unsigned char)*pch)) { while(isspace((unsigned char)*end)) {
pch--; end--;
} }
*++pch = '\0'; *++end = '\0';
return str; return end - pch;
} }
static int register_syncs(void) { static int register_syncs(void) {