summaryrefslogtreecommitdiffabout
path: root/ui-tree.c
Unidiff
Diffstat (limited to 'ui-tree.c') (more/less context) (ignore whitespace changes)
-rw-r--r--ui-tree.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/ui-tree.c b/ui-tree.c
index c608754..7bf2ad2 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -13,47 +13,49 @@
13 13
14char *curr_rev; 14char *curr_rev;
15char *match_path; 15char *match_path;
16int header = 0; 16int header = 0;
17 17
18static void print_text_buffer(const char *name, char *buf, unsigned long size) 18static void print_text_buffer(const char *name, char *buf, unsigned long size)
19{ 19{
20 unsigned long lineno, idx; 20 unsigned long lineno, idx;
21 const char *numberfmt = 21 const char *numberfmt =
22 "<a class='no' id='n%1$d' name='n%1$d' href='#n%1$d'>%1$d</a>\n"; 22 "<a class='no' id='n%1$d' name='n%1$d' href='#n%1$d'>%1$d</a>\n";
23 23
24 html("<table summary='blob content' class='blob'>\n"); 24 html("<table summary='blob content' class='blob'>\n");
25 if (ctx.repo->source_filter) {
26 html("<tr><td class='lines'><pre><code>");
27 ctx.repo->source_filter->argv[1] = xstrdup(name);
28 cgit_open_filter(ctx.repo->source_filter);
29 write(STDOUT_FILENO, buf, size);
30 cgit_close_filter(ctx.repo->source_filter);
31 html("</code></pre></td></tr></table>\n");
32 return;
33 }
34 25
35 html("<tr><td class='linenumbers'><pre>"); 26 html("<tr><td class='linenumbers'><pre>");
36 idx = 0; 27 idx = 0;
37 lineno = 0; 28 lineno = 0;
38 29
39 if (size) { 30 if (size) {
40 htmlf(numberfmt, ++lineno); 31 htmlf(numberfmt, ++lineno);
41 while(idx < size - 1) { // skip absolute last newline 32 while(idx < size - 1) { // skip absolute last newline
42 if (buf[idx] == '\n') 33 if (buf[idx] == '\n')
43 htmlf(numberfmt, ++lineno); 34 htmlf(numberfmt, ++lineno);
44 idx++; 35 idx++;
45 } 36 }
46 } 37 }
47 html("</pre></td>\n"); 38 html("</pre></td>\n");
39
40 if (ctx.repo->source_filter) {
41 html("<td class='lines'><pre><code>");
42 ctx.repo->source_filter->argv[1] = xstrdup(name);
43 cgit_open_filter(ctx.repo->source_filter);
44 write(STDOUT_FILENO, buf, size);
45 cgit_close_filter(ctx.repo->source_filter);
46 html("</code></pre></td></tr></table>\n");
47 return;
48 }
49
48 html("<td class='lines'><pre><code>"); 50 html("<td class='lines'><pre><code>");
49 html_txt(buf); 51 html_txt(buf);
50 html("</code></pre></td></tr></table>\n"); 52 html("</code></pre></td></tr></table>\n");
51} 53}
52 54
53#define ROWLEN 32 55#define ROWLEN 32
54 56
55static void print_binary_buffer(char *buf, unsigned long size) 57static void print_binary_buffer(char *buf, unsigned long size)
56{ 58{
57 unsigned long ofs, idx; 59 unsigned long ofs, idx;
58 static char ascii[ROWLEN + 1]; 60 static char ascii[ROWLEN + 1];
59 61