summaryrefslogtreecommitdiffabout
authorLars Hjemli <hjemli@gmail.com>2008-11-14 08:30:28 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2008-11-14 08:30:28 (UTC)
commit7b5cee65fd9cf31e4f19ce4ff613778cb95512a9 (patch) (side-by-side diff)
tree0e245a9ac0d422259116d222b2899d90c1fef327
parent9895925db705c65ee7bc26cd593a5a36ecb7e2a7 (diff)
parentc7d1402b177f4cf835e81f962e2faa3c9e28c549 (diff)
downloadcgit-7b5cee65fd9cf31e4f19ce4ff613778cb95512a9.zip
cgit-7b5cee65fd9cf31e4f19ce4ff613778cb95512a9.tar.gz
cgit-7b5cee65fd9cf31e4f19ce4ff613778cb95512a9.tar.bz2
Merge branch 'stable'
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--ui-repolist.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/ui-repolist.c b/ui-repolist.c
index ab050c7..c23232c 100644
--- a/ui-repolist.c
+++ b/ui-repolist.c
@@ -1,70 +1,71 @@
/* ui-repolist.c: functions for generating the repolist page
*
* Copyright (C) 2006 Lars Hjemli
*
* Licensed under GNU General Public License v2
* (see COPYING for full license text)
*/
#include <time.h>
#include "cgit.h"
#include "html.h"
#include "ui-shared.h"
time_t read_agefile(char *path)
{
FILE *f;
static char buf[64], buf2[64];
if (!(f = fopen(path, "r")))
return -1;
- fgets(buf, sizeof(buf), f);
+ if (fgets(buf, sizeof(buf), f) == NULL)
+ return -1;
fclose(f);
if (parse_date(buf, buf2, sizeof(buf2)))
return strtoul(buf2, NULL, 10);
else
return 0;
}
static void print_modtime(struct cgit_repo *repo)
{
char *path;
struct stat s;
path = fmt("%s/%s", repo->path, ctx.cfg.agefile);
if (stat(path, &s) == 0) {
cgit_print_age(read_agefile(path), -1, NULL);
return;
}
path = fmt("%s/refs/heads/%s", repo->path, repo->defbranch);
if (stat(path, &s) != 0)
return;
cgit_print_age(s.st_mtime, -1, NULL);
}
int is_match(struct cgit_repo *repo)
{
if (!ctx.qry.search)
return 1;
if (repo->url && strcasestr(repo->url, ctx.qry.search))
return 1;
if (repo->name && strcasestr(repo->name, ctx.qry.search))
return 1;
if (repo->desc && strcasestr(repo->desc, ctx.qry.search))
return 1;
if (repo->owner && strcasestr(repo->owner, ctx.qry.search))
return 1;
return 0;
}
int is_in_url(struct cgit_repo *repo)
{
if (!ctx.qry.url)
return 1;
if (repo->url && !prefixcmp(repo->url, ctx.qry.url))
return 1;
return 0;
}