home *** CD-ROM | disk | FTP | other *** search
- /*
- File differences for LZ debug.
- R.J.P. 12-5-92
- 14th May 1992 Onto ARC.
-
-
- */
-
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
-
- char *Ustrupr( char *s,int l)
- {
-
- char *ss = s ;
- while( *s && l-- )
- *s++ = toupper( *s) ;
- return ss ;
- }
-
- char *scan( int ac , char **av , char *tag )
- {
- short sl = strlen(tag) ;
- while ( --ac )
- {
- if( !strncmp(tag,Ustrupr(*++av,sl),sl) )
- {
- if (!strlen(*av + sl) )
- return 0 ;
- else
- return *av + sl ;
- }
- }
- return 0 ;
- }
-
-
- /*
- Switches :
- /1: First file in comparison.
- /2: Second file in comparison.
- /N: Number of mis-matches before stop.
- */
-
- int main(int ac , char **av )
- {
- char *cp ;
- FILE *F1,*F2 ;
- char n1[60] , n2[60] ;
- int i , NO , N = 1 ;
- int c1,c2 ;
- long L = 0 ;
-
-
- fprintf (stderr ,
- "Byte-by-Byte file Comparison R.J.P. V1.1 14th May 1992\n"
- ) ;
-
- if ( (cp = scan(ac,av,"/1:" )),cp==0)
- {
- fprintf(stderr,"*No /1:\n" ) ;
- return 1 ;
- }
- strcpy( n1,cp) ;
- if ( (F1 = fopen(cp,"rb")),F1 ==0 )
- {
- fprintf(stderr,"*Can't open /1:%s",cp) ;
- return 2 ;
- }
-
- if ( (cp = scan(ac,av,"/2:" )),cp==0)
- {
- fprintf(stderr,"*No /2:\n" ) ;
- return 1 ;
- }
- strcpy( n2,cp ) ;
-
- if ( (F2 = fopen(cp,"rb")),F2 ==0 )
- {
- fprintf(stderr,"*Can't open /2:%s",cp) ;
- return 2 ;
- }
-
- if ( (cp = scan(ac,av,"/N:" )),cp != 0 )
- {
- if( sscanf(cp,"%d",&i)==1)
- N = i ;
- }
- /*
- Compare loop.
- */
- NO = N ;
-
- while ( N )
- {
- c1 = fgetc(F1) ;
- c2 = fgetc(F2) ;
-
- if ( feof(F1) || feof(F2) )
- {
- if (feof(F1) && feof(F2))
- {
- printf("*EOF on %s & %s\n",n1,n2) ;
- break ;
- }
- if (feof(F1))
- {
- printf("*EOF on %s\n",n1) ;
- break ;
- }
- printf("*EOF on %s\n",n2) ;
- break ;
- }
-
- if ( c1 != c2 )
- {
- printf( "\t! @ %ld (%lx) %s: %d (%x) %s: %d (%x)\n"
- , L , L ,n1, c1 , c1 ,n2, c2 , c2 ) ;
- --N ;
- }
- ++L ;
- }
-
- fclose(F1) ;
- fclose(F2) ;
- printf("* %d Differences %ld Bytes\n",NO-N,L);
- return (NO - N) ;
- }
-
-