- Timestamp:
- Jan 13, 2010, 12:54:09 AM (11 years ago)
- Location:
- zzuf/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
zzuf/trunk/doc/zzcat.1.in
r4246 r4254 3 3 zzcat \- debugging tool for zzuf 4 4 .SH SYNOPSIS 5 \fBzzcat\fR [\fB\- x\fR \fIsequence\fR] [\fIFILE\fR]...5 \fBzzcat\fR [\fB\-AbeEntTv\fR] [\fB\-x\fR \fIsequence\fR] [\fIFILE\fR]... 6 6 .br 7 7 \fBzzcat \-l\fR | \fB\-\-list\fR … … 21 21 \fB zzcat -x "fread(1,10000)" /dev/zero\fR 22 22 .SH OPTIONS 23 .TP 24 \fB\-A\fR, \fB\-\-show\-all\fR 25 Equivalent to \fB\-vET\fR. 26 .TP 27 \fB\-b\fR, \fB\-\-number\-nonblank\fR 28 Number nonempty output lines. 29 .TP 30 \fB\-e\fR 31 Equivalent to \fB\-vET\fR. 32 .TP 33 \fB\-E\fR, \fB\-\-show\-ends\fR 34 Display $ at end of each line. 35 .TP 36 \fB\-n\fR, \fB\-\-number\fR 37 Number all output lines. 38 .TP 39 \fB\-t\fR 40 Equivalent to \fB\-vT\fR. 41 .TP 42 \fB\-T\fR, \fB\-\-show\-tabs\fR 43 Display TAB characters as ^I. 44 .TP 45 \fB\-v\fR, \fB\-\-show\-nonprinting\fR 46 Use ^ and M- notation, except for LFD and TAB. 23 47 .TP 24 48 \fB\-x\fR, \fB\-\-execute\fR=\fIsequence\fR -
zzuf/trunk/src/zzcat.c
r4253 r4254 61 61 static void usage(void); 62 62 63 /* Output parameters */ 64 static int escape_tabs = 0; 65 static int escape_ends = 0; 66 static int escape_other = 0; 67 static int number_lines = 0; 68 static int number_nonblank = 0; 69 63 70 /* 64 71 * Main program. … … 72 79 for (;;) 73 80 { 74 #define OPTSTR "+ x:lhV"81 #define OPTSTR "+AbeEntTvx:lhV" 75 82 #define MOREINFO "Try `%s --help' for more information.\n" 76 83 int option_index = 0; 77 84 static struct myoption long_options[] = 78 85 { 79 { "execute", 1, NULL, 'x' }, 80 { "list", 0, NULL, 'l' }, 81 { "help", 0, NULL, 'h' }, 82 { "version", 0, NULL, 'V' }, 83 { NULL, 0, NULL, 0 } 86 { "show-all", 0, NULL, 'A' }, 87 { "number-nonblank", 0, NULL, 'b' }, 88 { "show-ends", 0, NULL, 'E' }, 89 { "number", 0, NULL, 'n' }, 90 { "show-tabs", 0, NULL, 'T' }, 91 { "show-nonprinting", 0, NULL, 'v' }, 92 { "execute", 1, NULL, 'x' }, 93 { "list", 0, NULL, 'l' }, 94 { "help", 0, NULL, 'h' }, 95 { "version", 0, NULL, 'V' }, 96 { NULL, 0, NULL, 0 } 84 97 }; 85 98 int c = mygetopt(argc, argv, OPTSTR, long_options, &option_index); … … 90 103 switch (c) 91 104 { 105 case 'A': /* --show-all */ 106 escape_tabs = escape_ends = escape_other = 1; 107 break; 108 case 'b': /* --number-nonblank */ 109 number_lines = 1; 110 break; 111 case 'e': 112 escape_ends = escape_other = 1; 113 break; 114 case 'E': /* --show-ends */ 115 escape_ends = 1; 116 break; 117 case 'n': /* --number */ 118 number_nonblank = 1; 119 break; 120 case 't': 121 escape_tabs = escape_other = 1; 122 break; 123 case 'T': /* --show-tabs */ 124 escape_tabs = 1; 125 break; 126 case 'v': /* --show-nonprinting */ 127 escape_tabs = 1; 128 break; 92 129 case 'x': /* --execute */ 93 130 if (myoptarg[0] == '=') … … 451 488 close(fd); 452 489 453 fwrite(retbuf, retlen, 1, stdout); 490 if (escape_tabs || escape_ends || escape_other || number_lines) 491 { 492 size_t i; 493 494 for (i = 0; i < retlen; i++) 495 { 496 int ch = (unsigned int)(unsigned char)retbuf[i]; 497 498 if (escape_other && ch >= 0x80) 499 { 500 if (ch - 0x80 < 0x20 || ch - 0x80 == 0x7f) 501 fprintf(stdout, "M-^%c", (ch - 0x80) ^ 0x40); 502 else 503 fprintf(stdout, "M-%c", ch - 0x80); 504 } 505 else if (escape_tabs && ch == '\t') 506 fprintf(stdout, "^I"); 507 else if (escape_ends && ch == '\n') 508 puts("$"); 509 else if (escape_other && (ch < 0x20 || ch == 0x7f)) 510 fprintf(stdout, "^%c", ch ^ 0x40); 511 else 512 putchar(ch); 513 } 514 } 515 else 516 { 517 fwrite(retbuf, retlen, 1, stdout); 518 } 454 519 455 520 free(retbuf); … … 661 726 static void usage(void) 662 727 { 663 printf("Usage: zzcat [ -x sequence] [FILE...]\n");728 printf("Usage: zzcat [AbeEntTv] [-x sequence] [FILE...]\n"); 664 729 printf(" zzcat -l | --list\n"); 665 730 printf(" zzcat -h | --help\n"); … … 668 733 printf("\n"); 669 734 printf("Mandatory arguments to long options are mandatory for short options too.\n"); 735 printf(" -A, --show-all equivalent to -vET\n"); 736 printf(" -b, --number-nonblank number nonempty output lines\n"); 737 printf(" -e equivalent to -vE\n"); 738 printf(" -E, --show-ends display $ at end of each line\n"); 739 printf(" -n, --number number all output lines\n"); 740 printf(" -t equivalent to -vT\n"); 741 printf(" -T, --show-tabs display TAB characters as ^I\n"); 742 printf(" -v, --show-nonprinting use ^ and M- notation, except for LFD and TAB\n"); 670 743 printf(" -x, --execute <sequence> execute commands in <sequence>\n"); 671 744 printf(" -l, --list list available program functions\n");
Note: See TracChangeset
for help on using the changeset viewer.