author | Lars Hjemli <hjemli@gmail.com> | 2008-12-05 18:04:17 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2008-12-05 18:04:17 (UTC) |
commit | 7115f7d257b5e3fb5d5d7ad6299214506fb35042 (patch) (unidiff) | |
tree | 844631b9f2a6354fcd988a13dfb9b1d567cb6344 | |
parent | a5e899e4c786e2ed7f58874d66956bf196cef8df (diff) | |
download | cgit-7115f7d257b5e3fb5d5d7ad6299214506fb35042.zip cgit-7115f7d257b5e3fb5d5d7ad6299214506fb35042.tar.gz cgit-7115f7d257b5e3fb5d5d7ad6299214506fb35042.tar.bz2 |
ui-repolist: avoid build warning for strcasestr(3)
The non-standard function strcasestr is only defined if _GNU_SOURCE has
also been defined.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | ui-repolist.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/ui-repolist.c b/ui-repolist.c index c23232c..2324273 100644 --- a/ui-repolist.c +++ b/ui-repolist.c | |||
@@ -1,72 +1,76 @@ | |||
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 | |||
9 | #include <time.h> | 13 | #include <time.h> |
10 | 14 | ||
11 | #include "cgit.h" | 15 | #include "cgit.h" |
12 | #include "html.h" | 16 | #include "html.h" |
13 | #include "ui-shared.h" | 17 | #include "ui-shared.h" |
14 | 18 | ||
15 | time_t read_agefile(char *path) | 19 | time_t read_agefile(char *path) |
16 | { | 20 | { |
17 | FILE *f; | 21 | FILE *f; |
18 | static char buf[64], buf2[64]; | 22 | static char buf[64], buf2[64]; |
19 | 23 | ||
20 | if (!(f = fopen(path, "r"))) | 24 | if (!(f = fopen(path, "r"))) |
21 | return -1; | 25 | return -1; |
22 | if (fgets(buf, sizeof(buf), f) == NULL) | 26 | if (fgets(buf, sizeof(buf), f) == NULL) |
23 | return -1; | 27 | return -1; |
24 | fclose(f); | 28 | fclose(f); |
25 | if (parse_date(buf, buf2, sizeof(buf2))) | 29 | if (parse_date(buf, buf2, sizeof(buf2))) |
26 | return strtoul(buf2, NULL, 10); | 30 | return strtoul(buf2, NULL, 10); |
27 | else | 31 | else |
28 | return 0; | 32 | return 0; |
29 | } | 33 | } |
30 | 34 | ||
31 | static void print_modtime(struct cgit_repo *repo) | 35 | static void print_modtime(struct cgit_repo *repo) |
32 | { | 36 | { |
33 | char *path; | 37 | char *path; |
34 | struct stat s; | 38 | struct stat s; |
35 | 39 | ||
36 | path = fmt("%s/%s", repo->path, ctx.cfg.agefile); | 40 | path = fmt("%s/%s", repo->path, ctx.cfg.agefile); |
37 | if (stat(path, &s) == 0) { | 41 | if (stat(path, &s) == 0) { |
38 | cgit_print_age(read_agefile(path), -1, NULL); | 42 | cgit_print_age(read_agefile(path), -1, NULL); |
39 | return; | 43 | return; |
40 | } | 44 | } |
41 | 45 | ||
42 | path = fmt("%s/refs/heads/%s", repo->path, repo->defbranch); | 46 | path = fmt("%s/refs/heads/%s", repo->path, repo->defbranch); |
43 | if (stat(path, &s) != 0) | 47 | if (stat(path, &s) != 0) |
44 | return; | 48 | return; |
45 | cgit_print_age(s.st_mtime, -1, NULL); | 49 | cgit_print_age(s.st_mtime, -1, NULL); |
46 | } | 50 | } |
47 | 51 | ||
48 | int is_match(struct cgit_repo *repo) | 52 | int is_match(struct cgit_repo *repo) |
49 | { | 53 | { |
50 | if (!ctx.qry.search) | 54 | if (!ctx.qry.search) |
51 | return 1; | 55 | return 1; |
52 | if (repo->url && strcasestr(repo->url, ctx.qry.search)) | 56 | if (repo->url && strcasestr(repo->url, ctx.qry.search)) |
53 | return 1; | 57 | return 1; |
54 | if (repo->name && strcasestr(repo->name, ctx.qry.search)) | 58 | if (repo->name && strcasestr(repo->name, ctx.qry.search)) |
55 | return 1; | 59 | return 1; |
56 | if (repo->desc && strcasestr(repo->desc, ctx.qry.search)) | 60 | if (repo->desc && strcasestr(repo->desc, ctx.qry.search)) |
57 | return 1; | 61 | return 1; |
58 | if (repo->owner && strcasestr(repo->owner, ctx.qry.search)) | 62 | if (repo->owner && strcasestr(repo->owner, ctx.qry.search)) |
59 | return 1; | 63 | return 1; |
60 | return 0; | 64 | return 0; |
61 | } | 65 | } |
62 | 66 | ||
63 | int is_in_url(struct cgit_repo *repo) | 67 | int is_in_url(struct cgit_repo *repo) |
64 | { | 68 | { |
65 | if (!ctx.qry.url) | 69 | if (!ctx.qry.url) |
66 | return 1; | 70 | return 1; |
67 | if (repo->url && !prefixcmp(repo->url, ctx.qry.url)) | 71 | if (repo->url && !prefixcmp(repo->url, ctx.qry.url)) |
68 | return 1; | 72 | return 1; |
69 | return 0; | 73 | return 0; |
70 | } | 74 | } |
71 | 75 | ||
72 | void print_header(int columns) | 76 | void print_header(int columns) |