forked from bonsai/harakit
npc(1): specifies sysexits imports, formatting
This commit is contained in:
parent
8421f8be87
commit
35a20dca79
14
src/npc.c
14
src/npc.c
@ -19,9 +19,9 @@
|
||||
|
||||
#include <stdio.h> /* fprintf(3), fputs(3), getc(3), putc(3), stdin, stdout,
|
||||
* EOF */
|
||||
#include <stdlib.h> /* EXIT_FAILURE, EXIT_SUCCESS */
|
||||
#include <stdlib.h> /* EXIT_FAILURE */
|
||||
#include <unistd.h> /* getopt(3) */
|
||||
#include <sysexits.h>
|
||||
#include <sysexits.h> /* EX_OK, EX_USAGE */
|
||||
|
||||
int usage(char *s) {
|
||||
fprintf(stderr, "Usage: %s [-et]\n", s);
|
||||
@ -36,17 +36,17 @@ int main(int argc, char *argv[]) {
|
||||
showend = 0;
|
||||
showtab = 0;
|
||||
|
||||
if(!argc > 0) { usage(argv[0]); }
|
||||
|
||||
if (argc > 0) {
|
||||
while ((c = getopt(argc, argv, "et")) != -1) {
|
||||
switch(c){
|
||||
switch (c){
|
||||
case 'e': showend = 1; break;
|
||||
case 't': showtab = 1; break;
|
||||
default: return usage(argv[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(argc > optind) { return usage(argv[0]); }
|
||||
if (argc > optind) { return usage(argv[0]); }
|
||||
|
||||
while ((c = getc(stdin)) != EOF) {
|
||||
if ((c & 0x80) != 0) { fputs("M-", stdout); }
|
||||
@ -55,7 +55,7 @@ int main(int argc, char *argv[]) {
|
||||
case 0x7f: fputs("^?", stdout); break;
|
||||
case '\n': if (showend) { putc('$', stdout); }
|
||||
default:
|
||||
if(c >= ' ' || c == '\n' || (!showtab && c == '\t')) {
|
||||
if (c >= ' ' || c == '\n' || (!showtab && c == '\t')) {
|
||||
putc(c, stdout);
|
||||
} else {
|
||||
fprintf(stdout, "^%c", c + '@');
|
||||
|
Loading…
Reference in New Issue
Block a user