summaryrefslogtreecommitdiffabout
authorMark Lodato <lodatom@gmail.com>2010-09-04 15:49:30 (UTC)
committer Mark Lodato <lodatom@gmail.com>2010-09-04 18:09:24 (UTC)
commit25e8ba1996a7b5ea291c924b0990d706176f6fe6 (patch) (unidiff)
tree935e6e9a5df75e98d293fc55577e9cc9f010086f
parente4ddc8f72b5a7d8c55a6c2042c7b7f945ba4b1a2 (diff)
downloadcgit-25e8ba1996a7b5ea291c924b0990d706176f6fe6.zip
cgit-25e8ba1996a7b5ea291c924b0990d706176f6fe6.tar.gz
cgit-25e8ba1996a7b5ea291c924b0990d706176f6fe6.tar.bz2
ui-repolist: fix redefinition of _XOPEN_SOURCE
Previously, ui-repolist.c set _GNU_SOURCE and then included a standard library before including <git-compat-util.h>. This was a problem, because <git-compat-util.h> redefined _XOPEN_SOURCE, which is set automatically by glibc when _GNU_SOURCE is set. However, <git-compat-util.h> already sets _GNU_SOURCE and includes both <string.h> and <time.h>, so there is no need to define _GNU_SOURCE or include either header within ui-repolist.c. Signed-off-by: Mark Lodato <lodatom@gmail.com>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--ui-repolist.c6
1 files changed, 0 insertions, 6 deletions
diff --git a/ui-repolist.c b/ui-repolist.c
index 0a0b6ca..2c98668 100644
--- a/ui-repolist.c
+++ b/ui-repolist.c
@@ -1,62 +1,56 @@
1/* ui-repolist.c: functions for generating the repolist page 1/* ui-repolist.c: functions for generating the repolist page
2 * 2 *
3 * Copyright (C) 2006 Lars Hjemli 3 * Copyright (C) 2006 Lars Hjemli
4 * 4 *
5 * Licensed under GNU General Public License v2 5 * Licensed under GNU General Public License v2
6 * (see COPYING for full license text) 6 * (see COPYING for full license text)
7 */ 7 */
8 8
9/* This is needed for strcasestr to be defined by <string.h> */
10#define _GNU_SOURCE 1
11#include <string.h>
12
13#include <time.h>
14
15#include "cgit.h" 9#include "cgit.h"
16#include "html.h" 10#include "html.h"
17#include "ui-shared.h" 11#include "ui-shared.h"
18 12
19time_t read_agefile(char *path) 13time_t read_agefile(char *path)
20{ 14{
21 time_t result; 15 time_t result;
22 size_t size; 16 size_t size;
23 char *buf; 17 char *buf;
24 static char buf2[64]; 18 static char buf2[64];
25 19
26 if (readfile(path, &buf, &size)) 20 if (readfile(path, &buf, &size))
27 return -1; 21 return -1;
28 22
29 if (parse_date(buf, buf2, sizeof(buf2))) 23 if (parse_date(buf, buf2, sizeof(buf2)))
30 result = strtoul(buf2, NULL, 10); 24 result = strtoul(buf2, NULL, 10);
31 else 25 else
32 result = 0; 26 result = 0;
33 free(buf); 27 free(buf);
34 return result; 28 return result;
35} 29}
36 30
37static int get_repo_modtime(const struct cgit_repo *repo, time_t *mtime) 31static int get_repo_modtime(const struct cgit_repo *repo, time_t *mtime)
38{ 32{
39 char *path; 33 char *path;
40 struct stat s; 34 struct stat s;
41 struct cgit_repo *r = (struct cgit_repo *)repo; 35 struct cgit_repo *r = (struct cgit_repo *)repo;
42 36
43 if (repo->mtime != -1) { 37 if (repo->mtime != -1) {
44 *mtime = repo->mtime; 38 *mtime = repo->mtime;
45 return 1; 39 return 1;
46 } 40 }
47 path = fmt("%s/%s", repo->path, ctx.cfg.agefile); 41 path = fmt("%s/%s", repo->path, ctx.cfg.agefile);
48 if (stat(path, &s) == 0) { 42 if (stat(path, &s) == 0) {
49 *mtime = read_agefile(path); 43 *mtime = read_agefile(path);
50 r->mtime = *mtime; 44 r->mtime = *mtime;
51 return 1; 45 return 1;
52 } 46 }
53 47
54 path = fmt("%s/refs/heads/%s", repo->path, repo->defbranch); 48 path = fmt("%s/refs/heads/%s", repo->path, repo->defbranch);
55 if (stat(path, &s) == 0) 49 if (stat(path, &s) == 0)
56 *mtime = s.st_mtime; 50 *mtime = s.st_mtime;
57 else 51 else
58 *mtime = 0; 52 *mtime = 0;
59 53
60 r->mtime = *mtime; 54 r->mtime = *mtime;
61 return (r->mtime != 0); 55 return (r->mtime != 0);
62} 56}