From: Hans-Bernhard B. <br...@us...> - 2006-10-15 16:53:30
|
Update of /cvsroot/cscope/cscope/src In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv32218 Modified Files: dir.c Log Message: Test for non-regular files liste in name files. Index: dir.c =================================================================== RCS file: /cvsroot/cscope/cscope/src/dir.c,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -r1.28 -r1.29 *** dir.c 20 Aug 2006 15:00:34 -0000 1.28 --- dir.c 15 Oct 2006 16:53:24 -0000 1.29 *************** *** 74,77 **** --- 74,78 ---- /* Internal prototypes: */ + static BOOL accessible_file(char *file); static BOOL issrcfile(char *file); static void addsrcdir(char *dir); *************** *** 287,291 **** } else { fprintf(stderr, "cscope: cannot find file %s\n", ! file); errorsfound = YES; } --- 288,292 ---- } else { fprintf(stderr, "cscope: cannot find file %s\n", ! file); errorsfound = YES; } *************** *** 342,346 **** fprintf(stderr, "\ cscope: Syntax error in namelist file %s: unfinished -I or -p option\n", ! namefile); unfinished_option = 0; } --- 343,347 ---- fprintf(stderr, "\ cscope: Syntax error in namelist file %s: unfinished -I or -p option\n", ! namefile); unfinished_option = 0; } *************** *** 371,398 **** * --> make it a macro to avoid unnecessary * duplication */ ! #define HANDLE_OPTION_ARGUMENT(i, s) \ ! switch (i) { \ ! case 'I': /* #include file directory */ \ ! if (firstbuild == YES) { \ ! /* expand $ and ~ */ \ ! shellpath(dir, sizeof(dir), (s)); \ ! includedir(dir); \ ! } \ ! unfinished_option = 0; \ ! done = YES; \ ! break; \ ! case 'p': /* file path components to display */ \ ! if (*(s) < '0' || *(s) > '9') { \ ! fprintf(stderr, \ ! "cscope: -p option in file %s: missing or invalid numeric value\n", \ ! namefile); \ ! } \ ! dispcomponents = atoi(s); \ ! unfinished_option = 0; \ ! done = YES; \ ! break; \ ! default: \ ! done = NO; \ ! } /* switch(i) */ /* ... and now call it for the first time */ --- 372,399 ---- * --> make it a macro to avoid unnecessary * duplication */ ! #define HANDLE_OPTION_ARGUMENT(i, s) \ ! switch (i) { \ ! case 'I': /* #include file directory */ \ ! if (firstbuild == YES) { \ ! /* expand $ and ~ */ \ ! shellpath(dir, sizeof(dir), (s)); \ ! includedir(dir); \ ! } \ ! unfinished_option = 0; \ ! done = YES; \ ! break; \ ! case 'p': /* file path components to display */ \ ! if (*(s) < '0' || *(s) > '9') { \ ! fprintf(stderr, \ ! "cscope: -p option in file %s: missing or invalid numeric value\n", \ ! namefile); \ ! } \ ! dispcomponents = atoi(s); \ ! unfinished_option = 0; \ ! done = YES; \ ! break; \ ! default: \ ! done = NO; \ ! } /* switch(i) */ /* ... and now call it for the first time */ *************** *** 401,405 **** default: fprintf(stderr, "cscope: only -I, -c, -k, -p, and -T options can be in file %s\n", ! namefile); } /* switch(i) */ } /* if('-') */ --- 402,406 ---- default: fprintf(stderr, "cscope: only -I, -c, -k, -p, and -T options can be in file %s\n", ! namefile); } /* switch(i) */ } /* if('-') */ *************** *** 412,416 **** if (point_in_line[in] == '"') { newpath[out] = '\0'; ! /* Tell outer loop to skip over this entire quoted string */ length_of_name = in + 1; break; /* found end of quoted string */ --- 413,418 ---- if (point_in_line[in] == '"') { newpath[out] = '\0'; ! /* Tell outer loop to skip over this entire ! * quoted string */ length_of_name = in + 1; break; /* found end of quoted string */ *************** *** 437,443 **** addsrcfile(s); } else { ! fprintf(stderr, ! "cscope: cannot find file %s\n", ! newpath); errorsfound = YES; } --- 439,444 ---- addsrcfile(s); } else { ! fprintf(stderr, "cscope: cannot find file %s\n", ! newpath); errorsfound = YES; } *************** *** 455,459 **** } else { fprintf(stderr, "cscope: cannot find file %s\n", ! path); errorsfound = YES; } --- 456,460 ---- } else { fprintf(stderr, "cscope: cannot find file %s\n", ! path); errorsfound = YES; } *************** *** 640,645 **** } - /* search for the file in the view path */ char * inviewpath(char *file) --- 641,662 ---- } + /* check if a file is readable enough to be allowed in the + * database */ + static BOOL + accessible_file(char *file) + { + if (access(compath(file), READ) == 0) { + struct stat stats; + + if (lstat(file, &stats) == 0 + && S_ISREG(stats.st_mode)) { + return YES; + } + } + return NO; + } + + /* search for the file in the view path */ char * inviewpath(char *file) *************** *** 649,653 **** /* look for the file */ ! if (access(compath(file), READ) == 0) { return(file); } --- 666,670 ---- /* look for the file */ ! if (accessible_file(file)) { return(file); } *************** *** 663,667 **** PATHLEN - 2 - file_len, srcdirs[i], file); ! if (access(compath(path), READ) == 0) { return(path); } --- 680,684 ---- PATHLEN - 2 - file_len, srcdirs[i], file); ! if (accessible_file(path)) { return(path); } |