|
From: Patrick M. <ume...@us...> - 2008-07-30 19:56:59
|
Update of /cvsroot/radmind/radmind In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv14267 Modified Files: fsdiff.c lfdiff.c transcript.c transcript.h twhich.c Log Message: Automatically convert paths between absolute and relative paths based on the path given to fsdiff. [PATCH 2020818] Index: transcript.h =================================================================== RCS file: /cvsroot/radmind/radmind/transcript.h,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** transcript.h 15 Jan 2008 20:04:03 -0000 1.43 --- transcript.h 30 Jul 2008 19:56:54 -0000 1.44 *************** *** 11,14 **** --- 11,17 ---- #define T_SPECIAL 3 + #define T_RELATIVE 0 + #define T_ABSOLUTE 1 + #define T_MOVE_TRAN 1 #define T_MOVE_FS 2 Index: fsdiff.c =================================================================== RCS file: /cvsroot/radmind/radmind/fsdiff.c,v retrieving revision 1.80 retrieving revision 1.81 diff -C2 -d -r1.80 -r1.81 *** fsdiff.c 17 Jul 2008 18:15:55 -0000 1.80 --- fsdiff.c 30 Jul 2008 19:56:54 -0000 1.81 *************** *** 33,36 **** --- 33,37 ---- int lastpercent = -1; int case_sensitive = 1; + int tran_format = -1; extern int exclude_warnings; const EVP_MD *md; *************** *** 354,359 **** path_prefix = argv[ optind ]; - /* Clip trailing '/' */ len = strlen( path_prefix ); if (( len > 1 ) && ( path_prefix[ len - 1 ] == '/' )) { path_prefix[ len - 1] = '\0'; --- 355,375 ---- path_prefix = argv[ optind ]; len = strlen( path_prefix ); + + /* Determine if called with relative or absolute pathing. Path is relative + * if it's just '.' or starts with './'. File names that start with a '.' + * are absolute. + */ + if ( path_prefix[ 0 ] == '.' ) { + if ( len == 1 ) { + tran_format = T_RELATIVE; + } else if ( path_prefix[ 1 ] == '/' ) { + tran_format = T_RELATIVE; + } + } else { + tran_format = T_ABSOLUTE; + } + + /* Clip trailing '/' */ if (( len > 1 ) && ( path_prefix[ len - 1 ] == '/' )) { path_prefix[ len - 1] = '\0'; Index: twhich.c =================================================================== RCS file: /cvsroot/radmind/radmind/twhich.c,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** twhich.c 7 Jun 2008 14:29:02 -0000 1.47 --- twhich.c 30 Jul 2008 19:56:54 -0000 1.48 *************** *** 24,27 **** --- 24,28 ---- int case_sensitive = 1; + int tran_format = -1; /* *************** *** 184,187 **** --- 185,203 ---- if ( len > 1 && pattern[ len - 1 ] == '/' ) { pattern[ len - 1 ] = '\0'; + len--; + } + + /* Determine if called with relative or absolute pathing. Path is relative + * if it's just '.' or starts with './'. File names that start with a '.' + * are absolute. + */ + if ( path_prefix[ 0 ] == '.' ) { + if ( len == 1 ) { + tran_format = T_RELATIVE; + } else if ( path_prefix[ 1 ] == '/' ) { + tran_format = T_RELATIVE; + } + } else { + tran_format = T_ABSOLUTE; } Index: transcript.c =================================================================== RCS file: /cvsroot/radmind/radmind/transcript.c,v retrieving revision 1.126 retrieving revision 1.127 diff -C2 -d -r1.126 -r1.127 *** transcript.c 12 Mar 2008 17:15:55 -0000 1.126 --- transcript.c 30 Jul 2008 19:56:54 -0000 1.127 *************** *** 29,32 **** --- 29,33 ---- #include "wildcard.h" + char * convert_path_type( char *path ); int read_kfile( char *kfile, int location ); static void t_remove( int type, char *shortname ); *************** *** 37,40 **** --- 38,42 ---- extern int edit_path; extern int case_sensitive; + extern int tran_format; static char *kdir; static struct list *kfile_list; *************** *** 50,53 **** --- 52,104 ---- FILE *outtran; + char * + convert_path_type( char *path ) + { + int len = 0; + static char buf[ MAXPATHLEN ]; + + len = strlen( path ); + + if ( len == 1 ) { + if (( tran_format == T_ABSOLUTE ) && ( path[ 0 ] == '.' )) { + buf[ 0 ] = '/'; + buf[ 1 ] = '\0'; + } else if (( tran_format == T_RELATIVE ) && ( path[ 0 ] == '/' )) { + buf[ 0 ] = '.'; + buf[ 1 ] = '\0'; + } else { + /* Nothing to convert */ + return( path ); + } + } else { + if (( tran_format == T_ABSOLUTE ) && ( path[ 0 ] == '.' )) { + if ( path[ 1 ] == '/' ) { + /* Move past leading '.' */ + path++; + if ( snprintf( buf, sizeof( buf ), "%s", + path ) >= MAXPATHLEN ) { + return( NULL ); + } + } else { + /* Instert leading '/' */ + if ( snprintf( buf, sizeof( buf ), "/%s", + path ) >= MAXPATHLEN ) { + return( NULL ); + } + } + } else if (( tran_format == T_RELATIVE ) && ( path[ 0 ] == '/' )) { + /* Instert leading '.' */ + if ( snprintf( buf, sizeof( buf ), ".%s", path ) >= MAXPATHLEN ) { + return( NULL ); + } + } else { + /* Nothing to convert */ + return( path ); + } + } + + return( buf ); + } + void transcript_parse( struct transcript *tran ) *************** *** 106,109 **** --- 157,168 ---- exit( 2 ); } + + /* Convert path to match transcript type */ + if (( epath = convert_path_type( epath )) == NULL ) {; + fprintf( stderr, "%s: line %d: path too long\n", tran->t_fullname, + tran->t_linenum ); + exit( 2 ); + } + if ( pathcasecmp( epath, tran->t_pinfo.pi_name, case_sensitive ) < 0 ) { fprintf( stderr, "%s: line %d: bad sort order\n", *************** *** 937,941 **** char fullpath[ MAXPATHLEN ]; char *subpath; ! char *d_pattern; char **av; FILE *fp; --- 996,1000 ---- char fullpath[ MAXPATHLEN ]; char *subpath; ! char *d_pattern, *path; char **av; FILE *fp; *************** *** 1052,1057 **** if (( d_pattern = decode( av[ 1 ] )) == NULL ) { fprintf( stderr, "%s: line %d: decode buffer too small\n", ! kfile, linenum ); } if ( minus ) { list_remove( exclude_list, d_pattern ); --- 1111,1124 ---- if (( d_pattern = decode( av[ 1 ] )) == NULL ) { fprintf( stderr, "%s: line %d: decode buffer too small\n", ! kfile, linenum ); ! } ! ! /* Convert path to match transcript type */ ! if (( d_pattern = convert_path_type( d_pattern )) == NULL ) { ! fprintf( stderr, "%s: line %d: path too long\n", ! kfile, linenum ); ! exit( 2 ); } + if ( minus ) { list_remove( exclude_list, d_pattern ); *************** *** 1067,1077 **** case 's': /* special */ if ( minus ) { ! if ( list_check( special_list, av[ 1 ] )) { ! list_remove( special_list, av[ 1 ] ); } } else { ! if ( !list_check( special_list, av[ 1 ] )) { ! if ( list_insert( special_list, av[ 1 ] ) != 0 ) { perror( "list_insert" ); return( -1 ); --- 1134,1153 ---- case 's': /* special */ + path = av[ 1 ]; + + /* Convert path to match transcript type */ + if (( path = convert_path_type( path )) == NULL ) { + fprintf( stderr, "%s: line %d: path too long\n", + kfile, linenum ); + exit( 2 ); + } + if ( minus ) { ! if ( list_check( special_list, path )) { ! list_remove( special_list, path ); } } else { ! if ( !list_check( special_list, path )) { ! if ( list_insert( special_list, path ) != 0 ) { perror( "list_insert" ); return( -1 ); Index: lfdiff.c =================================================================== RCS file: /cvsroot/radmind/radmind/lfdiff.c,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -d -r1.66 -r1.67 *** lfdiff.c 7 Jun 2008 14:26:54 -0000 1.66 --- lfdiff.c 30 Jul 2008 19:56:54 -0000 1.67 *************** *** 47,50 **** --- 47,51 ---- int cksum = 0; int case_sensitive = 1; + int tran_format = -1; int create_prefix = 0; int quiet = 1; *************** *** 114,118 **** main( int argc, char **argv, char **envp ) { ! int c, i, tac, err = 0; int special = 0, diffargc = 0; int fd; --- 115,119 ---- main( int argc, char **argv, char **envp ) { ! int c, i, tac, err = 0, len; int special = 0, diffargc = 0; int fd; *************** *** 336,339 **** --- 337,355 ---- } file = argv[ optind ]; + len = strlen( file ); + + /* Determine if called with relative or absolute pathing. Path is relative + * if it's just '.' or starts with './'. File names that start with a '.' + * are absolute. + */ + if ( file[ 0 ] == '.' ) { + if ( len == 1 ) { + tran_format = T_RELATIVE; + } else if ( file[ 1 ] == '/' ) { + tran_format = T_RELATIVE; + } + } else { + tran_format = T_ABSOLUTE; + } if ( authlevel != 0 ) { |