summaryrefslogtreecommitdiffabout
path: root/scan-tree.c
Side-by-side diff
Diffstat (limited to 'scan-tree.c') (more/less context) (ignore whitespace changes)
-rw-r--r--scan-tree.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/scan-tree.c b/scan-tree.c
index 47f3988..4da21a4 100644
--- a/scan-tree.c
+++ b/scan-tree.c
@@ -36,17 +36,4 @@ static int is_git_dir(const char *path)
}
-char *readfile(const char *path)
-{
- FILE *f;
- static char buf[MAX_PATH];
-
- if (!(f = fopen(path, "r")))
- return NULL;
- buf[0] = 0;
- fgets(buf, MAX_PATH, f);
- fclose(f);
- return buf;
-}
-
static void add_repo(const char *base, const char *path)
{
@@ -55,4 +42,5 @@ static void add_repo(const char *base, const char *path)
struct passwd *pwd;
char *p;
+ size_t size;
if (stat(path, &st)) {
@@ -77,9 +65,12 @@ static void add_repo(const char *base, const char *path)
repo->name = repo->url;
repo->path = xstrdup(path);
+ p = (pwd && pwd->pw_gecos) ? strchr(pwd->pw_gecos, ',') : NULL;
+ if (p)
+ *p = '\0';
repo->owner = (pwd ? xstrdup(pwd->pw_gecos ? pwd->pw_gecos : pwd->pw_name) : "");
p = fmt("%s/description", path);
if (!stat(p, &st))
- repo->desc = xstrdup(readfile(p));
+ readfile(p, &repo->desc, &size);
p = fmt("%s/README.html", path);