+ Harald Hanche-Olsen <[EMAIL PROTECTED]>:

| Adding the necessary code to fixcr.c in order to do this ought to be
| rather trivial.

In fact, I include below a first attempt at such a fix.
I warn you that I have only superficially tested this!
This is not DJB-ware by any stretch of the imagination, but it just
might work - a preliminary test indicates that it does.

Apply this patch to ucspitcp 0.84, run make fixcr, and voila.

- Harald

diff -u /stores/stash/ucspitcp/src-0.84/Makefile ./Makefile
--- /stores/stash/ucspitcp/src-0.84/Makefile    Thu Nov 12 06:32:01 1998
+++ ./Makefile  Thu Jun 17 20:19:08 1999
@@ -252,8 +252,8 @@
        nroff -man finger@.1 > finger@.0
 
 fixcr: \
-load fixcr.o substdio.a error.a str.a
-       ./load fixcr substdio.a error.a str.a 
+load fixcr.o substdio.a error.a str.a sig.a fd.a
+       ./load fixcr substdio.a error.a str.a sig.a fd.a
 
 fixcr.0: \
 fixcr.1
diff -u /stores/stash/ucspitcp/src-0.84/fixcr.1 ./fixcr.1
--- /stores/stash/ucspitcp/src-0.84/fixcr.1     Thu Nov 12 06:32:01 1998
+++ ./fixcr.1   Thu Jun 17 20:28:24 1999
@@ -3,9 +3,24 @@
 fixcr \- make sure that there is a CR before each LF
 .SH SYNOPSIS
 .B fixcr
+[
+.I program
+[
+.I arg ...
+]]
 .SH DESCRIPTION
 .B fixcr
 inserts CR at the end of each line of input where a CR is not already present.
 It does not insert CR at the end of a partial final line.
+
+If
+.I program
+is specified,
+.B fixcr
+runs it with the given arguments and pipes its output into it.
+
+Otherwise,
+.B fixcr
+writes to standard output.
 .SH "SEE ALSO"
 addcr(1)
diff -u /stores/stash/ucspitcp/src-0.84/fixcr.c ./fixcr.c
--- /stores/stash/ucspitcp/src-0.84/fixcr.c     Thu Nov 12 06:32:01 1998
+++ ./fixcr.c   Thu Jun 17 21:12:27 1999
@@ -1,13 +1,37 @@
+#include "sig.h"
 #include "substdio.h"
 #include "subfd.h"
 #include "exit.h"
 
-void main()
+static void die() { _exit(0); }
+
+void main(argc, argv)
+  int argc;
+  char *argv[];
 {
   register int n;
   register char *x;
   char ch;
   char lastch = 0;
+  int p[2];
+
+  if (argc > 1)
+  {
+    if (pipe(&p)<0) _exit(111);
+    switch(fork())
+    {
+    case -1: _exit(111);
+    case 0:
+      if (fd_move(0,p[0])<0) die();
+      close(p[1]);
+      execvp(argv[1], argv + 1);
+      _exit(111);
+    default:
+      if (fd_move(1,p[1])<0) die();
+      close(p[0]);
+      sig_childunblock(); sig_childcatch(&die);
+    }
+  }
 
   for (;;) {
     n = substdio_feed(subfdin);

Reply via email to