Changeset 2591 for trunk/src/kmk/vpath.c


Ignore:
Timestamp:
Jun 17, 2012, 10:45:31 PM (13 years ago)
Author:
bird
Message:

kmk: Merged in changes from GNU make 3.82. Previous GNU make base version was gnumake-2008-10-28-CVS.

Location:
trunk/src/kmk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk

    • Property svn:ignore
      •  

        old new  
        1313stamp-*
        1414makebook*
         15
        1516.*gdbinit
         17.gdb_history
         18
        1619*.dep
        1720*.dvi
         
        3134*.pg
        3235*.pgs
         36
        3337README
        3438README.DOS
        3539README.W32
         40README.OS2
        3641aclocal.m4
        3742autom4te.cache
         
        5257config.h.W32
        5358config.h-vms
         59
        5460loadavg
        5561loadavg.c
        5662make
         63
        5764.deps
        5865.dep_segment
         66ID
         67TAGS
         68
        5969_*
        6070sun4
         
        7282sol2
        7383i486-linux
         84
        7485customs
         86
        7587install-sh
        7688mkinstalldirs
         89
         90.directive.asc
  • trunk/src/kmk/vpath.c

    r1993 r2591  
    11/* Implementation of pattern-matching file search paths for GNU Make.
    22Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    4 Foundation, Inc.
     31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
     42010 Free Software Foundation, Inc.
    55This file is part of GNU Make.
    66
     
    150150
    151151
    152 /* Construct the VPATH listing for the pattern and searchpath given.
     152/* Construct the VPATH listing for the PATTERN and DIRPATH given.
    153153
    154154   This function is called to generate selective VPATH lists and also for
     
    158158   variable.
    159159
    160    If SEARCHPATH is nil, remove all previous listings with the same
     160   If DIRPATH is nil, remove all previous listings with the same
    161161   pattern.  If PATTERN is nil, remove all VPATH listings.  Existing
    162    and readable directories that are not "." given in the searchpath
     162   and readable directories that are not "." given in the DIRPATH
    163163   separated by the path element separator (defined in make.h) are
    164164   loaded into the directory hash table if they are not there already
     
    205205
    206206              /* Free its unused storage.  */
    207               free (path->searchpath);
     207              /* MSVC erroneously warns without a cast here.  */
     208              free ((void *)path->searchpath);
    208209              free (path);
    209210            }
     
    310311  else
    311312    /* There were no entries, so free whatever space we allocated.  */
    312     free (vpath);
     313    /* MSVC erroneously warns without a cast here.  */
     314    free ((void *)vpath);
    313315}
    314316
     
    335337   FILE exists.  If it is found, we return a cached name of the existing file
    336338   and set *MTIME_PTR (if MTIME_PTR is not NULL) to its modtime (or zero if no
    337    stat call was done).  Otherwise we return NULL.  */
     339   stat call was done). Also set the matching directory index in PATH_INDEX
     340   if it is not NULL. Otherwise we return NULL.  */
    338341
    339342static const char *
    340343selective_vpath_search (struct vpath *path, const char *file,
    341                         FILE_TIMESTAMP *mtime_ptr)
     344                        FILE_TIMESTAMP *mtime_ptr, unsigned int* path_index)
    342345{
    343346  int not_target;
     
    519522          /* Store the name we found and return it.  */
    520523
     524          if (path_index)
     525            *path_index = i;
     526
    521527          return strcache_add_len (name, (p + 1 - name) + flen);
    522528        }
     
    530536   exists.  If it is found, return the cached name of an existing file, and
    531537   set *MTIME_PTR (if MTIME_PTR is not NULL) to its modtime (or zero if no
    532    stat call was done).  Otherwise we return 0.  */
     538   stat call was done). Also set the matching directory index in VPATH_INDEX
     539   and PATH_INDEX if they are not NULL.  Otherwise we return 0.  */
    533540
    534541const char *
    535 vpath_search (const char *file, FILE_TIMESTAMP *mtime_ptr)
     542vpath_search (const char *file, FILE_TIMESTAMP *mtime_ptr,
     543              unsigned int* vpath_index, unsigned int* path_index)
    536544{
    537545  struct vpath *v;
     
    547555    return 0;
    548556
     557  if (vpath_index)
     558    {
     559      *vpath_index = 0;
     560      *path_index = 0;
     561    }
     562
    549563  for (v = vpaths; v != 0; v = v->next)
    550     if (pattern_matches (v->pattern, v->percent, file))
    551       {
    552         const char *p = selective_vpath_search (v, file, mtime_ptr);
    553         if (p)
    554           return p;
    555       }
     564    {
     565      if (pattern_matches (v->pattern, v->percent, file))
     566        {
     567          const char *p = selective_vpath_search (
     568            v, file, mtime_ptr, path_index);
     569          if (p)
     570            return p;
     571        }
     572
     573      if (vpath_index)
     574        ++*vpath_index;
     575    }
     576
    556577
    557578  if (general_vpath != 0)
    558579    {
    559       const char *p = selective_vpath_search (general_vpath, file, mtime_ptr);
     580      const char *p = selective_vpath_search (
     581        general_vpath, file, mtime_ptr, path_index);
    560582      if (p)
    561583        return p;
     
    564586  return 0;
    565587}
     588
     589
     590
    566591
    567592
Note: See TracChangeset for help on using the changeset viewer.