Diff options
Diffstat (limited to '')
-rw-r--r--source/parsing.c20
1 file changed, 2 insertions, 18 deletions
diff --git a/source/parsing.c b/source/parsing.c
index 71ecdb7..d70a1ff 100644
--- a/source/parsing.c
+++ b/source/parsing.c
@@ -15,22 +15,6 @@
#include <mailmap.h>
-static char *substr(const char *start, const char *end)
-{
- size_t len;
- char *buf;
-
- if (end < start)
- return xstrdup("");
- // start points into the object buffer, so strlcpy would measure the
- // whole rest of the object to copy a name off the front of it.
- len = end - start;
- buf = xmalloc(len + 1);
- memcpy(buf, start, len);
- buf[len] = '\0';
- return buf;
-}
-
// The repository's mailmap, read once per request and applied to every ident a
// page shows. Only the blob at HEAD is read, the way git reads a bare
// repository, so a repository cannot point the reader at a file on the server.
@@ -210,7 +194,7 @@ struct commitinfo *cgit_parse_commit(struct commit *commit)
if (p && skip_prefix(p, "encoding ", &p)) {
eol = strchr(p, '\n');
if (eol) {
- info->msg_encoding = substr(p, eol);
+ info->msg_encoding = xmemdupz(p, eol - p);
p = eol + 1;
}
}
@@ -227,7 +211,7 @@ struct commitinfo *cgit_parse_commit(struct commit *commit)
if (p) {
eol = strchrnul(p, '\n');
- info->subject = substr(p, eol);
+ info->subject = xmemdupz(p, eol - p);
while (*eol == '\n')
eol++;
info->msg = xstrdup(eol);