コード例 #1
0
ファイル: wgrep.c プロジェクト: ABratovic/open-watcom-v2
static void executeWgrep( void )
{
    DIR                 *dirh;
    struct dirent       *dp;
    unsigned            i;
    char                exp[_MAX_EXT];
    char                ext[_MAX_EXT];

    extendPath( PathBuff, CurrPattern );

    _splitpath( PathBuff, NULL, NULL, NULL, exp );

    if( strcmp( CurrPattern, "@@" ) == 0 ) {
        performSearch( CurrPattern );
    } else {
        dirh = opendir( PathBuff );
        if( dirh != NULL ) {
            for( ;; ) {
                if( DoneFlag ) return;
                dp = readdir( dirh );
                if( dp == NULL ) break;
#if defined( __WATCOMC__ ) && !defined( __UNIX__ )
                if( dp->d_attr & _A_SUBDIR ) continue;
#else
                {
                    struct stat sblk;
                    char tmp_path[_MAX_PATH+1];
                    strcpy( tmp_path, PathBuff );
                    extendPath( tmp_path, dp->d_name );
                    if( stat( tmp_path, &sblk ) == 0 && S_ISDIR( sblk.st_mode ) ) {
                        continue;
                    }
                }
#endif

                if( IgnoreListCnt > 0 ) {
                    _splitpath( dp->d_name, NULL, NULL, NULL, ext );
                    if( stricmp( ext, exp ) != 0 ) {
                        for( i=0; i < IgnoreListCnt; i++ ) {
                            if( stricmp( ext, IgnoreList[i] ) == 0 ) break;
                        }
                        if( i < IgnoreListCnt ) continue;
                    }
                }
                extendPath( PathBuff, dp->d_name );
                performSearch( PathBuff );
            }
            closedir( dirh );
        }
    }
}
bool VBTableBuilder::rebucketPaths(VBTablePathVector &Paths, size_t PathsStart,
                                   bool SecondPass) {
  // What we're essentially doing here is bucketing together ambiguous paths.
  // Any bucket with more than one path in it gets extended by NextBase, which
  // is usually the direct base of the inherited the vbptr.  This code uses a
  // sorted vector to implement a multiset to form the buckets.  Note that the
  // ordering is based on pointers, but it doesn't change our output order.  The
  // current algorithm is designed to match MSVC 2012's names.
  // TODO: Implement MSVC 2010 or earlier names to avoid extra vbtable cruft.
  VBTablePathVector PathsSorted(&Paths[PathsStart], &Paths.back() + 1);
  std::sort(PathsSorted.begin(), PathsSorted.end(), pathCompare);
  bool AmbiguousPaths = false;
  for (size_t I = 0, E = PathsSorted.size(); I != E;) {
    // Scan forward to find the end of the bucket.
    size_t BucketStart = I;
    do {
      ++I;
    } while (I != E && PathsSorted[BucketStart]->Path == PathsSorted[I]->Path);

    // If this bucket has multiple paths, extend them all.
    if (I - BucketStart > 1) {
      AmbiguousPaths = true;
      for (size_t II = BucketStart; II != I; ++II)
        extendPath(PathsSorted[II], SecondPass);
    }
  }
  return AmbiguousPaths;
}
コード例 #3
0
ファイル: wgrep.c プロジェクト: ABratovic/open-watcom-v2
static void processDirectory( void )
{
    DIR                 *dirh;
    struct dirent       *dp;
    dirstack            *tmp;

    if( RecurLevels != 0 ) {
        extendPath( PathBuff, "*.*" );
        dirh = opendir( PathBuff );
        if( dirh != NULL ) {
            --RecurLevels;
            for( ;; ) {
                if( DoneFlag ) return;
                dp = readdir( dirh );
                if( dp == NULL ) break;
#if defined( __WATCOMC__ ) && !defined( __UNIX__ )
                if( !( dp->d_attr & _A_SUBDIR ) ) continue;
#else
                {
                    struct stat sblk;
                    char tmp_path[_MAX_PATH+1];
                    strcpy( tmp_path, PathBuff );
                    extendPath( tmp_path, dp->d_name );
                    if( stat( tmp_path, &sblk ) == 0 && !S_ISDIR( sblk.st_mode ) ) {
                        continue;
                    }
                }
#endif
                if( dp->d_name[0] == '.' ) {
                    if( dp->d_name[1] == '.' || dp->d_name[1] == '\0' ) continue;
                }
                if( DoneFlag ) return;
                tmp = (dirstack *) SafeMalloc( sizeof( dirstack ) );
                extendPath( tmp->name, dp->d_name );
                tmp->prev = Stack;
                Stack = tmp;
                processDirectory();
                Stack = tmp->prev;
                free( tmp );
            }
            ++RecurLevels;
            closedir( dirh );
        }
    }
    executeWgrep();
}
コード例 #4
0
ファイル: setup.c プロジェクト: mdavidsaver/pyDevSup
static void insertDefaultPath(PyObject *list)
{
    const char *basedir, *pydevdir, *top, *arch;

    basedir = getenv("EPICS_BASE");
    if(!basedir)
        basedir = XEPICS_BASE;
    pydevdir = getenv("PYDEV_BASE");
    if(!pydevdir)
        pydevdir = XPYDEV_BASE;
    top = getenv("TOP");
    arch = getenv("ARCH");
    if(!arch)
        arch = XEPICS_ARCH;

    assert(PyList_Check(list));
    assert(PySequence_Check(list));
    extendPath(list, basedir, arch);
    extendPath(list, pydevdir, arch);
    if(top)
        extendPath(list, top, arch);
}
コード例 #5
0
ファイル: Graph.cpp プロジェクト: biointec/jabba
void Graph::extendPathNosink(std::vector<int> &path, int est_dist, bool rev = 0) const{
        return extendPath(path, 0, est_dist, rev);
}
コード例 #6
0
ファイル: Graph.cpp プロジェクト: biointec/jabba
std::vector<int> Graph::findPath(int source, int sink, int org_est_dist) const{
        int est_dist = org_est_dist;
        std::vector<int> path_i; //path from source
        std::vector<int> rev_path_t; //reverse path from sink
        //we always want to find a path from path_i.back to rev_path_t.back
        //a 0-value at position i means that the path is unknown between i-1 and i+1
        //the trivial correct solution is of course [source, 0, sink]
        path_i.push_back(source);
        rev_path_t.push_back(sink);
        //we try to extend the paths as much as possible
        int pi_len = 0;
        int rpt_len = 0;
        while (pi_len < path_i.size() || rpt_len < rev_path_t.size()) {
                pi_len = path_i.size();
                rpt_len = rev_path_t.size();
                extendPath(path_i, sink, est_dist);
                extendPath(rev_path_t, source, est_dist, 1);
        }
        
        if (path_i.back() != sink) {
                if (rev_path_t.back() != source) {
                        //we have not found a unique path yet
                        int signed i = path_i.size() - 1;
                        for (; -1 < i; --i) {
                                if (std::find(rev_path_t.begin(), rev_path_t.end(), path_i[i]) != rev_path_t.end()) {
                                        //if the paths have a common node we will merge them
                                        break;
                                }
                        }
                        if (i + 1 == path_i.size() && path_i.back() == rev_path_t.back()) {
                                std::vector<int> smallest_cycle = findMinSeqLenPath(path_i.back(), rev_path_t.back(), 2 * est_dist);
                                int cycle_size = 0;
                                for (int j = 1; j < smallest_cycle.size() - 1; ++j) {
                                        cycle_size += getSizeOfNode(smallest_cycle[j]) - (k_ - 1);
                                }
                                if (est_dist * .8 - 10 < cycle_size && cycle_size < est_dist * 1.1 + 5) {
                                        //cycle seems to fit
                                        path_i.insert(path_i.end(), smallest_cycle.begin() + 1, smallest_cycle.end() - 1);
                                        est_dist -= cycle_size;
                                } else {
                                        if (est_dist > 50) {
                                                path_i.push_back(0);
                                        } else {
                                                path_i.pop_back(); //we collapse the two equal nodes, since the gap is so small
                                        }
                                        
                                }
                        } else if (i == -1) {
                                //if both paths never meet we concatenate them through node 0 (= unknown path)
                                std::vector<int> smallest_path = findMinSeqLenPath(path_i.back(), rev_path_t.back(), 2 * est_dist);
                                int path_size = 0;
                                for (int j = 1; j < smallest_path.size() - 1; ++j) {
                                        path_size += getSizeOfNode(smallest_path[j]) - (k_ - 1);
                                }
                                if (est_dist * .8 - 10 < path_size && path_size < est_dist * 1.1 + 5) {
                                        //path seems to fit
                                        path_i.insert(path_i.end(), smallest_path.begin() + 1, smallest_path.end() - 1);
                                        est_dist -= path_size;
                                } else {
                                        path_i.push_back(0);
                                }
                        } else {
                                while (i + 1 < path_i.size()) {
                                        path_i.pop_back();
                                }
                                while (rev_path_t.back() != path_i.back()) {
                                        rev_path_t.pop_back();
                                }
                                rev_path_t.pop_back(); // else we add the match we found a second time!
                        }
                        while (!rev_path_t.empty()) {
                                path_i.push_back(rev_path_t.back());
                                rev_path_t.pop_back();
                        }
                } else {
                        //we have found a unique path
                        std::reverse(rev_path_t.begin(), rev_path_t.end());
                        path_i = rev_path_t;
                }
        } else {
                //we have found a unique path, it is stored in path_i already
                
        }
        return path_i;
}