#include #include #include "projet.h" static DPREFER pref_diffcmd("adm/projet:diff_cmd","diff %s %s"); /* Produit un fichier contenant la diff‚rence contextuelle entre deux fichiers source. Retourne -1 si erreur. */ int rcs_vdiff ( const char *fname1, const char *fname2, const char *result) // Contiendra le r‚sultat { char buf[200]; static char is_init = 0; static const char *cmd = NULL; if (!is_init){ /* #Sp‚cification: projet / commande diff Lorsqu'on commande la diff‚rence entre deux fichiers source, la commande "vdiff -b -n fichier1 fichier1" est ex‚cut‚. On peut red‚finir cette commande via la systŠme de pr‚f‚rence. La cl‚ est adm/projet:diff_cmd. La valeur par d‚faut est "vdiff -b -n %s %s" */ static char bufcmd[200]; cmd = pref_diffcmd.getval(bufcmd,sizeof(bufcmd)); is_init = 1; } sprintf (buf,cmd,fname1,fname2); #if defined( MSDOS) const char *pdir= NULL; SAVEPATH savePath; if (!is_os2()) { char bufp1[ MAXSIZ_PATH]; char buff1[ MAXSIZ_NAME]; char bufp2[ MAXSIZ_PATH]; char buff2[ MAXSIZ_NAME]; /* Une belle patch pour DOS. Elle sert a countourner le fait que DOS ne supporte pas les lignes de commandes de plus de 128 char */ if( strlen( buf) > 120) { path_splitlex ( fname1, bufp1, buff1); path_splitlex ( fname2, bufp2, buff2); const char *pf1; const char *pf2; if( strlen( buff1) + strlen( fname2) > strlen( buff2) + strlen( fname1)) { pdir= bufp2; pf1= fname1; pf2= buff2; } else{ pdir= bufp1; pf1= buff1; pf2= fname2; } sprintf( buf, cmd, pf1, pf2); } if( pdir != NULL) { if ( path_pushdir( pdir, &savePath) == -1) pdir= NULL; } } #endif rcs_system (NULL,result,result,buf); #if defined( MSDOS) if( pdir != NULL) path_popdir( &savePath); #endif return 0; }