summaryrefslogtreecommitdiffabout
authorLars Hjemli <hjemli@gmail.com>2007-06-17 10:58:59 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2007-06-17 10:58:59 (UTC)
commit486c87ec2906c445ca505c877720d56e02aed784 (patch) (unidiff)
tree42d66dc8e9dfee4812f3f37b7bc8deef04d4e78d
parent44947bfcdc0d6e8c7d673bea0538cbf2a182f289 (diff)
downloadcgit-486c87ec2906c445ca505c877720d56e02aed784.zip
cgit-486c87ec2906c445ca505c877720d56e02aed784.tar.gz
cgit-486c87ec2906c445ca505c877720d56e02aed784.tar.bz2
ui-shared: use strcmp() to compare strings
Somehow a couple of pointer comparisions crept into the new repolink() and cgit_tree_link() functions. Fix it. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--ui-shared.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/ui-shared.c b/ui-shared.c
index 9ab6409..657e8af 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -34,208 +34,208 @@ static long ttl_seconds(long ttl)
34} 34}
35 35
36void cgit_print_error(char *msg) 36void cgit_print_error(char *msg)
37{ 37{
38 html("<div class='error'>"); 38 html("<div class='error'>");
39 html_txt(msg); 39 html_txt(msg);
40 html("</div>\n"); 40 html("</div>\n");
41} 41}
42 42
43char *cgit_rooturl() 43char *cgit_rooturl()
44{ 44{
45 if (cgit_virtual_root) 45 if (cgit_virtual_root)
46 return fmt("%s/", cgit_virtual_root); 46 return fmt("%s/", cgit_virtual_root);
47 else 47 else
48 return cgit_script_name; 48 return cgit_script_name;
49} 49}
50 50
51char *cgit_repourl(const char *reponame) 51char *cgit_repourl(const char *reponame)
52{ 52{
53 if (cgit_virtual_root) { 53 if (cgit_virtual_root) {
54 return fmt("%s/%s/", cgit_virtual_root, reponame); 54 return fmt("%s/%s/", cgit_virtual_root, reponame);
55 } else { 55 } else {
56 return fmt("?r=%s", reponame); 56 return fmt("?r=%s", reponame);
57 } 57 }
58} 58}
59 59
60char *cgit_pageurl(const char *reponame, const char *pagename, 60char *cgit_pageurl(const char *reponame, const char *pagename,
61 const char *query) 61 const char *query)
62{ 62{
63 if (cgit_virtual_root) { 63 if (cgit_virtual_root) {
64 if (query) 64 if (query)
65 return fmt("%s/%s/%s/?%s", cgit_virtual_root, reponame, 65 return fmt("%s/%s/%s/?%s", cgit_virtual_root, reponame,
66 pagename, query); 66 pagename, query);
67 else 67 else
68 return fmt("%s/%s/%s/", cgit_virtual_root, reponame, 68 return fmt("%s/%s/%s/", cgit_virtual_root, reponame,
69 pagename); 69 pagename);
70 } else { 70 } else {
71 if (query) 71 if (query)
72 return fmt("?r=%s&amp;p=%s&amp;%s", reponame, pagename, query); 72 return fmt("?r=%s&amp;p=%s&amp;%s", reponame, pagename, query);
73 else 73 else
74 return fmt("?r=%s&amp;p=%s", reponame, pagename); 74 return fmt("?r=%s&amp;p=%s", reponame, pagename);
75 } 75 }
76} 76}
77 77
78char *cgit_currurl() 78char *cgit_currurl()
79{ 79{
80 if (!cgit_virtual_root) 80 if (!cgit_virtual_root)
81 return cgit_script_name; 81 return cgit_script_name;
82 else if (cgit_query_page) 82 else if (cgit_query_page)
83 return fmt("%s/%s/%s/", cgit_virtual_root, cgit_query_repo, cgit_query_page); 83 return fmt("%s/%s/%s/", cgit_virtual_root, cgit_query_repo, cgit_query_page);
84 else if (cgit_query_repo) 84 else if (cgit_query_repo)
85 return fmt("%s/%s/", cgit_virtual_root, cgit_query_repo); 85 return fmt("%s/%s/", cgit_virtual_root, cgit_query_repo);
86 else 86 else
87 return fmt("%s/", cgit_virtual_root); 87 return fmt("%s/", cgit_virtual_root);
88} 88}
89 89
90static char *repolink(char *title, char *class, char *page, char *head, 90static char *repolink(char *title, char *class, char *page, char *head,
91 char *path) 91 char *path)
92{ 92{
93 char *delim = "?"; 93 char *delim = "?";
94 94
95 html("<a"); 95 html("<a");
96 if (title) { 96 if (title) {
97 html(" title='"); 97 html(" title='");
98 html_attr(title); 98 html_attr(title);
99 html("'"); 99 html("'");
100 } 100 }
101 if (class) { 101 if (class) {
102 html(" class='"); 102 html(" class='");
103 html_attr(class); 103 html_attr(class);
104 html("'"); 104 html("'");
105 } 105 }
106 html(" href='"); 106 html(" href='");
107 if (cgit_virtual_root) { 107 if (cgit_virtual_root) {
108 html_attr(cgit_virtual_root); 108 html_attr(cgit_virtual_root);
109 if (cgit_virtual_root[strlen(cgit_virtual_root) - 1] != '/') 109 if (cgit_virtual_root[strlen(cgit_virtual_root) - 1] != '/')
110 html("/"); 110 html("/");
111 html_attr(cgit_repo->url); 111 html_attr(cgit_repo->url);
112 if (cgit_repo->url[strlen(cgit_repo->url) - 1] != '/') 112 if (cgit_repo->url[strlen(cgit_repo->url) - 1] != '/')
113 html("/"); 113 html("/");
114 html(page); 114 html(page);
115 html("/"); 115 html("/");
116 if (path) 116 if (path)
117 html_attr(path); 117 html_attr(path);
118 } else { 118 } else {
119 html(cgit_script_name); 119 html(cgit_script_name);
120 html("?url="); 120 html("?url=");
121 html_attr(cgit_repo->url); 121 html_attr(cgit_repo->url);
122 if (cgit_repo->url[strlen(cgit_repo->url) - 1] != '/') 122 if (cgit_repo->url[strlen(cgit_repo->url) - 1] != '/')
123 html("/"); 123 html("/");
124 html(page); 124 html(page);
125 html("/"); 125 html("/");
126 if (path) 126 if (path)
127 html_attr(path); 127 html_attr(path);
128 delim = "&amp;"; 128 delim = "&amp;";
129 } 129 }
130 if (head && head != cgit_query_head) { 130 if (head && strcmp(head, cgit_query_head)) {
131 html(delim); 131 html(delim);
132 html("h="); 132 html("h=");
133 html_attr(head); 133 html_attr(head);
134 delim = "&amp;"; 134 delim = "&amp;";
135 } 135 }
136 return fmt("%s", delim); 136 return fmt("%s", delim);
137} 137}
138 138
139void cgit_tree_link(char *name, char *title, char *class, char *head, 139void cgit_tree_link(char *name, char *title, char *class, char *head,
140 char *rev, char *path) 140 char *rev, char *path)
141{ 141{
142 char *delim; 142 char *delim;
143 143
144 delim = repolink(title, class, "tree", head, path); 144 delim = repolink(title, class, "tree", head, path);
145 if (rev && rev != cgit_query_head) { 145 if (rev && strcmp(rev, cgit_query_head)) {
146 html(delim); 146 html(delim);
147 html("id="); 147 html("id=");
148 html_attr(rev); 148 html_attr(rev);
149 } 149 }
150 html("'>"); 150 html("'>");
151 html_txt(name); 151 html_txt(name);
152 html("</a>"); 152 html("</a>");
153} 153}
154 154
155void cgit_print_date(time_t secs, char *format) 155void cgit_print_date(time_t secs, char *format)
156{ 156{
157 char buf[64]; 157 char buf[64];
158 struct tm *time; 158 struct tm *time;
159 159
160 time = gmtime(&secs); 160 time = gmtime(&secs);
161 strftime(buf, sizeof(buf)-1, format, time); 161 strftime(buf, sizeof(buf)-1, format, time);
162 html_txt(buf); 162 html_txt(buf);
163} 163}
164 164
165void cgit_print_age(time_t t, time_t max_relative, char *format) 165void cgit_print_age(time_t t, time_t max_relative, char *format)
166{ 166{
167 time_t now, secs; 167 time_t now, secs;
168 168
169 time(&now); 169 time(&now);
170 secs = now - t; 170 secs = now - t;
171 171
172 if (secs > max_relative && max_relative >= 0) { 172 if (secs > max_relative && max_relative >= 0) {
173 cgit_print_date(t, format); 173 cgit_print_date(t, format);
174 return; 174 return;
175 } 175 }
176 176
177 if (secs < TM_HOUR * 2) { 177 if (secs < TM_HOUR * 2) {
178 htmlf("<span class='age-mins'>%.0f min.</span>", 178 htmlf("<span class='age-mins'>%.0f min.</span>",
179 secs * 1.0 / TM_MIN); 179 secs * 1.0 / TM_MIN);
180 return; 180 return;
181 } 181 }
182 if (secs < TM_DAY * 2) { 182 if (secs < TM_DAY * 2) {
183 htmlf("<span class='age-hours'>%.0f hours</span>", 183 htmlf("<span class='age-hours'>%.0f hours</span>",
184 secs * 1.0 / TM_HOUR); 184 secs * 1.0 / TM_HOUR);
185 return; 185 return;
186 } 186 }
187 if (secs < TM_WEEK * 2) { 187 if (secs < TM_WEEK * 2) {
188 htmlf("<span class='age-days'>%.0f days</span>", 188 htmlf("<span class='age-days'>%.0f days</span>",
189 secs * 1.0 / TM_DAY); 189 secs * 1.0 / TM_DAY);
190 return; 190 return;
191 } 191 }
192 if (secs < TM_MONTH * 2) { 192 if (secs < TM_MONTH * 2) {
193 htmlf("<span class='age-weeks'>%.0f weeks</span>", 193 htmlf("<span class='age-weeks'>%.0f weeks</span>",
194 secs * 1.0 / TM_WEEK); 194 secs * 1.0 / TM_WEEK);
195 return; 195 return;
196 } 196 }
197 if (secs < TM_YEAR * 2) { 197 if (secs < TM_YEAR * 2) {
198 htmlf("<span class='age-months'>%.0f months</span>", 198 htmlf("<span class='age-months'>%.0f months</span>",
199 secs * 1.0 / TM_MONTH); 199 secs * 1.0 / TM_MONTH);
200 return; 200 return;
201 } 201 }
202 htmlf("<span class='age-years'>%.0f years</span>", 202 htmlf("<span class='age-years'>%.0f years</span>",
203 secs * 1.0 / TM_YEAR); 203 secs * 1.0 / TM_YEAR);
204} 204}
205 205
206void cgit_print_docstart(char *title, struct cacheitem *item) 206void cgit_print_docstart(char *title, struct cacheitem *item)
207{ 207{
208 html("Content-Type: text/html; charset=utf-8\n"); 208 html("Content-Type: text/html; charset=utf-8\n");
209 htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); 209 htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime));
210 htmlf("Expires: %s\n", http_date(item->st.st_mtime + 210 htmlf("Expires: %s\n", http_date(item->st.st_mtime +
211 ttl_seconds(item->ttl))); 211 ttl_seconds(item->ttl)));
212 html("\n"); 212 html("\n");
213 html(cgit_doctype); 213 html(cgit_doctype);
214 html("<html>\n"); 214 html("<html>\n");
215 html("<head>\n"); 215 html("<head>\n");
216 html("<title>"); 216 html("<title>");
217 html_txt(title); 217 html_txt(title);
218 html("</title>\n"); 218 html("</title>\n");
219 htmlf("<meta name='generator' content='cgit v%s'/>\n", cgit_version); 219 htmlf("<meta name='generator' content='cgit v%s'/>\n", cgit_version);
220 html("<link rel='stylesheet' type='text/css' href='"); 220 html("<link rel='stylesheet' type='text/css' href='");
221 html_attr(cgit_css); 221 html_attr(cgit_css);
222 html("'/>\n"); 222 html("'/>\n");
223 html("</head>\n"); 223 html("</head>\n");
224 html("<body>\n"); 224 html("<body>\n");
225} 225}
226 226
227void cgit_print_docend() 227void cgit_print_docend()
228{ 228{
229 html("</td></tr></table>"); 229 html("</td></tr></table>");
230 html("</body>\n</html>\n"); 230 html("</body>\n</html>\n");
231} 231}
232 232
233void cgit_print_pageheader(char *title, int show_search) 233void cgit_print_pageheader(char *title, int show_search)
234{ 234{
235 html("<table id='layout'>"); 235 html("<table id='layout'>");
236 html("<tr><td id='header'>"); 236 html("<tr><td id='header'>");
237 html(cgit_root_title); 237 html(cgit_root_title);
238 html("</td><td id='logo'>"); 238 html("</td><td id='logo'>");
239 html("<a href='"); 239 html("<a href='");
240 html_attr(cgit_logo_link); 240 html_attr(cgit_logo_link);
241 htmlf("'><img src='%s' alt='logo'/></a>", cgit_logo); 241 htmlf("'><img src='%s' alt='logo'/></a>", cgit_logo);