File: patterncompare.cc

package info (click to toggle)
icmake 13.05.01-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,132 kB
  • sloc: cpp: 11,595; fortran: 883; makefile: 853; sh: 546; pascal: 342
file content (27 lines) | stat: -rw-r--r-- 845 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//#define XERR
#include "builtin.ih"

//      stack[5]   : reference filename

vector<string> Builtin::patternCompare(
                    bool (*keep)(string const &entry, Stat const &reference)
                ) const
{
                                            // last modification time of the 
                                            // reference file
    Stat reference{ d_stack[5].str() };

    vector<string> ret = patternList();     // entries matching the pattern

                                            // move all entries that shouldn't
    auto iter = remove_if(ret.begin(), ret.end(),   // be kept to the back
        [&](string const &entry)
        {
            return not keep(entry, reference);
        }
    );
        
    ret.resize(iter - ret.begin());         // reduce to the remaining size

    return ret;
}