X-Git-Url: https://gitweb.ps.run/ps-cgit/blobdiff_plain/ae1d4d75b2a2eb3534ff4b3685cc5c0b80007ef7..03389d6e67bfda5cb3ff1504db815f09715ec6f4:/ui-tree.c?ds=inline diff --git a/ui-tree.c b/ui-tree.c index a37a4e5..7bf2ad2 100644 --- a/ui-tree.c +++ b/ui-tree.c @@ -15,49 +15,69 @@ char *curr_rev; char *match_path; int header = 0; -static void print_text_buffer(char *buf, unsigned long size) +static void print_text_buffer(const char *name, char *buf, unsigned long size) { unsigned long lineno, idx; const char *numberfmt = "%1$d\n"; html("
");
idx = 0;
lineno = 0;
- htmlf(numberfmt, ++lineno);
- while(idx < size - 1) { // skip absolute last newline
- if (buf[idx] == '\n')
- htmlf(numberfmt, ++lineno);
- idx++;
+
+ if (size) {
+ htmlf(numberfmt, ++lineno);
+ while(idx < size - 1) { // skip absolute last newline
+ if (buf[idx] == '\n')
+ htmlf(numberfmt, ++lineno);
+ idx++;
+ }
}
html(" | \n");
+
+ if (ctx.repo->source_filter) {
+ html(" |
");
html_txt(buf);
html("| ofs | hex dump | ascii |
|---|---|---|
| %04x | ", ofs); - for (idx = 0; idx < 32 && ofs + idx < size; idx++) + for (idx = 0; idx < ROWLEN && ofs + idx < size; idx++) htmlf("%*s%02x", idx == 16 ? 4 : 1, "", buf[idx] & 0xff); html(" | "); - for (idx = 0; idx < 32 && ofs + idx < size; idx++) - htmlf("%c", isgraph(buf[idx]) ? buf[idx] : '.'); + for (idx = 0; idx < ROWLEN && ofs + idx < size; idx++) + ascii[idx] = isgraph(buf[idx]) ? buf[idx] : '.'; + ascii[idx] = '\0'; + html_txt(ascii); html(" |