Xref: utzoo comp.sources.d:7058 comp.sources.bugs:2971 alt.sources.patches:36 Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!ccu.umanitoba.ca!herald.usask.ca!alberta!brazeau.ucs.ualberta.ca!unixg.ubc.ca!ubc-cs!van-bc!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!sample.eng.ohio-state.edu!purdue!haven.umd.edu!mimsy!mojo.eng.umd.edu!mojo!djm From: djm@eng.umd.edu (David J. MacKenzie) Newsgroups: comp.sources.d,comp.sources.bugs,alt.sources.patches Subject: Re: compress 4.1 file deletion fixes Message-ID: Date: 28 Jun 91 19:23:09 GMT References: <1991Jun26.221030.23987@motcad.portal.com> <1991Jun28.153802.22464@agate.berkeley.edu> Organization: Project GLUE, University of Maryland Lines: 81 > Pardon the ignorance, but what kind of diff format is the one above? > Larry Wall's patch doesn't seem to recognise it. Sorry, I forgot to mention it. It's a unified diff, produced by GNU diff 1.15. It's like context format except that it omits duplicate context lines to save space. If you can anonymous ftp, prep.ai.mit.edu:pub/gnu/patch-2.0.12u4.tar.Z is a version of patch that recognizes unified diffs. If not, here is a short program called unipatch that converts unified diffs to context diffs. It came from comp.sources.misc "v14i070: Unified context diff tools" plus a patch in comp.sources.bugs. You'll likely be seeing more unified diffs on the net as time goes on, so it's worth while having programs that can deal with them. /* A filter to turn a unidiff into a degenerate context diff (no '!'s) for patch. Author: davison@dri.com (uunet!drivax!davison). */ #include #define ERR(a) {fputs(a,stderr);exit(1);} struct Ln { struct Ln *lk; char t; char s[1]; } r,*h,*ln; char *malloc(); main() { char bf[2048],*cp,ch; long os,ol,ns,nl,ne,lncnt=0; for(;;){ for(;;){ if(!fgets(bf,sizeof bf,stdin)) exit(0); lncnt++; if(!strncmp(bf,"@@ -",4)) break; if(!strncmp(bf,"+++ ",4)) printf("***%s",bf+3); else fputs(bf,stdout); } if(sscanf(bf+4,"%ld,%ld +%ld,%ld %c",&os,&ol,&ns,&nl,&ch)!=5||ch!='@') goto bad; r.lk=0, h= &r, ne=ns+nl-1; printf("***************\n*** %ld,%ld ****\n",os,os+ol-(os>0)); while(ol||nl){ if(!fgets(bf,sizeof bf,stdin)){ if(nl>2) ERR("Unexpected end of file.\n"); strcpy(bf," \n"); } lncnt++; if(*bf=='\t'||*bf=='\n') ch=' ', cp=bf; else ch= *bf, cp=bf+1; switch(ch){ case'-':if(!ol--) goto bad; printf("- %s",cp); break; case'=':ch=' '; case' ':if(!ol--) goto bad; printf(" %s",cp); case'+':if(!nl--) goto bad; ln = (struct Ln*)malloc(sizeof(*ln)+strlen(cp)); if(!ln) ERR("Out of memory!\n"); ln->lk=0, ln->t=ch, strcpy(ln->s,cp); h->lk=ln, h=ln; break; default: bad: fprintf(stderr,"Malformed unidiff at line %ld: ",lncnt); ERR(bf); } } printf("--- %ld,%ld ----\n",ns,ne); for(ln=r.lk;ln;ln=h){ printf("%c %s",ln->t,ln->s); h=ln->lk; free(ln); } } } -- David J. MacKenzie