+ for (; i < end; i++) {
+ ds_put_format(ds, "%02x%c",
+ buf[i - start], i == per_line / 2 - 1? '-' : ' ');
+ }
+ if (ascii) {
+ for (; i < per_line; i++)
+ ds_put_format(ds, " ");
+ ds_put_format(ds, "|");
+ for (i = 0; i < start; i++)
+ ds_put_format(ds, " ");
+ for (; i < end; i++) {
+ int c = buf[i - start];
+ ds_put_char(ds, c >= 32 && c < 127 ? c : '.');
+ }
+ for (; i < per_line; i++)
+ ds_put_format(ds, " ");
+ ds_put_format(ds, "|");
+ } else {
+ ds_chomp(ds, ' ');
+ }
+ ds_put_format(ds, "\n");