index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Dan McGee <dan@archlinux.org> | 2011-07-29 18:49:38 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-08-02 08:20:34 -0400 |
commit | cbaff216b3eca57b4fd717da53f43a6713722e95 (patch) | |
tree | 1ef21cb061959410a827c3123ca0e7a28f7610a6 /lib/libalpm/util.c | |
parent | 573260556db49c62f5cf751f53812b7e06c1decb (diff) |
-rw-r--r-- | lib/libalpm/util.c | 20 |
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index 030cf43b..123cd24e 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -207,6 +207,26 @@ char *_alpm_strtrim(char *str) return str; } +/** + * Trim trailing newline from a string (if one exists). + * @param str a single line of text + * @return the length of the trimmed string + */ +size_t _alpm_strip_newline(char *str) +{ + size_t len; + if(str == '\0') { + return 0; + } + len = strlen(str); + while(str[len - 1] == '\n') { + len--; + } + str[len] = '\0'; + + return len; +} + /* Compression functions */ /** |