/[global]/global/libutil/find.c
ViewVC logotype

Diff of /global/libutil/find.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.54 by shigio, Sat Sep 3 10:48:58 2005 UTC revision 1.55 by shigio, Sun Sep 4 02:00:46 2005 UTC
# Line 79  static int list_count; Line 79  static int list_count;
79  static char **listarray;                /* list for skipping full path */  static char **listarray;                /* list for skipping full path */
80  static FILE *ip;  static FILE *ip;
81  static FILE *temp;  static FILE *temp;
82  static char root[MAXPATHLEN + 1];  static char rootdir[MAXPATHLEN+1];
 static size_t rootlen;  
83  static int opened;  static int opened;
84  #define FIND_OPEN       1  #define FIND_OPEN       1
85  #define FILELIST_OPEN   2  #define FILELIST_OPEN   2
# Line 434  find_open(start) Line 433  find_open(start)
433   *   *
434   *      i)      filename        file including list of file names.   *      i)      filename        file including list of file names.
435   *                              When "-" is specified, read from standard input.   *                              When "-" is specified, read from standard input.
436   *      i)      rootdir         root directory of source tree   *      i)      root            root directory of source tree
437   */   */
438  void  void
439  find_open_filelist(filename, rootdir)  find_open_filelist(filename, root)
440          const char *filename;          const char *filename;
441          const char *rootdir;          const char *root;
442  {  {
443          assert(opened == 0);          assert(opened == 0);
444          opened = FILELIST_OPEN;          opened = FILELIST_OPEN;
# Line 463  find_open_filelist(filename, rootdir) Line 462  find_open_filelist(filename, rootdir)
462                  if (ip == NULL)                  if (ip == NULL)
463                          die("cannot open '%s'.", filename);                          die("cannot open '%s'.", filename);
464          }          }
465          strlimcpy(root, rootdir, sizeof(root));          snprintf(rootdir, sizeof(rootdir), "%s/", root);
         rootlen = strlen(root);  
466    
467          /*          /*
468           * prepare regular expressions.           * prepare regular expressions.
# Line 596  find_read_filelist() Line 594  find_read_filelist()
594                  }                  }
595                  if (!isabspath(buf))                  if (!isabspath(buf))
596                          die("realpath(3) is not compatible with BSD version.");                          die("realpath(3) is not compatible with BSD version.");
597                  if (strncmp(buf, root, rootlen) || buf[rootlen] != '/') {                  /*
598                     * Remove the root part of buf and insert './'.
599                     *      rootdir  /a/b/
600                     *      buf      /a/b/c/d.c -> c/d.c -> ./c/d.c
601                     */
602                    path = locatestring(buf, rootdir, MATCH_AT_FIRST);
603                    if (path == NULL) {
604                          if (!qflag)                          if (!qflag)
605                                  fprintf(stderr, "'%s' is out of source tree.\n", buf);                                  fprintf(stderr, "'%s' is out of source tree.\n", buf);
606                          continue;                          continue;
607                  }                  }
608                  path = buf + rootlen - 1;                  path -= 2;
609                  *path = '.';                  *path = '.';
610                  /*                  /*
611                   * GLOBAL cannot treat path which includes blanks.                   * GLOBAL cannot treat path which includes blanks.

Legend:
Removed from v.1.54  
changed lines
  Added in v.1.55

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26