From 4093cb550d4c7acdef1314ebe255eba07ef1f3d1 Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Wed, 29 May 2019 17:55:10 -0400 Subject: Add xx -p option --- bin/man1/xx.1 | 9 +++++++++ bin/xx.c | 12 ++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/bin/man1/xx.1 b/bin/man1/xx.1 index 3fbcbd70..d38789a7 100644 --- a/bin/man1/xx.1 +++ b/bin/man1/xx.1 @@ -11,6 +11,7 @@ .Op Fl arsz .Op Fl c Ar cols .Op Fl g Ar group +.Op Fl p Ar count .Op Ar file . .Sh DESCRIPTION @@ -42,6 +43,14 @@ The default .Ar group is 8. . +.It Fl p Ar count +Output a blank line after every +.Ar count +bytes. +.Ar count +must be a multiple of +.Ar cols . +. .It Fl r Reverse hexdump. Read hexadecimal input diff --git a/bin/xx.c b/bin/xx.c index 1dd7ce5e..39d7ec07 100644 --- a/bin/xx.c +++ b/bin/xx.c @@ -34,10 +34,11 @@ static bool zero(const byte *ptr, size_t size) { static struct { size_t cols; size_t group; + size_t blank; bool ascii; bool offset; bool skip; -} options = { 16, 8, true, true, false }; +} options = { 16, 8, 0, true, true, false }; static void dump(FILE *file) { bool skip = false; @@ -59,6 +60,12 @@ static void dump(FILE *file) { } } + if (options.blank) { + if (offset && offset % options.blank == 0) { + printf("\n"); + } + } + if (options.offset) { printf("%08zX: ", offset); } @@ -106,11 +113,12 @@ int main(int argc, char *argv[]) { const char *path = NULL; int opt; - while (0 < (opt = getopt(argc, argv, "ac:g:rsz"))) { + while (0 < (opt = getopt(argc, argv, "ac:g:p:rsz"))) { switch (opt) { break; case 'a': options.ascii ^= true; break; case 'c': options.cols = strtoul(optarg, NULL, 0); break; case 'g': options.group = strtoul(optarg, NULL, 0); + break; case 'p': options.blank = strtoul(optarg, NULL, 0); break; case 'r': reverse = true; break; case 's': options.offset ^= true; break; case 'z': options.skip ^= true; -- cgit 1.4.1 ption value='grep'>log msg
path: root/url.c (unfollow)
Commit message (Collapse)Author
2018-09-11Add /help equivalent to /manJune McEnroe
2018-09-11Don't render every PM as a pingJune McEnroe
2018-09-11Add urlOpenMatchJune McEnroe
2018-09-10Depend on man.sh for chroot.tar targetJune McEnroe
2018-09-10Set LESSSECURE=1 in man.shJune McEnroe
Ridiculous.
2018-09-10Add /man commandJune McEnroe
2018-09-10Install man page in chrootJune McEnroe
2018-09-10Install man pageJune McEnroe
2018-09-10Split keys into subsections and document colorsJune McEnroe
2018-09-10Add "blank" lines to chatte.1June McEnroe
2018-09-10Document key bindings in chatte.1June McEnroe
2018-09-08Document slash commands in chatte.1June McEnroe