From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Thu, 17 Aug 1995 23:41:11 -0400 From: dhog@plan9.cs.su.oz.au dhog@plan9.cs.su.oz.au Subject: fixes Topicbox-Message-UUID: 17f6b606-eac8-11e9-9e20-41e7f4b1d025 Message-ID: <19950818034111.JG2-tOW-lqEoAp67xWctaeOQ1098r7f33oI_UEG2cvI@z> >Did anybody port "patch" to plan9? That would make >diffs a lot more useful. Yes, and it's not too hard either. You can run patch's configure script under ape, and it works suprisingly well. Then you just have to edit the Makefile, adding "LIBS = -lap" and deleting "rename.o" from OBJS, and edit util.c, replacing ask() with something sensible. Oh, and you need to apply the fix to ape's rename() function that I posted to the list. So, just run "ape/psh", then type "sh configure", edit the Makefile and util.c as suggested above, then type make, and you should get a patch binary. If patch corrupts your files, then you need to fix rename() (don't try this at home kids!) Here is the hacked version of ask() that I use, which doesn't try to read standard output or standard error: void ask(pat,arg1,arg2,arg3) char *pat; long arg1,arg2,arg3; { static int ttyfd = -1; int r; Sprintf(buf, pat, arg1, arg2, arg3); Fflush(stderr); if (ttyfd >= 0 || (ttyfd = open("/dev/cons", 2)) >= 0) { write(ttyfd, buf, strlen(buf)); r = read(ttyfd, buf, sizeof buf); Close(ttyfd); } else { /* no terminal at all--default it */ buf[0] = '\n'; r = 1; } if (r <= 0) buf[0] = 0; else buf[r] = '\0'; }