diff options
Diffstat (limited to 'shared.c')
-rw-r--r-- | shared.c | 14 |
1 files changed, 3 insertions, 11 deletions
@@ -100,23 +100,15 @@ void *cgit_free_commitinfo(struct commitinfo *info) | |||
100 | char *trim_end(const char *str, char c) | 100 | char *trim_end(const char *str, char c) |
101 | { | 101 | { |
102 | int len; | 102 | int len; |
103 | char *s, *t; | ||
104 | 103 | ||
105 | if (str == NULL) | 104 | if (str == NULL) |
106 | return NULL; | 105 | return NULL; |
107 | t = (char *)str; | 106 | len = strlen(str); |
108 | len = strlen(t); | 107 | while(len > 0 && str[len - 1] == c) |
109 | while(len > 0 && t[len - 1] == c) | ||
110 | len--; | 108 | len--; |
111 | |||
112 | if (len == 0) | 109 | if (len == 0) |
113 | return NULL; | 110 | return NULL; |
114 | 111 | return xstrndup(str, len); | |
115 | c = t[len]; | ||
116 | t[len] = '\0'; | ||
117 | s = xstrdup(t); | ||
118 | t[len] = c; | ||
119 | return s; | ||
120 | } | 112 | } |
121 | 113 | ||
122 | char *strlpart(char *txt, int maxlen) | 114 | char *strlpart(char *txt, int maxlen) |