# HG changeset patch # User Michael Spacefalcon # Date 1372614987 0 # Node ID 8256eec598ddd23ec035a376fa24fb6e1515a37f # Parent 390be89892c44adea3ee85baae77313c3b0209a9 mpffs-cat: more sensible handling of -v diff -r 390be89892c4 -r 8256eec598dd mpffs/cat.c --- a/mpffs/cat.c Sun Jun 30 17:24:21 2013 +0000 +++ b/mpffs/cat.c Sun Jun 30 17:56:27 2013 +0000 @@ -15,6 +15,8 @@ extern char *imgfile; extern int verbose; +int cat_v; + cat_chunk(chi) struct chunkinfo *chi; { @@ -26,7 +28,7 @@ len = chi->len; while (len) { c = *dp++; - if (!verbose || c >= ' ' && c <= '~' || c == '\n') + if (!cat_v || c >= ' ' && c <= '~' || c == '\n') putchar(c); else { if (c & 0x80) { @@ -59,8 +61,6 @@ } validate_chunk(&obj); size_head_chunk(&obj, &chi); - if (verbose) - printf("\n--- file content:\n"); cat_chunk(&chi); for (ent = obj.descend; ent != 0xFFFF; ent = obj.descend) { obj.entryno = ent; @@ -75,8 +75,8 @@ size_extra_chunk(&obj, &chi); cat_chunk(&chi); } - if (verbose) - printf("\n-- end quote --\n"); + if (cat_v) + putchar('\n'); } usage() @@ -94,6 +94,10 @@ parse_cmdline_options(argc, argv); if (argc - optind != 2) usage(); + if (verbose) { + cat_v = 1; + verbose--; + } imgfile = argv[optind]; preliminaries(); idx = find_pathname(argv[optind+1]);