Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 Oct 1995 02:31:38 +1000
From:      Bruce Evans <bde@zeta.org.au>
To:        davidg@Root.COM, joerg_wunsch@uriah.heep.sax.de
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: FreeBSD 2.1 will require a minimum of 8MB for installation.
Message-ID:  <199510031631.CAA23795@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>>That's what i was about to say: Jordan and David have enough items on
>>their plate.  So if they don't have time to implement it, somebody has
>>to deal with it and make a proposal that's not only verbal, but
>>accompanied by a diff -u output that would cleanly drop into the tree,

>   I read diff -c much easier.

There should be a standard utility to convert between -u and -c.  This
one came with the original unidiff posting.

Actually we need a diff that has been tested with many different kernel
configurations.

Bruce

/*
A filter to turn a unidiff into a degenerate context diff (no '!'s)
for patch. Author: davison@dri.com (uunet!drivax!davison).
*/
#include <stdio.h>
#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);
 }
}
}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199510031631.CAA23795>