|
diff --git a/ui-tree.c b/ui-tree.c index 7bf2ad2..f64e6e0 100644 --- a/ ui-tree.c+++ b/ ui-tree.c |
|
@@ -18,29 +18,34 @@ int header = 0; |
18 | static void print_text_buffer(const char *name, char *buf, unsigned long size) |
18 | static 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 | |
25 | |
26 | html("<tr><td class='linenumbers'><pre>"); |
26 | if (ctx.cfg.linenumbers) { |
27 | idx = 0; |
27 | html("<tr><td class='linenumbers'><pre>"); |
28 | lineno = 0; |
28 | idx = 0; |
29 | |
29 | lineno = 0; |
30 | if (size) { |
30 | |
31 | htmlf(numberfmt, ++lineno); |
31 | if (size) { |
32 | while(idx < size - 1) { // skip absolute last newline |
32 | htmlf(numberfmt, ++lineno); |
33 | if (buf[idx] == '\n') |
33 | while(idx < size - 1) { // skip absolute last newline |
34 | htmlf(numberfmt, ++lineno); |
34 | if (buf[idx] == '\n') |
35 | idx++; |
35 | htmlf(numberfmt, ++lineno); |
| |
36 | idx++; |
| |
37 | } |
36 | } |
38 | } |
| |
39 | html("</pre></td>\n"); |
| |
40 | } |
| |
41 | else { |
| |
42 | html("<tr>\n"); |
37 | } |
43 | } |
38 | html("</pre></td>\n"); |
| |
39 | |
44 | |
40 | if (ctx.repo->source_filter) { |
45 | if (ctx.repo->source_filter) { |
41 | html("<td class='lines'><pre><code>"); |
46 | html("<td class='lines'><pre><code>"); |
42 | ctx.repo->source_filter->argv[1] = xstrdup(name); |
47 | ctx.repo->source_filter->argv[1] = xstrdup(name); |
43 | cgit_open_filter(ctx.repo->source_filter); |
48 | cgit_open_filter(ctx.repo->source_filter); |
44 | write(STDOUT_FILENO, buf, size); |
49 | write(STDOUT_FILENO, buf, size); |
45 | cgit_close_filter(ctx.repo->source_filter); |
50 | cgit_close_filter(ctx.repo->source_filter); |
46 | html("</code></pre></td></tr></table>\n"); |
51 | html("</code></pre></td></tr></table>\n"); |
|