[hackers] [sbase] Add "-" support to comm(1) || sin
commit d208659414798cd47652a5aac67b4df8abfc380d
Author: sin <sin_AT_2f30.org>
Date: Thu Nov 13 15:38:39 2014 +0000
Add "-" support to comm(1)
diff --git a/comm.c b/comm.c
index 10f45b5..0cf3d41 100644
--- a/comm.c
+++ b/comm.c
_AT_@ -41,6 +41,8 @@ main(int argc, char *argv[])
usage();
for(i = 0; i < LEN(fp); i++) {
+ if (argv[i][0] == '-')
+ argv[i] = "/dev/fd/0";
if(!(fp[i] = fopen(argv[i], "r")))
eprintf("comm: '%s':", argv[i]);
}
_AT_@ -48,13 +50,13 @@ main(int argc, char *argv[])
for(;;) {
if(diff <= 0) {
if(!nextline(lines[0], sizeof(lines[0]),
- fp[0], argv[0])) {
+ fp[0], argv[0])) {
finish(1, fp[1], argv[1]);
}
}
if(diff >= 0) {
if(!nextline(lines[1], sizeof(lines[1]),
- fp[1], argv[1])) {
+ fp[1], argv[1])) {
finish(0, fp[0], argv[0]);
}
}
_AT_@ -89,7 +91,6 @@ nextline(char *buf, int n, FILE *f, char *name)
eprintf("comm: '%s':", name);
if(buf && !strchr(buf, '\n'))
eprintf("comm: '%s': line too long.\n", name);
-
return buf;
}
_AT_@ -100,6 +101,5 @@ finish(int pos, FILE *f, char *name)
while(nextline(buf, sizeof(buf), f, name))
printline(pos, buf);
-
exit(1);
}
Received on Thu Nov 13 2014 - 17:01:48 CET
This archive was generated by hypermail 2.3.0
: Thu Nov 13 2014 - 17:12:13 CET