summary refs log tree commit diff
path: root/bin/xx.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-05-29 17:55:10 -0400
committerJune McEnroe <june@causal.agency>2019-05-29 17:55:10 -0400
commit65feadc0658d8422f30c0cce7bd9af0fb183a2fa (patch)
tree970f9640a2325ecde898f19944f1849ad738f401 /bin/xx.c
parentAdd Frontier (diff)
downloadsrc-65feadc0658d8422f30c0cce7bd9af0fb183a2fa.tar.gz
src-65feadc0658d8422f30c0cce7bd9af0fb183a2fa.zip
Add xx -p option
Diffstat (limited to '')
-rw-r--r--bin/xx.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/bin/xx.c b/bin/xx.c
index 3a314c1b..6d04f2f5 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;