Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!cca!mirror!pyrnj!romain From: romain@pyrnj.uucp (Romain Kang) Newsgroups: comp.emacs Subject: applying diffs to GNU emacs Message-ID: <690@pyrnj.uucp> Date: Wed, 11-Nov-87 08:46:25 EST Article-I.D.: pyrnj.690 Posted: Wed Nov 11 08:46:25 1987 Date-Received: Fri, 13-Nov-87 22:22:24 EST Distribution: comp Organization: Pyramid Technology Corp, Woodbridge, NJ Lines: 78 The updates to GNU emacs aren't completely completely handled by patch because of the new files that come out from time to time. To avoid the tedium of breaking the new files out with an editor (I was three versions behind) I hacked this up thing out. It's a crock but it works. I suspect someone already has something like this, but I didn't see such a beast in the directories on prep. /* * gnumod.c * apply diffs from GNU project. * awful 5-minute hack. check diff file for special instructions. then * cd ~emacs; zcat diff-xx.xx-yy.yy.Z | gnumod */ #include #define PATCH "/usr/new/patch" /* current state of program */ #define PREAMBLE 0 #define INFILE 1 #define SKIPPING 2 #define DIFFING 3 #define NEWMARK \ "======================================== New file " #define NEWSIZE ((sizeof NEWMARK)-1) #define DIFMARK \ "======================================================================" main() { char fname[128], lbuf[BUFSIZ]; int state = PREAMBLE; FILE *newf; while (gets(lbuf)) { /* new file marker */ if (strncmp(lbuf, NEWMARK, NEWSIZE) == 0) { if (state == INFILE) fclose(newf); strcpy(fname, &lbuf[NEWSIZE]); printf("New file %s\n", fname); if ((newf = fopen(fname, "w")) == 0) { state = SKIPPING; perror(fname); puts("skipping..."); } else state = INFILE; continue; } /* diff marker -- get out and call patch */ if (strcmp(DIFMARK, lbuf) == 0) { if (state == INFILE) fclose(newf); state = DIFFING; break; } /* pass through to file */ if (state == INFILE) { fprintf(newf, "%s\n", lbuf); continue; } if (state == SKIPPING) continue; } if (state == DIFFING) { execl(PATCH, "patch", "-p1", 0); perror(PATCH); exit(1); } exit(0); }