summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--ui-tree.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/ui-tree.c b/ui-tree.c
index 0b1b531..442b6be 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -27,48 +27,50 @@ static void print_text_buffer(const char *name, char *buf, unsigned long size)
27 html("<tr><td class='linenumbers'><pre>"); 27 html("<tr><td class='linenumbers'><pre>");
28 idx = 0; 28 idx = 0;
29 lineno = 0; 29 lineno = 0;
30 30
31 if (size) { 31 if (size) {
32 htmlf(numberfmt, ++lineno); 32 htmlf(numberfmt, ++lineno);
33 while(idx < size - 1) { // skip absolute last newline 33 while(idx < size - 1) { // skip absolute last newline
34 if (buf[idx] == '\n') 34 if (buf[idx] == '\n')
35 htmlf(numberfmt, ++lineno); 35 htmlf(numberfmt, ++lineno);
36 idx++; 36 idx++;
37 } 37 }
38 } 38 }
39 html("</pre></td>\n"); 39 html("</pre></td>\n");
40 } 40 }
41 else { 41 else {
42 html("<tr>\n"); 42 html("<tr>\n");
43 } 43 }
44 44
45 if (ctx.repo->source_filter) { 45 if (ctx.repo->source_filter) {
46 html("<td class='lines'><pre><code>"); 46 html("<td class='lines'><pre><code>");
47 ctx.repo->source_filter->argv[1] = xstrdup(name); 47 ctx.repo->source_filter->argv[1] = xstrdup(name);
48 cgit_open_filter(ctx.repo->source_filter); 48 cgit_open_filter(ctx.repo->source_filter);
49 html_raw(buf, size); 49 html_raw(buf, size);
50 cgit_close_filter(ctx.repo->source_filter); 50 cgit_close_filter(ctx.repo->source_filter);
51 free(ctx.repo->source_filter->argv[1]);
52 ctx.repo->source_filter->argv[1] = NULL;
51 html("</code></pre></td></tr></table>\n"); 53 html("</code></pre></td></tr></table>\n");
52 return; 54 return;
53 } 55 }
54 56
55 html("<td class='lines'><pre><code>"); 57 html("<td class='lines'><pre><code>");
56 html_txt(buf); 58 html_txt(buf);
57 html("</code></pre></td></tr></table>\n"); 59 html("</code></pre></td></tr></table>\n");
58} 60}
59 61
60#define ROWLEN 32 62#define ROWLEN 32
61 63
62static void print_binary_buffer(char *buf, unsigned long size) 64static void print_binary_buffer(char *buf, unsigned long size)
63{ 65{
64 unsigned long ofs, idx; 66 unsigned long ofs, idx;
65 static char ascii[ROWLEN + 1]; 67 static char ascii[ROWLEN + 1];
66 68
67 html("<table summary='blob content' class='bin-blob'>\n"); 69 html("<table summary='blob content' class='bin-blob'>\n");
68 html("<tr><th>ofs</th><th>hex dump</th><th>ascii</th></tr>"); 70 html("<tr><th>ofs</th><th>hex dump</th><th>ascii</th></tr>");
69 for (ofs = 0; ofs < size; ofs += ROWLEN, buf += ROWLEN) { 71 for (ofs = 0; ofs < size; ofs += ROWLEN, buf += ROWLEN) {
70 htmlf("<tr><td class='right'>%04lx</td><td class='hex'>", ofs); 72 htmlf("<tr><td class='right'>%04lx</td><td class='hex'>", ofs);
71 for (idx = 0; idx < ROWLEN && ofs + idx < size; idx++) 73 for (idx = 0; idx < ROWLEN && ofs + idx < size; idx++)
72 htmlf("%*s%02x", 74 htmlf("%*s%02x",
73 idx == 16 ? 4 : 1, "", 75 idx == 16 ? 4 : 1, "",
74 buf[idx] & 0xff); 76 buf[idx] & 0xff);