aboutsummaryrefslogtreecommitdiff
path: root/func.cc
diff options
context:
space:
mode:
authorShinichiro Hamaji <shinichiro.hamaji@gmail.com>2015-07-05 15:48:28 +0900
committerShinichiro Hamaji <shinichiro.hamaji@gmail.com>2015-07-05 15:48:28 +0900
commit0e3873a2bed37cc4668919184cf338af80740cc5 (patch)
tree150e6bcac7e4ff6f0c271797603a050f7c9c40f2 /func.cc
parent0541651e3e8196e2847374b3e30e42b42f5d44bc (diff)
downloadkati-0e3873a2bed37cc4668919184cf338af80740cc5.tar.gz
[C++] Fix wildcard_cache.mk
Diffstat (limited to 'func.cc')
-rw-r--r--func.cc20
1 files changed, 4 insertions, 16 deletions
diff --git a/func.cc b/func.cc
index 6988b28..a33dd8e 100644
--- a/func.cc
+++ b/func.cc
@@ -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);
}
}