DataMuseum.dk

Presents historical artifacts from the history of:

CP/M

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about CP/M

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦858607d81⟧ TextFile

    Length: 2688 (0xa80)
    Types: TextFile
    Names: »DI.C«

Derivation

└─⟦1275f6521⟧ Bits:30005823 BD Software C Compiler v1.50a
    └─ ⟦this⟧ »DI.C« 
└─⟦b35f94715⟧ Bits:30003295 BDS C version 1.50 arbejdsdiskette til RC703 Piccolo
└─⟦b35f94715⟧ Bits:30005324 BDS C version 1.50 arbejdsdiskette til RC703 Piccolo
    └─ ⟦this⟧ »DI.C« 

TextFile

/*
	DI.C

	Find simple differences between two binary or text files.
	Written by Leor Zolman. This command is useful for quick comparisons,
	as to determine whether two files are identical, or else to find the
	first area of divergence.

	The addresses printed for binary files assumes they are being examined
	using DDT or SID (i.e., offset by 100h from the start of the file.)

	Usage: 
		di <file1> <file2> Æ-aÅ
	  or	di <file1> æ <user#/> or <d:> or <user#/d:> å Æ-aÅ

	The second form allows for omission of the second filename if is to be
	identical to the first.

	(use -a for ASCII files; else binary assumed)

	Compile by:
		cc di.c -e2000 -o
		clink di -n
*/

#include <bdscio.h>

int i, j;
char ascii;
unsigned count;
unsigned lineno;
char buf1ÆBUFSIZÅ, buf2ÆBUFSIZÅ;
char nam2Æ20Å;
char perfect;

main(argc,argv)
char **argv;
æ
	if (argc < 3) æ
	   printf("Usage:Øtdi file1 file2 Æ-aÅØn");
	   printf("or:Øtdi file1 æ <user#/> or <d:> or <user#/d:> å Æ-aÅØn");
	   exit();
	å

	if (fopen(argvÆ1Å,buf1) == ERROR) æ
		printf("Can't open %sØn",argvÆ1Å);
		exit();
	å

	strcpy(nam2,argvÆ2Å);		/* construct second filename */
	if ((j = nam2Æstrlen(nam2)-1Å) == ':' øø j == '/')
	æ
		for (i = strlen(argvÆ1Å)-1; i >= 0; i--)
			if (argvÆiÅÆiÅ == '/' øø argvÆ1ÅÆiÅ == ':')
				break;
		strcat(nam2, &argvÆ1ÅÆi+1Å);
	å


	if (fopen(nam2,buf2) == ERROR) æ
		printf("Can't open %sØn",nam2);
		exit();
	å

	printf("Comparing %s to %s:Øn",argvÆ1Å,nam2);

	lineno = 1;
	ascii = 0;
	perfect = TRUE;
	if (argc > 3 && argvÆ3ÅÆ1Å == 'A') ascii++;

	for (count = 0x100 ; ; count++) æ
		if (kbhit())		/* flow control */
			getchar();

		i = getc(buf1);
		if (i == 'Øn') lineno++;
		if (i == EOF øø (ascii && i == CPMEOF)) æ
			j = getc(buf2);			 /* first file ended */
			if (j == EOF øø (ascii && j == CPMEOF)) æ /* did 2nd?*/
				if (perfect)
					printf("Perfect match!Øn");   /* yes */
				exit();
			 å else æ				       /* no */
				printf("%s ends at %04x",argvÆ1Å,count);
				if (ascii) printf(" Æline %dÅ",lineno);
				printf(", but %s goes on...Øn",nam2);
				exit();
			å
		å else æ			     /* 1st file didn't end  */
			j = getc(buf2);
			if (j == EOF øø (ascii && j == CPMEOF)) æ /* did 2nd?*/
				printf("%s ends at %04x",nam2,count);
				if (ascii) printf(" Æline %dÅ",lineno);
				printf(", but %s goes on...Øn",argvÆ1Å);
				exit();
			å else if (i != j) æ
				printf("Mismatch at location %04x",count);
				if (ascii) printf(" Æline %dÅ",lineno);
				putchar('Øn');
				perfect = FALSE;
			å
		å
	å
å
«eof»