diff options
author | Shinichiro Hamaji <shinichiro.hamaji@gmail.com> | 2015-07-05 15:48:28 +0900 |
---|---|---|
committer | Shinichiro Hamaji <shinichiro.hamaji@gmail.com> | 2015-07-05 15:48:28 +0900 |
commit | 0e3873a2bed37cc4668919184cf338af80740cc5 (patch) | |
tree | 150e6bcac7e4ff6f0c271797603a050f7c9c40f2 /func.cc | |
parent | 0541651e3e8196e2847374b3e30e42b42f5d44bc (diff) | |
download | kati-0e3873a2bed37cc4668919184cf338af80740cc5.tar.gz |
[C++] Fix wildcard_cache.mk
Diffstat (limited to 'func.cc')
-rw-r--r-- | func.cc | 20 |
1 files changed, 4 insertions, 16 deletions
@@ -17,7 +17,6 @@ #include "func.h" #include <errno.h> -#include <glob.h> #include <limits.h> #include <stdio.h> #include <stdlib.h> @@ -257,25 +256,14 @@ void WildcardFunc(const vector<Value*>& args, Evaluator* ev, string* s) { } WordWriter ww(s); - vector<const char*> files; + vector<string>* files; for (StringPiece tok : WordScanner(*pat)) { ScopedTerminator st(tok); - // TODO: Make this faster by not always using glob. - files.clear(); - glob_t gl; - glob(tok.data(), GLOB_NOSORT, NULL, &gl); - for (size_t i = 0; i < gl.gl_pathc; i++) { - files.push_back(gl.gl_pathv[i]); - } - sort(files.begin(), files.end(), - [](const char* a, const char* b) { - return strcmp(a, b) < 0; - }); - for (const char* file : files) { + Glob(tok.data(), &files); + sort(files->begin(), files->end()); + for (const string& file : *files) { ww.Write(file); } - - globfree(&gl); } } |