コード例 #1
0
ファイル: wbdiff.c プロジェクト: siwuxian/open-watcom-v2
int DoBdiff( const char *srcPath, const char *tgtPath, const char *name )
{
    long        savings;
    foff        buffsize;
    int         i;
//    if( !MsgInit() ) exit( EXIT_FAILURE );
    /* initialize static variables each time */
    SimilarRegions = NULL;
    DiffRegions = NULL;
    HoleRegions = NULL;
    SimilarSize = 0;
    NumHoles = 0;
    NumDiffs = 0;
    DiffSize = 0;
    HolesInRegion = 0;
    HoleHeaders = 0;
    for( i = 0; i < 3; i += 1 ) {
        HoleCount[i] = 0;
    }

    init_diff();

    newName = name;
    EndOld = FileSize( srcPath, &OldCorrection );
    EndNew = FileSize( tgtPath, &NewCorrection );

    buffsize = ( EndOld > EndNew ) ? ( EndOld ) : ( EndNew );
    buffsize += sizeof( PATCH_LEVEL );
    OldFile = ReadIn( srcPath, buffsize, EndOld );
    NewFile = ReadIn( tgtPath, buffsize, EndNew );

    ScanSyncString( SyncString );

    FindRegions();

    if( NumHoles == 0 && DiffSize == 0 && EndOld == EndNew ) {
        printf( "Patch file not created - files are identical\n" );
        MsgFini();
        exit( EXIT_SUCCESS );
    }
    MakeHoleArray();
    SortHoleArray();
    ProcessHoleArray( 0 );
    savings = HolesToDiffs();
    WritePatchFile( "", newName );
    FreeHoleArray();
    VerifyCorrect( tgtPath );

    print_stats( savings );

    MsgFini();
    return ( EXIT_SUCCESS );
}
コード例 #2
0
ファイル: bdiff.c プロジェクト: Graham-stott/open-watcom-v2
void main( int argc, char **argv )
{
    long        savings;
    foff        buffsize;
    algorithm   alg;

    if( !MsgInit() )
        exit( EXIT_FAILURE );
    alg = ParseArgs( argc, argv );

    EndOld = FileSize( argv[1], &OldCorrection );
    EndNew = FileSize( argv[2], &NewCorrection );

    buffsize = ( EndOld > EndNew ) ? ( EndOld ) : ( EndNew );
    buffsize += sizeof( PATCH_LEVEL );
    OldFile = ReadIn( argv[1], buffsize, EndOld );
    NewFile = ReadIn( argv[2], buffsize, EndNew );

    ScanSyncString( SyncString );

    switch( alg ) {
    case ALG_NOTHING:
        FindRegions();
        break;
#ifdef USE_DBGINFO
    case ALG_ONLY_NEW:
    case ALG_BOTH:
        SymbolicDiff( alg, argv[1], argv[2] );
        break;
#endif
    }

    if( NumHoles == 0 && DiffSize == 0 && EndOld == EndNew ) {
        printf( "Patch file not created - files are identical\n" );
        MsgFini();
        exit( EXIT_SUCCESS );
    }
    MakeHoleArray();
    SortHoleArray();
    ProcessHoleArray( 0 );
    savings = HolesToDiffs();
    WritePatchFile( argv[3], newName );
    FreeHoleArray();
    VerifyCorrect( argv[2] );

    print_stats( savings );

    MsgFini();
    exit( EXIT_SUCCESS );
}