summaryrefslogtreecommitdiffabout
path: root/shared.c
Unidiff
Diffstat (limited to 'shared.c') (more/less context) (show whitespace changes)
-rw-r--r--shared.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/shared.c b/shared.c
index 50fe8e1..e06df91 100644
--- a/shared.c
+++ b/shared.c
@@ -305,2 +305,33 @@ char *trim_end(const char *str, char c)
305 305
306char *strlpart(char *txt, int maxlen)
307{
308 char *result;
309
310 if (!txt)
311 return txt;
312
313 if (strlen(txt) <= maxlen)
314 return txt;
315 result = xmalloc(maxlen + 1);
316 memcpy(result, txt, maxlen - 3);
317 result[maxlen-1] = result[maxlen-2] = result[maxlen-3] = '.';
318 result[maxlen] = '\0';
319 return result;
320}
321
322char *strrpart(char *txt, int maxlen)
323{
324 char *result;
325
326 if (!txt)
327 return txt;
328
329 if (strlen(txt) <= maxlen)
330 return txt;
331 result = xmalloc(maxlen + 1);
332 memcpy(result + 3, txt + strlen(txt) - maxlen + 4, maxlen - 3);
333 result[0] = result[1] = result[2] = '.';
334 return result;
335}
336
306void cgit_add_ref(struct reflist *list, struct refinfo *ref) 337void cgit_add_ref(struct reflist *list, struct refinfo *ref)